...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode, getResourceCode,getHomeContentCode} from '../../utils/home';
|
|
|
import { shouldDiscardTap, getGoodDetailParam, getImageUrl, formatImageUrl,getGuangType, getYHStorageSync} from '../../utils/util';
|
|
|
import homeService from './indexService.js'
|
|
|
import { JUMP_BRAND, JUMP_DETAIL, JUMP_PRODUCTPOOL} from './indexService.js'
|
|
|
import { parseProductListData } from '../../utils/productListUtil';
|
|
|
import router from '../../router/index.js'
|
|
|
|
...
|
...
|
@@ -18,6 +19,7 @@ let CHANNEL = "gender_channel" |
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
lastTapTimeStamp: 0,
|
|
|
currentDate:null,
|
|
|
selectedChannel: 'boy',
|
|
|
homelist:[],
|
...
|
...
|
@@ -42,7 +44,7 @@ Page({ |
|
|
}
|
|
|
},
|
|
|
},
|
|
|
onLoad: function () {
|
|
|
onLoad: function (e) {
|
|
|
this.getLastChannel();
|
|
|
this.fetchNewHomeData();
|
|
|
|
...
|
...
|
@@ -62,6 +64,60 @@ Page({ |
|
|
});
|
|
|
this.showIndexDialog();
|
|
|
}
|
|
|
|
|
|
let jumpType = e.jumpType;
|
|
|
if (jumpType == JUMP_BRAND) {
|
|
|
let brandId = e.brandId;
|
|
|
let brandName = e.brandName;
|
|
|
if (brandId != '' && brandName != '')
|
|
|
tt.navigateTo({
|
|
|
url: '../goodsList/brand?brandId=' + brandId + '&brandName=' + brandName + '&page_name=' + 'home' + '&page_param=' + ''
|
|
|
});
|
|
|
} else if (jumpType == JUMP_DETAIL) {
|
|
|
let productSkn = e.productSkn;
|
|
|
if (productSkn != '') {
|
|
|
tt.navigateTo({
|
|
|
url: '../goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + 'home' + '&page_param=' + ''
|
|
|
});
|
|
|
}
|
|
|
} else if (jumpType == JUMP_PRODUCTPOOL) {
|
|
|
let productPool = e.productPool;
|
|
|
if (productPool != '') {
|
|
|
tt.navigateTo({
|
|
|
url: '../goodsList/productPool?productPool=' + productPool + '&page_name=' + 'home' + '&page_param=' + ''
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
onShareAppMessage: function (res) {
|
|
|
let param = {
|
|
|
FROM: res.from,
|
|
|
SHARE_RESUIL: 0,
|
|
|
TITLE: 'Yoho!Buy有货-潮流购物逛不停',
|
|
|
PATH: '/pages/index/index',
|
|
|
}
|
|
|
|
|
|
// 用户点击右上角分享
|
|
|
return {
|
|
|
title: param.TITLE, // 分享标题
|
|
|
desc: '精选1400+全球潮流品牌,明星潮牌和新锐原创品牌每日上新,100%正品行货。', // 分享描述
|
|
|
path: param.PATH, // 分享路径
|
|
|
success: function (res) {
|
|
|
// param.SHARE_RESUIL = 1
|
|
|
// logEvent(YB_SHARE_RESULT_L, param);
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
// param.SHARE_RESUIL = 2
|
|
|
// logEvent(YB_SHARE_RESULT_L, param);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
tt.stopPullDownRefresh();
|
|
|
this.getLastChannel();
|
|
|
this.fetchNewHomeData(true);
|
|
|
},
|
|
|
|
|
|
//获取新首页数据
|
...
|
...
|
@@ -86,10 +142,11 @@ Page({ |
|
|
// union_id: app.globalData.WXUnion_ID || this.getStorage('unionID')
|
|
|
}
|
|
|
|
|
|
let that = this;
|
|
|
homeService.getHomeFloorlist(params)
|
|
|
.then(json => {
|
|
|
|
|
|
this.setLoadingHomeData(false);
|
|
|
that.setLoadingHomeData(false);
|
|
|
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
let homeList = json.data.list;
|
...
|
...
|
@@ -102,17 +159,17 @@ Page({ |
|
|
duration: 1500
|
|
|
});
|
|
|
}
|
|
|
let newChannels = this.data.newChannels;
|
|
|
let newChannels = that.data.newChannels;
|
|
|
let currentData = newChannels[channel];
|
|
|
currentData.data = homeList;
|
|
|
newChannels[channel] = currentData;
|
|
|
|
|
|
this.setData({
|
|
|
that.setData({
|
|
|
newChannels: newChannels
|
|
|
})
|
|
|
this.setHomeList(force);
|
|
|
that.setHomeList(force);
|
|
|
} else {
|
|
|
this.setHomeList(force);
|
|
|
that.setHomeList(force);
|
|
|
tt.showToast({
|
|
|
title: json.message,
|
|
|
icon: 'none',
|
...
|
...
|
@@ -121,8 +178,8 @@ Page({ |
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
this.setLoadingHomeData(false);
|
|
|
this.setHomeList(force);
|
|
|
that.setLoadingHomeData(false);
|
|
|
that.setHomeList(force);
|
|
|
|
|
|
tt.showToast({
|
|
|
title: error.message,
|
...
|
...
|
@@ -237,27 +294,63 @@ Page({ |
|
|
* 首页资源位dialog
|
|
|
*/
|
|
|
showIndexDialog: function(){
|
|
|
// var app = getApp();
|
|
|
// let that = this;
|
|
|
// let content_code = "0ddd512196d6eb4a571dc3281e0b2692";
|
|
|
|
|
|
// let param = {
|
|
|
// content_code,
|
|
|
// }
|
|
|
// GET(API_HOST + '/operations/api/v5/resource/get', param).then(json => {
|
|
|
// // console.log(json);
|
|
|
// if (json && json.code && json.code == 200 && json.data[0] && json.data[0].data[0] && json.data[0].data[0].url){
|
|
|
// this.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
// that.setData({
|
|
|
// dialogSrc: formatImageUrl(json.data[0].data[0].src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio,2),
|
|
|
// dialogUrl: json.data[0].data[0].url,
|
|
|
// });
|
|
|
// that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
// that.dialog.showDialog();
|
|
|
// }
|
|
|
// }).catch(error => { });
|
|
|
var app = getApp();
|
|
|
let that = this;
|
|
|
homeService.getIndexDialog({})
|
|
|
.then(json => {
|
|
|
// console.log(json);
|
|
|
if (json && json.code && json.code == 200 && json.data[0] && json.data[0].data[0] && json.data[0].data[0].url){
|
|
|
that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
that.setData({
|
|
|
dialogSrc: formatImageUrl(json.data[0].data[0].src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio,2),
|
|
|
dialogUrl: json.data[0].data[0].url,
|
|
|
});
|
|
|
that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
|
|
|
that.dialog.showDialog();
|
|
|
}
|
|
|
}).catch(error => { });
|
|
|
},
|
|
|
|
|
|
/*
|
|
|
首次点击,判断是否是新人(默认是新人):
|
|
|
(1)是新人,弹框授权,跳链接 (2)不是新人,显示提示,不跳转
|
|
|
*/
|
|
|
getPhoneNumber: function (e) {
|
|
|
if (this.getStorage('newCustomer')) {
|
|
|
this.jumpByRuleEvent(e);
|
|
|
return;
|
|
|
}
|
|
|
if (e.detail.errMsg === 'getPhoneNumber:ok') {
|
|
|
decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', (result) => {
|
|
|
if (result.code === 200) { // 首次授权的新人
|
|
|
//新注册用户
|
|
|
if (result.is_register){
|
|
|
that.showZanToast({
|
|
|
title:'欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',success: function() {
|
|
|
// 新人楼层标示newCustomer
|
|
|
this.setStorage('newCustomer', true);
|
|
|
this.jumpByRuleEvent(e);
|
|
|
}},1500);
|
|
|
} else {
|
|
|
// 新人楼层标示newCustomer
|
|
|
this.setStorage('newCustomer', true);
|
|
|
this.jumpByRuleEvent(e);
|
|
|
}
|
|
|
} else { // 不是新人,提示
|
|
|
tt.showModal({
|
|
|
title: '提示',
|
|
|
content: '活动仅限新用户参加',
|
|
|
showCancel: false
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
} else { // 取消手机号授权
|
|
|
tt.navigateTo({
|
|
|
url: '../bindPhoneNumber/bindPhoneNumber',
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
//获取上次切换的频道 默认显示上次频道
|
|
|
getLastChannel: function () {
|
|
|
let lastChannel = getYHStorageSync(CHANNEL,'index');
|
...
|
...
|
@@ -333,10 +426,12 @@ Page({ |
|
|
},
|
|
|
|
|
|
jumpToYohood:function(event){
|
|
|
// 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\"}}")
|
|
|
// this.setData({
|
|
|
// channelSelect: false
|
|
|
// });
|
|
|
|
|
|
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\"}}");
|
|
|
|
|
|
this.setData({
|
|
|
channelSelect: false
|
|
|
});
|
|
|
},
|
|
|
|
|
|
//formId上报
|
...
|
...
|
@@ -371,6 +466,44 @@ Page({ |
|
|
})
|
|
|
},
|
|
|
|
|
|
scanCodeTapped() {
|
|
|
|
|
|
tt.scanCode({
|
|
|
success: (res) => {
|
|
|
let url = res.path;
|
|
|
|
|
|
if (url) {
|
|
|
url = url.indexOf('page/subPackage') !== -1 ? '/' + url : url.replace(/pages/g, "..");
|
|
|
tt.navigateTo({
|
|
|
url: url,
|
|
|
});
|
|
|
} else {
|
|
|
let hasOpenby = url.indexOf('openby:yohobuy=');
|
|
|
|
|
|
url = res.result;
|
|
|
|
|
|
if (hasOpenby < 0) {
|
|
|
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')) {
|
|
|
tt.navigateTo({
|
|
|
url: '/pages/goodsDetail/goodsDetail?q=' + url
|
|
|
});
|
|
|
} else if (url.startsWith('https://m.yohobuy.com/shop') || url.startsWith('http://m.yohobuy.com/shop')) {
|
|
|
tt.navigateTo({
|
|
|
url: '/pages/goodsList/brandStore?q=' + url
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
router.goUrl(url);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
logEvent(YB_SCAN_CODE_SUCCESS, {
|
|
|
PAGE_PATH: url,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 清除storage
|
|
|
removeStorage: function(key) {
|
|
|
try {
|
...
|
...
|
@@ -390,12 +523,6 @@ Page({ |
|
|
} catch (e) {
|
|
|
// console.error(e);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
tt.stopPullDownRefresh();
|
|
|
this.getLastChannel();
|
|
|
this.fetchNewHomeData(true);
|
|
|
},
|
|
|
}
|
|
|
|
|
|
}) |
...
|
...
|
|