Commit 534b10d9 authored by Edwise's avatar Edwise 🍷

1234

parent 1d0dce52
'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;
......@@ -13,7 +25,7 @@ Page({
PRIZE_TYPE_MAP,
PRIZE_DRAW_STATUS_MAP,
myPrizeList: null, //我的奖品
endTime: null,//到期时间
endTime: null, //到期时间
task: {
image: {
bg: '//yun.duiba.com.cn/aurora/assets/8fa7cea57cc7071bcc1cbada32f5bfaeb2203981.jpg', //背景图
......@@ -56,9 +68,9 @@ Page({
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() + '';//获取秒
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')
......@@ -70,11 +82,19 @@ Page({
* @param {string} type 是否展示loading
*/
async getMyPrize(type) {
const { activityId } = app;
const {
activityId
} = app;
if (type != 'noLoading') {
my.showLoading();
}
const { success, data, message } = await API.getMyPrizeList({ activityId }).catch(res => {
const {
success,
data,
message
} = await API.getMyPrizeList({
activityId
}).catch(res => {
this.setData({
myPrizeList: []
})
......@@ -96,7 +116,9 @@ Page({
//领取奖品
async handleClick(e) {
const { item } = e.target.dataset;
const {
item
} = e.target.dataset;
// 领取权益
if (item.type === PRIZE_TYPE_MAP.EQUITY) return this.handleGetEquity(e)
// 领取实物
......@@ -106,10 +128,12 @@ Page({
},
/**
* 发奖
*/
* 发奖
*/
async cloudTBIssue(params) {
const { cloud } = app;
const {
cloud
} = app;
return new Promise((resolve, reject) => {
my.authorize({
scopes: "scope.latourBenefit",
......@@ -146,8 +170,18 @@ Page({
}
flag = true;
const { item: { strategyCode, code, channel } } = e.target.dataset;
this.cloudTBIssue({ strategyCode, code, channel })
const {
item: {
strategyCode,
code,
channel
}
} = e.target.dataset;
this.cloudTBIssue({
strategyCode,
code,
channel
})
// const { activityId } = app;
// console.log(item, '领取权益')
// const { success, data, message } = await API.receiveEnamePrize({ activityId, _id: item._id }).catch(res => {
......@@ -169,9 +203,23 @@ Page({
},
// 领取实物前询问
async handleGetEntity(e) {
my.confirm({
title: '领取奖品',
content: '是否允许访问您的粘贴板',
confirmButtonText: '确认',
cancelButtonText: '取消',
success: (result) => {
if (result.confirm) {
const text = 'zzzxxx'
commonToast('请前去钉钉领取,钉钉号为:'+text+'。钉钉号已经复制成功。',3000);
setClipboard({ text:`${text}` })
commonToast('请前去钉钉领取,钉钉号为:' + text + '。钉钉号已经复制成功。', 3000);
setClipboard({
text: `${text}`
})
}
},
});
// if (flag) {
// return
......@@ -229,7 +277,11 @@ Page({
// commonToast(JSON.stringify(res))
// }, 5000);
const { success, data, message } = res;
const {
success,
data,
message
} = res;
if (success && data) {
commonToast('领取成功')
} else {
......@@ -248,7 +300,10 @@ Page({
flag = true;
// 判断是否为会员
await this.getUserInfo()
const { isVip, vipLink } = app;
const {
isVip,
vipLink
} = app;
if (!isVip) {
commonToast('立即加入会员,即可领取奖品', 2000);
setTimeout(() => {
......@@ -257,10 +312,21 @@ Page({
flag = false
return
}
const { activityId } = app;
const { item } = e.target.dataset;
const {
activityId
} = app;
const {
item
} = e.target.dataset;
console.log(item, '领取积分')
const { success, data, message } = await API.receiveEnamePrize({ activityId, _id: item._id }) || {};
const {
success,
data,
message
} = await API.receiveEnamePrize({
activityId,
_id: item._id
}) || {};
if (success && data) {
commonToast('领取成功')
} else {
......@@ -272,8 +338,16 @@ Page({
//获取用户vip信息
async getUserInfo() {
const { activityId } = app;
const { success, data, message } = await API.getVipInfo({ activityId }) || {};
const {
activityId
} = app;
const {
success,
data,
message
} = await API.getVipInfo({
activityId
}) || {};
console.log(data, '用户vip信息');
if (success && data) {
app.isVip = (data && data.isVip) || false;
......
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