269 lines
5.8 KiB
JavaScript
269 lines
5.8 KiB
JavaScript
|
// pages/list/list.js
|
||
|
const app = getApp()
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
categoryName: '',
|
||
|
categoryId: '',
|
||
|
venueList: [],
|
||
|
showSelect: false,
|
||
|
selectType: 1,
|
||
|
latitude: '',
|
||
|
longitude: '',
|
||
|
cityName: '',
|
||
|
cityId: '',
|
||
|
areaName: '',
|
||
|
areaId: '',
|
||
|
adcode: '',
|
||
|
district: '',
|
||
|
selectList: [],
|
||
|
chargeName: '场馆类型',
|
||
|
venueCharge: '',
|
||
|
token: '',
|
||
|
requestIp: ''
|
||
|
},
|
||
|
checkall: function () {
|
||
|
if(this.data.selectType == 1){
|
||
|
this.setData({
|
||
|
areaId: '',
|
||
|
areaName: ''
|
||
|
})
|
||
|
} else if (this.data.selectType == 2){
|
||
|
this.setData({
|
||
|
categoryName: '体育项目',
|
||
|
categoryId: ''
|
||
|
})
|
||
|
} else {
|
||
|
this.setData({
|
||
|
chargeName: '场馆类型',
|
||
|
venueCharge: ''
|
||
|
})
|
||
|
}
|
||
|
this.getList()
|
||
|
},
|
||
|
doSelcet: function (e) {
|
||
|
var self = this
|
||
|
var type = e.currentTarget.dataset.id
|
||
|
this.setData({
|
||
|
showSelect: true,
|
||
|
selectType: e.currentTarget.dataset.id
|
||
|
})
|
||
|
if(type == 1){
|
||
|
self.getAreaList()
|
||
|
}else if(type == 2){
|
||
|
self.getProjectList()
|
||
|
}else{
|
||
|
self.getTypeList()
|
||
|
}
|
||
|
},
|
||
|
hideSelect: function () {
|
||
|
this.setData({
|
||
|
showSelect: false
|
||
|
})
|
||
|
},
|
||
|
getNewList: function (e) {
|
||
|
var self = this
|
||
|
if (self.data.selectType == 1){
|
||
|
self.setData({
|
||
|
showSelect: false,
|
||
|
areaName: e.currentTarget.dataset.name,
|
||
|
areaId: e.currentTarget.dataset.id
|
||
|
})
|
||
|
} else if (self.data.selectType == 2){
|
||
|
self.setData({
|
||
|
categoryId: e.currentTarget.dataset.id,
|
||
|
categoryName: e.currentTarget.dataset.name
|
||
|
})
|
||
|
} else {
|
||
|
self.setData({
|
||
|
chargeName: e.currentTarget.dataset.name,
|
||
|
venueCharge: e.currentTarget.dataset.id
|
||
|
})
|
||
|
}
|
||
|
self.getList()
|
||
|
},
|
||
|
goDetail: function (event) {
|
||
|
wx.navigateTo({
|
||
|
url: '../detail/detail?venuesInfoId=' + event.currentTarget.dataset.id,
|
||
|
})
|
||
|
},
|
||
|
getAreaId: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/getcityinfobyname',
|
||
|
data: {
|
||
|
cityName: self.data.cityName
|
||
|
},
|
||
|
header: {
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
cityId: res.data.dictionaryId
|
||
|
})
|
||
|
self.getList()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getList: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/listvenuesbykeywords',
|
||
|
data: {
|
||
|
categoryId: self.data.categoryId,
|
||
|
cityName: self.data.cityName,
|
||
|
cityId: 'fbd845d6-a74b-457a-8da1-fec66ab0d400',
|
||
|
adcode: self.data.adcode,
|
||
|
district: self.data.district,
|
||
|
areaId: self.data.areaId,
|
||
|
venueCharge: self.data.venueCharge
|
||
|
},
|
||
|
header: {
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
venueList: res.data.data,
|
||
|
showSelect: false
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getPosition: function () {
|
||
|
var self = this
|
||
|
wx.getLocation({
|
||
|
success: function(res) {
|
||
|
const latitude = res.latitude
|
||
|
const longitude = res.longitude
|
||
|
wx.request({
|
||
|
url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=Zk732rbyjd327q7Zj9EOtRjUn2ED1GWK&output=json&coordtype=wgs84ll&location=' + latitude + ',' + longitude,
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
cityName: res.data.result.addressComponent.city,
|
||
|
adcode: res.data.result.addressComponent.adcode,
|
||
|
district: res.data.result.addressComponent.district
|
||
|
})
|
||
|
self.getAreaId()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
getAreaList: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/getcityareabyid/' + self.data.cityId,
|
||
|
header: {
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
selectList: res.data.areaList
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getProjectList: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/listvenuesproject',
|
||
|
header: {
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
success: function (res) {
|
||
|
if (res.statusCode == 200) {
|
||
|
self.setData({
|
||
|
selectList: res.data.list
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getTypeList: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/listvenuechargetype',
|
||
|
header: {
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
selectList: res.data.chargeType
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getToken: function () {
|
||
|
var self = this
|
||
|
wx.getStorage({
|
||
|
key: 'token',
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
token: res.data
|
||
|
})
|
||
|
self.getPosition()
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.setData({
|
||
|
categoryId: options.categoryId,
|
||
|
categoryName: options.categoryName,
|
||
|
requestIp: app.globalData.requestIp
|
||
|
})
|
||
|
this.getToken()
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
}
|
||
|
})
|