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.
255 lines
5.7 KiB
255 lines
5.7 KiB
// pages/list/movieticket/list/ticket/index.js
|
|
let app = getApp()
|
|
import commonApi from "../../../../../utils/https/common"
|
|
import util from "../../../../../utils/util"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
id:null,
|
|
dates:[],
|
|
days:['周日','周一','周二','周三','周四','周五','周六'],
|
|
dateIndex:0,
|
|
areas:[],
|
|
areaIndex:0,
|
|
lat:"",
|
|
lon:"",
|
|
sort:null,
|
|
list:[],
|
|
title:"",
|
|
page:1,
|
|
isMore:true
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
pagePoint(e) {
|
|
util.pagePoint(e)
|
|
},
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
id:options.id,
|
|
title:options.title
|
|
})
|
|
commonApi._post("act/get_suzhou_areas").then(res=>{
|
|
res.data.unshift({
|
|
area_id:"",
|
|
area_title:"苏州"
|
|
})
|
|
this.setData({
|
|
areas:res.data
|
|
})
|
|
})
|
|
this.initDate();
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success:(res)=>{
|
|
this.setData({
|
|
lat:res.latitude,
|
|
lon:res.longitude
|
|
})
|
|
this.getList()
|
|
},
|
|
fail:()=>{
|
|
this.getList()
|
|
}
|
|
})
|
|
},
|
|
changeSort:function(e){
|
|
let sort = e.currentTarget.dataset.sort;
|
|
this.setData({
|
|
sort:this.data.sort==sort?null:sort,
|
|
list:[],
|
|
page:1,
|
|
isMore:true
|
|
})
|
|
if(this.data.sort=='distance' && !this.data.lon){
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success:(res)=>{
|
|
this.setData({
|
|
lat:res.latitude,
|
|
lon:res.longitude
|
|
})
|
|
this.getList()
|
|
},
|
|
fail:()=>{
|
|
this.getList()
|
|
}
|
|
})
|
|
}
|
|
else {
|
|
this.getList()
|
|
}
|
|
|
|
},
|
|
changeDateIndex:function(e){
|
|
this.setData({
|
|
dateIndex:e.currentTarget.dataset.index,
|
|
list:[],
|
|
page:1,
|
|
isMore:true
|
|
})
|
|
this.getList()
|
|
},
|
|
changeArea:function(e){
|
|
this.setData({
|
|
areaIndex:e.detail.value,
|
|
list:[],
|
|
page:1,
|
|
isMore:true
|
|
})
|
|
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 = this.data.days[item.getDay()]
|
|
if(i==0){
|
|
name="今天"
|
|
}
|
|
else if(i==1){
|
|
name="明天"
|
|
}
|
|
dates.push({
|
|
date:util.formatDate(item),
|
|
dateShort:util.formatDate(item).substr(5,5),
|
|
name:name
|
|
})
|
|
}
|
|
this.setData({
|
|
dates:dates
|
|
})
|
|
console.log(dates)
|
|
},
|
|
getList:function(){
|
|
if(!this.data.isMore) return
|
|
commonApi._post("Cinema/getCinemaListByShowId",{
|
|
third_id:this.data.id,
|
|
show_date:this.data.dates[this.data.dateIndex].date,
|
|
city_code:this.data.areas[this.data.areaIndex]?this.data.areas[this.data.areaIndex].area_id:"",
|
|
lon:this.data.lon,
|
|
lat:this.data.lat,
|
|
is_price_sort:this.data.sort=='price'?true:false,
|
|
is_distance_sort:this.data.sort=='distance',
|
|
page:this.data.page,
|
|
pageSize:10
|
|
}).then(res=>{
|
|
res.data.map(item=>{
|
|
if(item.distance>1000){
|
|
item.distanceText = (item.distance/1000).toFixed(2) + 'km';
|
|
}
|
|
else if(item.distance>0){
|
|
item.distanceText = (item.distance).toFixed(2) + 'm';
|
|
}
|
|
})
|
|
let list = this.data.list;
|
|
this.setData({
|
|
list:list.concat(res.data),
|
|
page:this.data.page+1
|
|
})
|
|
if(res.data.length<10){
|
|
this.setData({
|
|
isMore:false
|
|
})
|
|
}
|
|
console.log(res)
|
|
})
|
|
},
|
|
selectMovieSeat(e){
|
|
let info = e.currentTarget.dataset.info
|
|
let index = e.currentTarget.dataset.index
|
|
console.log(index);
|
|
console.log(info.schedules);
|
|
const areaInfo = JSON.parse(info.schedules[index].schedule_area).map(item => ({...item, price:item.areaPrice,areaId:item.seatAreaId}));
|
|
let planData = {
|
|
areaInfo,
|
|
fee:info.schedules[index].service_fee,
|
|
movieName: this.data.title,
|
|
planId : info.schedules[index].schedule_id,
|
|
planTime : info.schedules[index].show_time,
|
|
type:'WECHATXCX',
|
|
remake : ''
|
|
}
|
|
let show_id = info.schedules[index].show_id
|
|
let cinema_id = info.schedules[index].cinema_id
|
|
// let schedule_id = info.schedule_id
|
|
console.log(info);
|
|
commonApi._post('Cinema/getProductAndSku',{
|
|
show_id,
|
|
cinema_id,
|
|
}).then(res=>{
|
|
app.globalData.product ={
|
|
product:res.data,
|
|
info:{
|
|
hallName:info.schedules[index].hall_name,
|
|
cinemaName:info.title,
|
|
show_date:info.schedules[index].show_date,
|
|
show_time:info.schedules[index].show_time,
|
|
close_time:info.schedules[index].close_time,
|
|
movieName:this.data.title,
|
|
start_end_time:info.schedules[index].show_time,
|
|
show_version:info.schedules[index].show_version,
|
|
selectSeatInfo:null,
|
|
schedule_id:info.schedules[index].schedule_id
|
|
}
|
|
}
|
|
console.log(planData);
|
|
wx.navigateTo({
|
|
url:"/pages/list/movieticket/list/web/index?planData="+ JSON.stringify(planData),
|
|
})
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.getList()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|