Commit 534b10d9 authored by Edwise's avatar Edwise 🍷

1234

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