Commit 2cc2b8f4 authored by Edwise's avatar Edwise 🍷

111

parent 0b78ea6b
......@@ -30,8 +30,8 @@ Component({
},
didMount(){
const {unLockStep,warms}= this.props.gameOverData;
let str = unLockStep==2?'恭喜您解锁5系赛段,获得30温暖值':'恭喜您解锁7系赛段,,获得50温暖值';
let str1 = unLockStep==2?'进入三人场':'进入四人场';
let str = unLockStep==2?'恭喜您解锁5系赛段':'恭喜您解锁7系赛段';
let str1 = unLockStep==2?'进入三人场,获得30温暖值':'进入四人场,获得50温暖值';
this.setData({
unLockStep:unLockStep,
title1:str,
......
'use strict';
import API from "/api";
import { SHARE_CONFIG } from '/tbcc-sdk/lib/constants';
import {
SHARE_CONFIG
} from '/tbcc-sdk/lib/constants';
const app = getApp();
const { tbcc } = app;
const { commonToast, navigateToOutside, getUserAddress, setClipboard } = tbcc.tb;
const { PRIZE_TYPE_MAP, PRIZE_DRAW_STATUS_MAP } = tbcc.constants;
const {
tbcc
} = app;
const {
commonToast,
navigateToOutside,
getUserAddress,
setClipboard
} = tbcc.tb;
const {
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP
} = tbcc.constants;
let flag = false;
Page({
data: {
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP,
myPrizeList: null, //我的奖品
endTime: null,//到期时间
task: {
image: {
bg: '//yun.duiba.com.cn/spark/assets/myprizeBg.1f636c459b0a7e272f3cc65c80c7bc2a88bc2833.jpg', //背景图
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
addressBth: '//yun.duiba.com.cn/spark/assets/writeAddress.5d2f4dd2f643a6b6e37cb2a9725fc552cd56901d.png', //填写地址(实物奖品)
getBth: '//yun.duiba.com.cn/spark/assets/getImmite.46d6f54d3cd89200ae6514956404073220d430a9.png', //立即领取(除实物奖品外)
logisticsBth: '//yun.duiba.com.cn/spark/assets/查看物流.693fea0c226928d503e5d9b03adc83bd148e5506.png', //查看物流
useBtn: '//yun.duiba.com.cn/spark/assets/useIt.b8fdb31733471c7d5e346fe1b4be1d6cad6cb5f8.png', //去使用(除实物奖品外)
gotBtn: '//yun.duiba.com.cn/spark/assets/isGot.249e45c6dd688a8345384dee6a7d656db5303076.png', //已领取(优惠券)
getAgainBtn: '//yun.duiba.com.cn/spark/assets/regetBtn.46e12117eb7915dcf531aac0b684a634feaee516.png', //重新领取
invalidBtn: '//yun.duiba.com.cn/spark/assets/914ba8643c8abb8d710a3126ec312aecf6c4daf0.png', //已失效
failBth: '//yun.duiba.com.cn/spark/assets/8267375232058a6d0140270b1594427fb08d6ae3.png', //领取失败
},
logisticsImage: {
shipped: '//yun.duiba.com.cn/spark/assets/logisticsBg.9c4bbf261aac92d0462a48f6e1f5562d4564e855.png', // 已发货物理弹窗
notShipped: '//yun.duiba.com.cn/spark/assets/logisticsBg.9c4bbf261aac92d0462a48f6e1f5562d4564e855.png', // 待发货物流弹窗
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
},
btnStyle: { // 按钮自定义样式
width: '158rpx',
height: '53rpx',
}
}
},
onShow() {
flag = false
this.getMyPrize();
},
onShareAppMessage() {
return SHARE_CONFIG;
},
// 到期时间
getEndTime(prizeList = []) {
if (!prizeList || !prizeList.length) return null
const endTime = prizeList[0].expiredTime
if (!endTime) return null;
const yy = new Date(endTime).getFullYear();
const mm = new Date(endTime).getMonth() + 1;
const dd = new Date(endTime).getDate();
const t1 = `${yy}${mm}${dd}日`;
// console.log(new Date(endTime).toLocaleDateString())
// const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日
const t2 = new Date(endTime).getHours() + '';//获取时
const t3 = new Date(endTime).getMinutes() + '';//获取分
const t4 = new Date(endTime).getMilliseconds() + '';//获取秒
console.log(endTime, new Date(endTime + 48 * 60 * 60 * 1000).toLocaleString(), 'endTime');
this.setData({
endTime: t1 + "" + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0')
})
},
/**
* 获取奖品列表
* @param {string} type 是否展示loading
*/
async getMyPrize(type) {
const { activityId } = app;
if (type != 'noLoading') {
my.showLoading();
}
const { success, data, message } = await API.getMyPrizeList({ activityId }).catch(res => {
this.setData({
myPrizeList: []
})
}) || {};
if (success && data) {
this.setData({
myPrizeList: data.list
})
this.getEndTime(data.list)
}
if (type != 'noLoading') {
my.hideLoading();
}
},
//领取奖品
async handleClick(e) {
console.log("领取奖品",e)
const { item } = e.target.dataset;
// 领取权益
if (item.type === PRIZE_TYPE_MAP.EQUITY) return this.handleGetEquity(e)
// 领取实物
if (item.type === PRIZE_TYPE_MAP.ENTITY) return this.handleGetEntity(e)
// 领取积分
if (item.type === PRIZE_TYPE_MAP.INTEGRATION) return this.handleGetIntergation(e)
},
// 优惠券
async handleGetEquity(e) {
if (flag) {
return
}
flag = true;
const { activityId } = app;
const { item } = e.target.dataset;
console.log(item, '领取权益')
const { success, data, message } = await API.receiveEnamePrize({ _id: item._id }).catch(res => {
this.getMyPrize('noLoading')
commonToast(res && res.message)
}) || {};
if (success && data) {
commonToast('领取成功')
this.getMyPrize()
}
setTimeout(() => {
flag = false
}, 500)
},
// 领取实物前询问
async handleGetEntity(e) {
if (flag) {
return
}
// my.showLoading();
flag = true;
setTimeout(()=>{
data: {
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP,
myPrizeList: null, //我的奖品
endTime: null, //到期时间
task: {
image: {
bg: '//yun.duiba.com.cn/spark/assets/myprizeBg.1f636c459b0a7e272f3cc65c80c7bc2a88bc2833.jpg', //背景图
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
addressBth: '//yun.duiba.com.cn/spark/assets/writeAddress.5d2f4dd2f643a6b6e37cb2a9725fc552cd56901d.png', //填写地址(实物奖品)
getBth: '//yun.duiba.com.cn/spark/assets/getImmite.46d6f54d3cd89200ae6514956404073220d430a9.png', //立即领取(除实物奖品外)
logisticsBth: '//yun.duiba.com.cn/spark/assets/查看物流.693fea0c226928d503e5d9b03adc83bd148e5506.png', //查看物流
useBtn: '//yun.duiba.com.cn/spark/assets/useIt.b8fdb31733471c7d5e346fe1b4be1d6cad6cb5f8.png', //去使用(除实物奖品外)
gotBtn: '//yun.duiba.com.cn/spark/assets/isGot.249e45c6dd688a8345384dee6a7d656db5303076.png', //已领取(优惠券)
getAgainBtn: '//yun.duiba.com.cn/spark/assets/regetBtn.46e12117eb7915dcf531aac0b684a634feaee516.png', //重新领取
invalidBtn: '//yun.duiba.com.cn/spark/assets/914ba8643c8abb8d710a3126ec312aecf6c4daf0.png', //已失效
failBth: '//yun.duiba.com.cn/spark/assets/8267375232058a6d0140270b1594427fb08d6ae3.png', //领取失败
},
logisticsImage: {
shipped: '//yun.duiba.com.cn/spark/assets/logisticsBg.9c4bbf261aac92d0462a48f6e1f5562d4564e855.png', // 已发货物理弹窗
notShipped: '//yun.duiba.com.cn/spark/assets/logisticsBg.9c4bbf261aac92d0462a48f6e1f5562d4564e855.png', // 待发货物流弹窗
copyIcon: '//yun.dui88.com/duiba-components-c-myprizemyprize_copy_code.png', //复制
},
btnStyle: { // 按钮自定义样式
width: '158rpx',
height: '53rpx',
}
}
},
onShow() {
flag = false
},500)
console.log('领取实物')
const { activityId } = app;
const { item } = e.target.dataset;
const userAddress = await getUserAddress({ joinTag: " " }).catch((data)=>{
flag = false
console.log('getUserAddress出错了,错误信息是',data);
})
// my.hideLoading();
if (!userAddress) return
// commonToast(' getUserAddress =>'+JSON.stringify( userAddress))
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
const params = {
activityId,
area:countyName,
addressDetail:detailInfo,
name,
phone: telNumber,
detailInfo,
cityCode,
cityName,
city:cityName,
province:provinceName,
provinceName,
countyName,
streetName,
id: item._id
}
this.getMyPrize();
},
onShareAppMessage() {
return SHARE_CONFIG;
},
// 到期时间
getEndTime(prizeList = []) {
if (!prizeList || !prizeList.length) return null
const endTime = prizeList[0].expiredTime
if (!endTime) return null;
const yy = new Date(endTime).getFullYear();
const mm = new Date(endTime).getMonth() + 1;
const dd = new Date(endTime).getDate();
const t1 = `${yy}${mm}${dd}日`;
// console.log(new Date(endTime).toLocaleDateString())
// const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日
const t2 = new Date(endTime).getHours() + ''; //获取时
const t3 = new Date(endTime).getMinutes() + ''; //获取分
const t4 = new Date(endTime).getMilliseconds() + ''; //获取秒
console.log(endTime, new Date(endTime + 48 * 60 * 60 * 1000).toLocaleString(), 'endTime');
this.setData({
endTime: t1 + "" + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0')
})
},
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
console.log(result)
const { confirm } = result;
/**
* 获取奖品列表
* @param {string} type 是否展示loading
*/
async getMyPrize(type) {
const {
activityId
} = app;
if (type != 'noLoading') {
my.showLoading();
}
const {
success,
data,
message
} = await API.getMyPrizeList({
activityId
}).catch(res => {
this.setData({
myPrizeList: []
})
}) || {};
if (success && data) {
this.setData({
myPrizeList: data.list
})
this.getEndTime(data.list)
}
if (type != 'noLoading') {
my.hideLoading();
}
},
if (confirm) {
this.receiveObjectPrize(params);
//领取奖品
async handleClick(e) {
console.log("领取奖品", e)
const {
item
} = e.target.dataset;
// 领取权益
if (item.type === PRIZE_TYPE_MAP.EQUITY) return this.handleGetEquity(e)
// 领取实物
if (item.type === PRIZE_TYPE_MAP.ENTITY) return this.handleGetEntity(e)
// 领取积分
if (item.type === PRIZE_TYPE_MAP.INTEGRATION) return this.handleGetIntergation(e)
},
// 优惠券
async handleGetEquity(e) {
if (flag) {
return
}
flag = true;
const {
activityId
} = app;
const {
item
} = e.target.dataset;
console.log(item, '领取权益')
const {
success,
data,
message
} = await API.receiveEnamePrize({
id: item._id
}).catch(res => {
this.getMyPrize('noLoading')
commonToast(res && res.message)
}) || {};
if (success && data) {
commonToast('领取成功')
this.getMyPrize()
}
setTimeout(() => {
flag = false
}, 500)
},
// 领取实物前询问
async handleGetEntity(e) {
if (flag) {
return
}
},
});
flag = false
},
// 领取实物
async receiveObjectPrize(params) {
// commonToast('正在调用receiveObjectPrize'+JSON.stringify(params))
API.receiveObjectPrize(params).then((res) => {
// setTimeout(() => {
// commonToast(JSON.stringify(res))
// }, 5000);
// my.showLoading();
flag = true;
setTimeout(() => {
flag = false
}, 500)
console.log('领取实物')
const {
activityId
} = app;
const {
item
} = e.target.dataset;
const userAddress = await getUserAddress({
joinTag: " "
}).catch((data) => {
flag = false
console.log('getUserAddress出错了,错误信息是', data);
})
// my.hideLoading();
if (!userAddress) return
// commonToast(' getUserAddress =>'+JSON.stringify( userAddress))
const {
name,
telNumber,
provinceName,
cityName,
cityCode,
countyName,
detailInfo,
streetName
} = userAddress || {};
const params = {
activityId,
area: countyName,
addressDetail: detailInfo,
name,
phone: telNumber,
detailInfo,
cityCode,
cityName,
city: cityName,
province: provinceName,
provinceName,
countyName,
streetName,
id: item._id
}
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
console.log(result)
const {
confirm
} = result;
if (confirm) {
this.receiveObjectPrize(params);
}
},
});
flag = false
},
// 领取实物
async receiveObjectPrize(params) {
// commonToast('正在调用receiveObjectPrize'+JSON.stringify(params))
API.receiveObjectPrize(params).then((res) => {
// setTimeout(() => {
// commonToast(JSON.stringify(res))
// }, 5000);
const { success, data, message } = res;
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
this.getMyPrize()
},(rej)=>{
commonToast(rej.message)
});
},
// 积分
async handleGetIntergation(e) {
if (flag) {
return
}
flag = true;
console.log(item, '领取积分')
// 判断是否为会员
await this.getUserInfo()
const { isVip, vipLink } = app;
if (!isVip) {
commonToast('立即加入会员,即可领取奖品', 2000);
setTimeout(() => {
navigateToOutside(vipLink)
}, 1000)
flag = false
return
}
const { activityId } = app;
const { item } = e.target.dataset;
console.log(item, '领取积分')
const { success, data, message } = await API.receiveEnamePrize({ activityId, _id: item._id }) || {};
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
flag = false
this.getMyPrize()
},
const {
success,
data,
message
} = res;
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
this.getMyPrize()
}, (rej) => {
commonToast(rej.message)
});
},
// 积分
async handleGetIntergation(e) {
if (flag) {
return
}
flag = true;
console.log(item, '领取积分')
// 判断是否为会员
await this.getUserInfo()
const {
isVip,
vipLink
} = app;
if (!isVip) {
commonToast('立即加入会员,即可领取奖品', 2000);
setTimeout(() => {
navigateToOutside(vipLink)
}, 1000)
flag = false
return
}
const {
activityId
} = app;
const {
item
} = e.target.dataset;
console.log(item, '领取积分')
const {
success,
data,
message
} = await API.receiveEnamePrize({
id: item._id
}) || {};
if (success && data) {
commonToast('领取成功')
} else {
commonToast(message)
}
flag = false
this.getMyPrize()
},
//获取用户vip信息
async getUserInfo() {
const { activityId } = app;
const { success, data, message } = await API.getVipInfo({ activityId }) || {};
console.log(data, '用户vip信息');
if (success && data) {
app.isVip = (data && data.isVip) || false;
app.vipLink = (data && data.url) || '';
} else {
commonToast(message)
}
},
});
//获取用户vip信息
async getUserInfo() {
const {
activityId
} = app;
const {
success,
data,
message
} = await API.getVipInfo({
activityId
}) || {};
console.log(data, '用户vip信息');
if (success && data) {
app.isVip = (data && data.isVip) || false;
app.vipLink = (data && data.url) || '';
} else {
commonToast(message)
}
},
});
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment