...
|
...
|
@@ -17,8 +17,8 @@ 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';
|
|
|
|
|
|
const ACTIVITY = {
|
|
|
UNKNOWN: 0,
|
...
|
...
|
@@ -71,11 +71,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,
|
...
|
...
|
@@ -98,12 +98,14 @@ Page(Object.assign({ |
|
|
}
|
|
|
]
|
|
|
},
|
|
|
animation: null,
|
|
|
shareFlag:false
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
onLoad: function (options) {
|
|
|
app = getApp();
|
|
|
|
|
|
this.service = new ZeroSellService();
|
...
|
...
|
@@ -135,12 +137,13 @@ Page(Object.assign({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function() {},
|
|
|
onReady: function () {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
onShow: function () {
|
|
|
wx.showLoading({
|
|
|
mask: true
|
|
|
});
|
...
|
...
|
@@ -153,7 +156,7 @@ Page(Object.assign({ |
|
|
isLogin: app.isLogin(),
|
|
|
uid
|
|
|
})
|
|
|
|
|
|
this._getMineCode();
|
|
|
this._getUser();
|
|
|
this._getGroupList();
|
|
|
|
...
|
...
|
@@ -172,21 +175,21 @@ Page(Object.assign({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function() {
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function() {
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
onPullDownRefresh: function () {
|
|
|
wx.showLoading({
|
|
|
mask: true
|
|
|
});
|
...
|
...
|
@@ -198,7 +201,7 @@ Page(Object.assign({ |
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
onReachBottom: function () {
|
|
|
if (this.data.loading) return;
|
|
|
let page = this.data.page || 1;
|
|
|
page = page + 1;
|
...
|
...
|
@@ -227,13 +230,13 @@ Page(Object.assign({ |
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
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() {
|
...
|
...
|
@@ -243,7 +246,32 @@ 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;
|
|
|
let animation = wx.createAnimation({
|
|
|
duration: 400 * len,
|
|
|
})
|
|
|
this.setData({
|
|
|
codeList: res.data,
|
|
|
})
|
|
|
this.animation = animation
|
|
|
setTimeout(function () {
|
|
|
let query = wx.createSelectorQuery();
|
|
|
query.select('.code-list-item-container').boundingClientRect();
|
|
|
query.exec((res) => {
|
|
|
animation.height(res[0].height - 63).step();
|
|
|
this.setData({
|
|
|
animation: animation.export()
|
|
|
})
|
|
|
})
|
|
|
|
|
|
}.bind(this), 400);
|
|
|
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
_getGroupList() {
|
|
|
this.commonService.getGroupList({
|
|
|
limit: 20,
|
...
|
...
|
@@ -389,7 +417,6 @@ Page(Object.assign({ |
|
|
step: step
|
|
|
});
|
|
|
},
|
|
|
|
|
|
_setActionStatus() {
|
|
|
let status = ACTION_BAR_STATUS.START;
|
|
|
let activityStatus = this.data.product.status;
|
...
|
...
|
@@ -398,7 +425,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;
|
...
|
...
|
@@ -505,16 +532,25 @@ Page(Object.assign({ |
|
|
TITLE: `【0元抽奖】点一下,免费拿走${this.data.product.name}`,
|
|
|
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看吧!'
|
|
|
};
|
|
|
|
|
|
this.setData({
|
|
|
shareFlag: true
|
|
|
})
|
|
|
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() {}
|
|
|
success: ()=> {
|
|
|
this.setData({
|
|
|
shareFlag: false
|
|
|
})
|
|
|
},
|
|
|
fail: ()=> {
|
|
|
this.setData({
|
|
|
shareFlag: false
|
|
|
})
|
|
|
}
|
|
|
};
|
|
|
} else if (res.from === 'button') {
|
|
|
// 用户点击分享按钮
|
...
|
...
|
@@ -523,9 +559,16 @@ Page(Object.assign({ |
|
|
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() {}
|
|
|
success: ()=> {
|
|
|
this.setData({
|
|
|
shareFlag: false
|
|
|
})
|
|
|
},
|
|
|
fail: ()=> {
|
|
|
this.setData({
|
|
|
shareFlag: false
|
|
|
})
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -533,10 +576,10 @@ Page(Object.assign({ |
|
|
router.go('index');
|
|
|
},
|
|
|
|
|
|
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,
|
...
|
...
|
@@ -544,31 +587,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)
|
|
|
});
|
...
|
...
|
@@ -576,7 +620,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,
|
...
|
...
|
@@ -617,13 +661,13 @@ 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) {
|
|
|
getUnionID(app.getWechatThirdSession(), function (response) {
|
|
|
// console.log(response)
|
|
|
})
|
|
|
}
|
...
|
...
|
|