feat 倒计时抢票

develop
GJW200011 4 years ago
parent 01194eb66e
commit 4176ca7aa1

@ -177,13 +177,12 @@ Page({
// 使用最大减免优惠券
getRecommendCoupons(drama_id, tid) {
http('/api/v1/coupon-list', "post", {
drama_id,
drama_id:drama_id?drama_id:this.data.drama_id,
tid,
mode: 1
}).then(Response => {
if (Response.coupon_list.length > 0) {
let coupon_list = Response.coupon_list
// 选出status == 1 去除日期格式
let a = []
coupon_list.forEach((item) => {

@ -12,7 +12,9 @@ Page({
data: {
current: 0,
rolled: true,
swith_area: 0
swith_area: 0,
is_buy: 1, //1 可以购买 0 不可以购买
timeText: '00天00时00分00秒'
},
bindPlayCallBack: function (e) {
console.log('当前视频', e.target.id);
@ -149,6 +151,44 @@ Page({
})
},
getActiveTime(time) {
console.log(time, "剩余");
if (time < 1) {
this.setData({
is_buy: 1
})
return
}
var day = Math.floor(time / 86400);
var hour = Math.floor((time % 86400) / 3600);
var min = Math.floor(((time % 86400) % 3600) / 60);
var sec = Math.floor(((time % 86400) % 3600) % 60);
// if (day < 10) {
// day = "0" + day;
// }
if (sec < 10) {
sec = "0" + sec;
}
if (min < 10) {
min = "0" + min;
}
if (hour < 10) {
hour = "0" + hour;
}
let timeText = day + '天' + hour + '时' + min + '分' + sec + '秒'
if(day<=0){
timeText = hour + '时' + min + '分' + sec + '秒'
}
console.log(timeText, 'buy_time');
this.setData({
timeText
})
this.timer = setTimeout(() => {
this.getActiveTime(time - 1)
}, 1000);
},
/**
* 生命周期函数--监听页面加载
*/
@ -179,8 +219,21 @@ Page({
show_detail: res.show_info,
suggest_show: res.suggest_show
})
})
// this.data.show_detail.buy_time = new Date('2021/12/07 13:52:00').getTime()
let buy_time = this.data.show_detail.buy_time
if (buy_time != 0) {
this.setData({
is_buy: 0
})
// var now_time = new Date().getTime()
this.getActiveTime(buy_time)
} else {
this.setData({
is_buy: 1
})
}
})
} else {
wx.showToast({
title: '未传入轮次id',
@ -262,7 +315,7 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
clearTimeout(this.timer);
},
/**

@ -120,11 +120,15 @@
<van-goods-action safe-area-inset-bottom>
<van-goods-action-icon icon="/images/ui/{{show_detail.is_follow?'liked':'like'}}.png" text="想看" bind:click="_like" />
<van-goods-action-icon icon="/images/ui/share.png" text="分享" open-type="share" bind:click="_share" />
<block wx:if="{{is_buy==1}}">
<van-goods-action-button text="演出结束" class="btn{{show_detail.is_end}}"
color="linear-gradient(90deg, #CCC 0%, #CCC 100%)" wx:if="{{show_detail.is_end==1}}" />
<van-goods-action-button text="立即购买" bind:click="show_select" color="linear-gradient(90deg, #FF4284 0%, #FF1D42 100%)"
wx:if="{{show_detail.is_end==0}}" />
<van-goods-action-button text="立即购买" bind:click="show_select"
color="linear-gradient(90deg, #FF4284 0%, #FF1D42 100%)" wx:if="{{show_detail.is_end==0}}" />
</block>
<block wx:if="{{is_buy==0}}">
<van-goods-action-button text="{{timeText}}" class="btn" color="linear-gradient(90deg, #D0D0D0 0%, #D0D0D0 100%)"/>
</block>
<!-- <view class="btn btn{{show_detail.is_end}}" wx:if="{{show_detail.is_end==1}}">演出结束</view>
<view class="btn btn{{show_detail.is_end}}" bind:tap="show_select" wx:else>立即购买</view> -->

@ -184,7 +184,9 @@
font-size: 24rpx;
color: #1394F2;
}
.btn{
pointer-events: none;
}
._block .warning {
background: #fff;
padding-bottom: 20rpx;

@ -20,7 +20,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (login_check(1)) {
if (login_check()) {
this.getcollect_list(options.activity_id)
}
},

Loading…
Cancel
Save