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.
225 lines
5.1 KiB
225 lines
5.1 KiB
// pages/list/movieticket/list/cinema/index.js
|
|
let app = getApp()
|
|
import commonApi from "../../../../../utils/https/common"
|
|
import util from "../../../../../utils/util"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
movie:[],
|
|
currentNum:0,
|
|
show_id:null,
|
|
dates:[],
|
|
dateIndex:0,
|
|
list:[],
|
|
name:"",
|
|
invoiceId:null,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
id:options.id
|
|
})
|
|
this.initDate();
|
|
this.enlarge();
|
|
this.shrink();
|
|
// 先要获取影片列表 再获取排片
|
|
commonApi._post("Cinema/getMovieListByCinemaId",{
|
|
cinema_id:this.data.id
|
|
}).then(res=>{
|
|
if(res.data.length==0){
|
|
wx.showToast({
|
|
title: '该影院没有排片',
|
|
icon:'none'
|
|
})
|
|
setTimeout(()=>{
|
|
util.back();
|
|
},1000)
|
|
}
|
|
else {
|
|
this.setData({
|
|
movie:res.data
|
|
})
|
|
this.getList()
|
|
}
|
|
})
|
|
|
|
},
|
|
initDate:function(){
|
|
let today = new Date(util.formatDate(new Date()).replace(/-/g,'/')).getTime(),single = 24 * 60 * 60 *1000,dates=[];
|
|
for(let i=0;i<7;i++){
|
|
let item = new Date(today+i * single);
|
|
let name = util.formatDate(item).substr(5,5);
|
|
if(i==0){
|
|
name="今天 "+name
|
|
}
|
|
else if(i==1){
|
|
name="明天 "+name
|
|
}
|
|
else if(i==2){
|
|
name="后天 "+name
|
|
}
|
|
dates.push({
|
|
date:util.formatDate(item),
|
|
name:name
|
|
})
|
|
}
|
|
this.setData({
|
|
dates:dates
|
|
})
|
|
console.log(dates)
|
|
},
|
|
changeDate:function(e){
|
|
this.setData({
|
|
dateIndex:e.currentTarget.dataset.index,
|
|
list:[]
|
|
})
|
|
this.getList()
|
|
},
|
|
getList:function(){
|
|
commonApi._post("Cinema/getScheduleListByCinemaId",{
|
|
cinema_id:this.data.id,
|
|
show_date:this.data.dates[this.data.dateIndex].date,
|
|
show_id:this.data.movie[this.data.currentNum].show_id
|
|
}).then(res=>{
|
|
res.data.schedule_list.map(item=>{
|
|
item.show_time = item.show_time?(item.show_time.split(" ")[1].substr(0,5)):"";
|
|
item.close_time = item.close_time?(item.close_time.split(" ")[1].substr(0,5)):"";
|
|
|
|
})
|
|
this.setData({
|
|
list:res.data.schedule_list,
|
|
name:res.data.cinema_name
|
|
})
|
|
console.log(res)
|
|
})
|
|
},
|
|
selectMovieSeat(e){
|
|
let info = e.currentTarget.dataset.info
|
|
const areaInfo = JSON.parse(info.schedule_area).map(item => ({...item, price:item.areaPrice,areaId:item.seatAreaId}));
|
|
let planData = {
|
|
areaInfo,
|
|
fee:info.service_fee,
|
|
movieName: this.data.movie[this.data.currentNum].title,
|
|
planId : info.schedule_id,
|
|
planTime : info.show_time,
|
|
type:'WECHATXCX',
|
|
remake : ''
|
|
}
|
|
let show_id = info.show_id
|
|
let cinema_id = info.cinema_id
|
|
// let schedule_id = info.schedule_id
|
|
|
|
commonApi._post('Cinema/getProductAndSku',{
|
|
show_id,
|
|
cinema_id,
|
|
}).then(res=>{
|
|
this.setData({
|
|
productInfo:res.data
|
|
})
|
|
app.globalData.product ={
|
|
product:this.data.productInfo,
|
|
info:{
|
|
hallName:this.data.name,
|
|
show_date:info.show_date,
|
|
start_end_time:info.show_time,
|
|
movieName:this.data.movie[this.data.currentNum].title,
|
|
show_version:info.show_version,
|
|
selectSeatInfo:null,
|
|
schedule_id:info.schedule_id
|
|
}
|
|
}
|
|
wx.navigateTo({
|
|
url:"/pages/list/movieticket/list/web/index?planData="+ JSON.stringify(planData),
|
|
})
|
|
})
|
|
// wx.navigateTo({
|
|
// url: '/pages/list/movieticket/list/seats/index?show_id='+show_id+'&cinema_id='+cinema_id+'&schedule_id='+schedule_id+'&planData='+JSON.stringify(planData),
|
|
// })
|
|
},
|
|
onChange:function(e){
|
|
console.log(e)
|
|
this.setData({
|
|
list:[],
|
|
currentNum:e.detail.current
|
|
})
|
|
this.enlarge();
|
|
this.shrink();
|
|
this.getList()
|
|
},
|
|
// 轮播图缩小动画
|
|
shrink(){
|
|
const animationNoSelected = wx.createAnimation({
|
|
duration: 300,
|
|
timingFunction: 'ease'
|
|
})
|
|
animationNoSelected.height('215rpx').width('156rpx').step();
|
|
this.setData({
|
|
animationNoSelected: animationNoSelected.export()
|
|
})
|
|
},
|
|
// 轮播图放大动画
|
|
enlarge(){
|
|
const animationSelected = wx.createAnimation({
|
|
duration: 300,
|
|
timingFunction: 'ease'
|
|
})
|
|
animationSelected.height('253rpx').width('184rpx').step();
|
|
this.setData({
|
|
animationSelected: animationSelected.export()
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
console.log(123123123213);
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|