Commit d6bcc83d004cd6e5dc5c516684a176933c129f4a

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

首页新人有礼判断显示

pages/index/index/index.js
1   -var e = function (e) {
  1 +var e = function(e) {
2 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 14 var regeneratorRuntime = require('../../../utils/runtime.js');
8 15 var api = require('../../../api/api.js');
9 16 var d = getApp().globalData;
10   -
  17 +
11 18 Page({
12 19 data: {
13 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 22 resourceUrl: o.resourceUrl,
16 23 logo: o.appLogo,
17 24 homeData: null,
... ... @@ -32,69 +39,74 @@ Page({
32 39 banner: null,
33 40  
34 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 73 var th = this;
65 74 // n.init(th, "", "recommend");
66 75  
67 76 //看一下商家是否开通了权益
68 77 //--初始化是否有打勾--
69 78 getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
70   - data: { storeId: os.stoid }
  79 + data: {
  80 + storeId: os.stoid
  81 + }
71 82 }).then(res => {
72 83 if (res.data.data) {
73 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 90 th.is_new();
78 91  
79 92 },
80 93 //关闭新用户领取广告
81   - close_disgraceful:function(){
  94 + close_disgraceful: function() {
82 95 var th = this;
83   - th.setData({
84   - is_disgraceful:0
85   - })
  96 + th.setData({
  97 + is_disgraceful: 0
  98 + })
86 99 },
87 100 async onShow() {
88 101 var th = this;
89   - if(getApp().globalData.user_id) getApp().requestCardNum();
  102 + if (getApp().globalData.user_id) getApp().requestCardNum();
90 103 await this.init_load();
91 104 //显示的时候要开启计时器
92 105 this.data.is_timer = 1;
93 106 //如果是自定义模板
94 107 if (this.data.isTemplate) {
95 108 //---先获取会员---
96   - t.getUserFir(function () {
97   - });
  109 + t.getUserFir(function() {});
98 110 } else {
99 111 await this.init_fir();
100 112 }
... ... @@ -109,7 +121,9 @@ Page({
109 121 if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {
110 122 for (var i in th.data.pt_timer_arr) {
111 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 127 th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;
114 128 th.data.pt_timer_arr[i].nickname = res.data.data.nickname;
115 129 })
... ... @@ -119,51 +133,61 @@ Page({
119 133  
120 134 //---处理正在6个分类----
121 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 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 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 196 //----广告----
173 197 var e = this;
174 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 203 var a = res.data.data;
178 204 var arr = new Array();
179 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 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 216 wx.stopPullDownRefresh();
186 217 })
187 218  
... ... @@ -202,20 +233,20 @@ Page({
202 233 flash_data = e.data.data.pageData;
203 234 if (flash_data == null || flash_data.length <= 0) return false;
204 235  
205   -
  236 +
206 237 //当前时间戳
207 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 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 251 th.setData({
221 252 saleGoods: arr
... ... @@ -236,35 +267,35 @@ Page({
236 267 var e = res;
237 268 if (e.data.code == 0) {
238 269 var pd_data = e.data.data.pageData;
239   -
  270 +
240 271 if (pd_data.length == 0) return;
241   -
  272 +
242 273 //获取当前
243 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 282 var timestamp = new Date().getTime();
252 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 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 287 var is_team_tepy;
257 288 pd_data[j].is_team_tepy = 0;
258   - }
  289 + }
259 290 }
260   -
  291 +
261 292 var arr = new Array();
262 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 299 th.setData({
269 300 pindGoods: arr
270 301 });
... ... @@ -275,7 +306,13 @@ Page({
275 306 //------新品-------
276 307 await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
277 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 317 }).then(res => {
281 318 var e = res;
... ... @@ -283,8 +320,8 @@ Page({
283 320 var new_data = e.data.data.pageData;
284 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 326 th.setData({
290 327 newGoods: arr,
... ... @@ -295,7 +332,13 @@ Page({
295 332 //------热卖-------
296 333 await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
297 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 343 }).then(res => {
301 344 var e = res;
... ... @@ -303,8 +346,8 @@ Page({
303 346 var new_data = e.data.data.pageData;
304 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 352 th.setData({
310 353 hotGoods: arr,
... ... @@ -313,18 +356,22 @@ Page({
313 356 })
314 357 //---调用信息---
315 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 366 var goods_list = this.selectComponent("#goods_list"); //组件的id
322 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 375 if (t.isout == 1)
329 376 wx.navigateTo({
330 377 url: "/pages/error/error?msg=小程序已经过期",
... ... @@ -335,40 +382,42 @@ Page({
335 382 });
336 383 },
337 384 //---加载更多是靠这个函数----
338   - onReachBottom: function () {
  385 + onReachBottom: function() {
339 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 393 this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),
347 394 this.requestRecommend();
348 395 },
349   - onUnload: function () {
  396 + onUnload: function() {
350 397 this.destroyActivityTimer();
351 398 },
352   - setCountTime: function (e) {
  399 + setCountTime: function(e) {
353 400 e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({
354 401 "sale.diffTime": e.diffTime
355 402 }), this.setData({
356 403 "sale.good": e.flash_sale_goods[0]
357 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 412 a <= 0 ? t.requestHomePage() : t.setData({
364 413 "sale.countTime": o
365 414 });
366 415 }, 1e3);
367 416 },
368   - destroyActivityTimer: function () {
  417 + destroyActivityTimer: function() {
369 418 this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);
370 419 },
371   - onPageScroll: function (e) {
  420 + onPageScroll: function(e) {
372 421 this.setData({
373 422 scrollTop: e.scrollTop
374 423 });
... ... @@ -384,34 +433,34 @@ Page({
384 433 }));--*/
385 434  
386 435 },
387   - jumpSearch: function () {
  436 + jumpSearch: function() {
388 437 wx.navigateTo({
389 438 url: "/pages/goods/search/search"
390 439 });
391 440 },
392   - onShareAppMessage: function (e) {
  441 + onShareAppMessage: function(e) {
393 442 return o.share;
394 443 },
395 444  
396 445 //图片失败,默认图片
397   - bind_bnerr: function (e) {
  446 + bind_bnerr: function(e) {
398 447 var _errImg = e.target.dataset.errorimg;
399 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 450 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
402 451 },
403 452  
404 453 //图片失败,默认图片
405   - bind_bnerr2: function (e) {
  454 + bind_bnerr2: function(e) {
406 455 var _errImg = e.target.dataset.errorimg;
407 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 464 var _errImg = e.target.dataset.errorimg;
416 465 var _Img = e.target.dataset.img;
417 466 if (_Img != undefined) {
... ... @@ -430,7 +479,7 @@ Page({
430 479  
431 480 //----秒杀倒计时函数-----
432 481 countDown() {
433   - if(!this.data.is_timer) return false;
  482 + if (!this.data.is_timer) return false;
434 483 var th = this;
435 484 // 获取当前时间,同时得到活动结束时间数组
436 485 var newTime = ut.gettimestamp();
... ... @@ -479,7 +528,7 @@ Page({
479 528  
480 529 //----拼单倒计时函数-----
481 530 countDown2() {
482   - if(!this.data.is_timer) return false;
  531 + if (!this.data.is_timer) return false;
483 532  
484 533 var th = this;
485 534 // 获取当前时间,同时得到活动结束时间数组
... ... @@ -529,122 +578,146 @@ Page({
529 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 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 619 var _this = this;
560 620 // 允许从相机和相册扫码
561 621 wx.scanCode({
562 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 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 642 var def = "/miniapp/images/no_cate_def.png";
583 643 var _err = e.currentTarget.dataset.err;
584   - var ob={};
585   - ob[_err]=def;
  644 + var ob = {};
  645 + ob[_err] = def;
586 646 this.setData(ob);
587 647 },
588 648  
589 649 //跳转到分类的商品列表
590   - go_cate2: function (t) {
  650 + go_cate2: function(t) {
591 651 var cid = t.currentTarget.dataset.cid;
592 652 var pid = t.currentTarget.dataset.pid;
593 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 108 </view>
109 109 </view>
110 110 </view>
111   -
112 111 <!-- 轮播 -->
113 112 <swiper class="swiper" autoplay="true" interval="5000" circular="{{true}}" indicator-dots="{{true}}" indicator-active-color="rgb(255,255,255)">
114 113 <!-- 跳转我的权益 -->
115 114 <block wx:for="{{swiperimage}}" wx:for-item="adver" wx:for-index="key">
116 115 <swiper-item>
117 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 118 </view>
120 119 </swiper-item>
121 120 </block>
... ... @@ -349,7 +348,7 @@
349 348 <view>
350 349 <navigator url="">
351 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 352 </view>
354 353 </navigator>
355 354 <view class="flex-level">
... ...