Commit 9d3dbc4d8f91df57545550dcc4d3a918fd737f44

Authored by abson
1 parent 12ee8fb1

首页分享朋友圈不能调起解决

Showing 1 changed file with 1196 additions and 1198 deletions
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;
@@ -19,1202 +19,1200 @@ var full_screen = require('full_screen.js'); @@ -19,1202 +19,1200 @@ 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 -  
82 - is_full_screen_show: 0, //全屏显示  
83 - sec_show: 3, //倒计时的秒数  
84 - full_ad: null, //全屏广告  
85 - full_screen: 0, //全屏广告  
86 - is_ok_h5:0, //判断要不要显示关注二维码  
87 - },  
88 -  
89 - onLoad: async function (tt) {  
90 - var th = this;  
91 - var first_leader = tt.first_leader;  
92 - if (!first_leader && tt.scene) {  
93 - var first_leader_str = decodeURIComponent(tt.scene);  
94 - var f_arr = first_leader_str.split("_");  
95 - first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null;  
96 - //注册门店  
97 - if (f_arr[1] && parseFloat(f_arr[1]) > 0) {  
98 - getApp().globalData.store_number = f_arr[1];  
99 - }  
100 - }  
101 -  
102 - getApp().getConfig(function (e) {  
103 - //--首页的问题--  
104 - if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {  
105 - wx.setNavigationBarTitle({  
106 - title: getApp().globalData.config.store_name,  
107 - });  
108 - } else {  
109 - wx.setNavigationBarTitle({  
110 - title: getApp().globalData.setting.appName,  
111 - });  
112 - };  
113 - });  
114 -  
115 -  
116 - var th = this;  
117 - getApp().getConfig2(function (config2) {  
118 - if (config2 && config2.is_overdue == 1) {  
119 - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=5", {}).then(res => {  
120 - var o = res;  
121 - if (o.data.code == 0) {  
122 - var ob = { isout: 0, isbuy: 1 };  
123 - var arr = o.data.data.pageData;  
124 - var isbuy = 0;  
125 - //----如果数组不为空----  
126 - if (arr.length > 0) {  
127 - arr.forEach(function (val, ind) {  
128 - if (val.is_sy == 0 && val.type == 5) {  
129 - isbuy = 1;  
130 - var now = ut.gettimestamp();  
131 - if (now > val.end_time) ob.isout = 1;  
132 - return false;  
133 - }  
134 - })  
135 - }  
136 - ob.isbuy = isbuy;  
137 -  
138 - var pages = getCurrentPages(); //获取加载的页面  
139 - var currentPage = pages[pages.length - 1]; //获取当前页面的对象  
140 -  
141 - // console.log("当前路由");  
142 - // console.log(currentPage.route);  
143 -  
144 -  
145 - th.setappdata(ob);  
146 -  
147 - if (ob.isbuy && !ob.isout) {  
148 - th.onload_init();  
149 - }  
150 - } else {  
151 - th.onload_init();  
152 - }  
153 - })  
154 - }  
155 - else {  
156 - th.onload_init();  
157 - }  
158 - })  
159 -  
160 - if (first_leader) {  
161 - //-- user_id代过来免登录 --  
162 - getApp().globalData.first_leader = first_leader;  
163 - //调用接口判断是不是会员  
164 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {  
165 - if (res.data.code == 0) {  
166 - getApp().globalData.guide_id = res.data.data.id;  
167 - }  
168 - })  
169 - }  
170 -  
171 - // 判断是否有红包活动  
172 - getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, {  
173 - data: {}  
174 - }).then(function (data) {  
175 - let code = data.data.code;  
176 - if (code == 0) {  
177 -  
178 - th.setData({  
179 - showHongbao: true,  
180 - });  
181 - } else if (code == -1) {  
182 - th.setData({  
183 - showHongbao: false,  
184 - });  
185 - };  
186 - });  
187 -  
188 -  
189 - // console.log(9090909);  
190 - //看一下商家是否开通了权益  
191 - //--初始化是否有打勾--  
192 - getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {  
193 - data: {  
194 - storeId: os.stoid  
195 - }  
196 - }).then(res => {  
197 - if (res.data.data) {  
198 - var is_init = res.data.data.isBool;  
199 - th.setData({  
200 - is_boot: is_init  
201 - });  
202 -  
203 - if (!is_init) {  
204 - th.setData({  
205 - swiperimage: []  
206 - });  
207 - }  
208 - }  
209 - })  
210 -  
211 - //调用底部导航  
212 - //getApp().globalData.url=th.data.url  
213 - //t.editTabBar(th,o.stoid,th.data.url);  
214 -  
215 - },  
216 -  
217 - async onload_init() {  
218 - var th = this;  
219 - await this.init_load();  
220 - //显示的时候要开启计时器  
221 - this.data.is_timer = 1;  
222 - //如果是自定义模板  
223 - if (this.data.isTemplate) {  
224 - //---先获取会员---  
225 - //t.getUserFir(function () {  
226 - if(getApp().globalData.user_id) {  
227 - th.is_festival();  
228 - var new_nav = th.data.new_nav;  
229 - if (new_nav == "") {  
230 - th.is_new();  
231 - }  
232 - // sty  
233 - setTimeout(function () {  
234 - if (getApp().globalData.user_id) getApp().requestCardNum(th);  
235 - }, 500)  
236 - }  
237 -  
238 - //});  
239 - } else {  
240 - await this.init_fir();  
241 - wx.setNavigationBarColor({  
242 - frontColor: '#ffffff', // 必写项  
243 - backgroundColor: '#ff7295', // 必写项  
244 - })  
245 - }  
246 -  
247 - //--正再拼团中的处理--  
248 - var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"  
249 - await getApp().request.promiseGet(url, {}).then(res => {  
250 - if (res.data.code == 0 && res.data.data && res.data.data.pageData) {  
251 - th.data.pt_timer_arr = res.data.data.pageData;  
252 - }  
253 - })  
254 - if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {  
255 - for (var i in th.data.pt_timer_arr) {  
256 - var p_item = th.data.pt_timer_arr[i];  
257 - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {  
258 - 1: 1  
259 - }).then(res => {  
260 - th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;  
261 - th.data.pt_timer_arr[i].nickname = res.data.data.nickname;  
262 - })  
263 - }  
264 - th.Interval_pt();  
265 - }  
266 -  
267 - //---处理正在6个分类----  
268 - await getApp().request.promiseGet("/api/weshop/goodscategory/page", {  
269 - data: {  
270 - store_id: os.stoid,  
271 - pageSize: 5,  
272 - is_show: 1,  
273 - level: 1  
274 - }  
275 - }).then(res => {  
276 - if (res.data.data) {  
277 - var gd_category = res.data.data.pageData;  
278 - th.setData({  
279 - gd_category: gd_category  
280 - });  
281 - }  
282 - })  
283 - },  
284 -  
285 -  
286 - //关闭新用户领取广告  
287 - close_disgraceful: function () {  
288 - var th = this;  
289 - th.setData({  
290 - is_disgraceful: 0  
291 - })  
292 - },  
293 -  
294 - async onShow() {  
295 -  
296 - getApp().check_can_share(); 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 +
  82 + is_full_screen_show: 0, //全屏显示
  83 + sec_show: 3, //倒计时的秒数
  84 + full_ad: null, //全屏广告
  85 + full_screen: 0, //全屏广告
  86 + is_ok_h5: 0, //判断要不要显示关注二维码
  87 + },
  88 +
  89 + onLoad: async function (tt) {
  90 + wx.showShareMenu({
  91 + withShareTicket:true,
  92 + menus:['shareAppMessage','shareTimeline']
  93 + })
  94 + var th = this;
  95 + var first_leader = tt.first_leader;
  96 + if (!first_leader && tt.scene) {
  97 + var first_leader_str = decodeURIComponent(tt.scene);
  98 + var f_arr = first_leader_str.split("_");
  99 + first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null;
  100 + //注册门店
  101 + if (f_arr[1] && parseFloat(f_arr[1]) > 0) {
  102 + getApp().globalData.store_number = f_arr[1];
  103 + }
  104 + }
  105 +
  106 + getApp().getConfig(function (e) {
  107 + //--首页的问题--
  108 + if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {
  109 + wx.setNavigationBarTitle({
  110 + title: getApp().globalData.config.store_name,
  111 + });
  112 + } else {
  113 + wx.setNavigationBarTitle({
  114 + title: getApp().globalData.setting.appName,
  115 + });
  116 + };
  117 + });
  118 +
  119 +
  120 + var th = this;
  121 + getApp().getConfig2(function (config2) {
  122 + if (config2 && config2.is_overdue == 1) {
  123 + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=5", {}).then(res => {
  124 + var o = res;
  125 + if (o.data.code == 0) {
  126 + var ob = { isout: 0, isbuy: 1 };
  127 + var arr = o.data.data.pageData;
  128 + var isbuy = 0;
  129 + //----如果数组不为空----
  130 + if (arr.length > 0) {
  131 + arr.forEach(function (val, ind) {
  132 + if (val.is_sy == 0 && val.type == 5) {
  133 + isbuy = 1;
  134 + var now = ut.gettimestamp();
  135 + if (now > val.end_time) ob.isout = 1;
  136 + return false;
  137 + }
  138 + })
  139 + }
  140 + ob.isbuy = isbuy;
  141 +
  142 + var pages = getCurrentPages(); //获取加载的页面
  143 + var currentPage = pages[pages.length - 1]; //获取当前页面的对象
  144 +
  145 + // console.log("当前路由");
  146 + // console.log(currentPage.route);
  147 +
  148 +
  149 + th.setappdata(ob);
  150 +
  151 + if (ob.isbuy && !ob.isout) {
  152 + th.onload_init();
  153 + }
  154 + } else {
  155 + th.onload_init();
  156 + }
  157 + })
  158 + }
  159 + else {
  160 + th.onload_init();
  161 + }
  162 + })
  163 +
  164 + if (first_leader) {
  165 + //-- user_id代过来免登录 --
  166 + getApp().globalData.first_leader = first_leader;
  167 + //调用接口判断是不是会员
  168 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  169 + if (res.data.code == 0) {
  170 + getApp().globalData.guide_id = res.data.data.id;
  171 + }
  172 + })
  173 + }
  174 +
  175 + // 判断是否有红包活动
  176 + getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, {
  177 + data: {}
  178 + }).then(function (data) {
  179 + let code = data.data.code;
  180 + if (code == 0) {
  181 +
  182 + th.setData({
  183 + showHongbao: true,
  184 + });
  185 + } else if (code == -1) {
  186 + th.setData({
  187 + showHongbao: false,
  188 + });
  189 + };
  190 + });
  191 +
  192 +
  193 + // console.log(9090909);
  194 + //看一下商家是否开通了权益
  195 + //--初始化是否有打勾--
  196 + getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
  197 + data: {
  198 + storeId: os.stoid
  199 + }
  200 + }).then(res => {
  201 + if (res.data.data) {
  202 + var is_init = res.data.data.isBool;
  203 + th.setData({
  204 + is_boot: is_init
  205 + });
  206 +
  207 + if (!is_init) {
  208 + th.setData({
  209 + swiperimage: []
  210 + });
  211 + }
  212 + }
  213 + })
  214 +
  215 +
  216 +
  217 + //调用底部导航
  218 + //getApp().globalData.url=th.data.url
  219 + //t.editTabBar(th,o.stoid,th.data.url);
  220 +
  221 + },
  222 +
  223 + async onload_init() {
  224 + var th = this;
  225 + await this.init_load();
  226 + //显示的时候要开启计时器
  227 + this.data.is_timer = 1;
  228 + //如果是自定义模板
  229 + if (this.data.isTemplate) {
  230 + //---先获取会员---
  231 + //t.getUserFir(function () {
  232 + if (getApp().globalData.user_id) {
  233 + th.is_festival();
  234 + var new_nav = th.data.new_nav;
  235 + if (new_nav == "") {
  236 + th.is_new();
  237 + }
  238 + // sty
  239 + setTimeout(function () {
  240 + if (getApp().globalData.user_id) getApp().requestCardNum(th);
  241 + }, 500)
  242 + }
  243 +
  244 + //});
  245 + } else {
  246 + await this.init_fir();
  247 + wx.setNavigationBarColor({
  248 + frontColor: '#ffffff', // 必写项
  249 + backgroundColor: '#ff7295', // 必写项
  250 + })
  251 + }
  252 +
  253 + //--正再拼团中的处理--
  254 + var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"
  255 + await getApp().request.promiseGet(url, {}).then(res => {
  256 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  257 + th.data.pt_timer_arr = res.data.data.pageData;
  258 + }
  259 + })
  260 + if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {
  261 + for (var i in th.data.pt_timer_arr) {
  262 + var p_item = th.data.pt_timer_arr[i];
  263 + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {
  264 + 1: 1
  265 + }).then(res => {
  266 + th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;
  267 + th.data.pt_timer_arr[i].nickname = res.data.data.nickname;
  268 + })
  269 + }
  270 + th.Interval_pt();
  271 + }
  272 +
  273 + //---处理正在6个分类----
  274 + await getApp().request.promiseGet("/api/weshop/goodscategory/page", {
  275 + data: {
  276 + store_id: os.stoid,
  277 + pageSize: 5,
  278 + is_show: 1,
  279 + level: 1
  280 + }
  281 + }).then(res => {
  282 + if (res.data.data) {
  283 + var gd_category = res.data.data.pageData;
  284 + th.setData({
  285 + gd_category: gd_category
  286 + });
  287 + }
  288 + })
  289 + },
  290 +
  291 +
  292 + //关闭新用户领取广告
  293 + close_disgraceful: function () {
  294 + var th = this;
  295 + th.setData({
  296 + is_disgraceful: 0
  297 + })
  298 + },
  299 +
  300 + async onShow() {
  301 +
  302 + getApp().check_can_share();
  303 +
  304 + this.getTabBar().setData({
  305 + cartGoodsNum: getApp().globalData.cartGoodsNum
  306 + })
  307 + var th = this;
  308 + //-- 登录回来判断弹框 --
  309 + var user_id = getApp().globalData.user_id;
  310 +
  311 + if (!user_id) {
  312 + var userinfo = wx.getStorageSync('userinfo');
  313 + if (userinfo) user_id = userinfo.user_id
  314 + }
  315 +
  316 + if (user_id) {
  317 + th.is_festival();
  318 + var new_nav = th.data.new_nav;
  319 + if (new_nav == "") {
  320 + th.is_new();
  321 + }
  322 + }
  323 +
  324 + console.log(this.data.isTemplate, '首页');
  325 +
  326 + if (!this.data.isTemplate) {
  327 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1 };
  328 + if (user_id) {
  329 + pre_data.user_id = user_id;
  330 + }
  331 +
  332 + getApp().request.get("/api/weshop/marketing/marketingPresellList/page", {
  333 + data: pre_data,
  334 + success: function (e) {
  335 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  336 + var pre_data = e.data.data.pageData;
  337 + var arr = new Array();
  338 + //--三个三个一组---
  339 + for (var i = 0; i < pre_data.length; i += 3) {
  340 + arr.push(pre_data.slice(i, i + 3));
  341 + }
  342 + th.setData({
  343 + preGoods: arr
  344 + });
  345 + } else {
  346 + th.setData({
  347 + preGoods: null
  348 + });
  349 + }
  350 + }
  351 + })
297 352
  353 + // 获取幸运购活动列表
  354 + getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {
  355 + data: {
  356 + store_id: getApp().globalData.setting.stoid,
  357 + is_end: 0,
  358 + timetype: 1,
  359 + }
  360 + }).then(res => {
  361 + if (res.data.code == 0) {
  362 + th.setData({
  363 + luckGo_list: res.data.data.pageData.slice(0, 3),
  364 + });
  365 + }
  366 + });
  367 +
  368 + //-----秒杀-----
  369 + var flash_data = null;
  370 + var f_req = {
  371 + store_id: os.stoid,
  372 + timetype: 2,
  373 + is_end: 0,
  374 + is_show: 1,
  375 + pageSize: 9,
  376 + user_id: 0
  377 + };
  378 + if (user_id) f_req.user_id = user_id;
  379 + //--获取活动--
  380 + await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
  381 + data: f_req,
  382 + }).then(res => {
  383 + var e = res;
  384 + if (e.data.code == 0) {
  385 + flash_data = e.data.data.pageData;
  386 + if (flash_data == null || flash_data.length <= 0) return false;
  387 +
  388 + //当前时间戳
  389 + var nt = ut.gettimestamp();
  390 +
  391 + flash_data.forEach(function (val, ind) {
  392 +
  393 + if (val.user_price) val.price = val.user_price;
  394 + if (val.start_time > nt) {
  395 + flash_data[ind].status = 0;
  396 + } else if (val.end_time > nt) {
  397 + flash_data[ind].status = 1;
  398 + }
  399 +
  400 + if (val.buy_num >= val.goods_num) {
  401 + flash_data[ind].status = 2;
  402 + }
  403 + });
  404 +
  405 + var promisies = [];
  406 + for (const key in flash_data) {
  407 + if (Object.hasOwnProperty.call(flash_data, key)) {
  408 + const val = flash_data[key];
  409 + promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  410 + os.stoid + "/1/" + val.id,
  411 + {}
  412 + ).then(res => {
  413 + if (res.data.code == 0) {
  414 + if (res.data.data <= 0) flash_data[key].status = 2;
  415 + };
  416 + });
  417 + }
  418 + }
  419 +
  420 + Promise.all(promisies).then(() => {
  421 + var arr = new Array();
  422 + //--三个三个一组---
  423 + for (var i = 0; i < flash_data.length; i += 3) {
  424 + arr.push(flash_data.slice(i, i + 3));
  425 + }
  426 +
  427 + th.setData({
  428 + saleGoods: arr
  429 + });
  430 + });
  431 +
  432 +
  433 +
  434 + }
  435 + });
  436 +
  437 + }
  438 +
  439 +
  440 +
  441 +
  442 +
  443 +
  444 +
  445 +
  446 +
  447 + //优惠券要实时更新
  448 + getApp().getConfig2(function (e) {
  449 + var json_d = JSON.parse(e.switch_list);
  450 + th.setData({ is_closecoupon: json_d.is_closecoupon })
  451 + th.setData({ is_topstore: json_d.is_show_storeselect })
  452 + if (json_d.is_gz_h5) th.setData({ is_gz_h5: json_d.is_gz_h5 })
  453 + }, 1)
  454 +
  455 + if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  456 + var index = getApp().getPageIndex(this);
298 this.getTabBar().setData({ 457 this.getTabBar().setData({
299 - cartGoodsNum: getApp().globalData.cartGoodsNum 458 + active: index //数字是当前页面在tabbar的索引
300 }) 459 })
301 - var th = this;  
302 - //-- 登录回来判断弹框 --  
303 - var user_id=getApp().globalData.user_id;  
304 -  
305 - if(!user_id){  
306 - var userinfo=wx.getStorageSync('userinfo');  
307 - if(userinfo) user_id=userinfo.user_id  
308 - }  
309 -  
310 - if (user_id) {  
311 - th.is_festival();  
312 - var new_nav = th.data.new_nav;  
313 - if (new_nav == "") {  
314 - th.is_new();  
315 - }  
316 - }  
317 -  
318 - console.log(this.data.isTemplate,'首页');  
319 -  
320 - if(!this.data.isTemplate){  
321 - var pre_data={store_id:os.stoid,is_end:0,timetype:1,isuse:1};  
322 - if(user_id){  
323 - pre_data.user_id= user_id;  
324 - }  
325 -  
326 - getApp().request.get("/api/weshop/marketing/marketingPresellList/page",{  
327 - data:pre_data,  
328 - success:function (e) {  
329 - if(e.data.code==0 && e.data.data.pageData && e.data.data.pageData.length>0 ){  
330 - var pre_data=e.data.data.pageData;  
331 - var arr = new Array();  
332 - //--三个三个一组---  
333 - for (var i = 0; i < pre_data.length; i += 3) {  
334 - arr.push(pre_data.slice(i, i + 3));  
335 - }  
336 - th.setData({  
337 - preGoods: arr  
338 - });  
339 - }else{  
340 - th.setData({  
341 - preGoods: null  
342 - });  
343 - }  
344 - }  
345 - })  
346 -  
347 - // 获取幸运购活动列表  
348 - getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {  
349 - data: {  
350 - store_id: getApp().globalData.setting.stoid,  
351 - is_end: 0,  
352 - timetype: 1,  
353 - }  
354 - }).then(res => {  
355 - if(res.data.code == 0) {  
356 - th.setData({  
357 - luckGo_list: res.data.data.pageData.slice(0,3),  
358 - });  
359 - }  
360 - });  
361 -  
362 - //-----秒杀-----  
363 - var flash_data = null;  
364 - var f_req={  
365 - store_id: os.stoid,  
366 - timetype: 2,  
367 - is_end: 0,  
368 - is_show: 1,  
369 - pageSize: 9,  
370 - user_id:0  
371 - };  
372 - if(user_id) f_req.user_id=user_id;  
373 - //--获取活动--  
374 - await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {  
375 - data:f_req ,  
376 - }).then(res => {  
377 - var e = res;  
378 - if (e.data.code == 0) {  
379 - flash_data = e.data.data.pageData;  
380 - if (flash_data == null || flash_data.length <= 0) return false;  
381 -  
382 - //当前时间戳  
383 - var nt = ut.gettimestamp();  
384 -  
385 - flash_data.forEach(function (val, ind) {  
386 -  
387 - if(val.user_price) val.price=val.user_price;  
388 - if (val.start_time > nt) {  
389 - flash_data[ind].status = 0;  
390 - } else if (val.end_time > nt) {  
391 - flash_data[ind].status = 1;  
392 - }  
393 -  
394 - if (val.buy_num >= val.goods_num){  
395 - flash_data[ind].status = 2;  
396 - }  
397 - });  
398 -  
399 - var promisies = [];  
400 - for (const key in flash_data) {  
401 - if (Object.hasOwnProperty.call(flash_data, key)) {  
402 - const val = flash_data[key];  
403 - promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +  
404 - os.stoid + "/1/" + val.id,  
405 - {}  
406 - ).then(res => {  
407 - if (res.data.code == 0) {  
408 - if (res.data.data <= 0) flash_data[key].status = 2;  
409 - };  
410 - });  
411 - }  
412 - }  
413 -  
414 - Promise.all(promisies).then(() => {  
415 - var arr = new Array();  
416 - //--三个三个一组---  
417 - for (var i = 0; i < flash_data.length; i += 3) {  
418 - arr.push(flash_data.slice(i, i + 3));  
419 - }  
420 -  
421 - th.setData({  
422 - saleGoods: arr  
423 - });  
424 - });  
425 -  
426 -  
427 -  
428 - }  
429 - });  
430 -  
431 - }  
432 -  
433 -  
434 -  
435 -  
436 -  
437 -  
438 -  
439 -  
440 -  
441 - //优惠券要实时更新  
442 - getApp().getConfig2(function (e) {  
443 - var json_d = JSON.parse(e.switch_list);  
444 - th.setData({ is_closecoupon: json_d.is_closecoupon })  
445 - th.setData({ is_topstore: json_d.is_show_storeselect })  
446 - if(json_d.is_gz_h5) th.setData({is_gz_h5:json_d.is_gz_h5})  
447 - }, 1)  
448 -  
449 - if (typeof this.getTabBar === 'function' && this.getTabBar()) {  
450 - var index = getApp().getPageIndex(this);  
451 - this.getTabBar().setData({  
452 - active: index //数字是当前页面在tabbar的索引  
453 - })  
454 460
455 461
456 - getApp().requestCardNum(this);  
457 - }  
458 -  
459 - var th = this;  
460 -  
461 - var show = getApp().globalData.isLoad_ad;  
462 -  
463 - if(!show){  
464 - setTimeout(function () {  
465 - full_screen.get_the_full_screen(th);  
466 - }, 800);  
467 - getApp().globalData.isLoad_ad=1;  
468 - if (!th.data.f_hidden) {  
469 - setTimeout(function () {  
470 - th.setData({ f_hidden: 1 })  
471 - wx.hideLoading();  
472 - }, 960)  
473 - }  
474 - } else {  
475 - th.setData({ f_hidden: 1 })  
476 - }  
477 -  
478 - setTimeout(function () {  
479 - const query = wx.createSelectorQuery();  
480 - query.select('#off_top').boundingClientRect();  
481 - query.exec((res) => {  
482 - if(res && res[0] && res[0].height>0){  
483 - th.setData({is_ok_h5:1});  
484 - }  
485 - })  
486 - },3600);  
487 -  
488 - },  
489 - //当隐藏的时候就关闭计时器  
490 - onHide: function () {  
491 - this.data.is_timer = 0;  
492 - if (this.data.pt_timer) clearInterval(this.data.pt_timer);  
493 - if (this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop);  
494 - if (this.data.full_screen) clearInterval(this.data.full_screen);  
495 - this.data.w_holiday_pop = 0;  
496 -  
497 - },  
498 -  
499 - //同步初始加载  
500 - async init_load() {  
501 - var th = this;  
502 - //因为营销版本的功能包含了自定义模板的功能,是同时的  
503 - //读取全局是否有弄自定义模板  
504 - await api.get_template_fir(o.stoid).then(res => {  
505 - var data = res.data.data;  
506 - if (data && data.length > 0) {  
507 - var temp_data = data[0];  
508 - var t_arr = JSON.parse(temp_data.json_str);  
509 -  
510 - th.setData({  
511 - template_arr: t_arr,  
512 - isTemplate: 1,  
513 - bgcolor_t: temp_data.bkcolor  
514 - });  
515 -  
516 - //---如果有设定顶部的颜色的时候--  
517 - if (temp_data.top_color && temp_data.top_color != 'null') {  
518 -  
519 - var top_w_color = "#ffffff";  
520 - if (temp_data.top_word_color && temp_data.top_word_color == 'black') {  
521 - top_w_color = "#000000";  
522 - }  
523 - wx.setNavigationBarColor({  
524 - frontColor: top_w_color, // 必写项  
525 - backgroundColor: temp_data.top_color, // 必写项  
526 - })  
527 - }  
528 - }  
529 - })  
530 -  
531 -  
532 - },  
533 - //---读取数据内容---  
534 - async init_fir() {  
535 - console.log('init_fir');  
536 - var th = this;  
537 - //----广告----  
538 - var e = this;  
539 - await getApp().request.promiseGet("/api/weshop/ad/page?pid=2&store_id=" + o.stoid, {  
540 - data: {  
541 - enabled: 1  
542 - }  
543 - }).then(res => {  
544 -  
545 - if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {  
546 - var a = res.data.data.pageData;  
547 - var arr = new Array();  
548 - for (var i = 0; i < a.length; i++) {  
549 - var tt = {  
550 - 'ad_code': o.imghost + a[i].ad_code,  
551 - 'media_link': '',  
552 - 'ad_weapplink': a[i].ad_weapplink  
553 - };  
554 - arr.push(tt);  
555 - }  
556 - if (arr.length > 0) e.setData({  
557 - banner: arr,  
558 - });  
559 -  
560 - wx.stopPullDownRefresh();  
561 - }  
562 - })  
563 - let user_id=getApp().globalData.user_id;  
564 -  
565 - //----拼单-----  
566 - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {  
567 - data: {  
568 - store_id: os.stoid,  
569 - is_end: 0,  
570 - is_show: 1,  
571 - pageSize: 6,  
572 - user_id,  
573 - }  
574 - }).then(res => {  
575 - var e = res;  
576 - if (e.data.code == 0) {  
577 - var pd_data = e.data.data.pageData;  
578 -  
579 - if (pd_data.length == 0) return;  
580 -  
581 - //获取当前  
582 - var nt = ut.gettimestamp();  
583 - pd_data.forEach(function (val, ind) {  
584 - if (val.start_time > nt) pd_data[ind].status = 0;  
585 - else if (val.end_time > nt) pd_data[ind].status = 1;  
586 - if (val.buy_num >= val.goods_num) pd_data[ind].status = 2;  
587 - });  
588 -  
589 - //获取当前时间,比较拼团中还在未开始  
590 - var timestamp = new Date().getTime();  
591 - var is_team_tepy;  
592 - for (var j = 0; j < pd_data.length; j++) {  
593 - pd_data[j].is_team_tepy = 1;  
594 - if (timestamp < pd_data[j].start_time * 1000) {  
595 - var is_team_tepy;  
596 - pd_data[j].is_team_tepy = 0;  
597 - }  
598 - }  
599 -  
600 - var arr = new Array();  
601 - //--2个2个一组---  
602 - for (var i = 0; i < pd_data.length; i += 2) {  
603 -  
604 - arr.push(pd_data.slice(i, i + 2));  
605 - }  
606 -  
607 - th.setData({  
608 - pindGoods: arr  
609 - });  
610 - th.countDown2();  
611 - }  
612 - })  
613 -  
614 - //------新品-------  
615 - await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {  
616 - data: {  
617 - is_mainshow: 1,  
618 - isonsale: 1,  
619 - is_on_sale: 1,  
620 - store_id: o.stoid,  
621 - pageSize: 9,  
622 - is_new: 1,  
623 - orderField: "sort"  
624 - }  
625 - }).then(res => {  
626 - var e = res;  
627 - if (e.data.code == 0) {  
628 - var new_data = e.data.data.pageData;  
629 - var arr = new Array();  
630 - //--三个三个一组---  
631 - for (var i = 0; i < new_data.length; i += 3) {  
632 - arr.push(new_data.slice(i, i + 3));  
633 - }  
634 - th.setData({  
635 - newGoods: arr,  
636 - });  
637 - }  
638 - })  
639 -  
640 - //------热卖-------  
641 - await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {  
642 - data: {  
643 - is_mainshow: 1,  
644 - isonsale: 1,  
645 - is_on_sale: 1,  
646 - store_id: o.stoid,  
647 - pageSize: 9,  
648 - is_hot: 1,  
649 - orderField: "sort"  
650 - }  
651 - }).then(res => {  
652 - var e = res;  
653 - if (e.data.code == 0) {  
654 - var new_data = e.data.data.pageData;  
655 - var arr = new Array();  
656 - //--三个三个一组---  
657 - for (var i = 0; i < new_data.length; i += 3) {  
658 - arr.push(new_data.slice(i, i + 3));  
659 - }  
660 - console.log(arr);  
661 - th.setData({  
662 - hotGoods: arr,  
663 - });  
664 - }  
665 - })  
666 -  
667 - //---调用信息---  
668 - // this.requestRecommend();  
669 - this.setData({  
670 - ishow: 1  
671 - });  
672 -  
673 - //---先获取会员---  
674 - //t.getUserFir(function () {  
675 - if(getApp().globalData.user_id) {  
676 - th.is_festival();  
677 - var new_nav = th.data.new_nav;  
678 - if (new_nav == "") {  
679 - th.is_new(); 462 + getApp().requestCardNum(this);
  463 + }
  464 +
  465 + var th = this;
  466 +
  467 + var show = getApp().globalData.isLoad_ad;
  468 +
  469 + if (!show) {
  470 + setTimeout(function () {
  471 + full_screen.get_the_full_screen(th);
  472 + }, 800);
  473 + getApp().globalData.isLoad_ad = 1;
  474 + if (!th.data.f_hidden) {
  475 + setTimeout(function () {
  476 + th.setData({ f_hidden: 1 })
  477 + wx.hideLoading();
  478 + }, 960)
  479 + }
  480 + } else {
  481 + th.setData({ f_hidden: 1 })
  482 + }
  483 +
  484 + setTimeout(function () {
  485 + const query = wx.createSelectorQuery();
  486 + query.select('#off_top').boundingClientRect();
  487 + query.exec((res) => {
  488 + if (res && res[0] && res[0].height > 0) {
  489 + th.setData({ is_ok_h5: 1 });
  490 + }
  491 + })
  492 + }, 3600);
  493 +
  494 + },
  495 + //当隐藏的时候就关闭计时器
  496 + onHide: function () {
  497 + this.data.is_timer = 0;
  498 + if (this.data.pt_timer) clearInterval(this.data.pt_timer);
  499 + if (this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop);
  500 + if (this.data.full_screen) clearInterval(this.data.full_screen);
  501 + this.data.w_holiday_pop = 0;
  502 +
  503 + },
  504 +
  505 + //同步初始加载
  506 + async init_load() {
  507 + var th = this;
  508 + //因为营销版本的功能包含了自定义模板的功能,是同时的
  509 + //读取全局是否有弄自定义模板
  510 + await api.get_template_fir(o.stoid).then(res => {
  511 + var data = res.data.data;
  512 + if (data && data.length > 0) {
  513 + var temp_data = data[0];
  514 + var t_arr = JSON.parse(temp_data.json_str);
  515 +
  516 + th.setData({
  517 + template_arr: t_arr,
  518 + isTemplate: 1,
  519 + bgcolor_t: temp_data.bkcolor
  520 + });
  521 +
  522 + //---如果有设定顶部的颜色的时候--
  523 + if (temp_data.top_color && temp_data.top_color != 'null') {
  524 +
  525 + var top_w_color = "#ffffff";
  526 + if (temp_data.top_word_color && temp_data.top_word_color == 'black') {
  527 + top_w_color = "#000000";
  528 + }
  529 + wx.setNavigationBarColor({
  530 + frontColor: top_w_color, // 必写项
  531 + backgroundColor: temp_data.top_color, // 必写项
  532 + })
  533 + }
  534 + }
  535 + })
  536 +
  537 +
  538 + },
  539 + //---读取数据内容---
  540 + async init_fir() {
  541 + console.log('init_fir');
  542 + var th = this;
  543 + //----广告----
  544 + var e = this;
  545 + await getApp().request.promiseGet("/api/weshop/ad/page?pid=2&store_id=" + o.stoid, {
  546 + data: {
  547 + enabled: 1
  548 + }
  549 + }).then(res => {
  550 +
  551 + if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {
  552 + var a = res.data.data.pageData;
  553 + var arr = new Array();
  554 + for (var i = 0; i < a.length; i++) {
  555 + var tt = {
  556 + 'ad_code': o.imghost + a[i].ad_code,
  557 + 'media_link': '',
  558 + 'ad_weapplink': a[i].ad_weapplink
  559 + };
  560 + arr.push(tt);
  561 + }
  562 + if (arr.length > 0) e.setData({
  563 + banner: arr,
  564 + });
  565 +
  566 + wx.stopPullDownRefresh();
  567 + }
  568 + })
  569 + let user_id = getApp().globalData.user_id;
  570 +
  571 + //----拼单-----
  572 + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {
  573 + data: {
  574 + store_id: os.stoid,
  575 + is_end: 0,
  576 + is_show: 1,
  577 + pageSize: 6,
  578 + user_id,
  579 + }
  580 + }).then(res => {
  581 + var e = res;
  582 + if (e.data.code == 0) {
  583 + var pd_data = e.data.data.pageData;
  584 +
  585 + if (pd_data.length == 0) return;
  586 +
  587 + //获取当前
  588 + var nt = ut.gettimestamp();
  589 + pd_data.forEach(function (val, ind) {
  590 + if (val.start_time > nt) pd_data[ind].status = 0;
  591 + else if (val.end_time > nt) pd_data[ind].status = 1;
  592 + if (val.buy_num >= val.goods_num) pd_data[ind].status = 2;
  593 + });
  594 +
  595 + //获取当前时间,比较拼团中还在未开始
  596 + var timestamp = new Date().getTime();
  597 + var is_team_tepy;
  598 + for (var j = 0; j < pd_data.length; j++) {
  599 + pd_data[j].is_team_tepy = 1;
  600 + if (timestamp < pd_data[j].start_time * 1000) {
  601 + var is_team_tepy;
  602 + pd_data[j].is_team_tepy = 0;
  603 + }
  604 + }
  605 +
  606 + var arr = new Array();
  607 + //--2个2个一组---
  608 + for (var i = 0; i < pd_data.length; i += 2) {
  609 +
  610 + arr.push(pd_data.slice(i, i + 2));
  611 + }
  612 +
  613 + th.setData({
  614 + pindGoods: arr
  615 + });
  616 + th.countDown2();
  617 + }
  618 + })
  619 +
  620 + //------新品-------
  621 + await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
  622 + data: {
  623 + is_mainshow: 1,
  624 + isonsale: 1,
  625 + is_on_sale: 1,
  626 + store_id: o.stoid,
  627 + pageSize: 9,
  628 + is_new: 1,
  629 + orderField: "sort"
  630 + }
  631 + }).then(res => {
  632 + var e = res;
  633 + if (e.data.code == 0) {
  634 + var new_data = e.data.data.pageData;
  635 + var arr = new Array();
  636 + //--三个三个一组---
  637 + for (var i = 0; i < new_data.length; i += 3) {
  638 + arr.push(new_data.slice(i, i + 3));
  639 + }
  640 + th.setData({
  641 + newGoods: arr,
  642 + });
  643 + }
  644 + })
  645 +
  646 + //------热卖-------
  647 + await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
  648 + data: {
  649 + is_mainshow: 1,
  650 + isonsale: 1,
  651 + is_on_sale: 1,
  652 + store_id: o.stoid,
  653 + pageSize: 9,
  654 + is_hot: 1,
  655 + orderField: "sort"
  656 + }
  657 + }).then(res => {
  658 + var e = res;
  659 + if (e.data.code == 0) {
  660 + var new_data = e.data.data.pageData;
  661 + var arr = new Array();
  662 + //--三个三个一组---
  663 + for (var i = 0; i < new_data.length; i += 3) {
  664 + arr.push(new_data.slice(i, i + 3));
  665 + }
  666 + console.log(arr);
  667 + th.setData({
  668 + hotGoods: arr,
  669 + });
  670 + }
  671 + })
  672 +
  673 + //---调用信息---
  674 + // this.requestRecommend();
  675 + this.setData({
  676 + ishow: 1
  677 + });
  678 +
  679 + //---先获取会员---
  680 + //t.getUserFir(function () {
  681 + if (getApp().globalData.user_id) {
  682 + th.is_festival();
  683 + var new_nav = th.data.new_nav;
  684 + if (new_nav == "") {
  685 + th.is_new();
  686 + }
  687 +
  688 + // sty
  689 + setTimeout(function () {
  690 + if (getApp().globalData.user_id) getApp().requestCardNum(th);
  691 + }, 500)
  692 + }
  693 + //});
  694 +
  695 + setTimeout(function () {
  696 + var goods_list = th.selectComponent("#goods_list"); //组件的id
  697 + goods_list.init();
  698 + goods_list.get_list();
  699 + }, 2000)
  700 + },
  701 +
  702 + //--判断小程序是否过期--
  703 + setappdata: function (t) {
  704 + if (t && t.isout == 1)
  705 + wx.reLaunch({
  706 + url: "/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:" + getApp().globalData.config.store_tel,
  707 + });
  708 + if (t && t.isbuy == 0)
  709 + wx.reLaunch({
  710 + url: "/pages/error/error?msg=还未购买小程序",
  711 + });
  712 + },
  713 + //---加载更多是靠这个函数----
  714 + onReachBottom: function () {
  715 + var goods_list = this.selectComponent("#goods_list"); //组件的id
  716 + if (goods_list) goods_list.get_list();
  717 +
  718 + if (getApp().globalData.func_list) {
  719 + for (let i in getApp().globalData.func_list) {
  720 + let item = getApp().globalData.func_list[i];
  721 + item.re_show();
  722 + }
  723 + }
  724 + },
  725 +
  726 + onPullDownRefresh: function (e) {
  727 + this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),
  728 + this.requestRecommend();
  729 + },
  730 + requestRecommend() { },
  731 + requestHomePage() { },
  732 +
  733 + onUnload: function () {
  734 + this.destroyActivityTimer();
  735 + },
  736 + setCountTime: function (e) {
  737 + e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({
  738 + "sale.diffTime": e.diffTime
  739 + }), this.setData({
  740 + "sale.good": e.flash_sale_goods[0]
  741 + }), this.destroyActivityTimer(), this.createActivityTimer();
  742 + },
  743 + createActivityTimer: function () {
  744 + var e = this.data.sale,
  745 + t = this;
  746 + this.data.timer = setInterval(function () {
  747 + var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime,
  748 + o = i.transTime(a);
  749 + a <= 0 ? t.requestHomePage() : t.setData({
  750 + "sale.countTime": o
  751 + });
  752 + }, 1e3);
  753 + },
  754 + destroyActivityTimer: function () {
  755 + this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);
  756 + },
  757 + onPageScroll: function (e) {
  758 + this.data.scrollTop = e.scrollTop;
  759 + var t = getCurrentPages();
  760 + "pages/index/index/index" == t[t.length - 1].route;
  761 + /*--(e.scrollTop > 10 ? wx.setNavigationBarColor({
  762 + frontColor: "#ffffff",
  763 + backgroundColor: "#f95959"
  764 + }) : wx.setNavigationBarColor({
  765 + frontColor: "#000000",
  766 + backgroundColor: "#eeeeee"
  767 + }));--*/
  768 + },
  769 + jumpSearch: function () {
  770 + wx.navigateTo({
  771 + url: "/pages/goods/search/search"
  772 + });
  773 + },
  774 + onShareAppMessage: function (e) {
  775 + getApp().globalData.no_clear = 1;
  776 + var url = "/pages/index/index/index";
  777 + var userInfo = getApp().globalData.userInfo;
  778 + //是分销商才带
  779 + if (userInfo) {
  780 + url += "?first_leader=" + userInfo.user_id;
  781 + }
  782 + console.log("---首页---分享--");
  783 + var title = "商城首页"
  784 + //分享
  785 + if (getApp().globalData.config && getApp().globalData.config.store_name) {
  786 + title = getApp().globalData.config.store_name;
  787 + } else if (getApp().globalData.setting.appName) {
  788 + title = getApp().globalData.setting.appName;
  789 + }
  790 +
  791 + var ob = {
  792 + title: title,
  793 + path: url,
  794 + };
  795 + console.log(ob);
  796 + return ob;
  797 + },
  798 +
  799 + //图片失败,默认图片
  800 + bind_bnerr: function (e) {
  801 + var _errImg = e.target.dataset.errorimg;
  802 + var _errObj = {};
  803 + _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg";
  804 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  805 + },
  806 +
  807 + //图片失败,默认图片
  808 + bind_bnerr2: function (e) {
  809 + var _errImg = e.target.dataset.errorimg;
  810 + var _errurl = e.target.dataset.url;
  811 + var _errObj = {};
  812 + _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
  813 + this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  814 +
  815 + },
  816 + //图片失败,默认图片
  817 + bind_bnerr3: function (e) {
  818 + var _errImg = e.target.dataset.errorimg;
  819 + var _Img = e.target.dataset.img;
  820 + if (_Img != undefined) {
  821 + var _errObj = {};
  822 + _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
  823 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  824 + }
  825 + },
  826 +
  827 +
  828 + //秒杀倒计时
  829 + //---小于10的格式化函数----
  830 + timeFormat(param) {
  831 + return param < 10 ? '0' + param : param;
  832 + },
  833 +
  834 + //----秒杀倒计时函数-----
  835 + countDown() {
  836 + if (!this.data.is_timer) return false;
  837 + var th = this;
  838 + // 获取当前时间,同时得到活动结束时间数组
  839 + var newTime = ut.gettimestamp();
  840 + var List = this.data.saleGoods;
  841 + for (var j = 0; j < List.length; j++) {
  842 + var endTimeList = List[j];
  843 + // 对结束时间进行处理渲染到页面
  844 + for (var i = 0; i < endTimeList.length; i++) {
  845 + var o = endTimeList[i];
  846 + var endTime = o.end_time
  847 + if (o.status == 0) endTime = o.start_time
  848 +
  849 + var obj = null;
  850 + // 如果活动未结束,对时间进行处理
  851 + if (endTime - newTime > 0) {
  852 + var time = (endTime - newTime);
  853 + // 获取天、时、分、秒
  854 + var day = parseInt(time / (60 * 60 * 24));
  855 + var hou = parseInt(time % (60 * 60 * 24) / 3600);
  856 + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  857 + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  858 + obj = {
  859 + day: this.timeFormat(day),
  860 + hou: this.timeFormat(hou),
  861 + min: this.timeFormat(min),
  862 + sec: this.timeFormat(sec)
  863 + }
  864 + } else {
  865 + //活动已结束,全部设置为'00'
  866 + obj = {
  867 + day: '00',
  868 + hou: '00',
  869 + min: '00',
  870 + sec: '00'
  871 + }
  872 + }
  873 + var txt = "saleGoods[" + j + "][" + i + "].djs";
  874 + th.setData({
  875 + [txt]: obj
  876 + });
  877 + }
  878 +
  879 + }
  880 + setTimeout(th.countDown, 1000);
  881 + },
  882 +
  883 + //----拼单倒计时函数-----
  884 + countDown2() {
  885 + if (!this.data.is_timer) return false;
  886 +
  887 + var th = this;
  888 + // 获取当前时间,同时得到活动结束时间数组
  889 + var newTime = ut.gettimestamp();
  890 + var List = this.data.pindGoods;
  891 + for (var j = 0; j < List.length; j++) {
  892 + var endTimeList = List[j];
  893 + // 对结束时间进行处理渲染到页面
  894 + for (var i = 0; i < endTimeList.length; i++) {
  895 + var o = endTimeList[i];
  896 + var endTime = o.end_time;
  897 + if (o.status == 0) endTime = o.start_time;
  898 +
  899 + let obj = null;
  900 + // 如果活动未结束,对时间进行处理
  901 + if (endTime - newTime > 0) {
  902 + let time = (endTime - newTime);
  903 + // 获取天、时、分、秒
  904 + let day = parseInt(time / (60 * 60 * 24));
  905 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  906 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  907 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  908 + obj = {
  909 + day: this.timeFormat(day),
  910 + hou: this.timeFormat(hou),
  911 + min: this.timeFormat(min),
  912 + sec: this.timeFormat(sec)
  913 + }
  914 + } else {
  915 + //活动已结束,全部设置为'00'
  916 + obj = {
  917 + day: '00',
  918 + hou: '00',
  919 + min: '00',
  920 + sec: '00'
  921 + }
  922 + }
  923 + var txt = "pindGoods[" + j + "][" + i + "].djs";
  924 + th.setData({
  925 + [txt]: obj
  926 + });
  927 + }
  928 + }
  929 + setTimeout(th.countDown2, 1000);
  930 + },
  931 +
  932 + bannerSwiperChange: function (e) {
  933 + var index = e.detail.current;
  934 + this.setData({
  935 + banner_index: index
  936 + });
  937 + },
  938 + flashSwiperChange: function (e) {
  939 + var index = e.detail.current;
  940 + this.setData({
  941 + flash_index: index
  942 + });
  943 + },
  944 + ptSwiperChange: function (e) {
  945 + var index = e.detail.current;
  946 + this.setData({
  947 + pt_index: index
  948 + });
  949 + },
  950 +
  951 + Interval_pt() {
  952 + var th = this;
  953 + this.data.pt_timer = setInterval(function () {
  954 + var item = ut.get_rand_item(th.data.pt_timer_arr);
  955 + th.setData({
  956 + pt_timer_active: 1,
  957 + pt_timer_item: item
  958 + });
  959 + setTimeout(function () {
  960 + th.setData({
  961 + pt_timer_active: 0
  962 + });
  963 + }, 1500)
  964 + }, 4000);
  965 + },
  966 +
  967 +
  968 + //---扫一扫的函数---
  969 + getScancode: function () {
  970 + var _this = this;
  971 + getApp().globalData.no_clear = 1;
  972 + // 允许从相机和相册扫码
  973 + wx.scanCode({
  974 + success: (res) => {
  975 + var result = res.result;
  976 + wx.navigateTo({
  977 + url: "/pages/goods/search/search?s_key=" + result,
  978 + });
  979 + }
  980 + })
  981 + },
  982 +
  983 + //跳转到分类
  984 + go_cate: function () {
  985 + getApp().goto("/pages/goods/categoryList/categoryList");
  986 + },
  987 +
  988 + // 幸运购跳转
  989 + go_url: function (e) {
  990 +
  991 + var url = e.currentTarget.dataset.url;
  992 + getApp().goto(url);
  993 +
  994 + }, //
  995 +
  996 + bind_bnerr_icon: function (e) {
  997 + var def = "/miniapp/images/no_cate_def.png";
  998 + var _err = e.currentTarget.dataset.err;
  999 + var ob = {};
  1000 + ob[_err] = def;
  1001 + this.setData(ob);
  1002 + },
  1003 +
  1004 + //跳转到分类的商品列表
  1005 + go_cate2: function (t) {
  1006 + var cid = t.currentTarget.dataset.cid;
  1007 + var pid = t.currentTarget.dataset.pid;
  1008 + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid;
  1009 + wx.navigateTo({
  1010 + url: lurl
  1011 + });
  1012 + },
  1013 + new_nav: function (e) {
  1014 + var th = this;
  1015 + var new_nav = th.data.new_nav;
  1016 + getApp().goto(new_nav);
  1017 + },
  1018 + //跳转到权益
  1019 + go_quanyi: function (t) {
  1020 + var user_info = getApp().globalData.userInfo;
  1021 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  1022 + wx.navigateTo({
  1023 + url: '/pages/togoin/togoin',
  1024 + //url: '/pages/getphone/getphone',
  1025 + })
  1026 + return false;
  1027 + }
  1028 + getApp().goto("/pages/user/userqy/userqy");
  1029 + },
  1030 +
  1031 + imageLoad: function (e) {
  1032 + var imgwidth = e.detail.width;
  1033 + var imgheight = e.detail.height;
  1034 + //宽高比
  1035 + var ratio = imgwidth / imgheight;
  1036 + //计算的高度值
  1037 + var viewHeight = 715 / ratio;
  1038 + if (this.data.max_sw_height < viewHeight) this.setData({
  1039 + max_sw_height: viewHeight
  1040 + });
  1041 + },
  1042 + //判断该用户是否是新会员
  1043 + is_new: function () {
  1044 + var th = this;
  1045 + wx.hideLoading();
  1046 + getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {
  1047 + data: {
  1048 + storeId: os.stoid,
  1049 + userId: d.user_id
  1050 + }
  1051 + }).then(res => {
  1052 + if (res.data.code == 0) {
  1053 + var actid = res.data.data.id; //活动id
  1054 + var giftBagId = res.data.data.giftBagId; //礼包id
  1055 + var new_nav = "/pages/giftpack/newvipgift/newvipgift?actId=" + actid + '&' + 'actType=' + 1 + '&' + 'giftBagId=' + giftBagId;
  1056 + var new_image = res.data.data.imageurl;
  1057 + var swiperimage = th.data.swiperimage;
  1058 + var img = {
  1059 + image: "/miniapp/images/newpeople/newpeople.png",
  1060 + nav_url: new_nav
  1061 + }
  1062 + swiperimage.unshift(img);
  1063 + th.setData({
  1064 + swiperimage: swiperimage,
  1065 + new_image: new_image,
  1066 + new_nav: new_nav
  1067 + })
  1068 +
  1069 + getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/bound/judge", {
  1070 + data: {
  1071 + storeId: o.stoid,
  1072 + userId: d.user_id
  1073 + }
  1074 + }).then(res => {
  1075 + if (res.data.code == 0) {
  1076 + th.setData({
  1077 + is_disgraceful: 1
  1078 + })
  1079 + } else {
  1080 + th.check_holiday_pop(); //节日的弹窗
  1081 + }
  1082 +
  1083 + })
  1084 + } else {
  1085 + th.check_holiday_pop(); //节日的弹窗
  1086 + }
  1087 +
  1088 + })
  1089 +
  1090 + },
  1091 +
  1092 + is_festival: function (e) {
  1093 + var th = this;
  1094 + var url = "/api/weshop/marketing/holiday/act/judge";
  1095 + getApp().request.promiseGet(url, {
  1096 + data: {
  1097 + storeId: os.stoid,
  1098 + userId: d.user_id
  1099 + }
  1100 + }).then(res => {
  1101 + if (res.data.code == 0) {
  1102 + var actid = res.data.data.id; //活动id
  1103 + var giftBagId = res.data.data.gifBagId; //礼包id
  1104 + var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId;
  1105 + var swiperimage = th.data.swiperimage;
  1106 + var actBoundImg = res.data.data.actBoundImg ? res.data.data.actBoundImg : '/miniapp/images/default_g_img.gif';
  1107 +
  1108 + th.data.holiday_image = res.data.data.actImg;
  1109 + th.data.holiday_url = nav_url;
  1110 +
  1111 + var img = {
  1112 + image: actBoundImg,
  1113 + nav_url: nav_url,
  1114 + id: res.data.data.id,
  1115 + type: 'festival'
  1116 + }
  1117 +
  1118 + for (var i in swiperimage) {
  1119 + var item = swiperimage[i];
  1120 + if (item.id == img.id && item.type == img.type) {
  1121 + return false;
  1122 + }
  1123 + }
  1124 +
  1125 + swiperimage.unshift(img);
  1126 + th.setData({
  1127 + swiperimage: swiperimage,
  1128 + new_nav: nav_url
  1129 + })
  1130 + }
  1131 + })
  1132 + },
  1133 +
  1134 + //弹出节日有礼
  1135 + check_holiday_pop: function () {
  1136 + var th = this;
  1137 + getApp().waitfor2(th, 'w_holiday_pop', 'holiday_image', function () {
  1138 + //等到结果才显示
  1139 + if (th.data.holiday_image) {
  1140 + th.setData({
  1141 + new_image: th.data.holiday_image,
  1142 + new_nav: th.data.holiday_url,
  1143 + is_disgraceful: 1
  1144 + })
  1145 + }
  1146 + })
  1147 + },
  1148 +
  1149 + go_ad: function (e) {
  1150 + var url = e.currentTarget.dataset.url;
  1151 + if (!url || url == '') return;
  1152 + if (url[0] != '/') url = '/' + url;
  1153 + getApp().goto(url);
  1154 + },
  1155 +
  1156 + //导航跳转
  1157 + nav_goto: function (e) {
  1158 + var url = e.currentTarget.dataset.url;
  1159 + if (!url || url == '') return;
  1160 + if (url[0] != '/') url = '/' + url;
  1161 + getApp().goto(url);
  1162 + if (this.data.showHongbao) {
  1163 + this.setData({
  1164 + showHongbao: false,
  1165 + showHongbaoSmall: true, //显示抢红包小图标
  1166 + });
  1167 + }
  1168 + },
  1169 +
  1170 + //----跳转到搭配购买----
  1171 + go_test: function () {
  1172 + wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", })
  1173 + },
  1174 + onShareTimeline() {
  1175 + getApp().globalData.no_clear=1;
  1176 + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
  1177 + if (!store_name){
  1178 + store_name = getApp().globalData.setting.appName;
  1179 + }
  1180 + return {
  1181 + title: '首页-' + '-' + store_name,
680 } 1182 }
  1183 + },
681 1184
682 - // sty  
683 - setTimeout(function () {  
684 - if (getApp().globalData.user_id) getApp().requestCardNum(th);  
685 - }, 500)  
686 - }  
687 - //});  
688 -  
689 - setTimeout(function () {  
690 - var goods_list = th.selectComponent("#goods_list"); //组件的id  
691 - goods_list.init();  
692 - goods_list.get_list();  
693 - }, 2000)  
694 - },  
695 -  
696 - //--判断小程序是否过期--  
697 - setappdata: function (t) {  
698 - if (t && t.isout == 1)  
699 - wx.reLaunch({  
700 - url: "/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:" + getApp().globalData.config.store_tel,  
701 - });  
702 - if (t && t.isbuy == 0)  
703 - wx.reLaunch({  
704 - url: "/pages/error/error?msg=还未购买小程序",  
705 - });  
706 - },  
707 - //---加载更多是靠这个函数----  
708 - onReachBottom: function () {  
709 - var goods_list = this.selectComponent("#goods_list"); //组件的id  
710 - if (goods_list) goods_list.get_list();  
711 -  
712 - if (getApp().globalData.func_list) {  
713 - for (let i in getApp().globalData.func_list) {  
714 - let item = getApp().globalData.func_list[i];  
715 - item.re_show();  
716 - }  
717 - }  
718 - },  
719 -  
720 - onPullDownRefresh: function (e) {  
721 - this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),  
722 - this.requestRecommend();  
723 - },  
724 - requestRecommend() { },  
725 - requestHomePage() { },  
726 -  
727 - onUnload: function () {  
728 - this.destroyActivityTimer();  
729 - },  
730 - setCountTime: function (e) {  
731 - e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({  
732 - "sale.diffTime": e.diffTime  
733 - }), this.setData({  
734 - "sale.good": e.flash_sale_goods[0]  
735 - }), this.destroyActivityTimer(), this.createActivityTimer();  
736 - },  
737 - createActivityTimer: function () {  
738 - var e = this.data.sale,  
739 - t = this;  
740 - this.data.timer = setInterval(function () {  
741 - var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime,  
742 - o = i.transTime(a);  
743 - a <= 0 ? t.requestHomePage() : t.setData({  
744 - "sale.countTime": o  
745 - });  
746 - }, 1e3);  
747 - },  
748 - destroyActivityTimer: function () {  
749 - this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);  
750 - },  
751 - onPageScroll: function (e) {  
752 - this.data.scrollTop = e.scrollTop;  
753 - var t = getCurrentPages();  
754 - "pages/index/index/index" == t[t.length - 1].route;  
755 - /*--(e.scrollTop > 10 ? wx.setNavigationBarColor({  
756 - frontColor: "#ffffff",  
757 - backgroundColor: "#f95959"  
758 - }) : wx.setNavigationBarColor({  
759 - frontColor: "#000000",  
760 - backgroundColor: "#eeeeee"  
761 - }));--*/  
762 - },  
763 - jumpSearch: function () {  
764 - wx.navigateTo({  
765 - url: "/pages/goods/search/search"  
766 - });  
767 - },  
768 - onShareAppMessage: function (e) {  
769 - getApp().globalData.no_clear=1;  
770 - var url = "/pages/index/index/index";  
771 - var userInfo = getApp().globalData.userInfo;  
772 - //是分销商才带  
773 - if (userInfo) {  
774 - url += "?first_leader=" + userInfo.user_id;  
775 - }  
776 - console.log("---首页---分享--");  
777 - var title = "商城首页"  
778 - //分享  
779 - if (getApp().globalData.config && getApp().globalData.config.store_name) {  
780 - title = getApp().globalData.config.store_name;  
781 - } else if (getApp().globalData.setting.appName) {  
782 - title = getApp().globalData.setting.appName;  
783 - }  
784 -  
785 - var ob = {  
786 - title: title,  
787 - path: url,  
788 - };  
789 - console.log(ob);  
790 - return ob;  
791 - },  
792 -  
793 - //图片失败,默认图片  
794 - bind_bnerr: function (e) {  
795 - var _errImg = e.target.dataset.errorimg;  
796 - var _errObj = {};  
797 - _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg";  
798 - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
799 - },  
800 -  
801 - //图片失败,默认图片  
802 - bind_bnerr2: function (e) {  
803 - var _errImg = e.target.dataset.errorimg;  
804 - var _errurl = e.target.dataset.url;  
805 - var _errObj = {};  
806 - _errObj[_errImg] = "/miniapp/images/default_g_img.gif";  
807 - this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
808 -  
809 - },  
810 - //图片失败,默认图片  
811 - bind_bnerr3: function (e) {  
812 - var _errImg = e.target.dataset.errorimg;  
813 - var _Img = e.target.dataset.img;  
814 - if (_Img != undefined) {  
815 - var _errObj = {};  
816 - _errObj[_errImg] = "/public/images/default_goods_image_240.gif";  
817 - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
818 - }  
819 - },  
820 -  
821 -  
822 - //秒杀倒计时  
823 - //---小于10的格式化函数----  
824 - timeFormat(param) {  
825 - return param < 10 ? '0' + param : param;  
826 - },  
827 -  
828 - //----秒杀倒计时函数-----  
829 - countDown() {  
830 - if (!this.data.is_timer) return false;  
831 - var th = this;  
832 - // 获取当前时间,同时得到活动结束时间数组  
833 - var newTime = ut.gettimestamp();  
834 - var List = this.data.saleGoods;  
835 - for (var j = 0; j < List.length; j++) {  
836 - var endTimeList = List[j];  
837 - // 对结束时间进行处理渲染到页面  
838 - for (var i = 0; i < endTimeList.length; i++) {  
839 - var o = endTimeList[i];  
840 - var endTime = o.end_time  
841 - if (o.status == 0) endTime = o.start_time  
842 -  
843 - var obj = null;  
844 - // 如果活动未结束,对时间进行处理  
845 - if (endTime - newTime > 0) {  
846 - var time = (endTime - newTime);  
847 - // 获取天、时、分、秒  
848 - var day = parseInt(time / (60 * 60 * 24));  
849 - var hou = parseInt(time % (60 * 60 * 24) / 3600);  
850 - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60);  
851 - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);  
852 - obj = {  
853 - day: this.timeFormat(day),  
854 - hou: this.timeFormat(hou),  
855 - min: this.timeFormat(min),  
856 - sec: this.timeFormat(sec)  
857 - }  
858 - } else {  
859 - //活动已结束,全部设置为'00'  
860 - obj = {  
861 - day: '00',  
862 - hou: '00',  
863 - min: '00',  
864 - sec: '00'  
865 - }  
866 - }  
867 - var txt = "saleGoods[" + j + "][" + i + "].djs";  
868 - th.setData({  
869 - [txt]: obj  
870 - });  
871 - }  
872 -  
873 - }  
874 - setTimeout(th.countDown, 1000);  
875 - },  
876 -  
877 - //----拼单倒计时函数-----  
878 - countDown2() {  
879 - if (!this.data.is_timer) return false;  
880 -  
881 - var th = this;  
882 - // 获取当前时间,同时得到活动结束时间数组  
883 - var newTime = ut.gettimestamp();  
884 - var List = this.data.pindGoods;  
885 - for (var j = 0; j < List.length; j++) {  
886 - var endTimeList = List[j];  
887 - // 对结束时间进行处理渲染到页面  
888 - for (var i = 0; i < endTimeList.length; i++) {  
889 - var o = endTimeList[i];  
890 - var endTime = o.end_time;  
891 - if (o.status == 0) endTime = o.start_time;  
892 -  
893 - let obj = null;  
894 - // 如果活动未结束,对时间进行处理  
895 - if (endTime - newTime > 0) {  
896 - let time = (endTime - newTime);  
897 - // 获取天、时、分、秒  
898 - let day = parseInt(time / (60 * 60 * 24));  
899 - let hou = parseInt(time % (60 * 60 * 24) / 3600);  
900 - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);  
901 - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);  
902 - obj = {  
903 - day: this.timeFormat(day),  
904 - hou: this.timeFormat(hou),  
905 - min: this.timeFormat(min),  
906 - sec: this.timeFormat(sec)  
907 - }  
908 - } else {  
909 - //活动已结束,全部设置为'00'  
910 - obj = {  
911 - day: '00',  
912 - hou: '00',  
913 - min: '00',  
914 - sec: '00'  
915 - }  
916 - }  
917 - var txt = "pindGoods[" + j + "][" + i + "].djs";  
918 - th.setData({  
919 - [txt]: obj  
920 - });  
921 - }  
922 - }  
923 - setTimeout(th.countDown2, 1000);  
924 - },  
925 -  
926 - bannerSwiperChange: function (e) {  
927 - var index = e.detail.current;  
928 - this.setData({  
929 - banner_index: index  
930 - });  
931 - },  
932 - flashSwiperChange: function (e) {  
933 - var index = e.detail.current;  
934 - this.setData({  
935 - flash_index: index  
936 - });  
937 - },  
938 - ptSwiperChange: function (e) {  
939 - var index = e.detail.current;  
940 - this.setData({  
941 - pt_index: index  
942 - });  
943 - },  
944 -  
945 - Interval_pt() {  
946 - var th = this;  
947 - this.data.pt_timer = setInterval(function () {  
948 - var item = ut.get_rand_item(th.data.pt_timer_arr);  
949 - th.setData({  
950 - pt_timer_active: 1,  
951 - pt_timer_item: item  
952 - });  
953 - setTimeout(function () {  
954 - th.setData({  
955 - pt_timer_active: 0  
956 - });  
957 - }, 1500)  
958 - }, 4000);  
959 - },  
960 -  
961 -  
962 - //---扫一扫的函数---  
963 - getScancode: function () {  
964 - var _this = this;  
965 - getApp().globalData.no_clear=1;  
966 - // 允许从相机和相册扫码  
967 - wx.scanCode({  
968 - success: (res) => {  
969 - var result = res.result;  
970 - wx.navigateTo({  
971 - url: "/pages/goods/search/search?s_key=" + result,  
972 - });  
973 - }  
974 - })  
975 - },  
976 -  
977 - //跳转到分类  
978 - go_cate: function () {  
979 - getApp().goto("/pages/goods/categoryList/categoryList");  
980 - },  
981 -  
982 - // 幸运购跳转  
983 - go_url: function (e) {  
984 -  
985 - var url = e.currentTarget.dataset.url;  
986 - getApp().goto(url);  
987 -  
988 - }, //  
989 -  
990 - bind_bnerr_icon: function (e) {  
991 - var def = "/miniapp/images/no_cate_def.png";  
992 - var _err = e.currentTarget.dataset.err;  
993 - var ob = {};  
994 - ob[_err] = def;  
995 - this.setData(ob);  
996 - },  
997 -  
998 - //跳转到分类的商品列表  
999 - go_cate2: function (t) {  
1000 - var cid = t.currentTarget.dataset.cid;  
1001 - var pid = t.currentTarget.dataset.pid;  
1002 - var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid;  
1003 - wx.navigateTo({  
1004 - url: lurl  
1005 - });  
1006 - },  
1007 - new_nav: function (e) {  
1008 - var th = this;  
1009 - var new_nav = th.data.new_nav;  
1010 - getApp().goto(new_nav);  
1011 - },  
1012 - //跳转到权益  
1013 - go_quanyi: function (t) {  
1014 - var user_info = getApp().globalData.userInfo;  
1015 - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {  
1016 - wx.navigateTo({  
1017 - url: '/pages/togoin/togoin',  
1018 - //url: '/pages/getphone/getphone',  
1019 - })  
1020 - return false;  
1021 - }  
1022 - getApp().goto("/pages/user/userqy/userqy");  
1023 - },  
1024 -  
1025 - imageLoad: function (e) {  
1026 - var imgwidth = e.detail.width;  
1027 - var imgheight = e.detail.height;  
1028 - //宽高比  
1029 - var ratio = imgwidth / imgheight;  
1030 - //计算的高度值  
1031 - var viewHeight = 715 / ratio;  
1032 - if (this.data.max_sw_height < viewHeight) this.setData({  
1033 - max_sw_height: viewHeight  
1034 - });  
1035 - },  
1036 - //判断该用户是否是新会员  
1037 - is_new: function () {  
1038 - var th = this;  
1039 - wx.hideLoading();  
1040 - getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {  
1041 - data: {  
1042 - storeId: os.stoid,  
1043 - userId: d.user_id  
1044 - }  
1045 - }).then(res => {  
1046 - if (res.data.code == 0) {  
1047 - var actid = res.data.data.id; //活动id  
1048 - var giftBagId = res.data.data.giftBagId; //礼包id  
1049 - var new_nav = "/pages/giftpack/newvipgift/newvipgift?actId=" + actid + '&' + 'actType=' + 1 + '&' + 'giftBagId=' + giftBagId;  
1050 - var new_image = res.data.data.imageurl;  
1051 - var swiperimage = th.data.swiperimage;  
1052 - var img = {  
1053 - image: "/miniapp/images/newpeople/newpeople.png",  
1054 - nav_url: new_nav  
1055 - }  
1056 - swiperimage.unshift(img);  
1057 - th.setData({  
1058 - swiperimage: swiperimage,  
1059 - new_image: new_image,  
1060 - new_nav: new_nav  
1061 - })  
1062 -  
1063 - getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/bound/judge", {  
1064 - data: {  
1065 - storeId: o.stoid,  
1066 - userId: d.user_id  
1067 - }  
1068 - }).then(res => {  
1069 - if (res.data.code == 0) {  
1070 - th.setData({  
1071 - is_disgraceful: 1  
1072 - })  
1073 - } else {  
1074 - th.check_holiday_pop(); //节日的弹窗  
1075 - }  
1076 -  
1077 - })  
1078 - } else {  
1079 - th.check_holiday_pop(); //节日的弹窗  
1080 - }  
1081 -  
1082 - })  
1083 -  
1084 - },  
1085 -  
1086 - is_festival: function (e) {  
1087 - var th = this;  
1088 - var url = "/api/weshop/marketing/holiday/act/judge";  
1089 - getApp().request.promiseGet(url, {  
1090 - data: {  
1091 - storeId: os.stoid,  
1092 - userId: d.user_id  
1093 - }  
1094 - }).then(res => {  
1095 - if (res.data.code == 0) {  
1096 - var actid = res.data.data.id; //活动id  
1097 - var giftBagId = res.data.data.gifBagId; //礼包id  
1098 - var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId;  
1099 - var swiperimage = th.data.swiperimage;  
1100 - var actBoundImg = res.data.data.actBoundImg ? res.data.data.actBoundImg : '/miniapp/images/default_g_img.gif';  
1101 -  
1102 - th.data.holiday_image = res.data.data.actImg;  
1103 - th.data.holiday_url = nav_url;  
1104 -  
1105 - var img = {  
1106 - image: actBoundImg,  
1107 - nav_url: nav_url,  
1108 - id: res.data.data.id,  
1109 - type: 'festival'  
1110 - } 1185 + // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标
  1186 + closeHongbao() {
  1187 + this.setData({
  1188 + showHongbao: false, //关闭抢红包主弹窗
  1189 + showHongbaoSmall: true, //显示抢红包小图标
  1190 + });
  1191 + },
  1192 +
  1193 + /*-- 全屏广告 --*/
  1194 + close_full_screen() {
  1195 + this.setData({ is_full_screen_show: 0, sec_show: 0 });
  1196 + },
  1197 + //-- 跳转到满屏广告的链接 --
  1198 + go_full_ad() {
  1199 + if (!this.data.full_ad) return false;
  1200 + if (!this.data.full_ad.ad_weapplink) return false;
  1201 + getApp().goto(this.data.full_ad.ad_weapplink);
  1202 + this.close_full_screen();
  1203 + },
  1204 +
  1205 + go_pre: function (e) {
  1206 + var userInfo = getApp().globalData.userInfo;
  1207 + if (!userInfo) {
  1208 + getApp().goto("/pages/togoin/togoin");
  1209 + return false;
  1210 + }
  1211 + var url = e.currentTarget.dataset.url;
  1212 + getApp().goto(url);
  1213 + },
1111 1214
1112 - for (var i in swiperimage) {  
1113 - var item = swiperimage[i];  
1114 - if (item.id == img.id && item.type == img.type) {  
1115 - return false;  
1116 - }  
1117 - }  
1118 1215
1119 - swiperimage.unshift(img);  
1120 - th.setData({  
1121 - swiperimage: swiperimage,  
1122 - new_nav: nav_url  
1123 - })  
1124 - }  
1125 - })  
1126 - },  
1127 -  
1128 - //弹出节日有礼  
1129 - check_holiday_pop: function () {  
1130 - var th = this;  
1131 - getApp().waitfor2(th, 'w_holiday_pop', 'holiday_image', function () {  
1132 - //等到结果才显示  
1133 - if (th.data.holiday_image) {  
1134 - th.setData({  
1135 - new_image: th.data.holiday_image,  
1136 - new_nav: th.data.holiday_url,  
1137 - is_disgraceful: 1  
1138 - })  
1139 - }  
1140 - })  
1141 - },  
1142 -  
1143 - go_ad: function (e) {  
1144 - var url = e.currentTarget.dataset.url;  
1145 - if (!url || url == '') return;  
1146 - if (url[0] != '/') url = '/' + url;  
1147 - getApp().goto(url);  
1148 - },  
1149 -  
1150 - //导航跳转  
1151 - nav_goto: function (e) {  
1152 - var url = e.currentTarget.dataset.url;  
1153 - if (!url || url == '') return;  
1154 - if (url[0] != '/') url = '/' + url;  
1155 - getApp().goto(url);  
1156 - if (this.data.showHongbao) {  
1157 - this.setData({  
1158 - showHongbao: false,  
1159 - showHongbaoSmall: true, //显示抢红包小图标  
1160 - });  
1161 - }  
1162 - },  
1163 -  
1164 - //----跳转到搭配购买----  
1165 - go_test: function () {  
1166 - wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", })  
1167 - },  
1168 -  
1169 -  
1170 - onShareTimeline() {  
1171 - getApp().globalData.no_clear=1;  
1172 -  
1173 - // getApp().getConfig(function(t) {  
1174 - // return {  
1175 - // title: '首页-' + getApp().globalData.config.store_name,  
1176 - // }  
1177 - // });  
1178 - var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';  
1179 - if (!store_name)  
1180 - store_name = getApp().globalData.setting.appName;  
1181 - return {  
1182 - title: '首页-' + store_name,  
1183 - }  
1184 - },  
1185 -  
1186 -  
1187 - // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标  
1188 - closeHongbao() {  
1189 - this.setData({  
1190 - showHongbao: false, //关闭抢红包主弹窗  
1191 - showHongbaoSmall: true, //显示抢红包小图标  
1192 - });  
1193 - },  
1194 -  
1195 - /*-- 全屏广告 --*/  
1196 - close_full_screen() {  
1197 - this.setData({ is_full_screen_show: 0, sec_show: 0 });  
1198 - },  
1199 - //-- 跳转到满屏广告的链接 --  
1200 - go_full_ad() {  
1201 - if (!this.data.full_ad) return false;  
1202 - if (!this.data.full_ad.ad_weapplink) return false;  
1203 - getApp().goto(this.data.full_ad.ad_weapplink);  
1204 - this.close_full_screen();  
1205 - },  
1206 -  
1207 - go_pre:function (e) {  
1208 - var userInfo=getApp().globalData.userInfo;  
1209 - if(!userInfo){  
1210 - getApp().goto("/pages/togoin/togoin");  
1211 - return false;  
1212 - }  
1213 - var url=e.currentTarget.dataset.url;  
1214 - getApp().goto(url);  
1215 - },  
1216 -  
1217 -  
1218 1216
1219 1217
1220 1218