Commit e19b100c727ef11822d7c5e6d58cc280a06d0f15

Authored by 前端开发-罗建龙
1 parent de5ceeae

自定义模板首页顶部优化

pages/index/index/index.js
1 var e = function (e) { 1 var e = function (e) {
2 - return e && e.__esModule ? e : {  
3 - default: e  
4 - }; 2 + return e && e.__esModule ? e : {
  3 + default: e
  4 + };
5 }(require("../../../utils/LoadMore.js")), 5 }(require("../../../utils/LoadMore.js")),
6 - t = getApp(),  
7 - a = t.request,  
8 - o = t.globalData.setting,  
9 - os = o,  
10 - i = require("../../../utils/util.js"),  
11 - ut = i,  
12 - s = require("../../../utils/common.js"),  
13 - n = new e.default(); 6 + t = getApp(),
  7 + a = t.request,
  8 + o = t.globalData.setting,
  9 + os = o,
  10 + i = require("../../../utils/util.js"),
  11 + ut = i,
  12 + s = require("../../../utils/common.js"),
  13 + n = new e.default();
14 var regeneratorRuntime = require('../../../utils/runtime.js'); 14 var regeneratorRuntime = require('../../../utils/runtime.js');
15 var api = require('../../../api/api.js'); 15 var api = require('../../../api/api.js');
16 var d = getApp().globalData; 16 var d = getApp().globalData;
17 - 17 +
18 var full_screen = require('full_screen.js'); 18 var full_screen = require('full_screen.js');
19 19
20 20
21 Page({ 21 Page({
22 - data: {  
23 - url: o.imghost,  
24 - swiperimage: [{  
25 - image: "/miniapp/images/title.png",  
26 - nav_url: 0  
27 - }],  
28 - resourceUrl: o.resourceUrl,  
29 - logo: o.appLogo,  
30 - homeData: null,  
31 - saleGoods: null,  
32 - sale: {  
33 - countTime: {  
34 - hour: 0,  
35 - minute: 0,  
36 - second: 0  
37 - },  
38 - diffTime: 0,  
39 - good: null,  
40 - },  
41 - timer: null,  
42 - recommend: null,  
43 - scrollTop: 0,  
44 - currentPage: 1,  
45 - banner: null,  
46 -  
47 - appdata: null,  
48 - saleGoods: null, //秒杀数据  
49 - pindGoods: null, //拼单数据  
50 - newGoods: null, //新商品  
51 - hotGoods: null, //hot商品  
52 - preGoods: null, //预售商品  
53 - //----控制是是否显示计时器---  
54 - is_timer: 1,  
55 - ishow: 0,  
56 - //是不是显示自定义模板  
57 - isTemplate: 0,  
58 - template_arr: null,  
59 - bgcolor_t: '',  
60 -  
61 - banner_index: 0,  
62 - flash_index: 0,  
63 - pt_index: 0,  
64 -  
65 - pt_timer_item: null,  
66 - pt_timer_arr: null,  
67 - pt_timer: null,  
68 - pt_timer_active: 0,  
69 - //看下商家是否开通会员权益  
70 - is_boot: 0,  
71 - gd_category: null,  
72 - is_no_more: 0,  
73 - max_sw_height: 0, //banner的最大高度  
74 - is_disgraceful: 0, //是否显示新人广告  
75 - new_image: "", //新人有礼弹窗图片  
76 - new_nav: "", //新人页面跳转地址  
77 - w_holiday_pop: 0,  
78 -  
79 - showHongbao: false,  
80 - showHongbaoSmall: false,  
81 - goodsGroupArr:[], //商品模块列表  
82 - is_full_screen_show: 0, //全屏显示  
83 - sec_show: 3, //倒计时的秒数  
84 - full_ad: null, //全屏广告  
85 - full_screen: 0, //全屏广告  
86 - is_ok_h5: 0, //判断要不要显示关注二维码  
87 - mb_banner:{},//首页广告  
88 - container: null,  
89 - is_retail_price:0,  
90 - },  
91 -  
92 -  
93 - onLoad: async function (tt) { 22 + data: {
  23 + url: o.imghost,
  24 + swiperimage: [{
  25 + image: "/miniapp/images/title.png",
  26 + nav_url: 0
  27 + }],
  28 + resourceUrl: o.resourceUrl,
  29 + logo: o.appLogo,
  30 + homeData: null,
  31 + saleGoods: null,
  32 + sale: {
  33 + countTime: {
  34 + hour: 0,
  35 + minute: 0,
  36 + second: 0
  37 + },
  38 + diffTime: 0,
  39 + good: null,
  40 + },
  41 + timer: null,
  42 + recommend: null,
  43 + scrollTop: 0,
  44 + currentPage: 1,
  45 + banner: null,
  46 +
  47 + appdata: null,
  48 + saleGoods: null, //秒杀数据
  49 + pindGoods: null, //拼单数据
  50 + newGoods: null, //新商品
  51 + hotGoods: null, //hot商品
  52 + preGoods: null, //预售商品
  53 + //----控制是是否显示计时器---
  54 + is_timer: 1,
  55 + ishow: 0,
  56 + //是不是显示自定义模板
  57 + isTemplate: 0,
  58 + template_arr: null,
  59 + bgcolor_t: '',
  60 +
  61 + banner_index: 0,
  62 + flash_index: 0,
  63 + pt_index: 0,
  64 +
  65 + pt_timer_item: null,
  66 + pt_timer_arr: null,
  67 + pt_timer: null,
  68 + pt_timer_active: 0,
  69 + //看下商家是否开通会员权益
  70 + is_boot: 0,
  71 + gd_category: null,
  72 + is_no_more: 0,
  73 + max_sw_height: 0, //banner的最大高度
  74 + is_disgraceful: 0, //是否显示新人广告
  75 + new_image: "", //新人有礼弹窗图片
  76 + new_nav: "", //新人页面跳转地址
  77 + w_holiday_pop: 0,
  78 +
  79 + showHongbao: false,
  80 + showHongbaoSmall: false,
  81 + goodsGroupArr: [], //商品模块列表
  82 + is_full_screen_show: 0, //全屏显示
  83 + sec_show: 3, //倒计时的秒数
  84 + full_ad: null, //全屏广告
  85 + full_screen: 0, //全屏广告
  86 + is_ok_h5: 0, //判断要不要显示关注二维码
  87 + mb_banner: {},//首页广告
  88 + container: null,
  89 + is_retail_price: 0,
  90 + //满屏顶部导航参数------------
  91 + is_full_screen_navigation: false, //是否满屏
  92 + is_full_screen_navigation_index: -1, //广告轮播满屏下标
  93 + nav_title: '首页',
  94 + nav_frontColor: "#ffffff",
  95 + nav_backgroundColor: "#ff7295",
  96 + nav_type: 1, //导航类型
  97 + searchbox_transparent: 1, //搜索框背景是否透明
  98 +
  99 + // nav_but_color: '#32ACF9', //导航按钮颜色
  100 + // sele_pickup: null, //默认门店
  101 + // nav_bg_color:'#e823e8', //导航按钮颜色
  102 + //----------------
  103 + },
  104 +
  105 +
  106 + onLoad: async function (tt) {
94 wx.offCopyUrl() 107 wx.offCopyUrl()
95 - wx.showShareMenu({  
96 - withShareTicket:true,  
97 - menus:['shareAppMessage','shareTimeline']  
98 - })  
99 - var th = this; 108 + wx.showShareMenu({
  109 + withShareTicket: true,
  110 + menus: ['shareAppMessage', 'shareTimeline']
  111 + })
  112 + var th = this;
100 var first_leader = tt.first_leader; 113 var first_leader = tt.first_leader;
101 - //群id  
102 - if(tt && tt.groupchat_id && tt.groupchat_id!='undefined' && tt.groupchat_id!='null'){  
103 - getApp().globalData.groupchat_id=tt.groupchat_id 114 + //群id
  115 + if (tt && tt.groupchat_id && tt.groupchat_id != 'undefined' && tt.groupchat_id != 'null') {
  116 + getApp().globalData.groupchat_id = tt.groupchat_id
104 } 117 }
105 - if (!first_leader && tt.scene) {  
106 - var first_leader_str = decodeURIComponent(tt.scene);  
107 - var f_arr = first_leader_str.split("_");  
108 - first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null;  
109 - //注册门店  
110 - if (f_arr[1] && parseFloat(f_arr[1]) > 0) {  
111 - getApp().globalData.store_number = f_arr[1]; 118 + if (!first_leader && tt.scene) {
  119 + var first_leader_str = decodeURIComponent(tt.scene);
  120 + var f_arr = first_leader_str.split("_");
  121 + first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null;
  122 + //注册门店
  123 + if (f_arr[1] && parseFloat(f_arr[1]) > 0) {
  124 + getApp().globalData.store_number = f_arr[1];
112 } 125 }
113 //企业微信群id 126 //企业微信群id
114 - if (f_arr[2] && parseFloat(f_arr[2]) > 0) {  
115 - getApp().globalData.groupchat_id = f_arr[2]; 127 + if (f_arr[2] && parseFloat(f_arr[2]) > 0) {
  128 + getApp().globalData.groupchat_id = f_arr[2];
116 } 129 }
117 - 130 +
118 } 131 }
119 // console.error('群id------------------------------------------'); 132 // console.error('群id------------------------------------------');
120 // console.error(getApp().globalData.groupchat_id); 133 // console.error(getApp().globalData.groupchat_id);
121 // console.error('群id------------------------------------------2222222222222222222222'); 134 // console.error('群id------------------------------------------2222222222222222222222');
122 // getApp().globalData.groupchat_id=1 135 // getApp().globalData.groupchat_id=1
123 - console.log("first_leader:"+first_leader,"onload");  
124 -  
125 -  
126 - getApp().getConfig(function (e) {  
127 - //--首页的问题--  
128 - if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {  
129 - wx.setNavigationBarTitle({  
130 - title: getApp().globalData.config.store_name,  
131 - });  
132 - } else {  
133 - wx.setNavigationBarTitle({  
134 - title: getApp().globalData.setting.appName,  
135 - });  
136 - };  
137 - });  
138 -  
139 -  
140 - var th = this;  
141 - getApp().getConfig2(function (config2) {  
142 - var swithc_list = config2.switch_list;  
143 - var sw_arr = JSON.parse(swithc_list);  
144 - if(sw_arr.is_retail_price){  
145 - th.setData({is_retail_price:1});  
146 - }  
147 -  
148 - if (config2 && config2.is_overdue == 1) {  
149 - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=5", {}).then(res => {  
150 - var o = res;  
151 - if (o.data.code == 0) {  
152 - var ob = { isout: 0, isbuy: 1 };  
153 - var arr = o.data.data.pageData;  
154 - var isbuy = 0;  
155 - //----如果数组不为空----  
156 - if (arr.length > 0) {  
157 - arr.forEach(function (val, ind) {  
158 - if (val.is_sy == 0 && val.type == 5) {  
159 - isbuy = 1;  
160 - var now = ut.gettimestamp();  
161 - if (now > val.end_time) ob.isout = 1;  
162 - return false;  
163 - }  
164 - })  
165 - }  
166 - ob.isbuy = isbuy;  
167 -  
168 - var pages = getCurrentPages(); //获取加载的页面  
169 - var currentPage = pages[pages.length - 1]; //获取当前页面的对象  
170 -  
171 - // console.log("当前路由");  
172 - // console.log(currentPage.route);  
173 -  
174 -  
175 - th.setappdata(ob);  
176 -  
177 - if (ob.isbuy && !ob.isout) {  
178 - th.onload_init();  
179 - }  
180 - } else {  
181 - th.onload_init();  
182 - }  
183 - })  
184 - }  
185 - else {  
186 - th.onload_init();  
187 - }  
188 - })  
189 -  
190 - if (first_leader) {  
191 - //-- user_id代过来免登录 --  
192 - getApp().globalData.first_leader = first_leader;  
193 - //调用接口判断是不是会员  
194 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {  
195 - if (res.data.code == 0) {  
196 - getApp().globalData.guide_id = res.data.data.id;  
197 - getApp().globalData.guide_pick_id= res.data.data.pickup_id  
198 - }  
199 - })  
200 -  
201 - if(!getApp().globalData.user_id){  
202 - ut.new_user_go(os.stoid,first_leader);  
203 - }  
204 -  
205 - }  
206 -  
207 - // 判断是否有红包活动  
208 - getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, {  
209 - data: {}  
210 - }).then(function (data) { 136 + console.log("first_leader:" + first_leader, "onload");
  137 +
  138 +
  139 + getApp().getConfig(function (e) {
  140 + //--首页的问题--
  141 + if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {
  142 + wx.setNavigationBarTitle({
  143 + title: getApp().globalData.config.store_name,
  144 + });
  145 + } else {
  146 + wx.setNavigationBarTitle({
  147 + title: getApp().globalData.setting.appName,
  148 + });
  149 + };
  150 + th.setData({
  151 + nav_title:getApp().globalData.config.store_name
  152 + })
  153 + });
  154 +
  155 +
  156 + var th = this;
  157 + getApp().getConfig2(function (config2) {
  158 + var swithc_list = config2.switch_list;
  159 + var sw_arr = JSON.parse(swithc_list);
  160 + if (sw_arr.is_retail_price) {
  161 + th.setData({ is_retail_price: 1 });
  162 + }
  163 +
  164 + if (config2 && config2.is_overdue == 1) {
  165 + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=5", {}).then(res => {
  166 + var o = res;
  167 + if (o.data.code == 0) {
  168 + var ob = { isout: 0, isbuy: 1 };
  169 + var arr = o.data.data.pageData;
  170 + var isbuy = 0;
  171 + //----如果数组不为空----
  172 + if (arr.length > 0) {
  173 + arr.forEach(function (val, ind) {
  174 + if (val.is_sy == 0 && val.type == 5) {
  175 + isbuy = 1;
  176 + var now = ut.gettimestamp();
  177 + if (now > val.end_time) ob.isout = 1;
  178 + return false;
  179 + }
  180 + })
  181 + }
  182 + ob.isbuy = isbuy;
  183 +
  184 + var pages = getCurrentPages(); //获取加载的页面
  185 + var currentPage = pages[pages.length - 1]; //获取当前页面的对象
  186 +
  187 + // console.log("当前路由");
  188 + // console.log(currentPage.route);
  189 +
  190 +
  191 + th.setappdata(ob);
  192 +
  193 + if (ob.isbuy && !ob.isout) {
  194 + th.onload_init();
  195 + }
  196 + } else {
  197 + th.onload_init();
  198 + }
  199 + })
  200 + }
  201 + else {
  202 + th.onload_init();
  203 + }
  204 + })
  205 +
  206 + if (first_leader) {
  207 + //-- user_id代过来免登录 --
  208 + getApp().globalData.first_leader = first_leader;
  209 + //调用接口判断是不是会员
  210 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  211 + if (res.data.code == 0) {
  212 + getApp().globalData.guide_id = res.data.data.id;
  213 + getApp().globalData.guide_pick_id = res.data.data.pickup_id
  214 + }
  215 + })
  216 +
  217 + if (!getApp().globalData.user_id) {
  218 + ut.new_user_go(os.stoid, first_leader);
  219 + }
  220 +
  221 + }
  222 +
  223 + // 判断是否有红包活动
  224 + getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, {
  225 + data: {}
  226 + }).then(function (data) {
211 let code = data.data.code; 227 let code = data.data.code;
212 let resdata = data.data.data; 228 let resdata = data.data.data;
213 - if (code == 0 && resdata.is_index) {  
214 -  
215 - th.setData({  
216 - showHongbao: true,  
217 - });  
218 - } else if (code == -1) {  
219 - th.setData({  
220 - showHongbao: false,  
221 - });  
222 - };  
223 - });  
224 -  
225 -  
226 - // console.log(9090909);  
227 - //看一下商家是否开通了权益  
228 - //--初始化是否有打勾--  
229 - getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {  
230 - data: {  
231 - storeId: os.stoid  
232 - }  
233 - }).then(res => {  
234 - if (res.data.data) {  
235 - var is_init = res.data.data.isBool;  
236 - th.setData({  
237 - is_boot: is_init  
238 - });  
239 -  
240 - if (!is_init) {  
241 - th.setData({  
242 - swiperimage: []  
243 - });  
244 - }  
245 - }  
246 - })  
247 -  
248 -  
249 - var share_openid= tt.share_openid;  
250 - if(share_openid){  
251 - this.get_room_share_guide(share_openid);  
252 - }  
253 -  
254 - //调用底部导航  
255 - //getApp().globalData.url=th.data.url  
256 - //t.editTabBar(th,o.stoid,th.data.url);  
257 -  
258 - },  
259 -  
260 -  
261 - async get_room_share_guide(share_openid){  
262 -  
263 - var url="/api/weshop/users/page";  
264 - var first_leader=0;  
265 -  
266 - //调用接口判断是不是会员  
267 - await getApp().request.promiseGet(url, {  
268 - data:{stoid:os.stoid,weapp_openid:share_openid}  
269 - }).then(res => {  
270 - if (ut.ajax_ok(res)) {  
271 - first_leader=res.data.data.pageData[0].user_id;  
272 - // getApp().globalData.guide_id = res.data.data.id;  
273 - }  
274 - })  
275 - if(!first_leader) return false;  
276 -  
277 - getApp().globalData.first_leader = first_leader;  
278 - //调用接口判断是不是会员  
279 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {  
280 - if (res.data.code == 0) {  
281 - getApp().globalData.guide_id = res.data.data.id;  
282 - getApp().globalData.guide_pick_id= res.data.data.pickup_id  
283 - }  
284 - })  
285 -  
286 - },  
287 -  
288 -  
289 - async onload_init() {  
290 - var th = this;  
291 - await this.init_load();  
292 - //显示的时候要开启计时器  
293 - this.data.is_timer = 1;  
294 - //如果是自定义模板  
295 - if (this.data.isTemplate) {  
296 - //---先获取会员---  
297 - //t.getUserFir(function () {  
298 - if (getApp().globalData.user_id) {  
299 - th.is_festival();  
300 - var new_nav = th.data.new_nav;  
301 - if (new_nav == "") {  
302 - th.is_new();  
303 - }  
304 - // sty  
305 - setTimeout(function () {  
306 - if (getApp().globalData.user_id) getApp().requestCardNum(th);  
307 - }, 500)  
308 - }  
309 -  
310 - //});  
311 - } else {  
312 - await this.init_fir();  
313 - wx.setNavigationBarColor({  
314 - frontColor: '#ffffff', // 必写项  
315 - backgroundColor: '#ff7295', // 必写项  
316 - })  
317 - }  
318 -  
319 - //--正再拼团中的处理--  
320 - var url = "/api/weshop/order/pageTuanNew?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"  
321 - await getApp().request.promiseGet(url, {}).then(res => {  
322 - if (res.data.code == 0 && res.data.data && res.data.data.pageData) {  
323 - th.data.pt_timer_arr = res.data.data.pageData;  
324 - }  
325 - })  
326 - if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {  
327 - for (var i in th.data.pt_timer_arr) {  
328 - var p_item = th.data.pt_timer_arr[i];  
329 - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {  
330 - 1: 1  
331 - }).then(res => {  
332 - th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;  
333 - th.data.pt_timer_arr[i].nickname = res.data.data.nickname;  
334 - })  
335 - }  
336 - th.Interval_pt();  
337 - }  
338 -  
339 - //---处理正在6个分类----  
340 - await getApp().request.promiseGet("/api/weshop/goodscategory/page", {  
341 - data: {  
342 - store_id: os.stoid,  
343 - pageSize: 5,  
344 - is_show: 1,  
345 - level: 1  
346 - }  
347 - }).then(res => {  
348 - if (res.data.data) {  
349 - var gd_category = res.data.data.pageData;  
350 - th.setData({  
351 - gd_category: gd_category  
352 - });  
353 - }  
354 - }) 229 + if (code == 0 && resdata.is_index) {
  230 +
  231 + th.setData({
  232 + showHongbao: true,
  233 + });
  234 + } else if (code == -1) {
  235 + th.setData({
  236 + showHongbao: false,
  237 + });
  238 + };
  239 + });
  240 +
  241 +
  242 + // console.log(9090909);
  243 + //看一下商家是否开通了权益
  244 + //--初始化是否有打勾--
  245 + getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
  246 + data: {
  247 + storeId: os.stoid
  248 + }
  249 + }).then(res => {
  250 + if (res.data.data) {
  251 + var is_init = res.data.data.isBool;
  252 + th.setData({
  253 + is_boot: is_init
  254 + });
  255 +
  256 + if (!is_init) {
  257 + th.setData({
  258 + swiperimage: []
  259 + });
  260 + }
  261 + }
  262 + })
  263 +
  264 +
  265 + var share_openid = tt.share_openid;
  266 + if (share_openid) {
  267 + this.get_room_share_guide(share_openid);
  268 + }
  269 +
  270 + //调用底部导航
  271 + //getApp().globalData.url=th.data.url
  272 + //t.editTabBar(th,o.stoid,th.data.url);
  273 +
  274 + },
  275 +
  276 +
  277 + async get_room_share_guide(share_openid) {
  278 +
  279 + var url = "/api/weshop/users/page";
  280 + var first_leader = 0;
  281 +
  282 + //调用接口判断是不是会员
  283 + await getApp().request.promiseGet(url, {
  284 + data: { stoid: os.stoid, weapp_openid: share_openid }
  285 + }).then(res => {
  286 + if (ut.ajax_ok(res)) {
  287 + first_leader = res.data.data.pageData[0].user_id;
  288 + // getApp().globalData.guide_id = res.data.data.id;
  289 + }
  290 + })
  291 + if (!first_leader) return false;
  292 +
  293 + getApp().globalData.first_leader = first_leader;
  294 + //调用接口判断是不是会员
  295 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  296 + if (res.data.code == 0) {
  297 + getApp().globalData.guide_id = res.data.data.id;
  298 + getApp().globalData.guide_pick_id = res.data.data.pickup_id
  299 + }
  300 + })
  301 +
  302 + },
  303 +
  304 +
  305 + async onload_init() {
  306 + var th = this;
  307 + await this.init_load();
  308 + //显示的时候要开启计时器
  309 + this.data.is_timer = 1;
  310 + //如果是自定义模板
  311 + if (this.data.isTemplate) {
  312 + //---先获取会员---
  313 + //t.getUserFir(function () {
  314 + if (getApp().globalData.user_id) {
  315 + th.is_festival();
  316 + var new_nav = th.data.new_nav;
  317 + if (new_nav == "") {
  318 + th.is_new();
  319 + }
  320 + // sty
  321 + setTimeout(function () {
  322 + if (getApp().globalData.user_id) getApp().requestCardNum(th);
  323 + }, 500)
  324 + }
  325 +
  326 + //});
  327 + } else {
  328 + await this.init_fir();
  329 + wx.setNavigationBarColor({
  330 + frontColor: '#ffffff', // 必写项
  331 + backgroundColor: '#ff7295', // 必写项
  332 + })
  333 + this.setData({
  334 + nav_frontColor: '#ffffff', // 必写项
  335 + nav_backgroundColor: '#ff7295', // 必写项
  336 + })
  337 + }
  338 +
  339 + //--正再拼团中的处理--
  340 + var url = "/api/weshop/order/pageTuanNew?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"
  341 + await getApp().request.promiseGet(url, {}).then(res => {
  342 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  343 + th.data.pt_timer_arr = res.data.data.pageData;
  344 + }
  345 + })
  346 + if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {
  347 + for (var i in th.data.pt_timer_arr) {
  348 + var p_item = th.data.pt_timer_arr[i];
  349 + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {
  350 + 1: 1
  351 + }).then(res => {
  352 + th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;
  353 + th.data.pt_timer_arr[i].nickname = res.data.data.nickname;
  354 + })
  355 + }
  356 + th.Interval_pt();
  357 + }
  358 +
  359 + //---处理正在6个分类----
  360 + await getApp().request.promiseGet("/api/weshop/goodscategory/page", {
  361 + data: {
  362 + store_id: os.stoid,
  363 + pageSize: 5,
  364 + is_show: 1,
  365 + level: 1
  366 + }
  367 + }).then(res => {
  368 + if (res.data.data) {
  369 + var gd_category = res.data.data.pageData;
  370 + th.setData({
  371 + gd_category: gd_category
  372 + });
  373 + }
  374 + })
355 }, 375 },
356 - onReady(){ 376 + onReady() {
357 console.log('渲染完成----') 377 console.log('渲染完成----')
358 console.log(this.data.template_arr); 378 console.log(this.data.template_arr);
359 console.log('....................'); 379 console.log('....................');
360 }, 380 },
361 381
362 //获取商品模块实例 382 //获取商品模块实例
363 - newGoodsGroup(){  
364 - let arr=[] 383 + newGoodsGroup() {
  384 + let arr = []
365 if (this.data.template_arr.length == 0) { 385 if (this.data.template_arr.length == 0) {
366 return 386 return
367 } 387 }
368 - this.data.template_arr.map((item,index)=>{ 388 + this.data.template_arr.map((item, index) => {
369 if (item.ename == 'goodsGroup') { 389 if (item.ename == 'goodsGroup') {
370 arr.push(`goodsGroup${index}`) 390 arr.push(`goodsGroup${index}`)
371 } 391 }
372 }) 392 })
373 if (arr.length > 0) { 393 if (arr.length > 0) {
374 this.setData({ 394 this.setData({
375 - goodsGroupArr : arr 395 + goodsGroupArr: arr
376 }) 396 })
377 - arr.map(item=>{  
378 - let a = '.'+item 397 + arr.map(item => {
  398 + let a = '.' + item
379 this[item] = this.selectComponent(a); 399 this[item] = this.selectComponent(a);
380 }) 400 })
381 } 401 }
382 }, 402 },
383 403
384 - //关闭新用户领取广告  
385 - close_disgraceful: function () {  
386 - var th = this;  
387 - th.setData({  
388 - is_disgraceful: 0  
389 - })  
390 - },  
391 -  
392 - async onShow() {  
393 -  
394 - //-- 看一下隐私政策要不要显示 --  
395 - var privacy_pop = this.selectComponent("#privacy_pop"); //组件的id  
396 - if (privacy_pop) {  
397 - privacy_pop.check_pri_show();  
398 - }  
399 -  
400 - getApp().check_can_share();  
401 - if (typeof this.getTabBar === 'function' && this.getTabBar()) {  
402 - this.getTabBar().setData({  
403 - cartGoodsNum: getApp().globalData.cartGoodsNum  
404 - })  
405 - }  
406 - var th = this;  
407 - //-- 登录回来判断弹框 --  
408 - var user_id = getApp().globalData.user_id;  
409 -  
410 - if (!user_id) {  
411 - var userinfo = wx.getStorageSync('userinfo');  
412 - if (userinfo) user_id = userinfo.user_id  
413 - }  
414 -  
415 - if (user_id) {  
416 - th.is_festival();  
417 - var new_nav = th.data.new_nav;  
418 - if (new_nav == "") {  
419 - th.is_new();  
420 - }  
421 - }  
422 -  
423 - console.log(this.data.isTemplate, '首页');  
424 -  
425 - if (!this.data.isTemplate) {  
426 - //timetype: 1 仅查询已预售 置空查询全部,  
427 - var pre_data = { store_id: os.stoid, is_end: 0, isuse: 1,timetype:3 };  
428 - if (user_id) {  
429 - pre_data.user_id = user_id;  
430 - }  
431 -  
432 - getApp().request.get("/api/weshop/marketing/marketingPresellList/page", {  
433 - data: pre_data,  
434 - success: function (e) {  
435 - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { 404 + //关闭新用户领取广告
  405 + close_disgraceful: function () {
  406 + var th = this;
  407 + th.setData({
  408 + is_disgraceful: 0
  409 + })
  410 + },
  411 +
  412 + async onShow() {
  413 +
  414 + //-- 看一下隐私政策要不要显示 --
  415 + var privacy_pop = this.selectComponent("#privacy_pop"); //组件的id
  416 + if (privacy_pop) {
  417 + privacy_pop.check_pri_show();
  418 + }
  419 +
  420 + getApp().check_can_share();
  421 + if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  422 + this.getTabBar().setData({
  423 + cartGoodsNum: getApp().globalData.cartGoodsNum
  424 + })
  425 + }
  426 + var th = this;
  427 + //-- 登录回来判断弹框 --
  428 + var user_id = getApp().globalData.user_id;
  429 +
  430 + if (!user_id) {
  431 + var userinfo = wx.getStorageSync('userinfo');
  432 + if (userinfo) user_id = userinfo.user_id
  433 + }
  434 +
  435 + if (user_id) {
  436 + th.is_festival();
  437 + var new_nav = th.data.new_nav;
  438 + if (new_nav == "") {
  439 + th.is_new();
  440 + }
  441 + }
  442 +
  443 + console.log(this.data.isTemplate, '首页');
  444 +
  445 + if (!this.data.isTemplate) {
  446 + //timetype: 1 仅查询已预售 置空查询全部,
  447 + var pre_data = { store_id: os.stoid, is_end: 0, isuse: 1, timetype: 3 };
  448 + if (user_id) {
  449 + pre_data.user_id = user_id;
  450 + }
  451 +
  452 + getApp().request.get("/api/weshop/marketing/marketingPresellList/page", {
  453 + data: pre_data,
  454 + success: function (e) {
  455 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
436 var pre_data = e.data.data.pageData; 456 var pre_data = e.data.data.pageData;
437 //当前时间戳 457 //当前时间戳
438 var st = ut.gettimestamp(); 458 var st = ut.gettimestamp();
@@ -452,968 +472,1011 @@ Page({ @@ -452,968 +472,1011 @@ Page({
452 // pre_data[ind].status = 2; 472 // pre_data[ind].status = 2;
453 // } 473 // }
454 }); 474 });
455 - var arr = new Array();  
456 - //--三个三个一组---  
457 - for (var i = 0; i < pre_data.length; i += 3) {  
458 - arr.push(pre_data.slice(i, i + 3));  
459 - }  
460 - th.setData({  
461 - preGoods: arr  
462 - });  
463 - } else {  
464 - th.setData({  
465 - preGoods: null  
466 - });  
467 - }  
468 - }  
469 - })  
470 -  
471 - // 获取幸运购活动列表  
472 - getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {  
473 - data: {  
474 - store_id: getApp().globalData.setting.stoid,  
475 - is_end: 0,  
476 - timetype: 1,  
477 - }  
478 - }).then(res => {  
479 - if (res.data.code == 0) {  
480 - th.setData({  
481 - luckGo_list: res.data.data.pageData.slice(0, 3),  
482 - });  
483 - }  
484 - });  
485 -  
486 - //-----秒杀-----  
487 - var flash_data = null;  
488 - var f_req = {  
489 - store_id: os.stoid,  
490 - timetype: 2,  
491 - is_end: 0,  
492 - is_show: 1,  
493 - pageSize: 9,  
494 - user_id: 0  
495 - };  
496 - if (user_id) f_req.user_id = user_id;  
497 - //--获取活动--  
498 - await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {  
499 - data: f_req,  
500 - }).then(res => {  
501 - var e = res;  
502 - if (e.data.code == 0) {  
503 - flash_data = e.data.data.pageData;  
504 - if (flash_data == null || flash_data.length <= 0) return false;  
505 -  
506 - //当前时间戳  
507 - var nt = ut.gettimestamp();  
508 -  
509 - flash_data.forEach(function (val, ind) {  
510 -  
511 - if (val.user_price) val.price = val.user_price;  
512 - if (val.start_time > nt) {  
513 - flash_data[ind].status = 0;  
514 - } else if (val.end_time > nt) {  
515 - flash_data[ind].status = 1;  
516 - }  
517 -  
518 - if (val.buy_num >= val.goods_num) {  
519 - flash_data[ind].status = 2;  
520 - }  
521 - });  
522 -  
523 - var promisies = [];  
524 - for (const key in flash_data) {  
525 - if (Object.hasOwnProperty.call(flash_data, key)) {  
526 - const val = flash_data[key];  
527 - promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +  
528 - os.stoid + "/1/" + val.id,  
529 - {}  
530 - ).then(res => {  
531 - if (res.data.code == 0) {  
532 - if (res.data.data <= 0) flash_data[key].status = 2;  
533 - };  
534 - });  
535 - }  
536 - }  
537 -  
538 - Promise.all(promisies).then(() => {  
539 - var arr = new Array();  
540 - //--三个三个一组---  
541 - for (var i = 0; i < flash_data.length; i += 3) {  
542 - arr.push(flash_data.slice(i, i + 3));  
543 - }  
544 -  
545 - th.setData({  
546 - saleGoods: arr  
547 - });  
548 - });  
549 -  
550 -  
551 -  
552 - }  
553 - });  
554 -  
555 - }  
556 -  
557 -  
558 -  
559 -  
560 -  
561 -  
562 -  
563 -  
564 -  
565 - //优惠券要实时更新  
566 - getApp().getConfig2(function (e) {  
567 - var json_d = JSON.parse(e.switch_list);  
568 - th.setData({ is_closecoupon: json_d.is_closecoupon })  
569 - th.setData({ is_topstore: json_d.is_show_storeselect })  
570 - if (json_d.is_gz_h5) th.setData({ is_gz_h5: json_d.is_gz_h5 })  
571 - }, 1)  
572 -  
573 - if (typeof this.getTabBar === 'function' && this.getTabBar()) {  
574 - var index = getApp().getPageIndex(this);  
575 - this.getTabBar().setData({  
576 - active: index //数字是当前页面在tabbar的索引  
577 - })  
578 -  
579 -  
580 - getApp().requestCardNum(this);  
581 - }  
582 -  
583 - var th = this;  
584 -  
585 - var show = getApp().globalData.isLoad_ad;  
586 -  
587 - if (!show) {  
588 - setTimeout(function () {  
589 - full_screen.get_the_full_screen(th);  
590 - }, 800);  
591 - getApp().globalData.isLoad_ad = 1;  
592 - if (!th.data.f_hidden) {  
593 - setTimeout(function () {  
594 - th.setData({ f_hidden: 1 })  
595 - wx.hideLoading();  
596 - }, 960)  
597 - }  
598 - } else {  
599 - th.setData({ f_hidden: 1 })  
600 - }  
601 -  
602 - setTimeout(function () {  
603 - const query = wx.createSelectorQuery();  
604 - query.select('#off_top').boundingClientRect();  
605 - query.exec((res) => {  
606 - if (res && res[0] && res[0].height > 0) {  
607 - th.setData({ is_ok_h5: 1 });  
608 - }  
609 - })  
610 - }, 3600);  
611 -  
612 - },  
613 - //当隐藏的时候就关闭计时器  
614 - onHide: function () {  
615 - this.data.is_timer = 0;  
616 - if (this.data.pt_timer) clearInterval(this.data.pt_timer);  
617 - if (this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop);  
618 - if (this.data.full_screen) clearInterval(this.data.full_screen);  
619 - this.data.w_holiday_pop = 0;  
620 -  
621 - },  
622 -  
623 - //同步初始加载  
624 - async init_load() {  
625 - var th = this;  
626 - //因为营销版本的功能包含了自定义模板的功能,是同时的  
627 - //读取全局是否有弄自定义模板  
628 - await api.get_template_fir(o.stoid).then(res => {  
629 - var data = res.data.data;  
630 - if (data && data.length > 0) {  
631 - var temp_data = data[0];  
632 - var t_arr = JSON.parse(temp_data.json_str);  
633 - console.log('商品列表------------1')  
634 - console.log(t_arr)  
635 - console.log('商品列表------------2')  
636 - th.setData({  
637 - template_arr: t_arr,  
638 - isTemplate: 1,  
639 - bgcolor_t: temp_data.bkcolor 475 + var arr = new Array();
  476 + //--三个三个一组---
  477 + for (var i = 0; i < pre_data.length; i += 3) {
  478 + arr.push(pre_data.slice(i, i + 3));
  479 + }
  480 + th.setData({
  481 + preGoods: arr
  482 + });
  483 + } else {
  484 + th.setData({
  485 + preGoods: null
  486 + });
  487 + }
  488 + }
  489 + })
  490 +
  491 + // 获取幸运购活动列表
  492 + getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {
  493 + data: {
  494 + store_id: getApp().globalData.setting.stoid,
  495 + is_end: 0,
  496 + timetype: 1,
  497 + }
  498 + }).then(res => {
  499 + if (res.data.code == 0) {
  500 + th.setData({
  501 + luckGo_list: res.data.data.pageData.slice(0, 3),
  502 + });
  503 + }
  504 + });
  505 +
  506 + //-----秒杀-----
  507 + var flash_data = null;
  508 + var f_req = {
  509 + store_id: os.stoid,
  510 + timetype: 2,
  511 + is_end: 0,
  512 + is_show: 1,
  513 + pageSize: 9,
  514 + user_id: 0
  515 + };
  516 + if (user_id) f_req.user_id = user_id;
  517 + //--获取活动--
  518 + await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
  519 + data: f_req,
  520 + }).then(res => {
  521 + var e = res;
  522 + if (e.data.code == 0) {
  523 + flash_data = e.data.data.pageData;
  524 + if (flash_data == null || flash_data.length <= 0) return false;
  525 +
  526 + //当前时间戳
  527 + var nt = ut.gettimestamp();
  528 +
  529 + flash_data.forEach(function (val, ind) {
  530 +
  531 + if (val.user_price) val.price = val.user_price;
  532 + if (val.start_time > nt) {
  533 + flash_data[ind].status = 0;
  534 + } else if (val.end_time > nt) {
  535 + flash_data[ind].status = 1;
  536 + }
  537 +
  538 + if (val.buy_num >= val.goods_num) {
  539 + flash_data[ind].status = 2;
  540 + }
  541 + });
  542 +
  543 + var promisies = [];
  544 + for (const key in flash_data) {
  545 + if (Object.hasOwnProperty.call(flash_data, key)) {
  546 + const val = flash_data[key];
  547 + promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  548 + os.stoid + "/1/" + val.id,
  549 + {}
  550 + ).then(res => {
  551 + if (res.data.code == 0) {
  552 + if (res.data.data <= 0) flash_data[key].status = 2;
  553 + };
  554 + });
  555 + }
  556 + }
  557 +
  558 + Promise.all(promisies).then(() => {
  559 + var arr = new Array();
  560 + //--三个三个一组---
  561 + for (var i = 0; i < flash_data.length; i += 3) {
  562 + arr.push(flash_data.slice(i, i + 3));
  563 + }
  564 +
  565 + th.setData({
  566 + saleGoods: arr
  567 + });
  568 + });
  569 +
  570 +
  571 +
  572 + }
  573 + });
  574 +
  575 + }
  576 +
  577 +
  578 +
  579 +
  580 +
  581 +
  582 +
  583 +
  584 +
  585 + //优惠券要实时更新
  586 + getApp().getConfig2(function (e) {
  587 + var json_d = JSON.parse(e.switch_list);
  588 + th.setData({ is_closecoupon: json_d.is_closecoupon })
  589 + th.setData({ is_topstore: json_d.is_show_storeselect })
  590 + if (json_d.is_gz_h5) th.setData({ is_gz_h5: json_d.is_gz_h5 })
  591 + }, 1)
  592 +
  593 + if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  594 + var index = getApp().getPageIndex(this);
  595 + this.getTabBar().setData({
  596 + active: index //数字是当前页面在tabbar的索引
  597 + })
  598 +
  599 +
  600 + getApp().requestCardNum(this);
  601 + }
  602 +
  603 + var th = this;
  604 +
  605 + var show = getApp().globalData.isLoad_ad;
  606 +
  607 + if (!show) {
  608 + setTimeout(function () {
  609 + full_screen.get_the_full_screen(th);
  610 + }, 800);
  611 + getApp().globalData.isLoad_ad = 1;
  612 + if (!th.data.f_hidden) {
  613 + setTimeout(function () {
  614 + th.setData({ f_hidden: 1 })
  615 + wx.hideLoading();
  616 + }, 960)
  617 + }
  618 + } else {
  619 + th.setData({ f_hidden: 1 })
  620 + }
  621 +
  622 + setTimeout(function () {
  623 + const query = wx.createSelectorQuery();
  624 + query.select('#off_top').boundingClientRect();
  625 + query.exec((res) => {
  626 + if (res && res[0] && res[0].height > 0) {
  627 + th.setData({ is_ok_h5: 1 });
  628 + }
  629 + })
  630 + }, 3600);
  631 +
  632 + },
  633 + //当隐藏的时候就关闭计时器
  634 + onHide: function () {
  635 + this.data.is_timer = 0;
  636 + if (this.data.pt_timer) clearInterval(this.data.pt_timer);
  637 + if (this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop);
  638 + if (this.data.full_screen) clearInterval(this.data.full_screen);
  639 + this.data.w_holiday_pop = 0;
  640 +
  641 + },
  642 +
  643 + //同步初始加载
  644 + async init_load() {
  645 + var th = this;
  646 + //因为营销版本的功能包含了自定义模板的功能,是同时的
  647 + //读取全局是否有弄自定义模板
  648 + await api.get_template_fir(o.stoid).then(res => {
  649 + var data = res.data.data;
  650 + if (data && data.length > 0) {
  651 + var temp_data = data[0];
  652 + var t_arr = JSON.parse(temp_data.json_str);
  653 +
  654 + //增加判断是否是满屏
  655 + let is_full_screen_navigation = false
  656 + let is_full_screen_navigation_index = -1
  657 + let nav_but_color = "#32ACF9"
  658 + if (t_arr) {
  659 + t_arr.map((item, index) => {
  660 + if (item && item.content && item.content.full_screen == 1 && !is_full_screen_navigation) {
  661 + is_full_screen_navigation = true
  662 + is_full_screen_navigation_index = index
  663 + try {
  664 + nav_but_color = item.content.data[0].but_color
  665 + } catch (error) { }
  666 + }
  667 + })
  668 + }
  669 +
  670 + th.setData({
  671 + nav_but_color,
  672 + is_full_screen_navigation,
  673 + is_full_screen_navigation_index,
  674 + template_arr: t_arr,
  675 + isTemplate: 1,
  676 + bgcolor_t: temp_data.bkcolor
640 }); 677 });
641 - setTimeout(()=>{ 678 + setTimeout(() => {
642 th.newGoodsGroup() 679 th.newGoodsGroup()
643 - },1000)  
644 - //---如果有设定顶部的颜色的时候--  
645 - if (temp_data.top_color && temp_data.top_color != 'null') {  
646 -  
647 - var top_w_color = "#ffffff";  
648 - if (temp_data.top_word_color && temp_data.top_word_color == 'black') {  
649 - top_w_color = "#000000";  
650 - }  
651 - wx.setNavigationBarColor({  
652 - frontColor: top_w_color, // 必写项  
653 - backgroundColor: temp_data.top_color, // 必写项  
654 - })  
655 - }  
656 - }  
657 - })  
658 -  
659 -  
660 - },  
661 - //---读取数据内容---  
662 - async init_fir() {  
663 - console.log('init_fir');  
664 - var th = this;  
665 - //----广告----  
666 - var e = this;  
667 - await getApp().request.promiseGet("/api/weshop/ad/page?pid=2&store_id=" + o.stoid, {  
668 - data: {  
669 - enabled: 1  
670 - }  
671 - }).then(res => {  
672 -  
673 - if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {  
674 - var a = res.data.data.pageData;  
675 - var arr = new Array();  
676 - for (var i = 0; i < a.length; i++) {  
677 - var tt = {  
678 - 'ad_code': o.imghost + a[i].ad_code,  
679 - 'media_link': '',  
680 - 'ad_weapplink': a[i].ad_weapplink  
681 - };  
682 - arr.push(tt);  
683 - }  
684 - if (arr.length > 0) e.setData({  
685 - banner: arr,  
686 - });  
687 -  
688 - wx.stopPullDownRefresh();  
689 - }  
690 - })  
691 - let user_id = getApp().globalData.user_id; 680 + }, 1000)
  681 + //---如果有设定顶部的颜色的时候--
  682 + if (temp_data.top_color && temp_data.top_color != 'null') {
  683 +
  684 + var top_w_color = "#ffffff";
  685 + if (temp_data.top_word_color && temp_data.top_word_color == 'black') {
  686 + top_w_color = "#000000";
  687 + }
  688 + wx.setNavigationBarColor({
  689 + frontColor: top_w_color, // 必写项
  690 + backgroundColor: temp_data.top_color, // 必写项
  691 + })
  692 + th.setData({
  693 + // nav_frontColor: top_w_color, // 必写项
  694 + nav_backgroundColor: temp_data.top_color, // 必写项
  695 + })
  696 + }
  697 + }
  698 + })
  699 +
  700 +
  701 + },
  702 + //---读取数据内容---
  703 + async init_fir() {
  704 + console.log('init_fir');
  705 + var th = this;
  706 + //----广告----
  707 + var e = this;
  708 + await getApp().request.promiseGet("/api/weshop/ad/page?pid=2&store_id=" + o.stoid, {
  709 + data: {
  710 + enabled: 1
  711 + }
  712 + }).then(res => {
  713 +
  714 + if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {
  715 + var a = res.data.data.pageData;
  716 + var arr = new Array();
  717 + for (var i = 0; i < a.length; i++) {
  718 + var tt = {
  719 + 'ad_code': o.imghost + a[i].ad_code,
  720 + 'media_link': '',
  721 + 'ad_weapplink': a[i].ad_weapplink
  722 + };
  723 + arr.push(tt);
  724 + }
  725 + if (arr.length > 0) e.setData({
  726 + banner: arr,
  727 + });
  728 +
  729 + wx.stopPullDownRefresh();
  730 + }
  731 + })
  732 + let user_id = getApp().globalData.user_id;
692 733
693 //---首页广告------- 734 //---首页广告-------
694 await getApp().request.promiseGet("/api/weshop/ad/page?pids=300,301,302,303,304&store_id=" + o.stoid, { 735 await getApp().request.promiseGet("/api/weshop/ad/page?pids=300,301,302,303,304&store_id=" + o.stoid, {
695 - data: {  
696 - enabled: 1  
697 - }  
698 - }).then(res => { 736 + data: {
  737 + enabled: 1
  738 + }
  739 + }).then(res => {
699 console.log('首页广告--------------------------'); 740 console.log('首页广告--------------------------');
700 console.log(res); 741 console.log(res);
701 - if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {  
702 - var a = res.data.data.pageData;  
703 - var obj = {};  
704 - for (var i = 0; i < a.length; i++) {  
705 - var tt = {  
706 - 'ad_code': o.imghost + a[i].ad_code,  
707 - 'media_link': '', 742 + if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {
  743 + var a = res.data.data.pageData;
  744 + var obj = {};
  745 + for (var i = 0; i < a.length; i++) {
  746 + var tt = {
  747 + 'ad_code': o.imghost + a[i].ad_code,
  748 + 'media_link': '',
708 'ad_weapplink': a[i].ad_weapplink, 749 'ad_weapplink': a[i].ad_weapplink,
709 - 'pid':a[i].pid  
710 - }; 750 + 'pid': a[i].pid
  751 + };
711 // arr.push(tt); 752 // arr.push(tt);
712 - obj[a[i].pid]=tt  
713 - }  
714 - if (a.length > 0) e.setData({  
715 - mb_banner: obj,  
716 - });  
717 -  
718 - wx.stopPullDownRefresh();  
719 - }  
720 - })  
721 -  
722 -  
723 - //----拼单-----  
724 - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {  
725 - data: {  
726 - store_id: os.stoid,  
727 - is_end: 0,  
728 - is_show: 1,  
729 - pageSize: 6,  
730 - user_id,  
731 - }  
732 - }).then(res => {  
733 - var e = res;  
734 - if (e.data.code == 0) {  
735 - var pd_data = e.data.data.pageData;  
736 -  
737 - if (pd_data.length == 0) return;  
738 -  
739 - //获取当前  
740 - var nt = ut.gettimestamp();  
741 - pd_data.forEach(function (val, ind) {  
742 - if (val.start_time > nt) pd_data[ind].status = 0;  
743 - else if (val.end_time > nt) pd_data[ind].status = 1;  
744 - if (val.buy_num >= val.goods_num) pd_data[ind].status = 2;  
745 - });  
746 -  
747 - //获取当前时间,比较拼团中还在未开始  
748 - var timestamp = new Date().getTime();  
749 - var is_team_tepy;  
750 - for (var j = 0; j < pd_data.length; j++) {  
751 - pd_data[j].is_team_tepy = 1;  
752 - if (timestamp < pd_data[j].start_time * 1000) {  
753 - var is_team_tepy;  
754 - pd_data[j].is_team_tepy = 0;  
755 - }  
756 - }  
757 -  
758 - var arr = new Array();  
759 - //--2个2个一组---  
760 - for (var i = 0; i < pd_data.length; i += 2) {  
761 -  
762 - arr.push(pd_data.slice(i, i + 2));  
763 - }  
764 -  
765 - th.setData({  
766 - pindGoods: arr  
767 - });  
768 - th.countDown2();  
769 - }  
770 - })  
771 -  
772 - //------新品-------  
773 - await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {  
774 - data: {  
775 - is_mainshow: 1,  
776 - isonsale: 1,  
777 - is_on_sale: 1,  
778 - store_id: o.stoid,  
779 - pageSize: 9,  
780 - is_new: 1,  
781 - orderField: "sort"  
782 - }  
783 - }).then(res => {  
784 - var e = res;  
785 - if (e.data.code == 0) {  
786 - var new_data = e.data.data.pageData;  
787 - var arr = new Array();  
788 - //--三个三个一组---  
789 - for (var i = 0; i < new_data.length; i += 3) {  
790 - arr.push(new_data.slice(i, i + 3));  
791 - }  
792 - th.setData({  
793 - newGoods: arr,  
794 - });  
795 - }  
796 - })  
797 -  
798 - //------热卖-------  
799 - await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {  
800 - data: {  
801 - is_mainshow: 1,  
802 - isonsale: 1,  
803 - is_on_sale: 1,  
804 - store_id: o.stoid,  
805 - pageSize: 9,  
806 - is_hot: 1,  
807 - orderField: "sort"  
808 - }  
809 - }).then(res => {  
810 - var e = res;  
811 - if (e.data.code == 0) {  
812 - var new_data = e.data.data.pageData;  
813 - var arr = new Array();  
814 - //--三个三个一组---  
815 - for (var i = 0; i < new_data.length; i += 3) {  
816 - arr.push(new_data.slice(i, i + 3));  
817 - }  
818 - console.log(arr);  
819 - th.setData({  
820 - hotGoods: arr,  
821 - });  
822 - }  
823 - })  
824 -  
825 - //---调用信息---  
826 - // this.requestRecommend();  
827 - this.setData({  
828 - ishow: 1  
829 - });  
830 -  
831 - //---先获取会员---  
832 - //t.getUserFir(function () {  
833 - if (getApp().globalData.user_id) {  
834 - th.is_festival();  
835 - var new_nav = th.data.new_nav;  
836 - if (new_nav == "") {  
837 - th.is_new();  
838 - }  
839 -  
840 - // sty  
841 - setTimeout(function () {  
842 - if (getApp().globalData.user_id) getApp().requestCardNum(th);  
843 - }, 500)  
844 - }  
845 - //});  
846 -  
847 - setTimeout(function () {  
848 - var goods_list = th.selectComponent("#goods_list"); //组件的id  
849 - goods_list.init();  
850 - goods_list.get_list();  
851 - }, 2000)  
852 - },  
853 -  
854 - //--判断小程序是否过期--  
855 - setappdata: function (t) {  
856 - if (t && t.isout == 1)  
857 - wx.reLaunch({  
858 - url: "/packageD/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:" + getApp().globalData.config.store_tel,  
859 - });  
860 - if (t && t.isbuy == 0)  
861 - wx.reLaunch({  
862 - url: "/packageD/pages/error/error?msg=还未购买小程序",  
863 - });  
864 - },  
865 - //---加载更多是靠这个函数----  
866 - onReachBottom: function () { 753 + obj[a[i].pid] = tt
  754 + }
  755 + if (a.length > 0) e.setData({
  756 + mb_banner: obj,
  757 + });
  758 +
  759 + wx.stopPullDownRefresh();
  760 + }
  761 + })
  762 +
  763 +
  764 + //----拼单-----
  765 + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {
  766 + data: {
  767 + store_id: os.stoid,
  768 + is_end: 0,
  769 + is_show: 1,
  770 + pageSize: 6,
  771 + user_id,
  772 + }
  773 + }).then(res => {
  774 + var e = res;
  775 + if (e.data.code == 0) {
  776 + var pd_data = e.data.data.pageData;
  777 +
  778 + if (pd_data.length == 0) return;
  779 +
  780 + //获取当前
  781 + var nt = ut.gettimestamp();
  782 + pd_data.forEach(function (val, ind) {
  783 + if (val.start_time > nt) pd_data[ind].status = 0;
  784 + else if (val.end_time > nt) pd_data[ind].status = 1;
  785 + if (val.buy_num >= val.goods_num) pd_data[ind].status = 2;
  786 + });
  787 +
  788 + //获取当前时间,比较拼团中还在未开始
  789 + var timestamp = new Date().getTime();
  790 + var is_team_tepy;
  791 + for (var j = 0; j < pd_data.length; j++) {
  792 + pd_data[j].is_team_tepy = 1;
  793 + if (timestamp < pd_data[j].start_time * 1000) {
  794 + var is_team_tepy;
  795 + pd_data[j].is_team_tepy = 0;
  796 + }
  797 + }
  798 +
  799 + var arr = new Array();
  800 + //--2个2个一组---
  801 + for (var i = 0; i < pd_data.length; i += 2) {
  802 +
  803 + arr.push(pd_data.slice(i, i + 2));
  804 + }
  805 +
  806 + th.setData({
  807 + pindGoods: arr
  808 + });
  809 + th.countDown2();
  810 + }
  811 + })
  812 +
  813 + //------新品-------
  814 + await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
  815 + data: {
  816 + is_mainshow: 1,
  817 + isonsale: 1,
  818 + is_on_sale: 1,
  819 + store_id: o.stoid,
  820 + pageSize: 9,
  821 + is_new: 1,
  822 + orderField: "sort"
  823 + }
  824 + }).then(res => {
  825 + var e = res;
  826 + if (e.data.code == 0) {
  827 + var new_data = e.data.data.pageData;
  828 + var arr = new Array();
  829 + //--三个三个一组---
  830 + for (var i = 0; i < new_data.length; i += 3) {
  831 + arr.push(new_data.slice(i, i + 3));
  832 + }
  833 + th.setData({
  834 + newGoods: arr,
  835 + });
  836 + }
  837 + })
  838 +
  839 + //------热卖-------
  840 + await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
  841 + data: {
  842 + is_mainshow: 1,
  843 + isonsale: 1,
  844 + is_on_sale: 1,
  845 + store_id: o.stoid,
  846 + pageSize: 9,
  847 + is_hot: 1,
  848 + orderField: "sort"
  849 + }
  850 + }).then(res => {
  851 + var e = res;
  852 + if (e.data.code == 0) {
  853 + var new_data = e.data.data.pageData;
  854 + var arr = new Array();
  855 + //--三个三个一组---
  856 + for (var i = 0; i < new_data.length; i += 3) {
  857 + arr.push(new_data.slice(i, i + 3));
  858 + }
  859 + console.log(arr);
  860 + th.setData({
  861 + hotGoods: arr,
  862 + });
  863 + }
  864 + })
  865 +
  866 + //---调用信息---
  867 + // this.requestRecommend();
  868 + this.setData({
  869 + ishow: 1
  870 + });
  871 +
  872 + //---先获取会员---
  873 + //t.getUserFir(function () {
  874 + if (getApp().globalData.user_id) {
  875 + th.is_festival();
  876 + var new_nav = th.data.new_nav;
  877 + if (new_nav == "") {
  878 + th.is_new();
  879 + }
  880 +
  881 + // sty
  882 + setTimeout(function () {
  883 + if (getApp().globalData.user_id) getApp().requestCardNum(th);
  884 + }, 500)
  885 + }
  886 + //});
  887 +
  888 + setTimeout(function () {
  889 + var goods_list = th.selectComponent("#goods_list"); //组件的id
  890 + goods_list.init();
  891 + goods_list.get_list();
  892 + }, 2000)
  893 + },
  894 +
  895 + //--判断小程序是否过期--
  896 + setappdata: function (t) {
  897 + if (t && t.isout == 1)
  898 + wx.reLaunch({
  899 + url: "/packageD/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:" + getApp().globalData.config.store_tel,
  900 + });
  901 + if (t && t.isbuy == 0)
  902 + wx.reLaunch({
  903 + url: "/packageD/pages/error/error?msg=还未购买小程序",
  904 + });
  905 + },
  906 + //---加载更多是靠这个函数----
  907 + onReachBottom: function () {
867 console.log('下拉加载2'); 908 console.log('下拉加载2');
868 909
869 - var goods_list = this.selectComponent("#goods_list"); //组件的id  
870 - if (goods_list) goods_list.get_list(); 910 + var goods_list = this.selectComponent("#goods_list"); //组件的id
  911 + if (goods_list) goods_list.get_list();
871 912
872 - if (getApp().globalData.func_list) {  
873 - for (let i in getApp().globalData.func_list) {  
874 - let item = getApp().globalData.func_list[i];  
875 - item.re_show();  
876 - } 913 + if (getApp().globalData.func_list) {
  914 + for (let i in getApp().globalData.func_list) {
  915 + let item = getApp().globalData.func_list[i];
  916 + item.re_show();
  917 + }
877 } 918 }
878 - 919 +
879 920
880 //自定义时商品自动加载更多 921 //自定义时商品自动加载更多
881 let goodsGroupArr = this.data.goodsGroupArr 922 let goodsGroupArr = this.data.goodsGroupArr
882 - if (this.data.isTemplate && goodsGroupArr.length >0) {  
883 - goodsGroupArr.map(item=>{  
884 - if(this[item]) this[item].automore()  
885 - }) 923 + if (this.data.isTemplate && goodsGroupArr.length > 0) {
  924 + goodsGroupArr.map(item => {
  925 + if (this[item]) this[item].automore()
  926 + })
886 } 927 }
887 928
888 - },  
889 -  
890 - onPullDownRefresh: function (e) {  
891 - this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),  
892 - this.requestRecommend();  
893 - },  
894 - requestRecommend() { },  
895 - requestHomePage() { },  
896 -  
897 - onUnload: function () {  
898 - this.destroyActivityTimer();  
899 - },  
900 - setCountTime: function (e) {  
901 - e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({  
902 - "sale.diffTime": e.diffTime  
903 - }), this.setData({  
904 - "sale.good": e.flash_sale_goods[0]  
905 - }), this.destroyActivityTimer(), this.createActivityTimer();  
906 - },  
907 - createActivityTimer: function () {  
908 - var e = this.data.sale,  
909 - t = this;  
910 - this.data.timer = setInterval(function () {  
911 - var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime,  
912 - o = i.transTime(a);  
913 - a <= 0 ? t.requestHomePage() : t.setData({  
914 - "sale.countTime": o  
915 - });  
916 - }, 1e3);  
917 - },  
918 - destroyActivityTimer: function () {  
919 - this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);  
920 - },  
921 - onPageScroll: function (e) {  
922 - this.data.scrollTop = e.scrollTop;  
923 - var t = getCurrentPages();  
924 - "pages/index/index/index" == t[t.length - 1].route;  
925 - /*--(e.scrollTop > 10 ? wx.setNavigationBarColor({  
926 - frontColor: "#ffffff",  
927 - backgroundColor: "#f95959"  
928 - }) : wx.setNavigationBarColor({  
929 - frontColor: "#000000",  
930 - backgroundColor: "#eeeeee"  
931 - }));--*/  
932 - },  
933 - jumpSearch: function () {  
934 - wx.navigateTo({  
935 - url: "/packageG/pages/goods/search/search"  
936 - });  
937 - },  
938 - onShareAppMessage: function (e) {  
939 - getApp().globalData.no_clear = 1;  
940 - var url = "/pages/index/index/index";  
941 - var userInfo = getApp().globalData.userInfo;  
942 - //是分销商才带  
943 - if (userInfo) { 929 + },
  930 +
  931 + onPullDownRefresh: function (e) {
  932 + this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),
  933 + this.requestRecommend();
  934 + },
  935 + requestRecommend() { },
  936 + requestHomePage() { },
  937 +
  938 + onUnload: function () {
  939 + this.destroyActivityTimer();
  940 + },
  941 + setCountTime: function (e) {
  942 + e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({
  943 + "sale.diffTime": e.diffTime
  944 + }), this.setData({
  945 + "sale.good": e.flash_sale_goods[0]
  946 + }), this.destroyActivityTimer(), this.createActivityTimer();
  947 + },
  948 + createActivityTimer: function () {
  949 + var e = this.data.sale,
  950 + t = this;
  951 + this.data.timer = setInterval(function () {
  952 + var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime,
  953 + o = i.transTime(a);
  954 + a <= 0 ? t.requestHomePage() : t.setData({
  955 + "sale.countTime": o
  956 + });
  957 + }, 1e3);
  958 + },
  959 + destroyActivityTimer: function () {
  960 + this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);
  961 + },
  962 + onPageScroll: function (e) {
  963 + //满屏模式监听
  964 + if (this.data.is_full_screen_navigation) {
  965 + let num = e.scrollTop
  966 + let nav_type = this.data.nav_type
  967 + if (num >= 100 && nav_type) {
  968 + this.setData({
  969 + nav_type: 0,
  970 + searchbox_transparent: 0,
  971 + nav_frontColor: '#000'
  972 + })
  973 + // this.data.nav_type = 0
  974 + }
  975 + if (num < 100 && !nav_type) {
  976 + this.setData({
  977 + nav_type: 1,
  978 + searchbox_transparent: 1,
  979 + nav_frontColor: '#fff'
  980 + })
  981 + // this.data.nav_type = 1
  982 + }
  983 + }
  984 + //-----------end-------
  985 + this.data.scrollTop = e.scrollTop;
  986 + var t = getCurrentPages();
  987 + "pages/index/index/index" == t[t.length - 1].route;
  988 + /*--(e.scrollTop > 10 ? wx.setNavigationBarColor({
  989 + frontColor: "#ffffff",
  990 + backgroundColor: "#f95959"
  991 + }) : wx.setNavigationBarColor({
  992 + frontColor: "#000000",
  993 + backgroundColor: "#eeeeee"
  994 + }));--*/
  995 + },
  996 + jumpSearch: function () {
  997 + wx.navigateTo({
  998 + url: "/packageG/pages/goods/search/search"
  999 + });
  1000 + },
  1001 + onShareAppMessage: function (e) {
  1002 + getApp().globalData.no_clear = 1;
  1003 + var url = "/pages/index/index/index";
  1004 + var userInfo = getApp().globalData.userInfo;
  1005 + //是分销商才带
  1006 + if (userInfo) {
944 url += "?first_leader=" + userInfo.user_id; 1007 url += "?first_leader=" + userInfo.user_id;
945 //群id分享 1008 //群id分享
946 if (getApp().globalData.groupchat_id) { 1009 if (getApp().globalData.groupchat_id) {
947 - url+="&groupchat_id="+getApp().globalData.groupchat_id 1010 + url += "&groupchat_id=" + getApp().globalData.groupchat_id
948 } 1011 }
949 - }else{ 1012 + } else {
950 //群id分享 1013 //群id分享
951 if (getApp().globalData.groupchat_id) { 1014 if (getApp().globalData.groupchat_id) {
952 - url+="?groupchat_id="+getApp().globalData.groupchat_id 1015 + url += "?groupchat_id=" + getApp().globalData.groupchat_id
  1016 + }
  1017 + }
  1018 + console.log("---首页---分享--");
  1019 + var title = "商城首页"
  1020 + //分享
  1021 + if (getApp().globalData.config && getApp().globalData.config.store_name) {
  1022 + title = getApp().globalData.config.store_name;
  1023 + } else if (getApp().globalData.setting.appName) {
  1024 + title = getApp().globalData.setting.appName;
  1025 + }
  1026 +
  1027 +
  1028 +
  1029 + var ob = {
  1030 + title: title,
  1031 + path: url,
  1032 + };
  1033 + console.log(ob);
  1034 + return ob;
  1035 + },
  1036 +
  1037 + //图片失败,默认图片
  1038 + bind_bnerr: function (e) {
  1039 + var _errImg = e.target.dataset.errorimg;
  1040 + var _errObj = {};
  1041 + _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg";
  1042 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  1043 + },
  1044 +
  1045 + //图片失败,默认图片
  1046 + bind_bnerr2: function (e) {
  1047 + var _errImg = e.target.dataset.errorimg;
  1048 + var _errurl = e.target.dataset.url;
  1049 + var _errObj = {};
  1050 + _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
  1051 + this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  1052 +
  1053 + },
  1054 + //图片失败,默认图片
  1055 + bind_bnerr3: function (e) {
  1056 + var _errImg = e.target.dataset.errorimg;
  1057 + var _Img = e.target.dataset.img;
  1058 + if (_Img != undefined) {
  1059 + var _errObj = {};
  1060 + _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
  1061 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  1062 + }
  1063 + },
  1064 +
  1065 +
  1066 + //秒杀倒计时
  1067 + //---小于10的格式化函数----
  1068 + timeFormat(param) {
  1069 + return param < 10 ? '0' + param : param;
  1070 + },
  1071 +
  1072 + //----秒杀倒计时函数-----
  1073 + countDown() {
  1074 + if (!this.data.is_timer) return false;
  1075 + var th = this;
  1076 + // 获取当前时间,同时得到活动结束时间数组
  1077 + var newTime = ut.gettimestamp();
  1078 + var List = this.data.saleGoods;
  1079 + for (var j = 0; j < List.length; j++) {
  1080 + var endTimeList = List[j];
  1081 + // 对结束时间进行处理渲染到页面
  1082 + for (var i = 0; i < endTimeList.length; i++) {
  1083 + var o = endTimeList[i];
  1084 + var endTime = o.end_time
  1085 + if (o.status == 0) endTime = o.start_time
  1086 +
  1087 + var obj = null;
  1088 + // 如果活动未结束,对时间进行处理
  1089 + if (endTime - newTime > 0) {
  1090 + var time = (endTime - newTime);
  1091 + // 获取天、时、分、秒
  1092 + var day = parseInt(time / (60 * 60 * 24));
  1093 + var hou = parseInt(time % (60 * 60 * 24) / 3600);
  1094 + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  1095 + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  1096 + obj = {
  1097 + day: this.timeFormat(day),
  1098 + hou: this.timeFormat(hou),
  1099 + min: this.timeFormat(min),
  1100 + sec: this.timeFormat(sec)
  1101 + }
  1102 + } else {
  1103 + //活动已结束,全部设置为'00'
  1104 + obj = {
  1105 + day: '00',
  1106 + hou: '00',
  1107 + min: '00',
  1108 + sec: '00'
  1109 + }
  1110 + }
  1111 + var txt = "saleGoods[" + j + "][" + i + "].djs";
  1112 + th.setData({
  1113 + [txt]: obj
  1114 + });
953 } 1115 }
  1116 +
954 } 1117 }
955 - console.log("---首页---分享--");  
956 - var title = "商城首页"  
957 - //分享  
958 - if (getApp().globalData.config && getApp().globalData.config.store_name) {  
959 - title = getApp().globalData.config.store_name;  
960 - } else if (getApp().globalData.setting.appName) {  
961 - title = getApp().globalData.setting.appName; 1118 + setTimeout(th.countDown, 1000);
  1119 + },
  1120 +
  1121 + //----拼单倒计时函数-----
  1122 + countDown2() {
  1123 + if (!this.data.is_timer) return false;
  1124 +
  1125 + var th = this;
  1126 + // 获取当前时间,同时得到活动结束时间数组
  1127 + var newTime = ut.gettimestamp();
  1128 + var List = this.data.pindGoods;
  1129 + for (var j = 0; j < List.length; j++) {
  1130 + var endTimeList = List[j];
  1131 + // 对结束时间进行处理渲染到页面
  1132 + for (var i = 0; i < endTimeList.length; i++) {
  1133 + var o = endTimeList[i];
  1134 + var endTime = o.end_time;
  1135 + if (o.status == 0) endTime = o.start_time;
  1136 +
  1137 + let obj = null;
  1138 + // 如果活动未结束,对时间进行处理
  1139 + if (endTime - newTime > 0) {
  1140 + let time = (endTime - newTime);
  1141 + // 获取天、时、分、秒
  1142 + let day = parseInt(time / (60 * 60 * 24));
  1143 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  1144 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  1145 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  1146 + obj = {
  1147 + day: this.timeFormat(day),
  1148 + hou: this.timeFormat(hou),
  1149 + min: this.timeFormat(min),
  1150 + sec: this.timeFormat(sec)
  1151 + }
  1152 + } else {
  1153 + //活动已结束,全部设置为'00'
  1154 + obj = {
  1155 + day: '00',
  1156 + hou: '00',
  1157 + min: '00',
  1158 + sec: '00'
  1159 + }
  1160 + }
  1161 + var txt = "pindGoods[" + j + "][" + i + "].djs";
  1162 + th.setData({
  1163 + [txt]: obj
  1164 + });
  1165 + }
962 } 1166 }
963 -  
964 -  
965 -  
966 - var ob = {  
967 - title: title,  
968 - path: url,  
969 - };  
970 - console.log(ob);  
971 - return ob;  
972 - },  
973 -  
974 - //图片失败,默认图片  
975 - bind_bnerr: function (e) {  
976 - var _errImg = e.target.dataset.errorimg;  
977 - var _errObj = {};  
978 - _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg";  
979 - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
980 - },  
981 -  
982 - //图片失败,默认图片  
983 - bind_bnerr2: function (e) {  
984 - var _errImg = e.target.dataset.errorimg;  
985 - var _errurl = e.target.dataset.url;  
986 - var _errObj = {};  
987 - _errObj[_errImg] = "/miniapp/images/default_g_img.gif";  
988 - this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
989 -  
990 - },  
991 - //图片失败,默认图片  
992 - bind_bnerr3: function (e) {  
993 - var _errImg = e.target.dataset.errorimg;  
994 - var _Img = e.target.dataset.img;  
995 - if (_Img != undefined) {  
996 - var _errObj = {};  
997 - _errObj[_errImg] = "/public/images/default_goods_image_240.gif";  
998 - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
999 - }  
1000 - },  
1001 -  
1002 -  
1003 - //秒杀倒计时  
1004 - //---小于10的格式化函数----  
1005 - timeFormat(param) {  
1006 - return param < 10 ? '0' + param : param;  
1007 - },  
1008 -  
1009 - //----秒杀倒计时函数-----  
1010 - countDown() {  
1011 - if (!this.data.is_timer) return false;  
1012 - var th = this;  
1013 - // 获取当前时间,同时得到活动结束时间数组  
1014 - var newTime = ut.gettimestamp();  
1015 - var List = this.data.saleGoods;  
1016 - for (var j = 0; j < List.length; j++) {  
1017 - var endTimeList = List[j];  
1018 - // 对结束时间进行处理渲染到页面  
1019 - for (var i = 0; i < endTimeList.length; i++) {  
1020 - var o = endTimeList[i];  
1021 - var endTime = o.end_time  
1022 - if (o.status == 0) endTime = o.start_time  
1023 -  
1024 - var obj = null;  
1025 - // 如果活动未结束,对时间进行处理  
1026 - if (endTime - newTime > 0) {  
1027 - var time = (endTime - newTime);  
1028 - // 获取天、时、分、秒  
1029 - var day = parseInt(time / (60 * 60 * 24));  
1030 - var hou = parseInt(time % (60 * 60 * 24) / 3600);  
1031 - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60);  
1032 - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);  
1033 - obj = {  
1034 - day: this.timeFormat(day),  
1035 - hou: this.timeFormat(hou),  
1036 - min: this.timeFormat(min),  
1037 - sec: this.timeFormat(sec)  
1038 - }  
1039 - } else {  
1040 - //活动已结束,全部设置为'00'  
1041 - obj = {  
1042 - day: '00',  
1043 - hou: '00',  
1044 - min: '00',  
1045 - sec: '00'  
1046 - }  
1047 - }  
1048 - var txt = "saleGoods[" + j + "][" + i + "].djs";  
1049 - th.setData({  
1050 - [txt]: obj  
1051 - });  
1052 - }  
1053 -  
1054 - }  
1055 - setTimeout(th.countDown, 1000);  
1056 - },  
1057 -  
1058 - //----拼单倒计时函数-----  
1059 - countDown2() {  
1060 - if (!this.data.is_timer) return false;  
1061 -  
1062 - var th = this;  
1063 - // 获取当前时间,同时得到活动结束时间数组  
1064 - var newTime = ut.gettimestamp();  
1065 - var List = this.data.pindGoods;  
1066 - for (var j = 0; j < List.length; j++) {  
1067 - var endTimeList = List[j];  
1068 - // 对结束时间进行处理渲染到页面  
1069 - for (var i = 0; i < endTimeList.length; i++) {  
1070 - var o = endTimeList[i];  
1071 - var endTime = o.end_time;  
1072 - if (o.status == 0) endTime = o.start_time;  
1073 -  
1074 - let obj = null;  
1075 - // 如果活动未结束,对时间进行处理  
1076 - if (endTime - newTime > 0) {  
1077 - let time = (endTime - newTime);  
1078 - // 获取天、时、分、秒  
1079 - let day = parseInt(time / (60 * 60 * 24));  
1080 - let hou = parseInt(time % (60 * 60 * 24) / 3600);  
1081 - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);  
1082 - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);  
1083 - obj = {  
1084 - day: this.timeFormat(day),  
1085 - hou: this.timeFormat(hou),  
1086 - min: this.timeFormat(min),  
1087 - sec: this.timeFormat(sec)  
1088 - }  
1089 - } else {  
1090 - //活动已结束,全部设置为'00'  
1091 - obj = {  
1092 - day: '00',  
1093 - hou: '00',  
1094 - min: '00',  
1095 - sec: '00'  
1096 - }  
1097 - }  
1098 - var txt = "pindGoods[" + j + "][" + i + "].djs";  
1099 - th.setData({  
1100 - [txt]: obj  
1101 - });  
1102 - }  
1103 - }  
1104 - setTimeout(th.countDown2, 1000);  
1105 - },  
1106 -  
1107 - bannerSwiperChange: function (e) {  
1108 - var index = e.detail.current;  
1109 - this.setData({  
1110 - banner_index: index  
1111 - });  
1112 - },  
1113 - flashSwiperChange: function (e) {  
1114 - var index = e.detail.current;  
1115 - this.setData({  
1116 - flash_index: index  
1117 - });  
1118 - },  
1119 - ptSwiperChange: function (e) {  
1120 - var index = e.detail.current;  
1121 - this.setData({  
1122 - pt_index: index  
1123 - });  
1124 - },  
1125 -  
1126 - Interval_pt() {  
1127 - var th = this;  
1128 - this.data.pt_timer = setInterval(function () {  
1129 - var item = ut.get_rand_item(th.data.pt_timer_arr);  
1130 - th.setData({  
1131 - pt_timer_active: 1,  
1132 - pt_timer_item: item  
1133 - });  
1134 - setTimeout(function () {  
1135 - th.setData({  
1136 - pt_timer_active: 0  
1137 - });  
1138 - }, 1500)  
1139 - }, 4000);  
1140 - },  
1141 -  
1142 -  
1143 - //---扫一扫的函数---  
1144 - getScancode: function () {  
1145 - var _this = this;  
1146 - getApp().globalData.no_clear = 1;  
1147 - // 允许从相机和相册扫码  
1148 - wx.scanCode({  
1149 - success: (res) => {  
1150 - var result = res.result;  
1151 - wx.navigateTo({  
1152 - url: "/packageG/pages/goods/search/search?s_key=" + result,  
1153 - });  
1154 - }  
1155 - })  
1156 - },  
1157 - //广告跳转  
1158 - go_mb(e){  
1159 - let url=e.currentTarget.dataset.url 1167 + setTimeout(th.countDown2, 1000);
  1168 + },
  1169 +
  1170 + bannerSwiperChange: function (e) {
  1171 + var index = e.detail.current;
  1172 + this.setData({
  1173 + banner_index: index
  1174 + });
  1175 + },
  1176 + flashSwiperChange: function (e) {
  1177 + var index = e.detail.current;
  1178 + this.setData({
  1179 + flash_index: index
  1180 + });
  1181 + },
  1182 + ptSwiperChange: function (e) {
  1183 + var index = e.detail.current;
  1184 + this.setData({
  1185 + pt_index: index
  1186 + });
  1187 + },
  1188 +
  1189 + Interval_pt() {
  1190 + var th = this;
  1191 + this.data.pt_timer = setInterval(function () {
  1192 + var item = ut.get_rand_item(th.data.pt_timer_arr);
  1193 + th.setData({
  1194 + pt_timer_active: 1,
  1195 + pt_timer_item: item
  1196 + });
  1197 + setTimeout(function () {
  1198 + th.setData({
  1199 + pt_timer_active: 0
  1200 + });
  1201 + }, 1500)
  1202 + }, 4000);
  1203 + },
  1204 +
  1205 +
  1206 + //---扫一扫的函数---
  1207 + getScancode: function () {
  1208 + var _this = this;
  1209 + getApp().globalData.no_clear = 1;
  1210 + // 允许从相机和相册扫码
  1211 + wx.scanCode({
  1212 + success: (res) => {
  1213 + var result = res.result;
  1214 + wx.navigateTo({
  1215 + url: "/packageG/pages/goods/search/search?s_key=" + result,
  1216 + });
  1217 + }
  1218 + })
  1219 + },
  1220 + //广告跳转
  1221 + go_mb(e) {
  1222 + let url = e.currentTarget.dataset.url
1160 getApp().goto(url); 1223 getApp().goto(url);
1161 }, 1224 },
1162 1225
1163 - //跳转到分类  
1164 - go_cate: function () {  
1165 - getApp().goto("/pages/goods/categoryList/categoryList");  
1166 - },  
1167 -  
1168 - // 幸运购跳转  
1169 - go_url: function (e) {  
1170 -  
1171 - var url = e.currentTarget.dataset.url;  
1172 - getApp().goto(url);  
1173 -  
1174 - }, //  
1175 -  
1176 - bind_bnerr_icon: function (e) {  
1177 - var def = "/miniapp/images/no_cate_def.png";  
1178 - var _err = e.currentTarget.dataset.err;  
1179 - var ob = {};  
1180 - ob[_err] = def;  
1181 - this.setData(ob);  
1182 - },  
1183 -  
1184 - //跳转到分类的商品列表  
1185 - go_cate2: function (t) {  
1186 - var cid = t.currentTarget.dataset.cid;  
1187 - var pid = t.currentTarget.dataset.pid;  
1188 - var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid;  
1189 - wx.navigateTo({  
1190 - url: lurl  
1191 - });  
1192 - },  
1193 - new_nav: function (e) {  
1194 - var th = this;  
1195 - var new_nav = th.data.new_nav;  
1196 - getApp().goto(new_nav);  
1197 - },  
1198 - //跳转到权益  
1199 - go_quanyi: function (t) {  
1200 - var user_info = getApp().globalData.userInfo;  
1201 - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {  
1202 - wx.navigateTo({  
1203 - url: '/packageE/pages/togoin/togoin',  
1204 - //url: '/pages/getphone/getphone',  
1205 - })  
1206 - return false;  
1207 - }  
1208 - getApp().goto("/pages/user/userqy/userqy");  
1209 - },  
1210 -  
1211 - imageLoad: function (e) {  
1212 - var imgwidth = e.detail.width;  
1213 - var imgheight = e.detail.height;  
1214 - //宽高比  
1215 - var ratio = imgwidth / imgheight;  
1216 - //计算的高度值  
1217 - var viewHeight = 715 / ratio;  
1218 - if (this.data.max_sw_height < viewHeight) this.setData({  
1219 - max_sw_height: viewHeight  
1220 - });  
1221 - },  
1222 - //判断该用户是否是新会员  
1223 - is_new: function () {  
1224 - var th = this;  
1225 - wx.hideLoading();  
1226 - getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {  
1227 - data: {  
1228 - storeId: os.stoid,  
1229 - userId: d.user_id  
1230 - }  
1231 - }).then(res => {  
1232 - if (res.data.code == 0) {  
1233 - var actid = res.data.data.id; //活动id  
1234 - var giftBagId = res.data.data.giftBagId; //礼包id  
1235 - var new_nav = "/pages/giftpack/newvipgift/newvipgift?actId=" + actid + '&' + 'actType=' + 1 + '&' + 'giftBagId=' + giftBagId;  
1236 - var new_image = res.data.data.imageurl;  
1237 - var swiperimage = th.data.swiperimage;  
1238 - var img = {  
1239 - image: "/miniapp/images/newpeople/newpeople.png",  
1240 - nav_url: new_nav  
1241 - }  
1242 - swiperimage.unshift(img);  
1243 - th.setData({  
1244 - swiperimage: swiperimage,  
1245 - new_image: new_image,  
1246 - new_nav: new_nav  
1247 - })  
1248 -  
1249 - getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/bound/judge", {  
1250 - data: {  
1251 - storeId: o.stoid,  
1252 - userId: d.user_id  
1253 - }  
1254 - }).then(res => {  
1255 - if (res.data.code == 0) {  
1256 - th.setData({  
1257 - is_disgraceful: 1  
1258 - })  
1259 - } else {  
1260 - th.check_holiday_pop(); //节日的弹窗  
1261 - }  
1262 -  
1263 - })  
1264 - } else {  
1265 - th.check_holiday_pop(); //节日的弹窗  
1266 - }  
1267 -  
1268 - })  
1269 -  
1270 - },  
1271 -  
1272 - is_festival: function (e) {  
1273 - var th = this;  
1274 - var url = "/api/weshop/marketing/holiday/act/judge";  
1275 - getApp().request.promiseGet(url, {  
1276 - data: {  
1277 - storeId: os.stoid,  
1278 - userId: d.user_id  
1279 - }  
1280 - }).then(res => {  
1281 - if (res.data.code == 0) {  
1282 - var actid = res.data.data.id; //活动id  
1283 - var giftBagId = res.data.data.gifBagId; //礼包id  
1284 - var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId;  
1285 - var swiperimage = th.data.swiperimage;  
1286 - var actBoundImg = res.data.data.actBoundImg ? res.data.data.actBoundImg : '/miniapp/images/default_g_img.gif';  
1287 -  
1288 - th.data.holiday_image = res.data.data.actImg;  
1289 - th.data.holiday_url = nav_url;  
1290 -  
1291 - var img = {  
1292 - image: actBoundImg,  
1293 - nav_url: nav_url,  
1294 - id: res.data.data.id,  
1295 - type: 'festival'  
1296 - }  
1297 -  
1298 - for (var i in swiperimage) {  
1299 - var item = swiperimage[i];  
1300 - if (item.id == img.id && item.type == img.type) {  
1301 - return false;  
1302 - }  
1303 - }  
1304 -  
1305 - swiperimage.unshift(img);  
1306 - th.setData({  
1307 - swiperimage: swiperimage,  
1308 - new_nav: nav_url  
1309 - })  
1310 - }  
1311 - })  
1312 - },  
1313 -  
1314 - //弹出节日有礼  
1315 - check_holiday_pop: function () {  
1316 - var th = this;  
1317 - getApp().waitfor2(th, 'w_holiday_pop', 'holiday_image', function () {  
1318 - //等到结果才显示  
1319 - if (th.data.holiday_image) {  
1320 - th.setData({  
1321 - new_image: th.data.holiday_image,  
1322 - new_nav: th.data.holiday_url,  
1323 - is_disgraceful: 1  
1324 - })  
1325 - }  
1326 - })  
1327 - },  
1328 -  
1329 - go_ad: function (e) {  
1330 - var url = e.currentTarget.dataset.url;  
1331 - if (!url || url == '') return;  
1332 - if (url[0] != '/') url = '/' + url;  
1333 - getApp().goto(url);  
1334 - },  
1335 -  
1336 - //导航跳转  
1337 - nav_goto: function (e) {  
1338 - var url = e.currentTarget.dataset.url;  
1339 - if (!url || url == '') return;  
1340 - if (url[0] != '/') url = '/' + url;  
1341 - getApp().goto(url);  
1342 - if (this.data.showHongbao) {  
1343 - this.setData({  
1344 - showHongbao: false,  
1345 - showHongbaoSmall: true, //显示抢红包小图标  
1346 - });  
1347 - }  
1348 - },  
1349 -  
1350 - //----跳转到搭配购买----  
1351 - go_test: function () {  
1352 - wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", })  
1353 - },  
1354 - onShareTimeline() {  
1355 - getApp().globalData.no_clear=1;  
1356 - var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';  
1357 - if (!store_name){  
1358 - store_name = getApp().globalData.setting.appName;  
1359 - }  
1360 - var user_id=getApp().globalData.user_id;  
1361 - if(!user_id) user_id=0;  
1362 - var url=''  
1363 - //群id分享  
1364 - if (getApp().globalData.groupchat_id) {  
1365 - url+="&groupchat_id="+getApp().globalData.groupchat_id 1226 + //跳转到分类
  1227 + go_cate: function () {
  1228 + getApp().goto("/pages/goods/categoryList/categoryList");
  1229 + },
  1230 +
  1231 + // 幸运购跳转
  1232 + go_url: function (e) {
  1233 +
  1234 + var url = e.currentTarget.dataset.url;
  1235 + getApp().goto(url);
  1236 +
  1237 + }, //
  1238 +
  1239 + bind_bnerr_icon: function (e) {
  1240 + var def = "/miniapp/images/no_cate_def.png";
  1241 + var _err = e.currentTarget.dataset.err;
  1242 + var ob = {};
  1243 + ob[_err] = def;
  1244 + this.setData(ob);
  1245 + },
  1246 +
  1247 + //跳转到分类的商品列表
  1248 + go_cate2: function (t) {
  1249 + var cid = t.currentTarget.dataset.cid;
  1250 + var pid = t.currentTarget.dataset.pid;
  1251 + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid;
  1252 + wx.navigateTo({
  1253 + url: lurl
  1254 + });
  1255 + },
  1256 + new_nav: function (e) {
  1257 + var th = this;
  1258 + var new_nav = th.data.new_nav;
  1259 + getApp().goto(new_nav);
  1260 + },
  1261 + //跳转到权益
  1262 + go_quanyi: function (t) {
  1263 + var user_info = getApp().globalData.userInfo;
  1264 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  1265 + wx.navigateTo({
  1266 + url: '/packageE/pages/togoin/togoin',
  1267 + //url: '/pages/getphone/getphone',
  1268 + })
  1269 + return false;
  1270 + }
  1271 + getApp().goto("/pages/user/userqy/userqy");
  1272 + },
  1273 +
  1274 + imageLoad: function (e) {
  1275 + var imgwidth = e.detail.width;
  1276 + var imgheight = e.detail.height;
  1277 + //宽高比
  1278 + var ratio = imgwidth / imgheight;
  1279 + //计算的高度值
  1280 + var viewHeight = 715 / ratio;
  1281 + if (this.data.max_sw_height < viewHeight) this.setData({
  1282 + max_sw_height: viewHeight
  1283 + });
  1284 + },
  1285 + //判断该用户是否是新会员
  1286 + is_new: function () {
  1287 + var th = this;
  1288 + wx.hideLoading();
  1289 + getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {
  1290 + data: {
  1291 + storeId: os.stoid,
  1292 + userId: d.user_id
  1293 + }
  1294 + }).then(res => {
  1295 + if (res.data.code == 0) {
  1296 + var actid = res.data.data.id; //活动id
  1297 + var giftBagId = res.data.data.giftBagId; //礼包id
  1298 + var new_nav = "/pages/giftpack/newvipgift/newvipgift?actId=" + actid + '&' + 'actType=' + 1 + '&' + 'giftBagId=' + giftBagId;
  1299 + var new_image = res.data.data.imageurl;
  1300 + var swiperimage = th.data.swiperimage;
  1301 + var img = {
  1302 + image: "/miniapp/images/newpeople/newpeople.png",
  1303 + nav_url: new_nav
1366 } 1304 }
1367 - return {  
1368 - title: '首页-' + '-' + store_name,  
1369 - query: 'first_leader='+user_id+url 1305 + swiperimage.unshift(img);
  1306 + th.setData({
  1307 + swiperimage: swiperimage,
  1308 + new_image: new_image,
  1309 + new_nav: new_nav
  1310 + })
  1311 +
  1312 + getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/bound/judge", {
  1313 + data: {
  1314 + storeId: o.stoid,
  1315 + userId: d.user_id
  1316 + }
  1317 + }).then(res => {
  1318 + if (res.data.code == 0) {
  1319 + th.setData({
  1320 + is_disgraceful: 1
  1321 + })
  1322 + } else {
  1323 + th.check_holiday_pop(); //节日的弹窗
  1324 + }
  1325 +
  1326 + })
  1327 + } else {
  1328 + th.check_holiday_pop(); //节日的弹窗
  1329 + }
  1330 +
  1331 + })
  1332 +
  1333 + },
  1334 +
  1335 + is_festival: function (e) {
  1336 + var th = this;
  1337 + var url = "/api/weshop/marketing/holiday/act/judge";
  1338 + getApp().request.promiseGet(url, {
  1339 + data: {
  1340 + storeId: os.stoid,
  1341 + userId: d.user_id
  1342 + }
  1343 + }).then(res => {
  1344 + if (res.data.code == 0) {
  1345 + var actid = res.data.data.id; //活动id
  1346 + var giftBagId = res.data.data.gifBagId; //礼包id
  1347 + var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId;
  1348 + var swiperimage = th.data.swiperimage;
  1349 + var actBoundImg = res.data.data.actBoundImg ? res.data.data.actBoundImg : '/miniapp/images/default_g_img.gif';
  1350 +
  1351 + th.data.holiday_image = res.data.data.actImg;
  1352 + th.data.holiday_url = nav_url;
  1353 +
  1354 + var img = {
  1355 + image: actBoundImg,
  1356 + nav_url: nav_url,
  1357 + id: res.data.data.id,
  1358 + type: 'festival'
1370 } 1359 }
1371 - },  
1372 1360
1373 - // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标  
1374 - closeHongbao() {  
1375 - this.setData({  
1376 - showHongbao: false, //关闭抢红包主弹窗  
1377 - showHongbaoSmall: true, //显示抢红包小图标  
1378 - });  
1379 - },  
1380 -  
1381 - /*-- 全屏广告 --*/  
1382 - close_full_screen() {  
1383 - this.setData({ is_full_screen_show: 0, sec_show: 0 });  
1384 - },  
1385 - //-- 跳转到满屏广告的链接 --  
1386 - go_full_ad() {  
1387 - if (!this.data.full_ad) return false;  
1388 - if (!this.data.full_ad.ad_weapplink) return false;  
1389 - getApp().goto(this.data.full_ad.ad_weapplink);  
1390 - this.close_full_screen();  
1391 - },  
1392 -  
1393 - go_pre: function (e) {  
1394 - var userInfo = getApp().globalData.userInfo;  
1395 - if (!userInfo) {  
1396 - getApp().goto("/packageE/pages/togoin/togoin");  
1397 - return false;  
1398 - }  
1399 - var url = e.currentTarget.dataset.url;  
1400 - getApp().goto(url);  
1401 - }, 1361 + for (var i in swiperimage) {
  1362 + var item = swiperimage[i];
  1363 + if (item.id == img.id && item.type == img.type) {
  1364 + return false;
  1365 + }
  1366 + }
  1367 +
  1368 + swiperimage.unshift(img);
  1369 + th.setData({
  1370 + swiperimage: swiperimage,
  1371 + new_nav: nav_url
  1372 + })
  1373 + }
  1374 + })
  1375 + },
  1376 +
  1377 + //弹出节日有礼
  1378 + check_holiday_pop: function () {
  1379 + var th = this;
  1380 + getApp().waitfor2(th, 'w_holiday_pop', 'holiday_image', function () {
  1381 + //等到结果才显示
  1382 + if (th.data.holiday_image) {
  1383 + th.setData({
  1384 + new_image: th.data.holiday_image,
  1385 + new_nav: th.data.holiday_url,
  1386 + is_disgraceful: 1
  1387 + })
  1388 + }
  1389 + })
  1390 + },
  1391 +
  1392 + go_ad: function (e) {
  1393 + var url = e.currentTarget.dataset.url;
  1394 + if (!url || url == '') return;
  1395 + if (url[0] != '/') url = '/' + url;
  1396 + getApp().goto(url);
  1397 + },
  1398 +
  1399 + //导航跳转
  1400 + nav_goto: function (e) {
  1401 + var url = e.currentTarget.dataset.url;
  1402 + if (!url || url == '') return;
  1403 + if (url[0] != '/') url = '/' + url;
  1404 + getApp().goto(url);
  1405 + if (this.data.showHongbao) {
  1406 + this.setData({
  1407 + showHongbao: false,
  1408 + showHongbaoSmall: true, //显示抢红包小图标
  1409 + });
  1410 + }
  1411 + },
  1412 +
  1413 + //----跳转到搭配购买----
  1414 + go_test: function () {
  1415 + wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", })
  1416 + },
  1417 + onShareTimeline() {
  1418 + getApp().globalData.no_clear = 1;
  1419 + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
  1420 + if (!store_name) {
  1421 + store_name = getApp().globalData.setting.appName;
  1422 + }
  1423 + var user_id = getApp().globalData.user_id;
  1424 + if (!user_id) user_id = 0;
  1425 + var url = ''
  1426 + //群id分享
  1427 + if (getApp().globalData.groupchat_id) {
  1428 + url += "&groupchat_id=" + getApp().globalData.groupchat_id
  1429 + }
  1430 + return {
  1431 + title: '首页-' + '-' + store_name,
  1432 + query: 'first_leader=' + user_id + url
  1433 + }
  1434 + },
  1435 +
  1436 + // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标
  1437 + closeHongbao() {
  1438 + this.setData({
  1439 + showHongbao: false, //关闭抢红包主弹窗
  1440 + showHongbaoSmall: true, //显示抢红包小图标
  1441 + });
  1442 + },
  1443 +
  1444 + /*-- 全屏广告 --*/
  1445 + close_full_screen() {
  1446 + this.setData({ is_full_screen_show: 0, sec_show: 0 });
  1447 + },
  1448 + //-- 跳转到满屏广告的链接 --
  1449 + go_full_ad() {
  1450 + if (!this.data.full_ad) return false;
  1451 + if (!this.data.full_ad.ad_weapplink) return false;
  1452 + getApp().goto(this.data.full_ad.ad_weapplink);
  1453 + this.close_full_screen();
  1454 + },
  1455 +
  1456 + go_pre: function (e) {
  1457 + var userInfo = getApp().globalData.userInfo;
  1458 + if (!userInfo) {
  1459 + getApp().goto("/packageE/pages/togoin/togoin");
  1460 + return false;
  1461 + }
  1462 + var url = e.currentTarget.dataset.url;
  1463 + getApp().goto(url);
  1464 + },
1402 1465
1403 //视频号跳转 1466 //视频号跳转
1404 - nv_void(){ 1467 + nv_void() {
1405 // getApp().openChannelsActivity() 1468 // getApp().openChannelsActivity()
1406 wx.getChannelsLiveInfo({ 1469 wx.getChannelsLiveInfo({
1407 - finderUserName:'sphYA5FuPCZxHaw',  
1408 - success:(res)=>{ 1470 + finderUserName: 'sphYA5FuPCZxHaw',
  1471 + success: (res) => {
1409 console.log(res) 1472 console.log(res)
1410 }, 1473 },
1411 - fail:(error)=>{ 1474 + fail: (error) => {
1412 console.log(error) 1475 console.log(error)
1413 } 1476 }
1414 }) 1477 })
1415 }, 1478 },
1416 - getchir(){ 1479 + getchir() {
1417 const child = this.selectComponent('.goodsg'); 1480 const child = this.selectComponent('.goodsg');
1418 console.log('子组件--------111111------') 1481 console.log('子组件--------111111------')
1419 console.log(child) 1482 console.log(child)
pages/index/index/index.json
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 "usingComponents": { 2 "usingComponents": {
3 "goods_recommend":"/components/goods_list/goods_list", 3 "goods_recommend":"/components/goods_list/goods_list",
4 "nav": "/components/diy_nav/diy_nav", 4 "nav": "/components/diy_nav/diy_nav",
  5 + "top_nav": "/components/diy_top_nav/diy_top_nav",
5 "advertising":"/components/diy_advertising/diy_advertising", 6 "advertising":"/components/diy_advertising/diy_advertising",
6 "groupbuy": "/components/diy_groupbuy/diy_groupbuy", 7 "groupbuy": "/components/diy_groupbuy/diy_groupbuy",
7 "goodsGroup": "/components/diy_goodsGroup/diy_goodsGroup", 8 "goodsGroup": "/components/diy_goodsGroup/diy_goodsGroup",
@@ -31,5 +32,6 @@ @@ -31,5 +32,6 @@
31 "privacy_pop": "/components/privacy_pop/privacy_pop" 32 "privacy_pop": "/components/privacy_pop/privacy_pop"
32 }, 33 },
33 "enablePullDownRefresh": false, 34 "enablePullDownRefresh": false,
34 - "onReachBottomDistance":300 35 + "onReachBottomDistance":300,
  36 + "navigationStyle":"custom"
35 } 37 }
36 \ No newline at end of file 38 \ No newline at end of file
pages/index/index/index.wxml
@@ -23,6 +23,8 @@ @@ -23,6 +23,8 @@
23 </block> 23 </block>
24 24
25 <view class="top-bar"> 25 <view class="top-bar">
  26 + <top_nav nav_type="{{0}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor ? nav_backgroundColor :'#fff'}}" nav_title="{{nav_title}}"></top_nav>
  27 +
26 <!-- 顶部关注公众号 --> 28 <!-- 顶部关注公众号 -->
27 <view id="off_top" wx:if="{{is_gz_h5}}"> 29 <view id="off_top" wx:if="{{is_gz_h5}}">
28 <official-account></official-account> 30 <official-account></official-account>
@@ -48,6 +50,7 @@ @@ -48,6 +50,7 @@
48 </view> 50 </view>
49 </view> 51 </view>
50 </view> 52 </view>
  53 + <top_nav nav_type="{{-1}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor}}" nav_title="{{nav_title}}"></top_nav>
51 54
52 <!-- 如果有关注,要顶开位置,不能注释 --> 55 <!-- 如果有关注,要顶开位置,不能注释 -->
53 <view wx:if="{{is_gz_h5 && is_ok_h5}}" style="height: 84px;;flex-shrink:0"></view> 56 <view wx:if="{{is_gz_h5 && is_ok_h5}}" style="height: 84px;;flex-shrink:0"></view>
@@ -137,23 +140,23 @@ @@ -137,23 +140,23 @@
137 <view class="mb_box"> 140 <view class="mb_box">
138 <view class="mb_top"> 141 <view class="mb_top">
139 <view class="mb_top_item" data-url="{{mb_banner['300'].ad_weapplink}}" wx:if="{{mb_banner['300']}}" catchtap="go_mb"> 142 <view class="mb_top_item" data-url="{{mb_banner['300'].ad_weapplink}}" wx:if="{{mb_banner['300']}}" catchtap="go_mb">
140 - <image src="{{mb_banner['300'].ad_code}}" style="max-width: 100%;max-height: 360rpx;"></image> 143 + <image src="{{mb_banner['300'].ad_code}}" style="max-width: 100%;max-height: 360rpx;"></image>
141 </view> 144 </view>
142 <view class="mb_top_item"> 145 <view class="mb_top_item">
143 <view wx:if="{{mb_banner['301']}}" data-url="{{mb_banner['301'].ad_weapplink}}" catchtap="go_mb"> 146 <view wx:if="{{mb_banner['301']}}" data-url="{{mb_banner['301'].ad_weapplink}}" catchtap="go_mb">
144 - <image src="{{mb_banner['301'].ad_code}}" style="max-width: 100%;max-height: 180rpx;"></image> 147 + <image src="{{mb_banner['301'].ad_code}}" style="max-width: 100%;max-height: 180rpx;"></image>
145 </view> 148 </view>
146 <view wx:if="{{mb_banner['302']}}" data-url="{{mb_banner['302'].ad_weapplink}}" catchtap="go_mb"> 149 <view wx:if="{{mb_banner['302']}}" data-url="{{mb_banner['302'].ad_weapplink}}" catchtap="go_mb">
147 - <image src="{{mb_banner['302'].ad_code}}" style="max-width: 100%;max-height: 180rpx;"></image> 150 + <image src="{{mb_banner['302'].ad_code}}" style="max-width: 100%;max-height: 180rpx;"></image>
148 </view> 151 </view>
149 </view> 152 </view>
150 </view> 153 </view>
151 <view class="mb_bottom"> 154 <view class="mb_bottom">
152 <view wx:if="{{mb_banner['303']}}" data-url="{{mb_banner['303'].ad_weapplink}}" catchtap="go_mb"> 155 <view wx:if="{{mb_banner['303']}}" data-url="{{mb_banner['303'].ad_weapplink}}" catchtap="go_mb">
153 - <image src="{{mb_banner['303'].ad_code}}" style="max-width: 100%;max-height:200rpx;"></image> 156 + <image src="{{mb_banner['303'].ad_code}}" style="max-width: 100%;max-height:200rpx;"></image>
154 </view> 157 </view>
155 <view wx:if="{{mb_banner['304']}}" data-url="{{mb_banner['304'].ad_weapplink}}" catchtap="go_mb"> 158 <view wx:if="{{mb_banner['304']}}" data-url="{{mb_banner['304'].ad_weapplink}}" catchtap="go_mb">
156 - <image src="{{mb_banner['304'].ad_code}}" style="max-width: 100%;max-height: 200rpx;"></image> 159 + <image src="{{mb_banner['304'].ad_code}}" style="max-width: 100%;max-height: 200rpx;"></image>
157 </view> 160 </view>
158 </view> 161 </view>
159 </view> 162 </view>
@@ -412,14 +415,13 @@ @@ -412,14 +415,13 @@
412 <!--是否是自定义--> 415 <!--是否是自定义-->
413 <view class="container" wx:if="{{isTemplate}}" style="background-color:{{bgcolor_t}}; padding-bottom: 10rpx"> 416 <view class="container" wx:if="{{isTemplate}}" style="background-color:{{bgcolor_t}}; padding-bottom: 10rpx">
414 <!-- 置顶层 --> 417 <!-- 置顶层 -->
415 - <view class="dis_top" style="position:fixed">  
416 - <!-- 关注公众号的显示 -->  
417 - <view id="off_top" wx:if="{{is_gz_h5}}"> 418 + <!-- <view class="dis_top" style="position:fixed"> -->
  419 + <!-- 关注公众号的显示 -->
  420 + <!-- <view id="off_top" wx:if="{{is_gz_h5}}">
418 <official-account></official-account> 421 <official-account></official-account>
419 </view> 422 </view>
420 <block wx:for="{{template_arr}}"> 423 <block wx:for="{{template_arr}}">
421 <block wx:if="{{item.content.is_top==1}}"> 424 <block wx:if="{{item.content.is_top==1}}">
422 - <!--如果是搜索框的时候 -->  
423 <block wx:if="{{item.ename=='searchbox'}}"> 425 <block wx:if="{{item.ename=='searchbox'}}">
424 <searchbox object="{{item.content}}"></searchbox> 426 <searchbox object="{{item.content}}"></searchbox>
425 </block> 427 </block>
@@ -428,19 +430,87 @@ @@ -428,19 +430,87 @@
428 </block> 430 </block>
429 </block> 431 </block>
430 </block> 432 </block>
431 - </view> 433 + </view> -->
432 434
433 <!-- 撑开层 --> 435 <!-- 撑开层 -->
434 - <view> 436 + <!-- <view>
435 <view wx:if="{{is_gz_h5 && is_ok_h5}}" style="height: 84px;flex-shrink:0"></view> 437 <view wx:if="{{is_gz_h5 && is_ok_h5}}" style="height: 84px;flex-shrink:0"></view>
436 <block wx:for="{{template_arr}}"> 438 <block wx:for="{{template_arr}}">
437 <block wx:if="{{item.content.is_top==1}}"> 439 <block wx:if="{{item.content.is_top==1}}">
438 - <!-- <view style="height:88rpx"></view> -->  
439 <view style="height:{{item.content.style==1 ? 110 : 88}}rpx"></view> 440 <view style="height:{{item.content.style==1 ? 110 : 88}}rpx"></view>
440 </block> 441 </block>
  442 + </block>
  443 +
  444 + </view> -->
  445 +
  446 + <block wx:if="{{is_full_screen_navigation}}">
  447 + <view class="dis_top" style="position: fixed;">
  448 + <top_nav nav_type="{{nav_type}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor ? '#fff' :'#fff'}}" nav_title="{{nav_title}}"></top_nav>
  449 +
  450 + <!-- <js_store_select bindup_storid="get_new_storid" id="js_store_select" transparent="{{searchbox_transparent}}" bgcoler="{{nav_backgroundColor ? '#fff' :'#fff'}}" anclor="{{nav_but_color}}" ></js_store_select> -->
  451 +
  452 + <block wx:for="{{template_arr}}">
  453 + <block wx:if="{{item.content.is_top==1}}">
  454 + <!--如果是搜索框的时候 -->
  455 + <block wx:if="{{item.ename=='searchbox'}}">
  456 + <searchbox object="{{item.content}}" transparent="{{searchbox_transparent}}" nav_backgroundColor="{{nav_backgroundColor ? '#fff' :'#fff'}}"></searchbox>
  457 + </block>
  458 + <!-- <block wx:if="{{item.ename=='store_select'}}">
  459 + <store_select object="{{item.content}}"></store_select>
  460 + </block> -->
  461 + </block>
  462 + </block>
  463 + </view>
  464 + <block wx:for="{{template_arr}}">
  465 + <!--广告组合-->
  466 + <block wx:if="{{item.ename=='advertising' && item.content.full_screen==1 && is_full_screen_navigation_index==index}}">
  467 + <advertising object="{{item.content}}" bindbutColorEvent="bindbut_color_event_fn" is_full_screen_navigation_index="{{is_full_screen_navigation_index}}"></advertising>
  468 + </block>
441 </block> 469 </block>
  470 + </block>
  471 +
  472 + <block wx:else>
  473 + <!-- 置顶层 -->
  474 + <view class="dis_top" style="position:fixed">
  475 + <top_nav nav_type="{{0}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor}}" nav_title="{{nav_title}}"></top_nav>
  476 + <!-- 关注公众号的显示 -->
  477 + <view id="off_top" wx:if="{{is_gz_h5}}">
  478 + <official-account></official-account>
  479 + </view>
  480 +
  481 + <!-- <js_store_select id="js_store_select" bindup_storid="get_new_storid" transparent="{{0}}" bgcoler="{{nav_backgroundColor}}" anclor="{{nav_but_color}}" ></js_store_select> -->
  482 +
  483 + <block wx:for="{{template_arr}}">
  484 + <block wx:if="{{item.content.is_top==1}}">
  485 + <!--如果是搜索框的时候 -->
  486 + <block wx:if="{{item.ename=='searchbox'}}">
  487 + <searchbox object="{{item.content}}"></searchbox>
  488 + </block>
  489 + <!-- <block wx:if="{{item.ename=='store_select'}}">-->
  490 + <!-- <store_select object="{{item.content}}"></store_select>-->
  491 + <!-- </block>-->
  492 +
  493 + </block>
  494 + </block>
  495 + </view>
  496 +
  497 + <!-- 撑开层 -->
  498 + <view>
  499 + <!-- 顶部导航撑开层 -->
  500 + <top_nav nav_type="{{-1}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor}}" nav_title="{{nav_title}}"></top_nav>
  501 + <!-- 即时零售,门店选择撑开层 -->
  502 + <!-- <view style="width: 100%;height: 88rpx;"></view> -->
  503 + <view wx:if="{{is_gz_h5 && is_ok_h5}}" style="height: 84px;flex-shrink:0"></view>
  504 + <block wx:for="{{template_arr}}">
  505 + <block wx:if="{{item.content.is_top==1}}">
  506 + <view style="height:{{item.content.style==1 ? 110 : 88 }}rpx"></view>
  507 + </block>
  508 + </block>
  509 +
  510 + </view>
  511 + </block>
  512 +
442 513
443 - </view>  
444 514
445 <block wx:for="{{template_arr}}" wx:key="index"> 515 <block wx:for="{{template_arr}}" wx:key="index">
446 <view> 516 <view>
@@ -453,7 +523,7 @@ @@ -453,7 +523,7 @@
453 <shopname object="{{item.content}}"></shopname> 523 <shopname object="{{item.content}}"></shopname>
454 </block> 524 </block>
455 <!--广告组合--> 525 <!--广告组合-->
456 - <block wx:if="{{item.ename=='advertising'}}"> 526 + <block wx:if="{{item.ename=='advertising' && item.content.full_screen!=1}}">
457 <advertising object="{{item.content}}"></advertising> 527 <advertising object="{{item.content}}"></advertising>
458 </block> 528 </block>
459 <!--商品分组--> 529 <!--商品分组-->
@@ -490,7 +560,7 @@ @@ -490,7 +560,7 @@
490 </block> 560 </block>
491 <!-- 热区切图 --> 561 <!-- 热区切图 -->
492 <block wx:if="{{item.ename=='heatCutDiagram'}}"> 562 <block wx:if="{{item.ename=='heatCutDiagram'}}">
493 - <heat_img object="{{item.content}}" ></heat_img> 563 + <heat_img object="{{item.content}}"></heat_img>
494 </block> 564 </block>
495 <!--标题--> 565 <!--标题-->
496 <block wx:if="{{item.ename=='title'}}"> 566 <block wx:if="{{item.ename=='title'}}">
@@ -526,8 +596,8 @@ @@ -526,8 +596,8 @@
526 <presell object="{{item.content}}"></presell> 596 <presell object="{{item.content}}"></presell>
527 </block> 597 </block>
528 <block wx:if="{{item.ename=='presaleNew'}}"> 598 <block wx:if="{{item.ename=='presaleNew'}}">
529 - <diy_public object="{{item.content}}" prom_type="8"></diy_public>  
530 - </block> 599 + <diy_public object="{{item.content}}" prom_type="8"></diy_public>
  600 + </block>
531 <!-- 团购 --> 601 <!-- 团购 -->
532 <block wx:if="{{item.ename=='groupbuy'}}"> 602 <block wx:if="{{item.ename=='groupbuy'}}">
533 <groupbuy object="{{item.content}}"></groupbuy> 603 <groupbuy object="{{item.content}}"></groupbuy>
pages/template/index.js
@@ -4,81 +4,114 @@ var t = getApp(), @@ -4,81 +4,114 @@ var t = getApp(),
4 os = t.globalData.setting, 4 os = t.globalData.setting,
5 ut = require("../../utils/util.js"), 5 ut = require("../../utils/util.js"),
6 com = require("../../utils/common.js"); 6 com = require("../../utils/common.js");
7 - var regeneratorRuntime = require('../../utils/runtime.js');  
8 - var api = require('../../api/api.js');  
9 - var appd = getApp().globalData; 7 +var regeneratorRuntime = require('../../utils/runtime.js');
  8 +var api = require('../../api/api.js');
  9 +var appd = getApp().globalData;
10 10
11 Page({ 11 Page({
12 data: { 12 data: {
13 url: os.imghost, 13 url: os.imghost,
14 - temp_id:0,  
15 - goodsGroupArr:[] 14 + temp_id: 0,
  15 + goodsGroupArr: [],
  16 + //满屏顶部导航参数------------
  17 + is_full_screen_navigation: false, //是否满屏
  18 + is_full_screen_navigation_index: -1, //广告轮播满屏下标
  19 + nav_title: '首页',
  20 + nav_frontColor: "#ffffff",
  21 + nav_backgroundColor: "#ff7295",
  22 + nav_type: 1, //导航类型
  23 + searchbox_transparent: 1, //搜索框背景是否透明
  24 +
  25 + nav_but_color: '#32ACF9', //导航按钮颜色
  26 + sele_pickup: null, //默认门店
  27 + // nav_bg_color:'#e823e8', //导航按钮颜色
  28 + //----------------
16 }, 29 },
17 30
18 - onLoad: function(e) { 31 + onLoad: function (e) {
19 var th = this; 32 var th = this;
20 - this.data.temp_id=e.scene;  
21 - if(!this.data.temp_id)  
22 - this.data.temp_id=e.sence;  
23 - if(!this.data.temp_id) wx.showModal({ title:"未读取到模板ID" ,})  
24 -  
25 - var first_leader = e.first_leader;  
26 - if (first_leader) {  
27 - //-- user_id代过来免登录 --  
28 - getApp().globalData.first_leader = first_leader;  
29 - //调用接口判断是不是会员  
30 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {  
31 - if (res.data.code == 0) {  
32 - getApp().globalData.guide_id = res.data.data.id;  
33 - getApp().globalData.guide_pick_id= res.data.data.pickup_id  
34 - }  
35 - })  
36 - } 33 + this.data.temp_id = e.scene;
  34 + if (!this.data.temp_id)
  35 + this.data.temp_id = e.sence;
  36 + if (!this.data.temp_id) wx.showModal({ title: "未读取到模板ID", })
  37 +
  38 + var first_leader = e.first_leader;
  39 + if (first_leader) {
  40 + //-- user_id代过来免登录 --
  41 + getApp().globalData.first_leader = first_leader;
  42 + //调用接口判断是不是会员
  43 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  44 + if (res.data.code == 0) {
  45 + getApp().globalData.guide_id = res.data.data.id;
  46 + getApp().globalData.guide_pick_id = res.data.data.pickup_id
  47 + }
  48 + })
  49 +
  50 + }
  51 +
  52 + getApp().getConfig(function (e) {
  53 + //--首页的问题--
  54 + if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {
  55 + wx.setNavigationBarTitle({
  56 + title: getApp().globalData.config.store_name,
  57 + });
  58 + th.setData({
  59 + nav_title:getApp().globalData.config.store_name
  60 + })
  61 + } else {
  62 + wx.setNavigationBarTitle({
  63 + title: getApp().globalData.setting.appName,
  64 + });
  65 + th.setData({
  66 + nav_title: getApp().globalData.setting.appName,
  67 + })
  68 + };
  69 + });
  70 +
37 71
38 72
39 -  
40 }, 73 },
41 74
42 async onShow() { 75 async onShow() {
43 - getApp().check_can_share(); 76 + getApp().check_can_share();
44 var th = this; 77 var th = this;
45 await this.init_load(); 78 await this.init_load();
46 //如果是自定义模板 79 //如果是自定义模板
47 if (this.data.isTemplate) { 80 if (this.data.isTemplate) {
48 -  
49 - } 81 +
  82 + }
50 }, 83 },
51 //获取商品模块实例 84 //获取商品模块实例
52 - newGoodsGroup(){  
53 - let arr=[] 85 + newGoodsGroup() {
  86 + let arr = []
54 if (this.data.template_arr.length == 0) { 87 if (this.data.template_arr.length == 0) {
55 return 88 return
56 } 89 }
57 - this.data.template_arr.map((item,index)=>{ 90 + this.data.template_arr.map((item, index) => {
58 if (item.ename == 'goodsGroup') { 91 if (item.ename == 'goodsGroup') {
59 arr.push(`goodsGroup${index}`) 92 arr.push(`goodsGroup${index}`)
60 } 93 }
61 }) 94 })
62 if (arr.length > 0) { 95 if (arr.length > 0) {
63 this.setData({ 96 this.setData({
64 - goodsGroupArr : arr 97 + goodsGroupArr: arr
65 }) 98 })
66 - arr.map(item=>{  
67 - let a = '.'+item 99 + arr.map(item => {
  100 + let a = '.' + item
68 this[item] = this.selectComponent(a); 101 this[item] = this.selectComponent(a);
69 }) 102 })
70 } 103 }
71 }, 104 },
72 //当隐藏的时候就关闭计时器 105 //当隐藏的时候就关闭计时器
73 - onHide: function() {  
74 - 106 + onHide: function () {
  107 +
75 }, 108 },
76 //同步初始加载 109 //同步初始加载
77 async init_load() { 110 async init_load() {
78 var th = this; 111 var th = this;
79 //因为营销版本的功能包含了自定义模板的功能,是同时的 112 //因为营销版本的功能包含了自定义模板的功能,是同时的
80 //读取全局是否有弄自定义模板 113 //读取全局是否有弄自定义模板
81 - await getApp().request.promiseGet("/api/weshop/store_module/get/"+th.data.temp_id+"/4",{1:1} ).then(res => { 114 + await getApp().request.promiseGet("/api/weshop/store_module/get/" + th.data.temp_id + "/4", { 1: 1 }).then(res => {
82 var data = res.data.data; 115 var data = res.data.data;
83 if (data) { 116 if (data) {
84 var temp_data = data; 117 var temp_data = data;
@@ -86,114 +119,171 @@ Page({ @@ -86,114 +119,171 @@ Page({
86 title: temp_data.page_title, 119 title: temp_data.page_title,
87 }); 120 });
88 var t_arr = JSON.parse(temp_data.json_str); 121 var t_arr = JSON.parse(temp_data.json_str);
  122 + //增加判断是否是满屏
  123 + let is_full_screen_navigation = false
  124 + let is_full_screen_navigation_index = -1
  125 + let nav_but_color ="#32ACF9"
  126 + if (t_arr) {
  127 + t_arr.map((item,index)=>{
  128 + if (item && item.content && item.content.full_screen==1 && !is_full_screen_navigation) {
  129 + is_full_screen_navigation = true
  130 + is_full_screen_navigation_index = index
  131 + try {
  132 + nav_but_color = item.content.data[0].but_color
  133 + } catch (error) {}
  134 + }
  135 + })
  136 + }
89 th.setData({ 137 th.setData({
90 - share_title:temp_data.page_title, 138 + nav_but_color,
  139 + is_full_screen_navigation,
  140 + is_full_screen_navigation_index,
  141 + share_title: temp_data.page_title,
91 template_arr: t_arr, 142 template_arr: t_arr,
92 isTemplate: 1, 143 isTemplate: 1,
93 bgcolor_t: temp_data.bkcolor 144 bgcolor_t: temp_data.bkcolor
94 }); 145 });
95 - setTimeout(()=>{ 146 + setTimeout(() => {
96 th.newGoodsGroup() 147 th.newGoodsGroup()
97 - },1000) 148 + }, 1000)
98 149
99 //---如果有设定顶部的颜色的时候-- 150 //---如果有设定顶部的颜色的时候--
100 - if(temp_data.top_color && temp_data.top_color!='null' ){ 151 + if (temp_data.top_color && temp_data.top_color != 'null') {
101 152
102 - var top_w_color="#ffffff";  
103 - if(temp_data.top_word_color && temp_data.top_word_color=='black'){  
104 - top_w_color="#000000";  
105 - } 153 + var top_w_color = "#ffffff";
  154 + if (temp_data.top_word_color && temp_data.top_word_color == 'black') {
  155 + top_w_color = "#000000";
  156 + }
106 157
107 wx.setNavigationBarColor({ 158 wx.setNavigationBarColor({
108 frontColor: top_w_color, // 必写项 159 frontColor: top_w_color, // 必写项
109 backgroundColor: temp_data.top_color, // 必写项 160 backgroundColor: temp_data.top_color, // 必写项
110 }) 161 })
  162 + th.setData({
  163 + // nav_frontColor: top_w_color, // 必写项
  164 + nav_backgroundColor: temp_data.top_color, // 必写项
  165 + })
111 } 166 }
112 - 167 +
113 } 168 }
114 }) 169 })
115 -  
116 170
117 - 171 +
  172 +
118 }, 173 },
  174 + //广告轮播满屏按钮颜色传递方法
  175 + bindbut_color_event_fn(even){
  176 + let nav_but_color = even.detail.but_color
  177 + this.setData({
  178 + nav_but_color
  179 + })
  180 + },
  181 + onPageScroll: function (e) {
  182 + //满屏模式监听
  183 + if (this.data.is_full_screen_navigation) {
  184 + let num = e.scrollTop
  185 + let nav_type = this.data.nav_type
  186 + if (num >= 100 && nav_type) {
  187 + this.setData({
  188 + nav_type:0,
  189 + searchbox_transparent:0,
  190 + nav_frontColor:'#000'
  191 + })
  192 + // this.data.nav_type = 0
  193 + }
  194 + if (num < 100 && !nav_type) {
  195 + this.setData({
  196 + nav_type:1,
  197 + searchbox_transparent:1,
  198 + nav_frontColor:'#fff'
  199 + })
  200 + // this.data.nav_type = 1
  201 + }
  202 + }
  203 + //-----------end-------
  204 +
  205 +
  206 + // this.data.scrollTop = e.scrollTop;
  207 + // var t = getCurrentPages();
  208 + // "pages/index/index/index" == t[t.length - 1].route;
  209 +
  210 + },
  211 + onPullDownRefresh: function (e) {
119 212
120 - onPullDownRefresh: function(e) {  
121 -  
122 }, 213 },
123 214
124 -  
125 - onShareAppMessage:async function(e) {  
126 - var th=this;  
127 - getApp().globalData.no_clear=1;  
128 - getApp().getConfig(await function(e){  
129 - th.setData({  
130 - store_config:e  
131 - })  
132 - }.bind(this))  
133 215
134 - var url= `pages/template/index?sence=`+this.data.temp_id;  
135 - var userInfo = getApp().globalData.userInfo;  
136 - //是分销商才带  
137 - if (userInfo) {  
138 - url += "&first_leader=" + userInfo.user_id;  
139 - } 216 + onShareAppMessage: async function (e) {
  217 + var th = this;
  218 + getApp().globalData.no_clear = 1;
  219 + getApp().getConfig(await function (e) {
  220 + th.setData({
  221 + store_config: e
  222 + })
  223 + }.bind(this))
140 224
141 - var ob = {  
142 - title: this.data.share_title,  
143 - path: url,  
144 - //imageUrl:this.data.url+this.data.store_config.store_logo,  
145 - };  
146 - return ob; 225 + var url = `pages/template/index?sence=` + this.data.temp_id;
  226 + var userInfo = getApp().globalData.userInfo;
  227 + //是分销商才带
  228 + if (userInfo) {
  229 + url += "&first_leader=" + userInfo.user_id;
  230 + }
  231 +
  232 + var ob = {
  233 + title: this.data.share_title,
  234 + path: url,
  235 + //imageUrl:this.data.url+this.data.store_config.store_logo,
  236 + };
  237 + return ob;
147 }, 238 },
148 239
149 /** 240 /**
150 * 用户分享朋友圈 241 * 用户分享朋友圈
151 */ 242 */
152 - async onShareTimeline(){ 243 + async onShareTimeline() {
153 244
154 - var th=this;  
155 - getApp().globalData.no_clear=1;  
156 - getApp().getConfig(await function(e){ 245 + var th = this;
  246 + getApp().globalData.no_clear = 1;
  247 + getApp().getConfig(await function (e) {
157 th.setData({ 248 th.setData({
158 - store_config:e 249 + store_config: e
159 }) 250 })
160 }.bind(this)) 251 }.bind(this))
161 - var {share_title,temp_id,store_config} = this.data;  
162 - var url= `sence=${temp_id}`; 252 + var { share_title, temp_id, store_config } = this.data;
  253 + var url = `sence=${temp_id}`;
163 254
164 - var userInfo = getApp().globalData.userInfo;  
165 - //是分销商才带  
166 - if (userInfo) {  
167 - url += "&first_leader=" + userInfo.user_id;  
168 - } 255 + var userInfo = getApp().globalData.userInfo;
  256 + //是分销商才带
  257 + if (userInfo) {
  258 + url += "&first_leader=" + userInfo.user_id;
  259 + }
169 260
170 var ob = { 261 var ob = {
171 - title:share_title,  
172 - query:url,  
173 - //imageUrl:this.data.url+store_config.store_logo, 262 + title: share_title,
  263 + query: url,
  264 + //imageUrl:this.data.url+store_config.store_logo,
174 }; 265 };
175 console.log(ob); 266 console.log(ob);
176 return ob; 267 return ob;
177 -},  
178 - //---加载更多是靠这个函数----  
179 - onReachBottom: function() {  
180 - if(getApp().globalData.func_list)  
181 - {  
182 - for(let i in getApp().globalData.func_list){  
183 - let item=getApp().globalData.func_list[i];  
184 - item.re_show();  
185 - }  
186 - }  
187 -  
188 - //自定义时商品自动加载更多  
189 - let goodsGroupArr = this.data.goodsGroupArr  
190 - if (this.data.isTemplate && goodsGroupArr.length >0) {  
191 - goodsGroupArr.map(item=>{  
192 - this[item].automore()  
193 - }) 268 + },
  269 + //---加载更多是靠这个函数----
  270 + onReachBottom: function () {
  271 + if (getApp().globalData.func_list) {
  272 + for (let i in getApp().globalData.func_list) {
  273 + let item = getApp().globalData.func_list[i];
  274 + item.re_show();
194 } 275 }
195 - }, 276 + }
  277 +
  278 + //自定义时商品自动加载更多
  279 + let goodsGroupArr = this.data.goodsGroupArr
  280 + if (this.data.isTemplate && goodsGroupArr.length > 0) {
  281 + goodsGroupArr.map(item => {
  282 + this[item].automore()
  283 + })
  284 + }
  285 + },
  286 +
  287 +
196 288
197 -  
198 -  
199 }); 289 });
200 \ No newline at end of file 290 \ No newline at end of file
pages/template/index.json
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 "usingComponents": { 4 "usingComponents": {
5 "goods_recommend":"/components/goods_list/goods_list", 5 "goods_recommend":"/components/goods_list/goods_list",
6 "nav": "/components/diy_nav/diy_nav", 6 "nav": "/components/diy_nav/diy_nav",
  7 + "top_nav": "/components/diy_top_nav/diy_top_nav",
7 "advertising":"/components/diy_advertising/diy_advertising", 8 "advertising":"/components/diy_advertising/diy_advertising",
8 "groupbuy": "/components/diy_groupbuy/diy_groupbuy", 9 "groupbuy": "/components/diy_groupbuy/diy_groupbuy",
9 "goodsGroup": "/components/diy_goodsGroup/diy_goodsGroup", 10 "goodsGroup": "/components/diy_goodsGroup/diy_goodsGroup",
@@ -27,5 +28,6 @@ @@ -27,5 +28,6 @@
27 "presell": "/components/diy_pregoods/diy_pregoods" 28 "presell": "/components/diy_pregoods/diy_pregoods"
28 }, 29 },
29 "enablePullDownRefresh": false, 30 "enablePullDownRefresh": false,
30 - "onReachBottomDistance":300 31 + "onReachBottomDistance":300,
  32 + "navigationStyle":"custom"
31 } 33 }
32 \ No newline at end of file 34 \ No newline at end of file
pages/template/index.wxml
1 <view class="container" style="background-color:{{bgcolor_t}}"> 1 <view class="container" style="background-color:{{bgcolor_t}}">
  2 +
  3 +
  4 + <block wx:if="{{is_full_screen_navigation}}">
  5 + <view class="dis_top" style="position: fixed;">
  6 + <top_nav nav_type="{{nav_type}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor ? '#fff' :'#fff'}}" nav_title="{{nav_title}}"></top_nav>
  7 +
  8 + <!-- <js_store_select bindup_storid="get_new_storid" id="js_store_select" transparent="{{searchbox_transparent}}" bgcoler="{{nav_backgroundColor ? '#fff' :'#fff'}}" anclor="{{nav_but_color}}" ></js_store_select> -->
  9 +
  10 + <block wx:for="{{template_arr}}">
  11 + <block wx:if="{{item.content.is_top==1}}">
  12 + <!--如果是搜索框的时候 -->
  13 + <block wx:if="{{item.ename=='searchbox'}}">
  14 + <searchbox object="{{item.content}}" transparent="{{searchbox_transparent}}" nav_backgroundColor="{{nav_backgroundColor ? '#fff' :'#fff'}}"></searchbox>
  15 + </block>
  16 + <!-- <block wx:if="{{item.ename=='store_select'}}">
  17 + <store_select object="{{item.content}}"></store_select>
  18 + </block> -->
  19 + </block>
  20 + </block>
  21 + </view>
  22 + <block wx:for="{{template_arr}}">
  23 + <!--广告组合-->
  24 + <block wx:if="{{item.ename=='advertising' && item.content.full_screen==1 && is_full_screen_navigation_index==index}}">
  25 + <advertising object="{{item.content}}" bindbutColorEvent="bindbut_color_event_fn" is_full_screen_navigation_index="{{is_full_screen_navigation_index}}"></advertising>
  26 + </block>
  27 + </block>
  28 + </block>
  29 +
  30 + <block wx:else>
  31 + <!-- 置顶层 -->
  32 + <view class="dis_top" style="position:fixed">
  33 + <top_nav nav_type="{{0}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor}}" nav_title="{{nav_title}}"></top_nav>
  34 + <!-- 关注公众号的显示 -->
  35 + <view id="off_top" wx:if="{{is_gz_h5}}">
  36 + <official-account></official-account>
  37 + </view>
  38 +
  39 + <!-- <js_store_select id="js_store_select" bindup_storid="get_new_storid" transparent="{{0}}" bgcoler="{{nav_backgroundColor}}" anclor="{{nav_but_color}}" ></js_store_select> -->
  40 +
  41 + <block wx:for="{{template_arr}}">
  42 + <block wx:if="{{item.content.is_top==1}}">
  43 + <!--如果是搜索框的时候 -->
  44 + <block wx:if="{{item.ename=='searchbox'}}">
  45 + <searchbox object="{{item.content}}"></searchbox>
  46 + </block>
  47 + <!-- <block wx:if="{{item.ename=='store_select'}}">-->
  48 + <!-- <store_select object="{{item.content}}"></store_select>-->
  49 + <!-- </block>-->
  50 +
  51 + </block>
  52 + </block>
  53 + </view>
  54 +
  55 + <!-- 撑开层 -->
  56 + <view>
  57 + <!-- 顶部导航撑开层 -->
  58 + <top_nav nav_type="{{-1}}" nav_frontColor="{{nav_frontColor}}" nav_backgroundColor="{{nav_backgroundColor}}" nav_title="{{nav_title}}"></top_nav>
  59 + <!-- 即时零售,门店选择撑开层 -->
  60 + <!-- <view style="width: 100%;height: 88rpx;"></view> -->
  61 + <view wx:if="{{is_gz_h5 && is_ok_h5}}" style="height: 84px;flex-shrink:0"></view>
  62 + <block wx:for="{{template_arr}}">
  63 + <block wx:if="{{item.content.is_top==1}}">
  64 + <view style="height:{{item.content.style==1 ? 110 : 88 }}rpx"></view>
  65 + </block>
  66 + </block>
  67 +
  68 + </view>
  69 + </block>
  70 +
  71 +
2 <block wx:for="{{template_arr}}" wx:key="{{index}}"> 72 <block wx:for="{{template_arr}}" wx:key="{{index}}">
3 <view> 73 <view>
4 <!--导航--> 74 <!--导航-->
@@ -10,7 +80,7 @@ @@ -10,7 +80,7 @@
10 <shopname object="{{item.content}}"></shopname> 80 <shopname object="{{item.content}}"></shopname>
11 </block> 81 </block>
12 <!--广告组合--> 82 <!--广告组合-->
13 - <block wx:if="{{item.ename=='advertising'}}"> 83 + <block wx:if="{{item.ename=='advertising' && item.content.full_screen!=1}}">
14 <advertising object="{{item.content}}"></advertising> 84 <advertising object="{{item.content}}"></advertising>
15 </block> 85 </block>
16 <!--商品分组--> 86 <!--商品分组-->
@@ -33,7 +103,7 @@ @@ -33,7 +103,7 @@
33 <mvideo object="{{item.content}}"></mvideo> 103 <mvideo object="{{item.content}}"></mvideo>
34 </block> 104 </block>
35 <!--搜索--> 105 <!--搜索-->
36 - <block wx:if="{{item.ename=='searchbox'}}"> 106 + <block wx:if="{{item.ename=='searchbox' && item.content.is_top!=1}}">
37 <searchbox object="{{item.content}}"></searchbox> 107 <searchbox object="{{item.content}}"></searchbox>
38 </block> 108 </block>
39 <!--天天拼单--> 109 <!--天天拼单-->
pages/template/index.wxss
@@ -15,6 +15,13 @@ @@ -15,6 +15,13 @@
15 width: 50rpx; 15 width: 50rpx;
16 height: 45rpx; 16 height: 45rpx;
17 } 17 }
  18 +.dis_top {
  19 + position: sticky;
  20 + top: 0;
  21 + left: 0;
  22 + width: 100%;
  23 + z-index: 100000;
  24 +}
18 25
19 .logo { 26 .logo {
20 width: 48rpx; 27 width: 48rpx;