|
|
// page/subPackage/pages/zeroSell/detail.js
|
|
|
|
|
|
import ZeroSellService from './service/zero-sell'
|
|
|
import CommonService from './service/common'
|
|
|
import {
|
...
|
...
|
@@ -31,18 +29,10 @@ const ACTIVITY = { |
|
|
READY: 1, // 活动未开始
|
|
|
START: 2, // 活动开始
|
|
|
END: 3, // 活动结束
|
|
|
LUCK: 4, // 抽奖结束
|
|
|
LUCK: 4, // 活动已开奖、抽奖结束
|
|
|
END_LESS_PEOPLE: 5 // 人数不足
|
|
|
}
|
|
|
|
|
|
const STEP = {
|
|
|
ZERO: 0,
|
|
|
FIRST: 1,
|
|
|
SECOND: 2,
|
|
|
THIRD: 3,
|
|
|
FOURTH: 4,
|
|
|
}
|
|
|
|
|
|
const ACTION_BAR_STATUS = {
|
|
|
UNKNOWN: 0,
|
|
|
READY: 1, // 未开始
|
...
|
...
|
@@ -51,6 +41,7 @@ const ACTION_BAR_STATUS = { |
|
|
WAIT: 4, // 等待抽奖中
|
|
|
LUCK: 5, // 抽奖结束
|
|
|
END: 6, // 活动结束
|
|
|
PEOPLE_LIMIT_WAIT: 7 // 人数达到活动限制、已满员、人数不足统一为待开奖状态
|
|
|
}
|
|
|
|
|
|
let app = getApp();
|
...
|
...
|
@@ -66,12 +57,10 @@ Page(Object.assign({ |
|
|
actPrizeId: '',
|
|
|
shareUid: 0,
|
|
|
scene: '',
|
|
|
participantCount: 0,
|
|
|
myPrizeCount: 0,
|
|
|
product: {},
|
|
|
avatars: [],
|
|
|
recommends: [],
|
|
|
step: STEP.ZERO,
|
|
|
actionStatus: ACTION_BAR_STATUS.UNKNOWN,
|
|
|
snapData: {},
|
|
|
hasUnionID: false,
|
...
|
...
|
@@ -346,8 +335,6 @@ Page(Object.assign({ |
|
|
product_qrCode: qrcode
|
|
|
};
|
|
|
|
|
|
let participantCount = r1.code === 200 ? r1.data.joinNum : 0;
|
|
|
|
|
|
this.setData({
|
|
|
product: product,
|
|
|
recommends: r2.code === 200 ? r2.data : [],
|
...
|
...
|
@@ -358,14 +345,12 @@ Page(Object.assign({ |
|
|
}),
|
|
|
|
|
|
myPrizeCount: r1.code === 200 ? r1.data.myCodeNum : 0,
|
|
|
participantCount,
|
|
|
snapData,
|
|
|
notice: JSON.parse(product.notice || '{}'),
|
|
|
lottery: JSON.parse(product.lottery_info || '{}')
|
|
|
});
|
|
|
|
|
|
this._setActionStatus();
|
|
|
this._setStep();
|
|
|
} else {
|
|
|
return Promise.reject();
|
|
|
}
|
...
|
...
|
@@ -383,40 +368,6 @@ Page(Object.assign({ |
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
_setStep() {
|
|
|
let step = STEP.ZERO;
|
|
|
let activityStatus = this.data.product.status;
|
|
|
let myPrizeCount = this.data.myPrizeCount;
|
|
|
|
|
|
if (myPrizeCount === 0) {
|
|
|
step = STEP.ZERO
|
|
|
} else {
|
|
|
if (activityStatus === ACTIVITY.START) {
|
|
|
let myPrizeCount = this.data.myPrizeCount;
|
|
|
|
|
|
if (myPrizeCount === 0) {
|
|
|
step = STEP.ZERO;
|
|
|
} else if (myPrizeCount === 1) {
|
|
|
step = STEP.FIRST;
|
|
|
} else if (myPrizeCount >= 2) {
|
|
|
step = STEP.SECOND;
|
|
|
} else {
|
|
|
step = STEP.ZERO;
|
|
|
}
|
|
|
} else if (activityStatus === ACTIVITY.END || activityStatus === ACTIVITY.LUCK) {
|
|
|
step = STEP.THIRD;
|
|
|
} else if (activityStatus === ACTIVITY.END_LESS_PEOPLE) {
|
|
|
step = STEP.FOURTH;
|
|
|
} else {
|
|
|
step = STEP.ZERO;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
step: step
|
|
|
});
|
|
|
},
|
|
|
_setActionStatus() {
|
|
|
let status = ACTION_BAR_STATUS.START;
|
|
|
let activityStatus = this.data.product.status;
|
...
|
...
|
@@ -425,15 +376,25 @@ 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;
|
|
|
} else {
|
|
|
}
|
|
|
else if (activityStatus === ACTIVITY.END_LESS_PEOPLE || activityStatus === ACTIVITY.END) {
|
|
|
status = ACTION_BAR_STATUS.WAIT;
|
|
|
}
|
|
|
else {
|
|
|
status = ACTION_BAR_STATUS.WAIT;
|
|
|
}
|
|
|
} else {
|
|
|
status = ACTION_BAR_STATUS.END;
|
|
|
if (activityStatus === ACTIVITY.END_LESS_PEOPLE || activityStatus === ACTIVITY.END) {
|
|
|
status = ACTION_BAR_STATUS.PEOPLE_LIMIT_WAIT;
|
|
|
} else {
|
|
|
status = ACTION_BAR_STATUS.END;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
if (this._isInActivity()) {
|
...
|
...
|
@@ -586,7 +547,6 @@ Page(Object.assign({ |
|
|
var that = this;
|
|
|
if (e.detail.errMsg === 'getPhoneNumber:ok') {
|
|
|
decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', function (result) {
|
|
|
// console.log('!!!!result',result)
|
|
|
if (result.code != 200) {
|
|
|
that.wetoast.toast({
|
|
|
title: result.message,
|
...
|
...
|
|