You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

348 lines
9.4 KiB

// pages/show/show_detail.js
import {
httpUtil,
http,
login_check
} from '../../../utils/util'
Page({
/**
* 页面的初始数据
*/
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
})
})
}
},
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 })
})
}
},
_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,
})
},
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);
},
/**
* 生命周期函数--监听页面加载
*/
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
})
})
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
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
clearTimeout(this.timer);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
wx.stopPullDownRefresh()
},
/**
* 页面上拉触底事件的处理函数
*/
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 //不设置此字段时,默认截取当前页面作为展示的图片
}
}
})