...
|
...
|
@@ -23,36 +23,41 @@ Page({ |
|
|
cityList: [],
|
|
|
addr:'', //切换地址
|
|
|
},
|
|
|
//获取城市列表
|
|
|
getCityList() {
|
|
|
const self = this;
|
|
|
let url = '/portal/Index/cityList';
|
|
|
app.post(url, {}, {}).then((res) => {
|
|
|
console.log('获取城市列表', res);
|
|
|
if (+res.code === 1) {
|
|
|
const arr = [];
|
|
|
res.data.list.forEach((item) => {
|
|
|
arr.push(item.title)
|
|
|
});
|
|
|
self.setData({
|
|
|
city_picker_list: arr,
|
|
|
cityList:res.data.list,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
//打开城市列表页面
|
|
|
chooseCity() {
|
|
|
// this.setData({is_show_city:!this.data.is_show_city})
|
|
|
wx.navigateTo({url:'/pages/index/city-list/city-list'})
|
|
|
},
|
|
|
//获取城市列表
|
|
|
// getCityList() {
|
|
|
// const self = this;
|
|
|
// let url = '/portal/Index/cityList';
|
|
|
// app.post(url, {}, {}).then((res) => {
|
|
|
// console.log('获取城市列表', res);
|
|
|
// if (+res.code === 1) {
|
|
|
// const arr = [];
|
|
|
// res.data.list.forEach((item) => {
|
|
|
// arr.push(item.title)
|
|
|
// });
|
|
|
// self.setData({
|
|
|
// city_picker_list: arr,
|
|
|
// cityList:res.data.list,
|
|
|
// });
|
|
|
// }
|
|
|
// })
|
|
|
// },
|
|
|
//切换城市
|
|
|
cityPickerChange(e) {
|
|
|
this.setData({
|
|
|
current_city: e.detail.value,
|
|
|
is_city_change: true
|
|
|
});
|
|
|
const lat = this.data.cityList[e.detail.value].latng.split(',')[1];
|
|
|
const lng = this.data.cityList[e.detail.value].latng.split(',')[0];
|
|
|
this.setData({latitude: lat, longitude: lng,addr:this.data.cityList[e.detail.value].title});
|
|
|
console.log('lat', 'lng',lat,lng);
|
|
|
this.getTypeList();
|
|
|
},
|
|
|
// cityPickerChange(e) {
|
|
|
// this.setData({
|
|
|
// current_city: e.detail.value,
|
|
|
// is_city_change: true
|
|
|
// });
|
|
|
// const lat = this.data.cityList[e.detail.value].latng.split(',')[1];
|
|
|
// const lng = this.data.cityList[e.detail.value].latng.split(',')[0];
|
|
|
// this.setData({latitude: lat, longitude: lng,addr:this.data.cityList[e.detail.value].title});
|
|
|
// console.log('lat', 'lng',lat,lng);
|
|
|
// this.getTypeList();
|
|
|
// },
|
|
|
goPostDetail(e) {
|
|
|
const id = +e.currentTarget.dataset.id;
|
|
|
const type = +e.currentTarget.dataset.type;
|
...
|
...
|
@@ -178,6 +183,11 @@ Page({ |
|
|
console.log('options', options);
|
|
|
this.setData({select_id:+options.id?+options.id:''});
|
|
|
wx.setNavigationBarTitle({title:options.name})
|
|
|
if(options.city !== 'null') {
|
|
|
this.setData({city_params:JSON.parse(options.city)});
|
|
|
console.log('load里的调用');
|
|
|
// this.getTypeList();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -192,9 +202,9 @@ Page({ |
|
|
console.log('city',self.data.city);
|
|
|
let url = '/portal/Index/cate';
|
|
|
let params = {
|
|
|
lat: self.data.latitude,
|
|
|
lng: self.data.longitude,
|
|
|
addr: self.data.is_city_change?self.data.addr:self.data.city, // 浮点型 必填 - - 用户位置名称
|
|
|
lat: wx.getStorageSync('lat') !== ''?self.data.lat:self.data.latitude,
|
|
|
lng: wx.getStorageSync('lng') !== ''?self.data.lng:self.data.longitude,
|
|
|
addr: wx.getStorageSync('addr') !== ''?self.data.addr:self.data.addr,
|
|
|
keyword: '', // 浮点型 非必填 - - 搜索关键字
|
|
|
score: self.data.score, // 浮点型 非必填 - - 排序(1智能排序,2最具人气,3距离最近)
|
|
|
startTime: self.data.start_time_date,// 浮点型 非必填 - - 筛选开始时间
|
...
|
...
|
@@ -232,7 +242,7 @@ Page({ |
|
|
console.log('获取城市', res);
|
|
|
if (+res.code === 1) {
|
|
|
self.setData({
|
|
|
city: res.data.city.city,
|
|
|
addr: res.data.city.city,
|
|
|
});
|
|
|
self.getTypeList();
|
|
|
}
|
...
|
...
|
@@ -241,15 +251,19 @@ Page({ |
|
|
//获取地理位置
|
|
|
getLocation() {
|
|
|
const self = this;
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84',
|
|
|
altitude: 'true',
|
|
|
success(res) {
|
|
|
console.log('获取地理位', res);
|
|
|
self.setData({latitude: res.latitude, longitude: res.longitude});
|
|
|
self.getCity();
|
|
|
}
|
|
|
})
|
|
|
if(wx.getStorageSync('lat') === '' &&
|
|
|
wx.getStorageSync('lng') === '' &&
|
|
|
wx.getStorageSync('addr') === '') {
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84',
|
|
|
altitude: 'true',
|
|
|
success(res) {
|
|
|
console.log('获取地理位', res);
|
|
|
self.setData({latitude: res.latitude, longitude: res.longitude});
|
|
|
self.getCity();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
...
|
...
|
@@ -257,7 +271,19 @@ Page({ |
|
|
onShow: function () {
|
|
|
const self = this;
|
|
|
self.getLocation();
|
|
|
self.getCityList();
|
|
|
if(wx.getStorageSync('lat') !== '' &&
|
|
|
wx.getStorageSync('lng') !== '' &&
|
|
|
wx.getStorageSync('addr') !== '') {
|
|
|
console.log('已选择城市',wx.getStorageSync('lat'),wx.getStorageSync('lng'),wx.getStorageSync('addr'));
|
|
|
self.setData({
|
|
|
is_city_change:true,
|
|
|
lat:wx.getStorageSync('lat'),
|
|
|
lng: wx.getStorageSync('lng'),
|
|
|
addr:wx.getStorageSync('addr'),
|
|
|
});
|
|
|
self.getTypeList();
|
|
|
}
|
|
|
// self.getCityList();
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
|