Commit 4bfca2ee authored by 汪欢's avatar 汪欢

timer

parent 5487f171
...@@ -6,8 +6,8 @@ cloud.init({ ...@@ -6,8 +6,8 @@ cloud.init({
}); });
App({ App({
requestType: 'cloud', // yapi,cloud: 云函数 // requestType: 'cloud', // yapi,cloud: 云函数
// requestType: 'yapi', // yapi,cloud: 云函数 requestType: 'yapi', // yapi,cloud: 云函数
cloudName: 'floor', // 主云函数项目名 base clientTemplate2C cloudName: 'floor', // 主云函数项目名 base clientTemplate2C
cloud, cloud,
tbcc, tbcc,
......
...@@ -258,3 +258,7 @@ ...@@ -258,3 +258,7 @@
top: 365rpx; top: 365rpx;
position: absolute; position: absolute;
} }
.click{
pointer-events: none;
}
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<label class="grade_name">您是{{vipCredits.gradeName}}</label> <label class="grade_name">您是{{vipCredits.gradeName}}</label>
<label class="gou_maixxx_ge_lou_ceng_yi_gong_xu_yao_hua_feixxxx_ji_fen22"> <label class="gou_maixxx_ge_lou_ceng_yi_gong_xu_yao_hua_feixxxx_ji_fen22">
购买 {{vipCredits.canBuyFloor}} 个楼层 一共需要花费 {{vipCredits.gradeCredits}} 积分 购买 {{vipCredits.canBuyFloor}} 个楼层 一共需要花费 {{vipCredits.gradeCredits * vipCredits.canBuyFloor}} 积分
</label> </label>
<label class="ps_mei_ceng_lou50_ji_fen">(PS:每层楼50积分)</label> <label class="ps_mei_ceng_lou50_ji_fen">(PS:每层楼50积分)</label>
</view> </view>
...@@ -21,6 +21,6 @@ ...@@ -21,6 +21,6 @@
购买 XXX 个楼层 一共需要花费 XXXX 积分</label><label class="ps_mei_ceng_lou20_ji_fen">(PS:每层楼20积分)</label></view><view class="hei_qia_hui_yuan"><image class="bei_jing5" src={{resList['c46f1953-53df-4fdd-aaab-b5e8252b84ce'].url}} /><image class="zu926" src={{resList['53ff1056-22d3-48ad-8f55-3e8a459073b2'].url}} /><label class="gou_maixxx_ge_lou_ceng_yi_gong_xu_yao_hua_feixxxx_ji_fen21"> 购买 XXX 个楼层 一共需要花费 XXXX 积分</label><label class="ps_mei_ceng_lou20_ji_fen">(PS:每层楼20积分)</label></view><view class="hei_qia_hui_yuan"><image class="bei_jing5" src={{resList['c46f1953-53df-4fdd-aaab-b5e8252b84ce'].url}} /><image class="zu926" src={{resList['53ff1056-22d3-48ad-8f55-3e8a459073b2'].url}} /><label class="gou_maixxx_ge_lou_ceng_yi_gong_xu_yao_hua_feixxxx_ji_fen21">
购买 XXX 个楼层 一共需要花费 XXXX 积分</label><label class="ps_mei_ceng_lou10_ji_fen">(PS:每层楼10积分)</label><label class="xu_yao_xiao_hao10n_ge_ji_fen">需要消耗 10*N 个积分</label></view> --> 购买 XXX 个楼层 一共需要花费 XXXX 积分</label><label class="ps_mei_ceng_lou10_ji_fen">(PS:每层楼10积分)</label><label class="xu_yao_xiao_hao10n_ge_ji_fen">需要消耗 10*N 个积分</label></view> -->
</view> </view>
<image class="an_niu66" onTap="consumeCredits" src={{resList['3cd0f2ce-f2e0-42c6-be49-52b3177164c5'].url}} /> <image class="an_niu66 {{enableTap}}" onTap="consumeCredits" src={{resList['3cd0f2ce-f2e0-42c6-be49-52b3177164c5'].url}} />
<image class="an_niu_kao_bei2" onTap="onOrderNowModalClose" src={{resList['0eba7d77-43f9-4127-8976-ebf54e0b84be'].url}} /> <image class="an_niu_kao_bei2" onTap="onOrderNowModalClose" src={{resList['0eba7d77-43f9-4127-8976-ebf54e0b84be'].url}} />
</view> </view>
\ No newline at end of file
...@@ -11,7 +11,8 @@ Component({ ...@@ -11,7 +11,8 @@ Component({
onUserCredit:()=>{} onUserCredit:()=>{}
}, },
data: { data: {
resList: resList resList: resList,
enableTap:true
}, },
methods: { methods: {
// 关闭 // 关闭
...@@ -23,6 +24,11 @@ Component({ ...@@ -23,6 +24,11 @@ Component({
// 购买判断 // 购买判断
async consumeCredits(){ async consumeCredits(){
let vipCredits = this.props.vipCredits; let vipCredits = this.props.vipCredits;
this.setData({
enableTap:false
})
// console.log(this.props,'datas') // console.log(this.props,'datas')
// API.getCredits().catch((res)=>{ // API.getCredits().catch((res)=>{
// console.log('resdata',res) // console.log('resdata',res)
...@@ -50,6 +56,9 @@ Component({ ...@@ -50,6 +56,9 @@ Component({
// } // }
// }) // })
this.setData({
enableTap:true
})
commonToast("恭喜你购买成功"); commonToast("恭喜你购买成功");
this.props.onUserCredit(); this.props.onUserCredit();
......
...@@ -265,13 +265,12 @@ ...@@ -265,13 +265,12 @@
width: 86rpx; width: 86rpx;
height: 34rpx; height: 34rpx;
opacity: 1; opacity: 1;
/* left: 270rpx; left: 270rpx;
top: 18rpx; */
left: 290rpx;
top: 12rpx; top: 12rpx;
position: absolute; position: absolute;
font-size: 28.61729rpx; font-size: 30rpx;
color: #f23f47; color: #f23f47;
text-align: center;
} }
.huo_dong_ye .zu4 { .huo_dong_ye .zu4 {
width: 120rpx; width: 120rpx;
......
...@@ -22,7 +22,7 @@ Page({ ...@@ -22,7 +22,7 @@ Page({
// m: '', // m: '',
// s: '', // s: '',
// }, // },
endingTime: '', endingTime: {},
// 奖品列表数据 // 奖品列表数据
prizeList: [], prizeList: [],
...@@ -56,23 +56,13 @@ Page({ ...@@ -56,23 +56,13 @@ Page({
// this.setData({ // this.setData({
// resList: resList // resList: resList
// }); // });
console.log(props.data,'dataprops');
const { endTime } = JSON.parse(props.data);
this.setData({
endTime
})
this.getBaseInfo(); this.getBaseInfo();
this.getRuleSource(); this.getRuleSource();
this.getUserCredits(); this.getUserCredits();
// this.getEndTime();
this.getOrderList(); this.getOrderList();
}, },
// onReady() {
// let {endTime} = this.data
// this.countDowning(endTime);
// },
onPrizeBtnClick() { onPrizeBtnClick() {
my.navigateTo({ my.navigateTo({
...@@ -182,7 +172,7 @@ Page({ ...@@ -182,7 +172,7 @@ Page({
orderNowModalVisible: true orderNowModalVisible: true
}) })
} else { } else {
commonToast('活动已结束,无法购买') commonToast('无法购买')
} }
}, },
...@@ -240,9 +230,6 @@ Page({ ...@@ -240,9 +230,6 @@ Page({
let start = data.startTime; let start = data.startTime;
let eachBuyMostFloor = data.eachBuyMostFloor; let eachBuyMostFloor = data.eachBuyMostFloor;
// startTime = data.startTime;
// endingTime = data.endTime;
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
let listStyle = { let listStyle = {
left: 180 * i + 'rpx', left: 180 * i + 'rpx',
...@@ -263,8 +250,7 @@ Page({ ...@@ -263,8 +250,7 @@ Page({
eachBuyMostFloor eachBuyMostFloor
}) })
console.log('zhixingcount'); console.log('zhixingcount');
this.countDowning(end);
} else { } else {
// 错误码 // 错误码
// console.log('error'); // console.log('error');
...@@ -273,13 +259,20 @@ Page({ ...@@ -273,13 +259,20 @@ Page({
}, },
async countDowning(end) { countDowning(end) {
// let { start, end } = this.data;
// let { data, success, code, message } = await API.getActivityBaseInfoById() || {};
console.log('执行时间count') console.log('执行时间count')
// let end = data.endTime; if(end.length == 0){
this.setData({
endingTime: {
d: '00',
h: '00',
m: '00',
s: '00'
}
})
} else {
var nowTime = new Date().getTime();//现在时间(时间戳) var nowTime = new Date().getTime();//现在时间(时间戳)
var endTimess = new Date(end).getTime();//结束时间(时间戳) var endTimess = new Date(end).getTime();//结束时间(时间戳)
var time = (endTimess - nowTime) / 1000;//距离结束的毫秒数 var time = (endTimess - nowTime) / 1000;//距离结束的毫秒数
...@@ -308,33 +301,23 @@ Page({ ...@@ -308,33 +301,23 @@ Page({
} }
}) })
let timer
// 每1000ms刷新一次 // 每1000ms刷新一次
if (time > 0) { if (time > 0) {
this.setData({ this.setData({
countDown: true countDown:true
}) })
setTimeout(this.countDowning.bind(this), 1000); timer = setTimeout(this.countDowning.bind(this,end), 1000);
} else { } else {
clearTimeout(timer);
this.setData({ this.setData({
countDown: false countDown: true
}) })
} }
// if(end.length == 0){
// this.setData({
// endingTime: {
// d: '00',
// h: '00',
// m: '00',
// s: '00'
// }
// })
// } else {
// const endtime = '2020-10-17T00:00:00'
}
// }
}, },
// 获取购买记录信息 // 获取购买记录信息
...@@ -418,57 +401,7 @@ Page({ ...@@ -418,57 +401,7 @@ Page({
}) })
}, },
// 倒计时 //
// getEndTime() {
// let { prizeList, endingTime } = this.data
// if (!prizeList || !prizeList.length) return null
// // const endTime = prizeList[0].expiredTime
// // if (!endTime) return null
// // const endTime = '2020/09/30';
// // const endTime = '2020-10-17T00:00:00'
// let endTime = endingTime;
// let stringTime = this.data.stringTime || (new Date(endTime)).getTime();
// // this.setData({
// // stringTime
// // })
// // const t1 = new Date(endTime).toLocaleDateString() + '';//获取年月日
// // const d1 = new Date(endTime).getDate() + '';
// // 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',t1);
// const t1 = new Date(stringTime).toLocaleDateString() + '';//获取年月日
// const d1 = new Date(stringTime).getDate() + '';
// const t2 = new Date(stringTime).getHours() + '';//获取时
// const t3 = new Date(stringTime).getMinutes() + '';//获取分
// const t4 = new Date(stringTime).getSeconds() + '';//获取秒
// let hh = t2.padStart(2, '0');
// let mm = t3.padStart(2, '0');
// let ss = t4.padStart(2, '0');
// let timer = setTimeout(() => {
// this.setData({
// stringTime: stringTime - 1
// })
// console.log(stringTime, 'stringTime');
// if (stringTime <= 0) {
// clearTimeout(timer);
// }
// this.setData({
// // endTime: t1 + " " + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0')
// endTime: {
// d: d1,
// h: hh,
// m: mm,
// s: ss
// }
// })
// }, 1000)
// },
//小于10的格式化函数(2变成02) //小于10的格式化函数(2变成02)
timeFormat(param) { timeFormat(param) {
......
...@@ -16,7 +16,8 @@ Page({ ...@@ -16,7 +16,8 @@ Page({
ruleData:'', ruleData:'',
joinCount:'', joinCount:'',
endTime:'' endTime:'',
startTime:''
}, },
onLoad(query) { onLoad(query) {
...@@ -30,14 +31,23 @@ Page({ ...@@ -30,14 +31,23 @@ Page({
}, },
gotoVipPage() { gotoVipPage() {
let {endTime} = this.data let {endTime,startTime} = this.data
API.getVipInfo().then(res => { API.getVipInfo().then(res => {
// res.data.isVip=true; // res.data.isVip=true;
// 判断活动时间
let currentTime = new Date().getTime();
if(currentTime < startTime){
commonToast('活动未开始');
}
if(currentTime > endTime){
commonToast('活动已结束');
}
if (!res.data.isVip) if (!res.data.isVip)
navigateToOutside(res.data.url) navigateToOutside(res.data.url)
else else
// my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye' }); my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye' });
my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye?data=' + JSON.stringify({endTime}) }); // my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye?data=' + JSON.stringify({endTime}) });
}) })
}, },
...@@ -64,13 +74,14 @@ Page({ ...@@ -64,13 +74,14 @@ Page({
}) })
}, },
async init() { async init() {
const [{ data: { isUserJoin, endTime, openPrizeStatus, prize, isShowPrize, rule, joinCount } }, vipInfo] = await Promise.all([ const [{ data: { isUserJoin,startTime, endTime, openPrizeStatus, prize, isShowPrize, rule, joinCount } }, vipInfo] = await Promise.all([
API.getActivityBaseInfoById(), API.getActivityBaseInfoById(),
API.getVipInfo(), API.getVipInfo(),
]); ]);
this.setData({ this.setData({
endTime endTime,
startTime
}) })
console.log('fuck'); console.log('fuck');
......
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