|
@@ -2,6 +2,7 @@ |
|
@@ -2,6 +2,7 @@ |
2
|
import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode, getResourceCode,getHomeContentCode} from '../../utils/home';
|
2
|
import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode, getResourceCode,getHomeContentCode} from '../../utils/home';
|
3
|
import { shouldDiscardTap, getGoodDetailParam, getImageUrl, formatImageUrl,getGuangType, getYHStorageSync} from '../../utils/util';
|
3
|
import { shouldDiscardTap, getGoodDetailParam, getImageUrl, formatImageUrl,getGuangType, getYHStorageSync} from '../../utils/util';
|
4
|
import homeService from './indexService.js'
|
4
|
import homeService from './indexService.js'
|
|
|
5
|
+import { JUMP_BRAND, JUMP_DETAIL, JUMP_PRODUCTPOOL} from './indexService.js'
|
5
|
import { parseProductListData } from '../../utils/productListUtil';
|
6
|
import { parseProductListData } from '../../utils/productListUtil';
|
6
|
import router from '../../router/index.js'
|
7
|
import router from '../../router/index.js'
|
7
|
|
8
|
|
|
@@ -18,6 +19,7 @@ let CHANNEL = "gender_channel" |
|
@@ -18,6 +19,7 @@ let CHANNEL = "gender_channel" |
18
|
|
19
|
|
19
|
Page({
|
20
|
Page({
|
20
|
data: {
|
21
|
data: {
|
|
|
22
|
+ lastTapTimeStamp: 0,
|
21
|
currentDate:null,
|
23
|
currentDate:null,
|
22
|
selectedChannel: 'boy',
|
24
|
selectedChannel: 'boy',
|
23
|
homelist:[],
|
25
|
homelist:[],
|
|
@@ -42,7 +44,7 @@ Page({ |
|
@@ -42,7 +44,7 @@ Page({ |
42
|
}
|
44
|
}
|
43
|
},
|
45
|
},
|
44
|
},
|
46
|
},
|
45
|
- onLoad: function () {
|
47
|
+ onLoad: function (e) {
|
46
|
this.getLastChannel();
|
48
|
this.getLastChannel();
|
47
|
this.fetchNewHomeData();
|
49
|
this.fetchNewHomeData();
|
48
|
|
50
|
|
|
@@ -62,6 +64,60 @@ Page({ |
|
@@ -62,6 +64,60 @@ Page({ |
62
|
});
|
64
|
});
|
63
|
this.showIndexDialog();
|
65
|
this.showIndexDialog();
|
64
|
}
|
66
|
}
|
|
|
67
|
+
|
|
|
68
|
+ let jumpType = e.jumpType;
|
|
|
69
|
+ if (jumpType == JUMP_BRAND) {
|
|
|
70
|
+ let brandId = e.brandId;
|
|
|
71
|
+ let brandName = e.brandName;
|
|
|
72
|
+ if (brandId != '' && brandName != '')
|
|
|
73
|
+ tt.navigateTo({
|
|
|
74
|
+ url: '../goodsList/brand?brandId=' + brandId + '&brandName=' + brandName + '&page_name=' + 'home' + '&page_param=' + ''
|
|
|
75
|
+ });
|
|
|
76
|
+ } else if (jumpType == JUMP_DETAIL) {
|
|
|
77
|
+ let productSkn = e.productSkn;
|
|
|
78
|
+ if (productSkn != '') {
|
|
|
79
|
+ tt.navigateTo({
|
|
|
80
|
+ url: '../goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + 'home' + '&page_param=' + ''
|
|
|
81
|
+ });
|
|
|
82
|
+ }
|
|
|
83
|
+ } else if (jumpType == JUMP_PRODUCTPOOL) {
|
|
|
84
|
+ let productPool = e.productPool;
|
|
|
85
|
+ if (productPool != '') {
|
|
|
86
|
+ tt.navigateTo({
|
|
|
87
|
+ url: '../goodsList/productPool?productPool=' + productPool + '&page_name=' + 'home' + '&page_param=' + ''
|
|
|
88
|
+ });
|
|
|
89
|
+ }
|
|
|
90
|
+ }
|
|
|
91
|
+ },
|
|
|
92
|
+
|
|
|
93
|
+ onShareAppMessage: function (res) {
|
|
|
94
|
+ let param = {
|
|
|
95
|
+ FROM: res.from,
|
|
|
96
|
+ SHARE_RESUIL: 0,
|
|
|
97
|
+ TITLE: 'Yoho!Buy有货-潮流购物逛不停',
|
|
|
98
|
+ PATH: '/pages/index/index',
|
|
|
99
|
+ }
|
|
|
100
|
+
|
|
|
101
|
+ // 用户点击右上角分享
|
|
|
102
|
+ return {
|
|
|
103
|
+ title: param.TITLE, // 分享标题
|
|
|
104
|
+ desc: '精选1400+全球潮流品牌,明星潮牌和新锐原创品牌每日上新,100%正品行货。', // 分享描述
|
|
|
105
|
+ path: param.PATH, // 分享路径
|
|
|
106
|
+ success: function (res) {
|
|
|
107
|
+ // param.SHARE_RESUIL = 1
|
|
|
108
|
+ // logEvent(YB_SHARE_RESULT_L, param);
|
|
|
109
|
+ },
|
|
|
110
|
+ fail: function (res) {
|
|
|
111
|
+ // param.SHARE_RESUIL = 2
|
|
|
112
|
+ // logEvent(YB_SHARE_RESULT_L, param);
|
|
|
113
|
+ }
|
|
|
114
|
+ }
|
|
|
115
|
+ },
|
|
|
116
|
+
|
|
|
117
|
+ onPullDownRefresh: function () {
|
|
|
118
|
+ tt.stopPullDownRefresh();
|
|
|
119
|
+ this.getLastChannel();
|
|
|
120
|
+ this.fetchNewHomeData(true);
|
65
|
},
|
121
|
},
|
66
|
|
122
|
|
67
|
//获取新首页数据
|
123
|
//获取新首页数据
|
|
@@ -86,10 +142,11 @@ Page({ |
|
@@ -86,10 +142,11 @@ Page({ |
86
|
// union_id: app.globalData.WXUnion_ID || this.getStorage('unionID')
|
142
|
// union_id: app.globalData.WXUnion_ID || this.getStorage('unionID')
|
87
|
}
|
143
|
}
|
88
|
|
144
|
|
|
|
145
|
+ let that = this;
|
89
|
homeService.getHomeFloorlist(params)
|
146
|
homeService.getHomeFloorlist(params)
|
90
|
.then(json => {
|
147
|
.then(json => {
|
91
|
|
148
|
|
92
|
- this.setLoadingHomeData(false);
|
149
|
+ that.setLoadingHomeData(false);
|
93
|
|
150
|
|
94
|
if (json && json.code && json.code == 200) {
|
151
|
if (json && json.code && json.code == 200) {
|
95
|
let homeList = json.data.list;
|
152
|
let homeList = json.data.list;
|
|
@@ -102,17 +159,17 @@ Page({ |
|
@@ -102,17 +159,17 @@ Page({ |
102
|
duration: 1500
|
159
|
duration: 1500
|
103
|
});
|
160
|
});
|
104
|
}
|
161
|
}
|
105
|
- let newChannels = this.data.newChannels;
|
162
|
+ let newChannels = that.data.newChannels;
|
106
|
let currentData = newChannels[channel];
|
163
|
let currentData = newChannels[channel];
|
107
|
currentData.data = homeList;
|
164
|
currentData.data = homeList;
|
108
|
newChannels[channel] = currentData;
|
165
|
newChannels[channel] = currentData;
|
109
|
|
166
|
|
110
|
- this.setData({
|
167
|
+ that.setData({
|
111
|
newChannels: newChannels
|
168
|
newChannels: newChannels
|
112
|
})
|
169
|
})
|
113
|
- this.setHomeList(force);
|
170
|
+ that.setHomeList(force);
|
114
|
} else {
|
171
|
} else {
|
115
|
- this.setHomeList(force);
|
172
|
+ that.setHomeList(force);
|
116
|
tt.showToast({
|
173
|
tt.showToast({
|
117
|
title: json.message,
|
174
|
title: json.message,
|
118
|
icon: 'none',
|
175
|
icon: 'none',
|
|
@@ -121,8 +178,8 @@ Page({ |
|
@@ -121,8 +178,8 @@ Page({ |
121
|
}
|
178
|
}
|
122
|
})
|
179
|
})
|
123
|
.catch(error => {
|
180
|
.catch(error => {
|
124
|
- this.setLoadingHomeData(false);
|
|
|
125
|
- this.setHomeList(force);
|
181
|
+ that.setLoadingHomeData(false);
|
|
|
182
|
+ that.setHomeList(force);
|
126
|
|
183
|
|
127
|
tt.showToast({
|
184
|
tt.showToast({
|
128
|
title: error.message,
|
185
|
title: error.message,
|
|
@@ -237,27 +294,63 @@ Page({ |
|
@@ -237,27 +294,63 @@ Page({ |
237
|
* 首页资源位dialog
|
294
|
* 首页资源位dialog
|
238
|
*/
|
295
|
*/
|
239
|
showIndexDialog: function(){
|
296
|
showIndexDialog: function(){
|
240
|
- // var app = getApp();
|
|
|
241
|
- // let that = this;
|
|
|
242
|
- // let content_code = "0ddd512196d6eb4a571dc3281e0b2692";
|
|
|
243
|
-
|
|
|
244
|
- // let param = {
|
|
|
245
|
- // content_code,
|
|
|
246
|
- // }
|
|
|
247
|
- // GET(API_HOST + '/operations/api/v5/resource/get', param).then(json => {
|
|
|
248
|
- // // console.log(json);
|
|
|
249
|
- // if (json && json.code && json.code == 200 && json.data[0] && json.data[0].data[0] && json.data[0].data[0].url){
|
|
|
250
|
- // this.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
251
|
- // that.setData({
|
|
|
252
|
- // dialogSrc: formatImageUrl(json.data[0].data[0].src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio,2),
|
|
|
253
|
- // dialogUrl: json.data[0].data[0].url,
|
|
|
254
|
- // });
|
|
|
255
|
- // that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
256
|
- // that.dialog.showDialog();
|
|
|
257
|
- // }
|
|
|
258
|
- // }).catch(error => { });
|
297
|
+ var app = getApp();
|
|
|
298
|
+ let that = this;
|
|
|
299
|
+ homeService.getIndexDialog({})
|
|
|
300
|
+ .then(json => {
|
|
|
301
|
+ // console.log(json);
|
|
|
302
|
+ if (json && json.code && json.code == 200 && json.data[0] && json.data[0].data[0] && json.data[0].data[0].url){
|
|
|
303
|
+ that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
304
|
+ that.setData({
|
|
|
305
|
+ dialogSrc: formatImageUrl(json.data[0].data[0].src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio,2),
|
|
|
306
|
+ dialogUrl: json.data[0].data[0].url,
|
|
|
307
|
+ });
|
|
|
308
|
+ that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
309
|
+ that.dialog.showDialog();
|
|
|
310
|
+ }
|
|
|
311
|
+ }).catch(error => { });
|
259
|
},
|
312
|
},
|
260
|
|
313
|
|
|
|
314
|
+ /*
|
|
|
315
|
+ 首次点击,判断是否是新人(默认是新人):
|
|
|
316
|
+ (1)是新人,弹框授权,跳链接 (2)不是新人,显示提示,不跳转
|
|
|
317
|
+ */
|
|
|
318
|
+ getPhoneNumber: function (e) {
|
|
|
319
|
+ if (this.getStorage('newCustomer')) {
|
|
|
320
|
+ this.jumpByRuleEvent(e);
|
|
|
321
|
+ return;
|
|
|
322
|
+ }
|
|
|
323
|
+ if (e.detail.errMsg === 'getPhoneNumber:ok') {
|
|
|
324
|
+ decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', (result) => {
|
|
|
325
|
+ if (result.code === 200) { // 首次授权的新人
|
|
|
326
|
+ //新注册用户
|
|
|
327
|
+ if (result.is_register){
|
|
|
328
|
+ that.showZanToast({
|
|
|
329
|
+ title:'欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',success: function() {
|
|
|
330
|
+ // 新人楼层标示newCustomer
|
|
|
331
|
+ this.setStorage('newCustomer', true);
|
|
|
332
|
+ this.jumpByRuleEvent(e);
|
|
|
333
|
+ }},1500);
|
|
|
334
|
+ } else {
|
|
|
335
|
+ // 新人楼层标示newCustomer
|
|
|
336
|
+ this.setStorage('newCustomer', true);
|
|
|
337
|
+ this.jumpByRuleEvent(e);
|
|
|
338
|
+ }
|
|
|
339
|
+ } else { // 不是新人,提示
|
|
|
340
|
+ tt.showModal({
|
|
|
341
|
+ title: '提示',
|
|
|
342
|
+ content: '活动仅限新用户参加',
|
|
|
343
|
+ showCancel: false
|
|
|
344
|
+ });
|
|
|
345
|
+ }
|
|
|
346
|
+ })
|
|
|
347
|
+ } else { // 取消手机号授权
|
|
|
348
|
+ tt.navigateTo({
|
|
|
349
|
+ url: '../bindPhoneNumber/bindPhoneNumber',
|
|
|
350
|
+ })
|
|
|
351
|
+ }
|
|
|
352
|
+},
|
|
|
353
|
+
|
261
|
//获取上次切换的频道 默认显示上次频道
|
354
|
//获取上次切换的频道 默认显示上次频道
|
262
|
getLastChannel: function () {
|
355
|
getLastChannel: function () {
|
263
|
let lastChannel = getYHStorageSync(CHANNEL,'index');
|
356
|
let lastChannel = getYHStorageSync(CHANNEL,'index');
|
|
@@ -333,10 +426,12 @@ Page({ |
|
@@ -333,10 +426,12 @@ Page({ |
333
|
},
|
426
|
},
|
334
|
|
427
|
|
335
|
jumpToYohood:function(event){
|
428
|
jumpToYohood:function(event){
|
336
|
- // jumpByUrl("https://ad.yoho.cn/html5/2018/yohood/index.html?share_id=5381&title=YOHOOD2018&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"title\":\"YOHOOD2018\",\"share_id\":5381,\"url\":\"https://ad.yoho.cn/html5/2018/yohood/index.html?share_id=5381&title=YOHOOD2018\"}}")
|
|
|
337
|
- // this.setData({
|
|
|
338
|
- // channelSelect: false
|
|
|
339
|
- // });
|
429
|
+
|
|
|
430
|
+ router.goUrl("https://ad.yoho.cn/html5/2018/yohood/index.html?share_id=5381&title=YOHOOD2018&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"title\":\"YOHOOD2018\",\"share_id\":5381,\"url\":\"https://ad.yoho.cn/html5/2018/yohood/index.html?share_id=5381&title=YOHOOD2018\"}}");
|
|
|
431
|
+
|
|
|
432
|
+ this.setData({
|
|
|
433
|
+ channelSelect: false
|
|
|
434
|
+ });
|
340
|
},
|
435
|
},
|
341
|
|
436
|
|
342
|
//formId上报
|
437
|
//formId上报
|
|
@@ -371,6 +466,44 @@ Page({ |
|
@@ -371,6 +466,44 @@ Page({ |
371
|
})
|
466
|
})
|
372
|
},
|
467
|
},
|
373
|
|
468
|
|
|
|
469
|
+ scanCodeTapped() {
|
|
|
470
|
+
|
|
|
471
|
+ tt.scanCode({
|
|
|
472
|
+ success: (res) => {
|
|
|
473
|
+ let url = res.path;
|
|
|
474
|
+
|
|
|
475
|
+ if (url) {
|
|
|
476
|
+ url = url.indexOf('page/subPackage') !== -1 ? '/' + url : url.replace(/pages/g, "..");
|
|
|
477
|
+ tt.navigateTo({
|
|
|
478
|
+ url: url,
|
|
|
479
|
+ });
|
|
|
480
|
+ } else {
|
|
|
481
|
+ let hasOpenby = url.indexOf('openby:yohobuy=');
|
|
|
482
|
+
|
|
|
483
|
+ url = res.result;
|
|
|
484
|
+
|
|
|
485
|
+ if (hasOpenby < 0) {
|
|
|
486
|
+ if (url.startsWith('https://m.yohobuy.com/product') || url.startsWith('http://m.yohobuy.com/product') || url.startsWith('https://o.yohobuy.com/mp') || url.startsWith('https://o.yohobuy.com/mp')) {
|
|
|
487
|
+ tt.navigateTo({
|
|
|
488
|
+ url: '/pages/goodsDetail/goodsDetail?q=' + url
|
|
|
489
|
+ });
|
|
|
490
|
+ } else if (url.startsWith('https://m.yohobuy.com/shop') || url.startsWith('http://m.yohobuy.com/shop')) {
|
|
|
491
|
+ tt.navigateTo({
|
|
|
492
|
+ url: '/pages/goodsList/brandStore?q=' + url
|
|
|
493
|
+ });
|
|
|
494
|
+ }
|
|
|
495
|
+ } else {
|
|
|
496
|
+ router.goUrl(url);
|
|
|
497
|
+ }
|
|
|
498
|
+ }
|
|
|
499
|
+
|
|
|
500
|
+ logEvent(YB_SCAN_CODE_SUCCESS, {
|
|
|
501
|
+ PAGE_PATH: url,
|
|
|
502
|
+ });
|
|
|
503
|
+ }
|
|
|
504
|
+ })
|
|
|
505
|
+ },
|
|
|
506
|
+
|
374
|
// 清除storage
|
507
|
// 清除storage
|
375
|
removeStorage: function(key) {
|
508
|
removeStorage: function(key) {
|
376
|
try {
|
509
|
try {
|
|
@@ -390,12 +523,6 @@ Page({ |
|
@@ -390,12 +523,6 @@ Page({ |
390
|
} catch (e) {
|
523
|
} catch (e) {
|
391
|
// console.error(e);
|
524
|
// console.error(e);
|
392
|
}
|
525
|
}
|
393
|
- },
|
|
|
394
|
-
|
|
|
395
|
- onPullDownRefresh: function () {
|
|
|
396
|
- tt.stopPullDownRefresh();
|
|
|
397
|
- this.getLastChannel();
|
|
|
398
|
- this.fetchNewHomeData(true);
|
|
|
399
|
- },
|
526
|
+ }
|
400
|
|
527
|
|
401
|
}) |
528
|
}) |