...
|
...
|
@@ -17,8 +17,14 @@ import { |
|
|
} from '../../vendors/zanui/index';
|
|
|
import router from './router/router'
|
|
|
import {wrapperName} from './helper'
|
|
|
import { formatImageUrl } from '../../utils/util'
|
|
|
import { jumpByUrl } from '../../libs/urlRoute';
|
|
|
import {formatImageUrl} from '../../utils/util'
|
|
|
import {jumpByUrl} from '../../libs/urlRoute';
|
|
|
import {
|
|
|
yasReport,
|
|
|
YB_PAGE_OPEN_L,
|
|
|
YB_LUCK_DT_GDS_C,
|
|
|
YB_LUCK_DT_JOIN_C
|
|
|
} from '../../libs/yas';
|
|
|
|
|
|
const ACTIVITY = {
|
|
|
UNKNOWN: 0,
|
...
|
...
|
@@ -55,6 +61,7 @@ Page(Object.assign({ |
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
tabIdx: '',
|
|
|
show: false,
|
|
|
showAuth: false,
|
|
|
actPrizeId: '',
|
...
|
...
|
@@ -71,11 +78,11 @@ Page(Object.assign({ |
|
|
hasUnionID: false,
|
|
|
uid: 0,
|
|
|
isLogin: false,
|
|
|
bannerSrc:null,
|
|
|
bannerSrc: null,
|
|
|
bannerUrl: null,
|
|
|
loading: false,
|
|
|
page: 1,
|
|
|
|
|
|
codeList: [],
|
|
|
actionsheet: {
|
|
|
componentId: 'shareActionSheet',
|
|
|
show: false,
|
...
|
...
|
@@ -84,12 +91,12 @@ Page(Object.assign({ |
|
|
isNewShareStyle: true,
|
|
|
unionUserImageUrl: 'http://img12.static.yhbimg.com/sns/2018/08/02/15/029b6acc4f8bc0620ecd7ec2133fcf900c.png',
|
|
|
actions: [{
|
|
|
name: '分享给好友',
|
|
|
className: 'action-class',
|
|
|
loading: false,
|
|
|
openType: 'share',
|
|
|
image_src: '../../images/share_wechat@2x.png',
|
|
|
},
|
|
|
name: '分享给好友',
|
|
|
className: 'action-class',
|
|
|
loading: false,
|
|
|
openType: 'share',
|
|
|
image_src: '../../images/share_wechat@2x.png',
|
|
|
},
|
|
|
{
|
|
|
name: '生成海报分享',
|
|
|
className: 'action-class',
|
...
|
...
|
@@ -98,12 +105,18 @@ Page(Object.assign({ |
|
|
}
|
|
|
]
|
|
|
},
|
|
|
animation: null,
|
|
|
shareFlag: false,
|
|
|
notice: {},
|
|
|
lottery: {}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
onLoad: function (options) {
|
|
|
app = getApp();
|
|
|
wx.hideShareMenu();
|
|
|
|
|
|
this.service = new ZeroSellService();
|
|
|
this.commonService = new CommonService();
|
...
|
...
|
@@ -114,11 +127,14 @@ Page(Object.assign({ |
|
|
data.shareUid = options.shareUid;
|
|
|
}
|
|
|
|
|
|
if (options.tabIdx) {
|
|
|
data.tabIdx = options.tabIdx;
|
|
|
}
|
|
|
|
|
|
if (options.actPrizeId) {
|
|
|
data.actPrizeId = options.actPrizeId;
|
|
|
}
|
|
|
|
|
|
console.log('options=>', options);
|
|
|
|
|
|
if (options.scene && options.scene.length === 32) {
|
|
|
data.scene = options.scene;
|
...
|
...
|
@@ -128,18 +144,20 @@ Page(Object.assign({ |
|
|
|
|
|
new app.WeToast();
|
|
|
|
|
|
this._getDetailBanner()
|
|
|
this._getDetailBanner();
|
|
|
yasReport(YB_PAGE_OPEN_L);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function() {},
|
|
|
onReady: function () {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
onShow: function () {
|
|
|
wx.showLoading({
|
|
|
mask: true
|
|
|
});
|
...
|
...
|
@@ -151,7 +169,7 @@ Page(Object.assign({ |
|
|
isLogin: app.isLogin(),
|
|
|
uid
|
|
|
})
|
|
|
|
|
|
this._getMineCode();
|
|
|
this._getUser();
|
|
|
this._getGroupList();
|
|
|
|
...
|
...
|
@@ -170,33 +188,34 @@ Page(Object.assign({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function() {
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function() {
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
onPullDownRefresh: function () {
|
|
|
wx.showLoading({
|
|
|
mask: true
|
|
|
});
|
|
|
this._init().then(() => {
|
|
|
wx.stopPullDownRefresh();
|
|
|
})
|
|
|
this._getMineCode()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
onReachBottom: function () {
|
|
|
if (this.data.loading) return;
|
|
|
let page = this.data.page || 1;
|
|
|
page = page + 1;
|
...
|
...
|
@@ -208,30 +227,20 @@ Page(Object.assign({ |
|
|
},
|
|
|
|
|
|
goToGroupMiniApp(e) {
|
|
|
console.log(e);
|
|
|
console.log(e.detail);
|
|
|
yasReport(YB_LUCK_DT_GDS_C, {
|
|
|
ACTIVITY_ID: this.data.actPrizeId,
|
|
|
PRD_SKN: e.detail.product_skn,
|
|
|
TAB_ID: this.data.tabIdx
|
|
|
});
|
|
|
wx.navigateToMiniProgram({
|
|
|
appId: 'wx207f18be42db9028',
|
|
|
path: `pages/group/detail?productSkn=${e.detail.product_skn}&activityId=${e.detail.activity_id}&page_param=${e.detail.activity_id}`,
|
|
|
success(res) {
|
|
|
|
|
|
},
|
|
|
fail(error) {
|
|
|
|
|
|
}
|
|
|
path: `pages/group/detail?productSkn=${e.detail.product_skn}&activityId=${e.detail.activity_id}&page_param=${e.detail.activity_id}`
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
goLogin() {
|
|
|
const event = global.event;
|
|
|
event.emit('user-is-login', { logged: this.logged, loginSuccess: this.loginSuccess });
|
|
|
event.emit('user-is-login', {logged: this.logged, loginSuccess: this.loginSuccess});
|
|
|
},
|
|
|
|
|
|
logged() {
|
...
|
...
|
@@ -241,7 +250,38 @@ Page(Object.assign({ |
|
|
loginSuccess() {
|
|
|
|
|
|
},
|
|
|
_getMineCode() {
|
|
|
if (this.data.uid) {
|
|
|
this.service.fetchMyPrizeList({uid: this.data.uid, actPrizeId: this.data.actPrizeId}).then(res => {
|
|
|
let len = res.data.length > 3 ? 3 : res.data.length;
|
|
|
if (len) {
|
|
|
res.data.map((value) => {
|
|
|
value.user_thumb = formatImageUrl(value.user_thumb, 60, 60);
|
|
|
})
|
|
|
this.setData({
|
|
|
codeList: res.data,
|
|
|
})
|
|
|
wx.getSystemInfo({
|
|
|
success: (sys) => {
|
|
|
let animation = wx.createAnimation({
|
|
|
duration: 400 * len,
|
|
|
})
|
|
|
setTimeout(function () {
|
|
|
wx.createSelectorQuery().select('.code-list-item-container').boundingClientRect().exec((r) => {
|
|
|
animation.height(r[0].height - 65 * sys.screenWidth / 375).step();
|
|
|
this.setData({
|
|
|
animation: animation.export()
|
|
|
})
|
|
|
})
|
|
|
|
|
|
}.bind(this), 800);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
_getGroupList() {
|
|
|
this.commonService.getGroupList({
|
|
|
limit: 20,
|
...
|
...
|
@@ -307,10 +347,6 @@ Page(Object.assign({ |
|
|
|
|
|
let participantCount = r1.code === 200 ? r1.data.joinNum : 0;
|
|
|
|
|
|
// if (product.status >= ACTIVITY.END) {
|
|
|
// participantCount = product.limit;
|
|
|
// }
|
|
|
|
|
|
this.setData({
|
|
|
product: product,
|
|
|
recommends: r2.code === 200 ? r2.data : [],
|
...
|
...
|
@@ -323,7 +359,9 @@ Page(Object.assign({ |
|
|
myPrizeCount: r1.code === 200 ? r1.data.myCodeNum : 0,
|
|
|
participantCount,
|
|
|
show: true,
|
|
|
snapData
|
|
|
snapData,
|
|
|
notice: JSON.parse(product.notice || '{}'),
|
|
|
lottery: JSON.parse(product.lottery_info || '{}')
|
|
|
});
|
|
|
|
|
|
this._setActionStatus();
|
...
|
...
|
@@ -335,12 +373,6 @@ Page(Object.assign({ |
|
|
}).catch((e) => {
|
|
|
console.error(e);
|
|
|
wx.hideLoading();
|
|
|
|
|
|
// wx.showModal({
|
|
|
// title: "出错了",
|
|
|
// content: '请重新加载!',
|
|
|
// showCancel: false
|
|
|
// })
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -382,12 +414,10 @@ Page(Object.assign({ |
|
|
}
|
|
|
}
|
|
|
|
|
|
console.log('step=>', step)
|
|
|
this.setData({
|
|
|
step: step
|
|
|
});
|
|
|
},
|
|
|
|
|
|
_setActionStatus() {
|
|
|
let status = ACTION_BAR_STATUS.START;
|
|
|
let activityStatus = this.data.product.status;
|
...
|
...
|
@@ -396,7 +426,7 @@ Page(Object.assign({ |
|
|
status = ACTION_BAR_STATUS.END;
|
|
|
} else if (activityStatus === ACTIVITY.READY) {
|
|
|
status = ACTION_BAR_STATUS.READY;
|
|
|
}else if (activityStatus >= ACTIVITY.END) {
|
|
|
} else if (activityStatus >= ACTIVITY.END) {
|
|
|
if (this._isInActivity()) {
|
|
|
if (activityStatus === ACTIVITY.LUCK) {
|
|
|
status = ACTION_BAR_STATUS.LUCK;
|
...
|
...
|
@@ -428,6 +458,7 @@ Page(Object.assign({ |
|
|
mask: true
|
|
|
});
|
|
|
this._init();
|
|
|
this._getMineCode();
|
|
|
},
|
|
|
|
|
|
share(event) {
|
...
|
...
|
@@ -436,11 +467,6 @@ Page(Object.assign({ |
|
|
})
|
|
|
},
|
|
|
|
|
|
requireAuth() {
|
|
|
// this.setData({
|
|
|
// showAuth: true
|
|
|
// })
|
|
|
},
|
|
|
_jumpBanner() {
|
|
|
if (this.data.bannerUrl == null) {
|
|
|
return;
|
...
|
...
|
@@ -451,20 +477,18 @@ Page(Object.assign({ |
|
|
let commonService = this.commonService;
|
|
|
commonService.getResourceCode('ccc32dbedf164a52b4efa34383878860')
|
|
|
.then(data => {
|
|
|
// console.log(data)
|
|
|
this.setData({
|
|
|
bannerSrc: formatImageUrl(data.src, 750, 140, 2),
|
|
|
bannerUrl: data.url
|
|
|
})
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
_getUser() {
|
|
|
const userInfo = app.getUserInfo();
|
|
|
|
|
|
|
|
|
if (app.isLogin() && (!userInfo || !userInfo.nickName)) {
|
|
|
return this.service.getUserProfile({uid: app.getUid()}).then(json => {
|
|
|
if (json && json.code && json.code === 200) {
|
...
|
...
|
@@ -479,17 +503,17 @@ Page(Object.assign({ |
|
|
},
|
|
|
|
|
|
handleZanActionsheetCancel({
|
|
|
componentId
|
|
|
}) {
|
|
|
componentId
|
|
|
}) {
|
|
|
this.setData({
|
|
|
'actionsheet.show': false
|
|
|
})
|
|
|
},
|
|
|
|
|
|
handleZanActionsheetClick({
|
|
|
componentId,
|
|
|
index
|
|
|
}) {
|
|
|
componentId,
|
|
|
index
|
|
|
}) {
|
|
|
this.setData({
|
|
|
'actionsheet.show': false
|
|
|
})
|
...
|
...
|
@@ -501,40 +525,42 @@ Page(Object.assign({ |
|
|
onShareAppMessage(res) {
|
|
|
let params = {
|
|
|
TITLE: `【0元抽奖】点一下,免费拿走${this.data.product.name}`,
|
|
|
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看吧!'
|
|
|
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看1吧!'
|
|
|
};
|
|
|
|
|
|
this.setData({
|
|
|
shareFlag: true
|
|
|
})
|
|
|
setTimeout(function () {
|
|
|
this.setData({shareFlag: false});
|
|
|
}.bind(this), 600);
|
|
|
if (res.from === 'menu') {
|
|
|
// 用户点击右上角分享
|
|
|
return {
|
|
|
title: params.TITLE, // 分享标题
|
|
|
desc: params.DESC, // 分享描述
|
|
|
path: `/pages/zeroSell/detail?actPrizeId=${this.data.product.id}`,
|
|
|
imageUrl: this.data.product.cover_img,
|
|
|
success: function() {},
|
|
|
fail: function() {}
|
|
|
path: `/pages/zeroSell/detail?actPrizeId=${this.data.product.id}`
|
|
|
};
|
|
|
} else if (res.from === 'button') {
|
|
|
// 用户点击分享按钮
|
|
|
|
|
|
return {
|
|
|
title: params.TITLE, // 分享标题
|
|
|
desc: params.DESC, // 分享描述
|
|
|
path: `/pages/zeroSell/detail?actPrizeId=${this.data.product.id}&shareUid=${app.getUid()}`,
|
|
|
imageUrl: this.data.product.cover_img,
|
|
|
success: function() {},
|
|
|
fail: function() {}
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
goList() {
|
|
|
router.go('index');
|
|
|
goList(e) {
|
|
|
let tab = e.target.dataset.index
|
|
|
router.go('index', {tabIndex: tab || 0, reload: 0});
|
|
|
},
|
|
|
reportSuccess({detail}) {
|
|
|
yasReport(YB_LUCK_DT_JOIN_C, {ACTIVITY_ID: detail})
|
|
|
},
|
|
|
|
|
|
getUserInfo: function(e) {
|
|
|
getUserInfo: function (e) {
|
|
|
var that = this;
|
|
|
if (e.detail.errMsg === 'getUserInfo:ok') {
|
|
|
decodeUnionId(app.getWechatThirdSession(), e, function(response) {
|
|
|
decodeUnionId(app.getWechatThirdSession(), e, function (response) {
|
|
|
if (response.isHaveUnionID) {
|
|
|
that.setData({
|
|
|
hasUnionID: true,
|
...
|
...
|
@@ -542,31 +568,32 @@ Page(Object.assign({ |
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
openAuthorizeSettings(function(response) {
|
|
|
openAuthorizeSettings(function (response) {
|
|
|
if (response.isHaveUnionID) {
|
|
|
that.setData({
|
|
|
hasUnionID: true,
|
|
|
})
|
|
|
};
|
|
|
}
|
|
|
;
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
getPhoneNumber: function(e) {
|
|
|
getPhoneNumber: function (e) {
|
|
|
this.setData({
|
|
|
showAuth: false
|
|
|
});
|
|
|
|
|
|
var that = this;
|
|
|
if (e.detail.errMsg === 'getPhoneNumber:ok') {
|
|
|
decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', function(result) {
|
|
|
decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', function (result) {
|
|
|
// console.log('!!!!result',result)
|
|
|
if (result.code != 200) {
|
|
|
that.wetoast.toast({
|
|
|
title: result.message,
|
|
|
titleClassName: 'wetoast-title',
|
|
|
duration: 1000,
|
|
|
success: function() {
|
|
|
success: function () {
|
|
|
that.loginAndRegisterTapped()
|
|
|
}.bind(that)
|
|
|
});
|
...
|
...
|
@@ -574,7 +601,7 @@ Page(Object.assign({ |
|
|
if (result.is_register) {
|
|
|
that.showZanToast({
|
|
|
title: '欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',
|
|
|
success: function() {
|
|
|
success: function () {
|
|
|
let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
|
|
|
that.setData({
|
|
|
uid,
|
...
|
...
|
@@ -615,14 +642,12 @@ Page(Object.assign({ |
|
|
content: '检测到您未打开微信用户信息授权,开启后即可进行登录',
|
|
|
confirmText: "去开启",
|
|
|
confirmColor: "#000000",
|
|
|
success: function(res) {
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.openSetting({
|
|
|
success: (res) => {
|
|
|
// console.log(res.authSetting["scope.userInfo"])
|
|
|
if (res.authSetting["scope.userInfo"] !== null && res.authSetting["scope.userInfo"] !== undefined && res.authSetting["scope.userInfo"] === true) {
|
|
|
getUnionID(app.getWechatThirdSession(), function(response) {
|
|
|
// console.log(response)
|
|
|
getUnionID(app.getWechatThirdSession(), function (response) {
|
|
|
})
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -638,7 +663,7 @@ Page(Object.assign({ |
|
|
wx.navigateTo({
|
|
|
url: '/pages/bindPhoneNumber/bindPhoneNumber'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
} else {
|
...
|
...
|
|