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.
231 lines
4.6 KiB
231 lines
4.6 KiB
// pages/list/movieticket/index.js
|
|
import commonApi from "../../../utils/https/common"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
type:1,
|
|
areas:[],
|
|
areaIndex:0,
|
|
sort:'distance',
|
|
lat:null,
|
|
lon:null,
|
|
page:1,
|
|
isMore:true,
|
|
list:[],
|
|
keyword:"",
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
commonApi._post("act/get_suzhou_areas_syt").then(res=>{
|
|
res.data.unshift({
|
|
area_id:"",
|
|
area_title:"苏州"
|
|
})
|
|
if(options.area_id){
|
|
let index = res.data.findIndex(item=>item.area_id==options.area_id);
|
|
this.setData({
|
|
areaIndex:index==-1?0:index
|
|
})
|
|
}
|
|
this.setData({
|
|
areas:res.data
|
|
})
|
|
})
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success:(res)=>{
|
|
this.setData({
|
|
lat:res.latitude,
|
|
lon:res.longitude
|
|
})
|
|
this.getList()
|
|
},
|
|
fail:()=>{
|
|
this.getList()
|
|
}
|
|
})
|
|
},
|
|
changeArea:function(e){
|
|
this.setData({
|
|
areaIndex:e.detail.value,
|
|
list:[],
|
|
page:1,
|
|
isMore:true
|
|
})
|
|
this.getList()
|
|
},
|
|
changeSort:function(e){
|
|
let sort = e.currentTarget.dataset.sort;
|
|
this.setData({
|
|
sort:sort==this.data.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()
|
|
}
|
|
|
|
},
|
|
// gotoDetail:function(e){
|
|
// let item = e.currentTarget.dataset.item;
|
|
// wx.navigateTo({
|
|
// url: 'info/ticket/index?id='+item.third_id+"&title="+item.title
|
|
// })
|
|
// },
|
|
inputKeyword:function(e){
|
|
this.setData({
|
|
keyword:e.detail.value
|
|
})
|
|
},
|
|
search:function(){
|
|
if(!this.data.keyword) {
|
|
// wx.showToast({
|
|
// title: '请输入关键字',
|
|
// icon:'none'
|
|
// })
|
|
// return;
|
|
}
|
|
this.setData({
|
|
page:1,
|
|
list:[],
|
|
isMore:true
|
|
})
|
|
this.getList()
|
|
// wx.navigateTo({
|
|
// url: 'list/index?keyword='+this.data.keyword,
|
|
// })
|
|
},
|
|
gotoDetail1:function(e){
|
|
let item = e.currentTarget.dataset.item;
|
|
wx.navigateTo({
|
|
url: 'list/ticket/index?id='+item.third_id+"&title="+item.title
|
|
})
|
|
},
|
|
gotoDetail2:function(e){
|
|
let item = e.currentTarget.dataset.item;
|
|
wx.navigateTo({
|
|
url: 'list/cinema/index?id='+item.third_id
|
|
})
|
|
},
|
|
changeType:function(e){
|
|
this.setData({
|
|
keyword:'',
|
|
type:e.currentTarget.dataset.type,
|
|
list:[],
|
|
page:1,
|
|
isMore:true
|
|
})
|
|
this.getList()
|
|
},
|
|
getList:function(){
|
|
if(!this.data.isMore) return;
|
|
let service = "Cinema/getHotMovieList",type = this.data.type,data={},sort=this.data.sort;
|
|
if(type==2){
|
|
service="Cinema/getCinemaList";
|
|
data = {
|
|
city_code:this.data.areas[this.data.areaIndex].area_id,
|
|
lat:this.data.lat,
|
|
lon:this.data.lon,
|
|
is_price_sort:sort=='price',
|
|
is_distance_sort:sort=='distance'
|
|
}
|
|
}
|
|
if(type==3){
|
|
service="Cinema/getSoonShowsList";
|
|
}
|
|
data.page = this.data.page;
|
|
data.pageSize = 10;
|
|
data.title = this.data.keyword
|
|
commonApi._post(service,data).then(res=>{
|
|
console.log(res)
|
|
res.data.map(item=>{
|
|
if(item.distance>1000){
|
|
item.distanceText = (item.distance/1000).toFixed(2) + 'km';
|
|
}
|
|
else if(item.distance){
|
|
item.distanceText = (item.distance).toFixed(2) + 'm';
|
|
}
|
|
})
|
|
this.setData({
|
|
list:this.data.list.concat(res.data),
|
|
page:this.data.page+1
|
|
})
|
|
if(res.data.length<10){
|
|
this.setData({
|
|
isMore:false
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.getList()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|