|
|
|
@ -8,19 +8,21 @@ Page({ |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
id:null, |
|
|
|
dates:[], |
|
|
|
days:['周日','周一','周二','周三','周四','周五','周六'], |
|
|
|
dateIndex:0, |
|
|
|
areas:[], |
|
|
|
areaIndex:0, |
|
|
|
lat:"", |
|
|
|
lon:"", |
|
|
|
sort:'distance', |
|
|
|
list:[], |
|
|
|
title:"", |
|
|
|
page:1, |
|
|
|
isMore:true |
|
|
|
id: null, |
|
|
|
dates: [], |
|
|
|
days: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], |
|
|
|
dateIndex: 0, |
|
|
|
areas: [], |
|
|
|
areaIndex: 0, |
|
|
|
lat: "", |
|
|
|
lon: "", |
|
|
|
sort: 'distance', |
|
|
|
list: [], |
|
|
|
title: "", |
|
|
|
page: 1, |
|
|
|
isMore: true, |
|
|
|
showQrCode: false, |
|
|
|
wxqrcode: null |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -31,178 +33,193 @@ Page({ |
|
|
|
}, |
|
|
|
onLoad: function (options) { |
|
|
|
this.setData({ |
|
|
|
id:options.id, |
|
|
|
title:options.title |
|
|
|
id: options.id, |
|
|
|
title: options.title |
|
|
|
}) |
|
|
|
commonApi._post("act/get_suzhou_areas").then(res=>{ |
|
|
|
commonApi._post("act/get_suzhou_areas").then(res => { |
|
|
|
res.data.unshift({ |
|
|
|
area_id:"", |
|
|
|
area_title:"苏州" |
|
|
|
area_id: "", |
|
|
|
area_title: "苏州" |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
areas:res.data |
|
|
|
areas: res.data |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.initDate(); |
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success:(res)=>{ |
|
|
|
success: (res) => { |
|
|
|
this.setData({ |
|
|
|
lat:res.latitude, |
|
|
|
lon:res.longitude |
|
|
|
lat: res.latitude, |
|
|
|
lon: res.longitude |
|
|
|
}) |
|
|
|
this.getList() |
|
|
|
}, |
|
|
|
fail:()=>{ |
|
|
|
fail: () => { |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
changeSort:function(e){ |
|
|
|
changeSort: function (e) { |
|
|
|
let sort = e.currentTarget.dataset.sort; |
|
|
|
this.setData({ |
|
|
|
sort:this.data.sort==sort?null:sort, |
|
|
|
list:[], |
|
|
|
page:1, |
|
|
|
isMore:true |
|
|
|
sort: this.data.sort == sort ? null : sort, |
|
|
|
list: [], |
|
|
|
page: 1, |
|
|
|
isMore: true |
|
|
|
}) |
|
|
|
if(this.data.sort=='distance' && !this.data.lon){ |
|
|
|
if (this.data.sort == 'distance' && !this.data.lon) { |
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success:(res)=>{ |
|
|
|
success: (res) => { |
|
|
|
this.setData({ |
|
|
|
lat:res.latitude, |
|
|
|
lon:res.longitude |
|
|
|
lat: res.latitude, |
|
|
|
lon: res.longitude |
|
|
|
}) |
|
|
|
this.getList() |
|
|
|
}, |
|
|
|
fail:()=>{ |
|
|
|
fail: () => { |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
changeDateIndex:function(e){ |
|
|
|
changeDateIndex: function (e) { |
|
|
|
this.setData({ |
|
|
|
dateIndex:e.currentTarget.dataset.index, |
|
|
|
list:[], |
|
|
|
page:1, |
|
|
|
isMore:true |
|
|
|
dateIndex: e.currentTarget.dataset.index, |
|
|
|
list: [], |
|
|
|
page: 1, |
|
|
|
isMore: true |
|
|
|
}) |
|
|
|
this.getList() |
|
|
|
}, |
|
|
|
changeArea:function(e){ |
|
|
|
changeArea: function (e) { |
|
|
|
this.setData({ |
|
|
|
areaIndex:e.detail.value, |
|
|
|
list:[], |
|
|
|
page:1, |
|
|
|
isMore:true |
|
|
|
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); |
|
|
|
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="明天" |
|
|
|
if (i == 0) { |
|
|
|
name = "今天" |
|
|
|
} else if (i == 1) { |
|
|
|
name = "明天" |
|
|
|
} |
|
|
|
dates.push({ |
|
|
|
date:util.formatDate(item), |
|
|
|
dateShort:util.formatDate(item).substr(5,5), |
|
|
|
name:name |
|
|
|
date: util.formatDate(item), |
|
|
|
dateShort: util.formatDate(item).substr(5, 5), |
|
|
|
name: name |
|
|
|
}) |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
dates:dates |
|
|
|
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){ |
|
|
|
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 |
|
|
|
list: list.concat(res.data), |
|
|
|
page: this.data.page + 1 |
|
|
|
}) |
|
|
|
if(res.data.length<10){ |
|
|
|
if (res.data.length < 10) { |
|
|
|
this.setData({ |
|
|
|
isMore:false |
|
|
|
isMore: false |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(res) |
|
|
|
}) |
|
|
|
}, |
|
|
|
selectMovieSeat(e){ |
|
|
|
selectMovieSeat(e) { |
|
|
|
commonApi.user_post('wx/get_user_keep', { |
|
|
|
jumpurl: '/pages/list/movieticket/list/ticket/index?id=' + this.data.id, |
|
|
|
title: this.data.title, |
|
|
|
type: 'mini' |
|
|
|
}).then(res => { |
|
|
|
if (res.data.subscribe == 0) { |
|
|
|
this.setData({ |
|
|
|
wxqrcode: res.data.qrcode, |
|
|
|
showQrCode: true |
|
|
|
}) |
|
|
|
} else { |
|
|
|
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})); |
|
|
|
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, |
|
|
|
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 : '' |
|
|
|
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',{ |
|
|
|
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 |
|
|
|
}).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), |
|
|
|
url: "/pages/list/movieticket/list/web/index?planData=" + JSON.stringify(planData), |
|
|
|
}) |
|
|
|
}) |
|
|
|
}}) |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
|
|