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) => {
@ -240,9 +239,9 @@ Page({
for (let i in _info.ticket_info) {
tprice += _info.ticket_info[i].price * _info.ticket_info[i].tkt_num
}
this.getRecommendCoupons(options.drama_id, options.tid)
this.setData({
_info,
tprice,

@ -1,295 +1,348 @@
// pages/show/show_detail.js
import {
httpUtil,
http,
login_check
httpUtil,
http,
login_check
} from '../../../utils/util'
Page({
/**
* 页面的初始数据
*/
data: {
current: 0,
rolled: true,
swith_area: 0
},
bindPlayCallBack: function (e) {
console.log('当前视频', e.target.id);
var current_video = e.target.id;
/**
* 页面的初始数据
*/
data: {
current: 0,
rolled: true,
swith_area: 0,
is_buy: 1, //1 可以购买 0 不可以购买
timeText: '00天00时00分00秒'
},
bindPlayCallBack: function (e) {
console.log('当前视频', e.target.id);
var current_video = e.target.id;
var that = this;
let video = that.data.show_detail.wonderful_list;
for (var i in video) {
var index_video = 'video_' + i;
var videoContextPrev = wx.createVideoContext(index_video);
if (current_video != index_video) {
// 暂停其他的
videoContextPrev.pause();
}
}
},
previewMedia(e) {
wx.previewMedia({
sources: this.data.show_detail.wonderful_list,
current: e.currentTarget.dataset.index
})
},
roll_spread() {
this.setData({
rolled: !this.data.rolled
})
},
show_select() {
wx.setNavigationBarTitle({
title: '选择场次'
})
var that = this
if (login_check()) {
let cycle_id = that.data.show_detail.cycle_id
httpUtil("/api/v1/drama-list", "get", {
cycle_id
}).then(res => {
that.setData({
drama_list: res.drama_list,
Xshow_detail: res.show_detail,
show: true
var that = this;
let video = that.data.show_detail.wonderful_list;
for (var i in video) {
var index_video = 'video_' + i;
var videoContextPrev = wx.createVideoContext(index_video);
if (current_video != index_video) {
// 暂停其他的
videoContextPrev.pause();
}
}
},
previewMedia(e) {
wx.previewMedia({
sources: this.data.show_detail.wonderful_list,
current: e.currentTarget.dataset.index
})
})
}
},
onClose() {
this.setData({
show: false
});
wx.setNavigationBarTitle({
title: '开心麻花'
})
},
_cur(e) {
this.setData({
current: e.currentTarget.dataset.index
})
},
_like() {
if (login_check()) {
let status
let follow = false
if ('undefined' !== typeof (this.data.show_detail.is_follow)) {
follow = this.data.show_detail.is_follow
}
let abb_id = this.data.show_detail.abb_id
if (follow) {
status = 0
} else if (!follow) {
status = 1
}
http("/api/v1/follow", "get", {
abb_id,
status
}).then(res => {
if (status == 1) {
wx.showToast({
icon: 'success',
title: '已添加到想看的演出列表',
duration: 2000
})
} else if (status == 0) {
wx.showToast({
icon: 'success',
title: '已取消想看',
duration: 2000
})
},
roll_spread() {
this.setData({
rolled: !this.data.rolled
})
},
show_select() {
wx.setNavigationBarTitle({
title: '选择场次'
})
var that = this
if (login_check()) {
let cycle_id = that.data.show_detail.cycle_id
httpUtil("/api/v1/drama-list", "get", {
cycle_id
}).then(res => {
that.setData({
drama_list: res.drama_list,
Xshow_detail: res.show_detail,
show: true
})
})
}
},
onClose() {
this.setData({
show: false
});
wx.setNavigationBarTitle({
title: '开心麻花'
})
},
_cur(e) {
this.setData({
current: e.currentTarget.dataset.index
})
},
_like() {
if (login_check()) {
let status
let follow = false
if ('undefined' !== typeof (this.data.show_detail.is_follow)) {
follow = this.data.show_detail.is_follow
}
let abb_id = this.data.show_detail.abb_id
if (follow) {
status = 0
} else if (!follow) {
status = 1
}
http("/api/v1/follow", "get", {
abb_id,
status
}).then(res => {
if (status == 1) {
wx.showToast({
icon: 'success',
title: '已添加到想看的演出列表',
duration: 2000
})
} else if (status == 0) {
wx.showToast({
icon: 'success',
title: '已取消想看',
duration: 2000
})
}
let show_detail = this.data.show_detail
show_detail.is_follow = !show_detail.is_follow
this.setData({ show_detail })
})
}
let show_detail = this.data.show_detail
show_detail.is_follow = !show_detail.is_follow
this.setData({ show_detail })
})
}
},
_next(e) {
if (this.data.Xshow_detail.tickets_status == 0) {
wx.navigateTo({
url: '/pages/make_order/choose_sit/choose_sit?drama_id=' + this.data.drama_list[e.currentTarget.dataset.cur_drama].drama_id,
})
} else if (this.data.Xshow_detail.tickets_status == 1) {
wx.navigateTo({
url: '/pages/make_order/random_sit/random_sit?drama_id=' + this.data.drama_list[e.currentTarget.dataset.cur_drama].drama_id,
})
}
},
loc(e) {
if (e.currentTarget.dataset.longitude && e.currentTarget.dataset.latitude) {
wx.openLocation({
latitude: e.currentTarget.dataset.latitude,
longitude: e.currentTarget.dataset.longitude,
name: this.data.show_detail.theater_name,
address: this.data.show_detail.traffic_info
})
} else {
wx.showToast({
title: '地址信息错误',
icon: "error",
duration: 2000
})
}
},
_next(e) {
if (this.data.Xshow_detail.tickets_status == 0) {
wx.navigateTo({
url: '/pages/make_order/choose_sit/choose_sit?drama_id=' + this.data.drama_list[e.currentTarget.dataset.cur_drama].drama_id,
})
} else if (this.data.Xshow_detail.tickets_status == 1) {
wx.navigateTo({
url: '/pages/make_order/random_sit/random_sit?drama_id=' + this.data.drama_list[e.currentTarget.dataset.cur_drama].drama_id,
})
}
},
loc(e) {
if (e.currentTarget.dataset.longitude && e.currentTarget.dataset.latitude) {
wx.openLocation({
latitude: e.currentTarget.dataset.latitude,
longitude: e.currentTarget.dataset.longitude,
name: this.data.show_detail.theater_name,
address: this.data.show_detail.traffic_info
})
} else {
wx.showToast({
title: '地址信息错误',
icon: "error",
duration: 2000
})
}
},
tabcoupon(e) {
let url = e.currentTarget.dataset.router
wx.navigateTo({
url
})
},
stage_click() {
let { abb_id } = this.data.Xshow_detail
wx.navigateTo({
url: '/pages/opera/stage/stage_photo?abb_id='+abb_id,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
wx.getSystemInfo({
success(res) {
that.setData({
windowHeight: res.windowHeight
},
tabcoupon(e) {
let url = e.currentTarget.dataset.router
wx.navigateTo({
url
})
},
stage_click() {
let { abb_id } = this.data.Xshow_detail
wx.navigateTo({
url: '/pages/opera/stage/stage_photo?abb_id=' + abb_id,
})
}
})
let cycle_id = options.cycle_id
http("/api/v1/drama-list", "get", {
cycle_id
}).then(res => {
this.setData({
drama_list: res.drama_list,
Xshow_detail: res.show_detail
})
})
if (cycle_id) {
http("/api/v1/show-detail", "get", {
cycle_id
}).then(res => {
},
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({
show_detail: res.show_info,
suggest_show: res.suggest_show
timeText
})
this.timer = setTimeout(() => {
this.getActiveTime(time - 1)
}, 1000);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
wx.getSystemInfo({
success(res) {
that.setData({
windowHeight: res.windowHeight
})
}
})
let cycle_id = options.cycle_id
http("/api/v1/drama-list", "get", {
cycle_id
}).then(res => {
this.setData({
drama_list: res.drama_list,
Xshow_detail: res.show_detail
})
})
})
} else {
wx.showToast({
title: '未传入轮次id',
icon: 'error',
duration: 2000
})
if (cycle_id) {
http("/api/v1/show-detail", "get", {
cycle_id
}).then(res => {
this.setData({
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',
icon: 'error',
duration: 2000
})
},
}
swith_tab: function (e) {
let swith_area = e.currentTarget.dataset.index
let seleted_id = '#nav' + swith_area
// wx.createSelectorQuery().select(seleted_id).boundingClientRect(function(rect){console.log(rect)}).exec()
wx.pageScrollTo({
selector: seleted_id,
duration: 300
})
// }).exec();
this.setData({
swith_area
})
},
},
onPageScroll: function (ev) {
let windowHeight = this.data.windowHeight
let arr
let a
let query = wx.createSelectorQuery()
for (var i = 0; i < 4; i++) {
query.select('#nav' + i).boundingClientRect()
}
query.exec((res) => {
arr = [res[0].top, res[1].top, res[2].top, res[3].top]
for (var i = 0; i < 4; i++) {
if (arr[i] < 20) {
a = i
}
}
if (a) {
this.setData({ swith_area: a })
}
})
if (ev.scrollTop > windowHeight) {
this.setData({
nav_show: true
})
} else if (ev.scrollTop < windowHeight) {
this.setData({
nav_show: false
})
}
},
swith_tab: function (e) {
let swith_area = e.currentTarget.dataset.index
let seleted_id = '#nav' + swith_area
// wx.createSelectorQuery().select(seleted_id).boundingClientRect(function(rect){console.log(rect)}).exec()
wx.pageScrollTo({
selector: seleted_id,
duration: 300
})
// }).exec();
this.setData({
swith_area
})
},
onPageScroll: function (ev) {
let windowHeight = this.data.windowHeight
let arr
let a
let query = wx.createSelectorQuery()
for (var i = 0; i < 4; i++) {
query.select('#nav' + i).boundingClientRect()
}
query.exec((res) => {
arr = [res[0].top, res[1].top, res[2].top, res[3].top]
for (var i = 0; i < 4; i++) {
if (arr[i] < 20) {
a = i
}
}
if (a) {
this.setData({ swith_area: a })
}
})
if (ev.scrollTop > windowHeight) {
this.setData({
nav_show: true
})
} else if (ev.scrollTop < windowHeight) {
this.setData({
nav_show: false
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
clearTimeout(this.timer);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
wx.stopPullDownRefresh()
},
wx.stopPullDownRefresh()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
var that = this;
console.log('转发事件的来源', res.from)
console.log(that.data)
return { //自定义转发内容
title: that.data.show_detail.show_name, //自定义转发标题
imageUrl: that.data.show_detail.background_pic //不设置此字段时,默认截取当前页面作为展示的图片
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
var that = this;
console.log('转发事件的来源', res.from)
console.log(that.data)
return { //自定义转发内容
title: that.data.show_detail.show_name, //自定义转发标题
imageUrl: that.data.show_detail.background_pic //不设置此字段时,默认截取当前页面作为展示的图片
}
}
}
})

@ -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" />
<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}}" />
<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}}" />
</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