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.
208 lines
4.2 KiB
208 lines
4.2 KiB
// pages/list/movieticket/list/ticket/index.js
|
|
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
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
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)
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.getList()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|