Commit 7fb3975aea3d073d6c190dbad502d8cf2d3529fe

Authored by yvan.ni
1 parent 13c179dd

1、首页修复一个bug

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