Commit d6bcc83d004cd6e5dc5c516684a176933c129f4a

Authored by 前端研发-钱巧玲
1 parent 187d5eec

首页新人有礼判断显示

pages/index/index/index.js
1 -var e = function (e) { 1 +var e = function(e) {
2 return e && e.__esModule ? e : { 2 return e && e.__esModule ? e : {
3 - default: e 3 + default: e
4 }; 4 };
5 - }(require("../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, os = o,  
6 - i = require("../../../utils/util.js"), ut = i, s = require("../../../utils/common.js"), n = new e.default(); 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();
7 var regeneratorRuntime = require('../../../utils/runtime.js'); 14 var regeneratorRuntime = require('../../../utils/runtime.js');
8 var api = require('../../../api/api.js'); 15 var api = require('../../../api/api.js');
9 var d = getApp().globalData; 16 var d = getApp().globalData;
10 - 17 +
11 Page({ 18 Page({
12 data: { 19 data: {
13 url: o.imghost, 20 url: o.imghost,
14 - swiperimage: ["/miniapp/images/title.png"],//,"/miniapp/images/newpeople/newpeople.png" 21 + swiperimage: ["/miniapp/images/title.png"], //,"/miniapp/images/newpeople/newpeople.png"
15 resourceUrl: o.resourceUrl, 22 resourceUrl: o.resourceUrl,
16 logo: o.appLogo, 23 logo: o.appLogo,
17 homeData: null, 24 homeData: null,
@@ -32,69 +39,74 @@ Page({ @@ -32,69 +39,74 @@ Page({
32 banner: null, 39 banner: null,
33 40
34 appdata: null, 41 appdata: null,
35 - saleGoods: null,//秒杀数据  
36 - pindGoods: null,//拼单数据  
37 - newGoods:null,//新商品  
38 - hotGoods:null,//hot商品 42 + saleGoods: null, //秒杀数据
  43 + pindGoods: null, //拼单数据
  44 + newGoods: null, //新商品
  45 + hotGoods: null, //hot商品
39 //----控制是是否显示计时器--- 46 //----控制是是否显示计时器---
40 - is_timer:1,  
41 - ishow:0, 47 + is_timer: 1,
  48 + ishow: 0,
42 //是不是显示自定义模板 49 //是不是显示自定义模板
43 - isTemplate:0,  
44 - template_arr:null,  
45 - bgcolor_t:'',  
46 -  
47 - banner_index:0,  
48 - flash_index:0,  
49 - pt_index:0,  
50 -  
51 - pt_timer_item:null,  
52 - pt_timer_arr:null,  
53 - pt_timer:null,  
54 - pt_timer_active:0, 50 + isTemplate: 0,
  51 + template_arr: null,
  52 + bgcolor_t: '',
  53 +
  54 + banner_index: 0,
  55 + flash_index: 0,
  56 + pt_index: 0,
  57 +
  58 + pt_timer_item: null,
  59 + pt_timer_arr: null,
  60 + pt_timer: null,
  61 + pt_timer_active: 0,
55 //看下商家是否开通会员权益 62 //看下商家是否开通会员权益
56 - is_boot:0,  
57 - gd_category:null,  
58 - is_no_more:0,  
59 - max_sw_height:0, //banner的最大高度  
60 - is_disgraceful:0,//是否显示新人广告 63 + is_boot: 0,
  64 + gd_category: null,
  65 + is_no_more: 0,
  66 + max_sw_height: 0, //banner的最大高度
  67 + is_disgraceful: 0, //是否显示新人广告
  68 + new_image: "", //新人有礼弹窗图片
  69 + new_nav: "/pages/giftpack/newvipgift/newvipgift", //新人页面跳转地址
61 }, 70 },
62 71
63 - onLoad: function () { 72 + onLoad: function() {
64 var th = this; 73 var th = this;
65 // n.init(th, "", "recommend"); 74 // n.init(th, "", "recommend");
66 75
67 //看一下商家是否开通了权益 76 //看一下商家是否开通了权益
68 //--初始化是否有打勾-- 77 //--初始化是否有打勾--
69 getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", { 78 getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
70 - data: { storeId: os.stoid } 79 + data: {
  80 + storeId: os.stoid
  81 + }
71 }).then(res => { 82 }).then(res => {
72 if (res.data.data) { 83 if (res.data.data) {
73 var is_init = res.data.data.isBool; 84 var is_init = res.data.data.isBool;
74 - th.setData({ is_boot: is_init }); 85 + th.setData({
  86 + is_boot: is_init
  87 + });
75 } 88 }
76 }) 89 })
77 th.is_new(); 90 th.is_new();
78 91
79 }, 92 },
80 //关闭新用户领取广告 93 //关闭新用户领取广告
81 - close_disgraceful:function(){ 94 + close_disgraceful: function() {
82 var th = this; 95 var th = this;
83 - th.setData({  
84 - is_disgraceful:0  
85 - }) 96 + th.setData({
  97 + is_disgraceful: 0
  98 + })
86 }, 99 },
87 async onShow() { 100 async onShow() {
88 var th = this; 101 var th = this;
89 - if(getApp().globalData.user_id) getApp().requestCardNum(); 102 + if (getApp().globalData.user_id) getApp().requestCardNum();
90 await this.init_load(); 103 await this.init_load();
91 //显示的时候要开启计时器 104 //显示的时候要开启计时器
92 this.data.is_timer = 1; 105 this.data.is_timer = 1;
93 //如果是自定义模板 106 //如果是自定义模板
94 if (this.data.isTemplate) { 107 if (this.data.isTemplate) {
95 //---先获取会员--- 108 //---先获取会员---
96 - t.getUserFir(function () {  
97 - }); 109 + t.getUserFir(function() {});
98 } else { 110 } else {
99 await this.init_fir(); 111 await this.init_fir();
100 } 112 }
@@ -109,7 +121,9 @@ Page({ @@ -109,7 +121,9 @@ Page({
109 if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) { 121 if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {
110 for (var i in th.data.pt_timer_arr) { 122 for (var i in th.data.pt_timer_arr) {
111 var p_item = th.data.pt_timer_arr[i]; 123 var p_item = th.data.pt_timer_arr[i];
112 - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {1: 1}).then(res => { 124 + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {
  125 + 1: 1
  126 + }).then(res => {
113 th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic; 127 th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;
114 th.data.pt_timer_arr[i].nickname = res.data.data.nickname; 128 th.data.pt_timer_arr[i].nickname = res.data.data.nickname;
115 }) 129 })
@@ -119,51 +133,61 @@ Page({ @@ -119,51 +133,61 @@ Page({
119 133
120 //---处理正在6个分类---- 134 //---处理正在6个分类----
121 await getApp().request.promiseGet("/api/weshop/goodscategory/page", { 135 await getApp().request.promiseGet("/api/weshop/goodscategory/page", {
122 - data: {store_id: os.stoid, pageSize: 5,is_show:1} 136 + data: {
  137 + store_id: os.stoid,
  138 + pageSize: 5,
  139 + is_show: 1
  140 + }
123 }).then(res => { 141 }).then(res => {
124 - if(res.data.data) {  
125 - var gd_category = res.data.data.pageData;  
126 -  
127 - th.setData({gd_category: gd_category}); 142 + if (res.data.data) {
  143 + var gd_category = res.data.data.pageData;
  144 +
  145 + th.setData({
  146 + gd_category: gd_category
  147 + });
128 } 148 }
129 }) 149 })
130 }, 150 },
131 - 151 +
132 //当隐藏的时候就关闭计时器 152 //当隐藏的时候就关闭计时器
133 - onHide:function(){  
134 - this.data.is_timer=0; 153 + onHide: function() {
  154 + this.data.is_timer = 0;
135 clearInterval(this.data.pt_timer) 155 clearInterval(this.data.pt_timer)
136 }, 156 },
137 157
138 //同步初始加载 158 //同步初始加载
139 - async init_load(){  
140 - var th=this;  
141 - await getApp().get_isbuy();  
142 - this.setappdata(getApp().globalData.wxapp_buy_obj);  
143 - await getApp().getConfig_ays();  
144 -  
145 - //因为营销版本的功能包含了自定义模板的功能,是同时的  
146 - //读取全局是否有弄自定义模板  
147 - await api.get_template_fir(o.stoid).then(res=>{  
148 - var data=res.data.data;  
149 - if(data.length>0){  
150 - var temp_data=data[0];  
151 - var t_arr=JSON.parse(temp_data.json_str);  
152 - th.setData({ template_arr: t_arr, isTemplate: 1, bgcolor_t: temp_data.bkcolor});  
153 - }  
154 - })  
155 -  
156 -  
157 - //--首页的问题--  
158 - if(getApp().globalData.config && getApp().globalData.config.store_name!=undefined && getApp().globalData.config.store_name!=null ){  
159 - wx.setNavigationBarTitle({  
160 - title: getApp().globalData.config.store_name,  
161 - });  
162 - }else{  
163 - wx.setNavigationBarTitle({  
164 - title: getApp().globalData.setting.appName,  
165 - }); 159 + async init_load() {
  160 + var th = this;
  161 + await getApp().get_isbuy();
  162 + this.setappdata(getApp().globalData.wxapp_buy_obj);
  163 + await getApp().getConfig_ays();
  164 +
  165 + //因为营销版本的功能包含了自定义模板的功能,是同时的
  166 + //读取全局是否有弄自定义模板
  167 + await api.get_template_fir(o.stoid).then(res => {
  168 + var data = res.data.data;
  169 + if (data.length > 0) {
  170 + var temp_data = data[0];
  171 + var t_arr = JSON.parse(temp_data.json_str);
  172 + th.setData({
  173 + template_arr: t_arr,
  174 + isTemplate: 1,
  175 + bgcolor_t: temp_data.bkcolor
  176 + });
166 } 177 }
  178 + })
  179 +
  180 +
  181 + //--首页的问题--
  182 + if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {
  183 + wx.setNavigationBarTitle({
  184 + title: getApp().globalData.config.store_name,
  185 + });
  186 + } else {
  187 + wx.setNavigationBarTitle({
  188 + title: getApp().globalData.setting.appName,
  189 + });
  190 + }
167 }, 191 },
168 192
169 //---读取数据内容--- 193 //---读取数据内容---
@@ -172,16 +196,23 @@ Page({ @@ -172,16 +196,23 @@ Page({
172 //----广告---- 196 //----广告----
173 var e = this; 197 var e = this;
174 await getApp().request.promiseGet("/api/weshop/ad/list?pid=2&store_id=" + o.stoid, { 198 await getApp().request.promiseGet("/api/weshop/ad/list?pid=2&store_id=" + o.stoid, {
175 - data:{enabled:1}  
176 - }).then(res=>{ 199 + data: {
  200 + enabled: 1
  201 + }
  202 + }).then(res => {
177 var a = res.data.data; 203 var a = res.data.data;
178 var arr = new Array(); 204 var arr = new Array();
179 for (var i = 0; i < a.length; i++) { 205 for (var i = 0; i < a.length; i++) {
180 - var tt = { 'ad_code': o.imghost + a[i].ad_code, 'media_link': '' }; 206 + var tt = {
  207 + 'ad_code': o.imghost + a[i].ad_code,
  208 + 'media_link': ''
  209 + };
181 arr.push(tt); 210 arr.push(tt);
182 } 211 }
183 - if (arr.length>0) e.setData({ banner: arr, });  
184 - 212 + if (arr.length > 0) e.setData({
  213 + banner: arr,
  214 + });
  215 +
185 wx.stopPullDownRefresh(); 216 wx.stopPullDownRefresh();
186 }) 217 })
187 218
@@ -202,20 +233,20 @@ Page({ @@ -202,20 +233,20 @@ Page({
202 flash_data = e.data.data.pageData; 233 flash_data = e.data.data.pageData;
203 if (flash_data == null || flash_data.length <= 0) return false; 234 if (flash_data == null || flash_data.length <= 0) return false;
204 235
205 - 236 +
206 //当前时间戳 237 //当前时间戳
207 var nt = ut.gettimestamp(); 238 var nt = ut.gettimestamp();
208 239
209 - flash_data.forEach(function (val,ind) {  
210 - if(val.start_time>nt) flash_data[ind].status=0;  
211 - else if(val.end_time>nt) flash_data[ind].status=1;  
212 - if(val.buy_num>=val.goods_num) flash_data[ind].status=2; 240 + flash_data.forEach(function(val, ind) {
  241 + if (val.start_time > nt) flash_data[ind].status = 0;
  242 + else if (val.end_time > nt) flash_data[ind].status = 1;
  243 + if (val.buy_num >= val.goods_num) flash_data[ind].status = 2;
213 }); 244 });
214 245
215 var arr = new Array(); 246 var arr = new Array();
216 //--三个三个一组--- 247 //--三个三个一组---
217 - for(var i=0;i< flash_data.length;i+=3){  
218 - arr.push(flash_data.slice(i,i+3)); 248 + for (var i = 0; i < flash_data.length; i += 3) {
  249 + arr.push(flash_data.slice(i, i + 3));
219 } 250 }
220 th.setData({ 251 th.setData({
221 saleGoods: arr 252 saleGoods: arr
@@ -236,35 +267,35 @@ Page({ @@ -236,35 +267,35 @@ Page({
236 var e = res; 267 var e = res;
237 if (e.data.code == 0) { 268 if (e.data.code == 0) {
238 var pd_data = e.data.data.pageData; 269 var pd_data = e.data.data.pageData;
239 - 270 +
240 if (pd_data.length == 0) return; 271 if (pd_data.length == 0) return;
241 - 272 +
242 //获取当前 273 //获取当前
243 var nt = ut.gettimestamp(); 274 var nt = ut.gettimestamp();
244 - pd_data.forEach(function (val,ind) {  
245 - if(val.start_time>nt) pd_data[ind].status=0;  
246 - else if(val.end_time>nt) pd_data[ind].status=1;  
247 - if(val.buy_num>=val.goods_num) pd_data[ind].status=2; 275 + pd_data.forEach(function(val, ind) {
  276 + if (val.start_time > nt) pd_data[ind].status = 0;
  277 + else if (val.end_time > nt) pd_data[ind].status = 1;
  278 + if (val.buy_num >= val.goods_num) pd_data[ind].status = 2;
248 }); 279 });
249 -  
250 - //获取当前时间,比较拼团中还在未开始 280 +
  281 + //获取当前时间,比较拼团中还在未开始
251 var timestamp = new Date().getTime(); 282 var timestamp = new Date().getTime();
252 var is_team_tepy; 283 var is_team_tepy;
253 - for (var j = 0; j < pd_data.length;j++ ){ 284 + for (var j = 0; j < pd_data.length; j++) {
254 pd_data[j].is_team_tepy = 1; 285 pd_data[j].is_team_tepy = 1;
255 - if (timestamp<pd_data[j].start_time*1000){ 286 + if (timestamp < pd_data[j].start_time * 1000) {
256 var is_team_tepy; 287 var is_team_tepy;
257 pd_data[j].is_team_tepy = 0; 288 pd_data[j].is_team_tepy = 0;
258 - } 289 + }
259 } 290 }
260 - 291 +
261 var arr = new Array(); 292 var arr = new Array();
262 //--2个2个一组--- 293 //--2个2个一组---
263 - for(var i=0;i< pd_data.length;i+=2){  
264 -  
265 - arr.push(pd_data.slice(i,i+2)); 294 + for (var i = 0; i < pd_data.length; i += 2) {
  295 +
  296 + arr.push(pd_data.slice(i, i + 2));
266 } 297 }
267 - 298 +
268 th.setData({ 299 th.setData({
269 pindGoods: arr 300 pindGoods: arr
270 }); 301 });
@@ -275,7 +306,13 @@ Page({ @@ -275,7 +306,13 @@ Page({
275 //------新品------- 306 //------新品-------
276 await getApp().request.promiseGet("/api/weshop/goods/page?page=1", { 307 await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
277 data: { 308 data: {
278 - is_mainshow: 1, isonsale: 1, is_on_sale: 1, store_id: o.stoid, pageSize: 9,is_new:1,orderField:"sort" 309 + is_mainshow: 1,
  310 + isonsale: 1,
  311 + is_on_sale: 1,
  312 + store_id: o.stoid,
  313 + pageSize: 9,
  314 + is_new: 1,
  315 + orderField: "sort"
279 } 316 }
280 }).then(res => { 317 }).then(res => {
281 var e = res; 318 var e = res;
@@ -283,8 +320,8 @@ Page({ @@ -283,8 +320,8 @@ Page({
283 var new_data = e.data.data.pageData; 320 var new_data = e.data.data.pageData;
284 var arr = new Array(); 321 var arr = new Array();
285 //--三个三个一组--- 322 //--三个三个一组---
286 - for(var i=0;i< new_data.length;i+=3){  
287 - arr.push(new_data.slice(i,i+3)); 323 + for (var i = 0; i < new_data.length; i += 3) {
  324 + arr.push(new_data.slice(i, i + 3));
288 } 325 }
289 th.setData({ 326 th.setData({
290 newGoods: arr, 327 newGoods: arr,
@@ -295,7 +332,13 @@ Page({ @@ -295,7 +332,13 @@ Page({
295 //------热卖------- 332 //------热卖-------
296 await getApp().request.promiseGet("/api/weshop/goods/page?page=1", { 333 await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
297 data: { 334 data: {
298 - is_mainshow: 1, isonsale: 1, is_on_sale: 1, store_id: o.stoid, pageSize: 9,is_hot:1,orderField:"sort" 335 + is_mainshow: 1,
  336 + isonsale: 1,
  337 + is_on_sale: 1,
  338 + store_id: o.stoid,
  339 + pageSize: 9,
  340 + is_hot: 1,
  341 + orderField: "sort"
299 } 342 }
300 }).then(res => { 343 }).then(res => {
301 var e = res; 344 var e = res;
@@ -303,8 +346,8 @@ Page({ @@ -303,8 +346,8 @@ Page({
303 var new_data = e.data.data.pageData; 346 var new_data = e.data.data.pageData;
304 var arr = new Array(); 347 var arr = new Array();
305 //--三个三个一组--- 348 //--三个三个一组---
306 - for(var i=0;i< new_data.length;i+=3){  
307 - arr.push(new_data.slice(i,i+3)); 349 + for (var i = 0; i < new_data.length; i += 3) {
  350 + arr.push(new_data.slice(i, i + 3));
308 } 351 }
309 th.setData({ 352 th.setData({
310 hotGoods: arr, 353 hotGoods: arr,
@@ -313,18 +356,22 @@ Page({ @@ -313,18 +356,22 @@ Page({
313 }) 356 })
314 //---调用信息--- 357 //---调用信息---
315 // this.requestRecommend(); 358 // this.requestRecommend();
316 - this.setData({ishow:1}); 359 + this.setData({
  360 + ishow: 1
  361 + });
317 //---先获取会员--- 362 //---先获取会员---
318 - t.getUserFir(function () { 363 + t.getUserFir(function() {
319 364
320 }); 365 });
321 var goods_list = this.selectComponent("#goods_list"); //组件的id 366 var goods_list = this.selectComponent("#goods_list"); //组件的id
322 goods_list.init(); 367 goods_list.init();
323 - setTimeout(function () { goods_list.get_list();},300) 368 + setTimeout(function() {
  369 + goods_list.get_list();
  370 + }, 300)
324 }, 371 },
325 372
326 //--判断小程序是否过期-- 373 //--判断小程序是否过期--
327 - setappdata: function (t) { 374 + setappdata: function(t) {
328 if (t.isout == 1) 375 if (t.isout == 1)
329 wx.navigateTo({ 376 wx.navigateTo({
330 url: "/pages/error/error?msg=小程序已经过期", 377 url: "/pages/error/error?msg=小程序已经过期",
@@ -335,40 +382,42 @@ Page({ @@ -335,40 +382,42 @@ Page({
335 }); 382 });
336 }, 383 },
337 //---加载更多是靠这个函数---- 384 //---加载更多是靠这个函数----
338 - onReachBottom: function () { 385 + onReachBottom: function() {
339 var goods_list = this.selectComponent("#goods_list"); //组件的id 386 var goods_list = this.selectComponent("#goods_list"); //组件的id
340 - if(goods_list) goods_list.get_list(); 387 + if (goods_list) goods_list.get_list();
341 }, 388 },
342 389
343 390
344 391
345 - onPullDownRefresh: function (e) { 392 + onPullDownRefresh: function(e) {
346 this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(), 393 this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),
347 this.requestRecommend(); 394 this.requestRecommend();
348 }, 395 },
349 - onUnload: function () { 396 + onUnload: function() {
350 this.destroyActivityTimer(); 397 this.destroyActivityTimer();
351 }, 398 },
352 - setCountTime: function (e) { 399 + setCountTime: function(e) {
353 e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({ 400 e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({
354 "sale.diffTime": e.diffTime 401 "sale.diffTime": e.diffTime
355 }), this.setData({ 402 }), this.setData({
356 "sale.good": e.flash_sale_goods[0] 403 "sale.good": e.flash_sale_goods[0]
357 }), this.destroyActivityTimer(), this.createActivityTimer(); 404 }), this.destroyActivityTimer(), this.createActivityTimer();
358 }, 405 },
359 - createActivityTimer: function () {  
360 - var e = this.data.sale, t = this;  
361 - this.data.timer = setInterval(function () {  
362 - var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime, o = i.transTime(a); 406 + createActivityTimer: function() {
  407 + var e = this.data.sale,
  408 + t = this;
  409 + this.data.timer = setInterval(function() {
  410 + var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime,
  411 + o = i.transTime(a);
363 a <= 0 ? t.requestHomePage() : t.setData({ 412 a <= 0 ? t.requestHomePage() : t.setData({
364 "sale.countTime": o 413 "sale.countTime": o
365 }); 414 });
366 }, 1e3); 415 }, 1e3);
367 }, 416 },
368 - destroyActivityTimer: function () { 417 + destroyActivityTimer: function() {
369 this.data.timer && (clearInterval(this.data.timer), this.data.timer = null); 418 this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);
370 }, 419 },
371 - onPageScroll: function (e) { 420 + onPageScroll: function(e) {
372 this.setData({ 421 this.setData({
373 scrollTop: e.scrollTop 422 scrollTop: e.scrollTop
374 }); 423 });
@@ -384,34 +433,34 @@ Page({ @@ -384,34 +433,34 @@ Page({
384 }));--*/ 433 }));--*/
385 434
386 }, 435 },
387 - jumpSearch: function () { 436 + jumpSearch: function() {
388 wx.navigateTo({ 437 wx.navigateTo({
389 url: "/pages/goods/search/search" 438 url: "/pages/goods/search/search"
390 }); 439 });
391 }, 440 },
392 - onShareAppMessage: function (e) { 441 + onShareAppMessage: function(e) {
393 return o.share; 442 return o.share;
394 }, 443 },
395 444
396 //图片失败,默认图片 445 //图片失败,默认图片
397 - bind_bnerr: function (e) { 446 + bind_bnerr: function(e) {
398 var _errImg = e.target.dataset.errorimg; 447 var _errImg = e.target.dataset.errorimg;
399 var _errObj = {}; 448 var _errObj = {};
400 - _errObj[_errImg] = this.data.url+ "/miniapp/images/del/logo.jpg"; 449 + _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg";
401 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; 450 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
402 }, 451 },
403 452
404 //图片失败,默认图片 453 //图片失败,默认图片
405 - bind_bnerr2: function (e) { 454 + bind_bnerr2: function(e) {
406 var _errImg = e.target.dataset.errorimg; 455 var _errImg = e.target.dataset.errorimg;
407 var _errurl = e.target.dataset.url; 456 var _errurl = e.target.dataset.url;
408 - var _errObj = {};  
409 - _errObj[_errImg] = "/miniapp/images/default_g_img.gif";  
410 - this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;  
411 - 457 + var _errObj = {};
  458 + _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
  459 + this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  460 +
412 }, 461 },
413 -//图片失败,默认图片  
414 - bind_bnerr3: function (e) { 462 + //图片失败,默认图片
  463 + bind_bnerr3: function(e) {
415 var _errImg = e.target.dataset.errorimg; 464 var _errImg = e.target.dataset.errorimg;
416 var _Img = e.target.dataset.img; 465 var _Img = e.target.dataset.img;
417 if (_Img != undefined) { 466 if (_Img != undefined) {
@@ -430,7 +479,7 @@ Page({ @@ -430,7 +479,7 @@ Page({
430 479
431 //----秒杀倒计时函数----- 480 //----秒杀倒计时函数-----
432 countDown() { 481 countDown() {
433 - if(!this.data.is_timer) return false; 482 + if (!this.data.is_timer) return false;
434 var th = this; 483 var th = this;
435 // 获取当前时间,同时得到活动结束时间数组 484 // 获取当前时间,同时得到活动结束时间数组
436 var newTime = ut.gettimestamp(); 485 var newTime = ut.gettimestamp();
@@ -479,7 +528,7 @@ Page({ @@ -479,7 +528,7 @@ Page({
479 528
480 //----拼单倒计时函数----- 529 //----拼单倒计时函数-----
481 countDown2() { 530 countDown2() {
482 - if(!this.data.is_timer) return false; 531 + if (!this.data.is_timer) return false;
483 532
484 var th = this; 533 var th = this;
485 // 获取当前时间,同时得到活动结束时间数组 534 // 获取当前时间,同时得到活动结束时间数组
@@ -529,122 +578,146 @@ Page({ @@ -529,122 +578,146 @@ Page({
529 setTimeout(th.countDown2, 1000); 578 setTimeout(th.countDown2, 1000);
530 }, 579 },
531 580
532 - bannerSwiperChange:function (e) {  
533 - var index=e.detail.current;  
534 - this.setData({banner_index:index}); 581 + bannerSwiperChange: function(e) {
  582 + var index = e.detail.current;
  583 + this.setData({
  584 + banner_index: index
  585 + });
535 }, 586 },
536 - flashSwiperChange:function (e) {  
537 - var index=e.detail.current;  
538 - this.setData({flash_index:index}); 587 + flashSwiperChange: function(e) {
  588 + var index = e.detail.current;
  589 + this.setData({
  590 + flash_index: index
  591 + });
539 }, 592 },
540 - ptSwiperChange:function (e) {  
541 - var index=e.detail.current;  
542 - this.setData({pt_index:index}); 593 + ptSwiperChange: function(e) {
  594 + var index = e.detail.current;
  595 + this.setData({
  596 + pt_index: index
  597 + });
543 }, 598 },
544 599
545 Interval_pt() { 600 Interval_pt() {
546 - var th=this;  
547 - this.data.pt_timer=setInterval(function () {  
548 - var item=ut.get_rand_item(th.data.pt_timer_arr);  
549 - th.setData({pt_timer_active:1,pt_timer_item:item});  
550 - setTimeout(function () {  
551 - th.setData({pt_timer_active:0});  
552 - },1500)  
553 - },4000); 601 + var th = this;
  602 + this.data.pt_timer = setInterval(function() {
  603 + var item = ut.get_rand_item(th.data.pt_timer_arr);
  604 + th.setData({
  605 + pt_timer_active: 1,
  606 + pt_timer_item: item
  607 + });
  608 + setTimeout(function() {
  609 + th.setData({
  610 + pt_timer_active: 0
  611 + });
  612 + }, 1500)
  613 + }, 4000);
554 }, 614 },
555 615
556 616
557 //---扫一扫的函数--- 617 //---扫一扫的函数---
558 - getScancode: function () { 618 + getScancode: function() {
559 var _this = this; 619 var _this = this;
560 // 允许从相机和相册扫码 620 // 允许从相机和相册扫码
561 wx.scanCode({ 621 wx.scanCode({
562 success: (res) => { 622 success: (res) => {
563 - var result = res.result;  
564 - wx.navigateTo({  
565 - url: "/pages/goods/search/search?s_key="+result,  
566 - }); 623 + var result = res.result;
  624 + wx.navigateTo({
  625 + url: "/pages/goods/search/search?s_key=" + result,
  626 + });
567 } 627 }
568 }) 628 })
569 }, 629 },
570 630
571 //跳转到分类 631 //跳转到分类
572 - go_cate:function(){ 632 + go_cate: function() {
573 getApp().goto("/pages/goods/categoryList/categoryList"); 633 getApp().goto("/pages/goods/categoryList/categoryList");
574 }, 634 },
575 635
576 - go_url:function(e){  
577 - var url=e.currentTarget.dataset.url;  
578 - getApp().goto(url); 636 + go_url: function(e) {
  637 + var url = e.currentTarget.dataset.url;
  638 + getApp().goto(url);
579 }, 639 },
580 640
581 - bind_bnerr_icon:function (e) { 641 + bind_bnerr_icon: function(e) {
582 var def = "/miniapp/images/no_cate_def.png"; 642 var def = "/miniapp/images/no_cate_def.png";
583 var _err = e.currentTarget.dataset.err; 643 var _err = e.currentTarget.dataset.err;
584 - var ob={};  
585 - ob[_err]=def; 644 + var ob = {};
  645 + ob[_err] = def;
586 this.setData(ob); 646 this.setData(ob);
587 }, 647 },
588 648
589 //跳转到分类的商品列表 649 //跳转到分类的商品列表
590 - go_cate2: function (t) { 650 + go_cate2: function(t) {
591 var cid = t.currentTarget.dataset.cid; 651 var cid = t.currentTarget.dataset.cid;
592 var pid = t.currentTarget.dataset.pid; 652 var pid = t.currentTarget.dataset.pid;
593 var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; 653 var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid;
594 - wx.navigateTo({ url: lurl });  
595 - },  
596 -  
597 - //跳转到权益  
598 - go_quanyi:function(t){  
599 - var user_info = getApp().globalData.userInfo;  
600 - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {  
601 - wx.navigateTo({ url: '/pages/getphone/getphone', })  
602 - return false;  
603 - }  
604 - getApp().goto("/pages/user/userqy/userqy");  
605 - },  
606 -  
607 - imageLoad:function (e) {  
608 - var imgwidth = e.detail.width;  
609 - var imgheight = e.detail.height;  
610 - //宽高比  
611 - var ratio = imgwidth / imgheight;  
612 - //计算的高度值  
613 - var viewHeight = 715 / ratio;  
614 - if(this.data.max_sw_height<viewHeight) this.setData({ max_sw_height:viewHeight });  
615 - }, 654 + wx.navigateTo({
  655 + url: lurl
  656 + });
  657 + },
  658 + new_nav: function() {
  659 + var th = this;
  660 + var new_nav = th.data.new_nav;
  661 + wx.navigateTo({
  662 + url: new_nav,
  663 + })
  664 + },
  665 + //跳转到权益
  666 + go_quanyi: function(t) {
  667 + var user_info = getApp().globalData.userInfo;
  668 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  669 + wx.navigateTo({
  670 + url: '/pages/getphone/getphone',
  671 + })
  672 + return false;
  673 + }
  674 + getApp().goto("/pages/user/userqy/userqy");
  675 + },
  676 +
  677 + imageLoad: function(e) {
  678 + var imgwidth = e.detail.width;
  679 + var imgheight = e.detail.height;
  680 + //宽高比
  681 + var ratio = imgwidth / imgheight;
  682 + //计算的高度值
  683 + var viewHeight = 715 / ratio;
  684 + if (this.data.max_sw_height < viewHeight) this.setData({
  685 + max_sw_height: viewHeight
  686 + });
  687 + },
616 //判断该用户是否是新会员 688 //判断该用户是否是新会员
617 - is_new: function () {  
618 - // var th = this;  
619 - // getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {  
620 - // data: {  
621 - // storeId: o.stoid,  
622 - // userId: d.user_id  
623 - // }  
624 - // }).then(res => {  
625 - // var swiperimage = th.data.swiperimage;  
626 - // swiperimage.push("/api/weshop/marketing/newpeople/act/bound/judge");  
627 - // if (res.data.code == 0) {  
628 - // th.setData({  
629 - // is_disgraceful:1  
630 - // })  
631 - // }  
632 - // })  
633 -  
634 - // getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {  
635 - // data: {  
636 - // storeId: o.stoid,  
637 - // userId: d.user_id  
638 - // }  
639 - // }).then(res => {  
640 - // var swiperimage = th.data.swiperimage;  
641 - // swiperimage.push("/miniapp/images/newpeople/newpeople.png");  
642 - // if (res.data.code == 0) {  
643 - // th.setData({  
644 - // swiperimage: swiperimage  
645 - // })  
646 - // }  
647 - // }) 689 + is_new: function() {
  690 + var th = this;
  691 +
  692 + getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {
  693 + data: {
  694 + storeId: o.stoid,
  695 + userId: d.user_id
  696 + }
  697 + }).then(res => {
  698 + var new_image = res.data.data.imageurl;
  699 + var swiperimage = th.data.swiperimage;
  700 + swiperimage.push("/miniapp/images/newpeople/newpeople.png");
  701 + if (res.data.code == 0) {
  702 + th.setData({
  703 + swiperimage: swiperimage,
  704 + new_image: new_image
  705 + })
  706 +
  707 + getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/bound/judge", {
  708 + data: {
  709 + storeId: o.stoid,
  710 + userId: d.user_id
  711 + }
  712 + }).then(res => {
  713 + if (res.data.code == 0) {
  714 + th.setData({
  715 + is_disgraceful: 1
  716 + })
  717 + }
  718 + })
  719 + }
  720 + })
648 721
649 } 722 }
650 723
pages/index/index/index.wxml
@@ -108,14 +108,13 @@ @@ -108,14 +108,13 @@
108 </view> 108 </view>
109 </view> 109 </view>
110 </view> 110 </view>
111 -  
112 <!-- 轮播 --> 111 <!-- 轮播 -->
113 <swiper class="swiper" autoplay="true" interval="5000" circular="{{true}}" indicator-dots="{{true}}" indicator-active-color="rgb(255,255,255)"> 112 <swiper class="swiper" autoplay="true" interval="5000" circular="{{true}}" indicator-dots="{{true}}" indicator-active-color="rgb(255,255,255)">
114 <!-- 跳转我的权益 --> 113 <!-- 跳转我的权益 -->
115 <block wx:for="{{swiperimage}}" wx:for-item="adver" wx:for-index="key"> 114 <block wx:for="{{swiperimage}}" wx:for-item="adver" wx:for-index="key">
116 <swiper-item> 115 <swiper-item>
117 <view class="title-img-frame"> 116 <view class="title-img-frame">
118 - <image class="xc-title-img" src="{{url+adver}}" bindtap="{{key==0?'go_quanyi':''}}"></image> 117 + <image class="xc-title-img" src="{{url+adver}}" bindtap="{{key==0?'go_quanyi':'new_nav'}}"></image>
119 </view> 118 </view>
120 </swiper-item> 119 </swiper-item>
121 </block> 120 </block>
@@ -349,7 +348,7 @@ @@ -349,7 +348,7 @@
349 <view> 348 <view>
350 <navigator url=""> 349 <navigator url="">
351 <view class="flex-level"> 350 <view class="flex-level">
352 - <image class="receive" src="{{url}}/miniapp/images/newpeople/newreceive.png"></image> 351 + <image class="receive" src="{{url}}{{new_image==''?'/miniapp/images/newpeople/newreceive.png':new_image}}"></image>
353 </view> 352 </view>
354 </navigator> 353 </navigator>
355 <view class="flex-level"> 354 <view class="flex-level">