...
|
...
|
@@ -45,75 +45,6 @@ Page({ |
|
|
// Do something when catch error
|
|
|
}
|
|
|
},
|
|
|
//获取国内城市列表
|
|
|
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,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//获取国外名
|
|
|
getAbroadList() {
|
|
|
const self = this;
|
|
|
let url = '/portal/Index/addr';
|
|
|
let params = {
|
|
|
token: wx.getStorageSync('token'),
|
|
|
};
|
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('获取国外列表', res);
|
|
|
if (+res.code === 1) {
|
|
|
const arr = [];
|
|
|
res.data.list.forEach((item) => {
|
|
|
arr.push(item.title)
|
|
|
});
|
|
|
self.setData({
|
|
|
Abroad_city_picker_list: arr,
|
|
|
AbroadCityList:res.data.list,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
chooseCity() {
|
|
|
this.setData({is_show_city:!this.data.is_show_city})
|
|
|
},
|
|
|
chooseDomesticCity(e) {
|
|
|
this.setData({is_show_city:false});
|
|
|
},
|
|
|
chooseAbroadCity(e) {
|
|
|
this.setData({
|
|
|
current_city: e.detail.value,
|
|
|
is_city_change: true,
|
|
|
is_show_city:false
|
|
|
});
|
|
|
const lat = this.data.cityList[e.detail.value].latng.split(',')[1];
|
|
|
const lng = this.data.cityList[e.detail.value].latng.split(',')[0];
|
|
|
this.setData({lat: lat, lng: lng,addr:this.data.cityList[e.detail.value].title});
|
|
|
// console.log('lat', 'lng',lat,lng);
|
|
|
this.getIndex();
|
|
|
},
|
|
|
//切换城市
|
|
|
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({lat: lat, lng: lng,addr:this.data.cityList[e.detail.value].title});
|
|
|
// console.log('lat', 'lng',lat,lng);
|
|
|
this.getIndex();
|
|
|
},
|
|
|
swiperChange(e) {
|
|
|
this.setData({current_swiper: e.detail.current})
|
|
|
},
|
...
|
...
|
@@ -176,7 +107,8 @@ Page({ |
|
|
let city = null;
|
|
|
if(this.data.is_city_change) {
|
|
|
city = JSON.stringify({
|
|
|
name:this.data.cityList[this.data.current_city].title,
|
|
|
// name:this.data.cityList[this.data.current_city].title,
|
|
|
name:this.data.addr,
|
|
|
lat: this.data.lat,
|
|
|
lng: this.data.lng,
|
|
|
})
|
...
|
...
|
@@ -344,9 +276,94 @@ Page({ |
|
|
})
|
|
|
}
|
|
|
},
|
|
|
//获取国内城市列表
|
|
|
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,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//获取国外名
|
|
|
getAbroadList() {
|
|
|
const self = this;
|
|
|
let url = '/portal/Index/addr';
|
|
|
let params = {
|
|
|
token: wx.getStorageSync('token'),
|
|
|
};
|
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('获取国外列表', res);
|
|
|
if (+res.code === 1) {
|
|
|
const arr = [];
|
|
|
res.data.forEach((item) => {
|
|
|
arr.push(item.title)
|
|
|
});
|
|
|
self.setData({
|
|
|
Abroad_city_picker_list: arr,
|
|
|
AbroadCityList:res.data,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//打开城市列表
|
|
|
chooseCity() {
|
|
|
// this.setData({is_show_city:!this.data.is_show_city})
|
|
|
wx.navigateTo({url:'/pages/index/city-list/city-list'})
|
|
|
},
|
|
|
//选择国内城市
|
|
|
chooseDomesticCity(e) {
|
|
|
const current = e.currentTarget.dataset.index;
|
|
|
wx.showLoading({title:'加载中',mask:true});
|
|
|
this.setData({is_show_city:false});
|
|
|
const lat = this.data.cityList[current].latng.split(',')[1];
|
|
|
const lng = this.data.cityList[current].latng.split(',')[0];
|
|
|
this.setData({lat: lat, lng: lng,addr:this.data.cityList[current].title});
|
|
|
// console.log('lat', 'lng',lat,lng);
|
|
|
this.getIndex();
|
|
|
},
|
|
|
//选择国外城市
|
|
|
chooseAbroadCity(e) {
|
|
|
const current = e.currentTarget.dataset.index;
|
|
|
wx.showLoading({title:'加载中',mask:true});
|
|
|
this.setData({
|
|
|
// current_city: e.detail.value,
|
|
|
is_city_change: true,
|
|
|
is_show_city:false
|
|
|
});
|
|
|
const lat = this.data.AbroadCityList[current].latng.split(',')[1];
|
|
|
const lng = this.data.AbroadCityList[current].latng.split(',')[0];
|
|
|
this.setData({lat: lat, lng: lng,addr:this.data.AbroadCityList[current].title});
|
|
|
console.log('lat', 'lng',lat,lng);
|
|
|
this.getIndex();
|
|
|
},
|
|
|
//切换城市
|
|
|
// 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({lat: lat, lng: lng,addr:this.data.cityList[e.detail.value].title});
|
|
|
// // console.log('lat', 'lng',lat,lng);
|
|
|
// this.getIndex();
|
|
|
// },
|
|
|
//获取经纬度
|
|
|
getLat() {
|
|
|
const self = this;
|
|
|
if(wx.getStorageSync('lat') === '' &&
|
|
|
wx.getStorageSync('lng') === '' &&
|
|
|
wx.getStorageSync('addr') === '') {
|
|
|
wx.getLocation({ //获取当前经纬度
|
|
|
type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
|
|
|
success: function (res) {
|
...
|
...
|
@@ -363,6 +380,7 @@ Page({ |
|
|
// };
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
// wx.setStorageSync('score',30);
|
|
|
console.log('score',wx.getStorageSync('score'));
|
|
|
if(wx.getStorageSync('score') !== '' && wx.getStorageSync('score')>=80) {
|
...
|
...
|
@@ -389,10 +407,11 @@ Page({ |
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('获取首页', res);
|
|
|
if (+res.code === 1) {
|
|
|
wx.hideLoading();
|
|
|
self.setData({
|
|
|
slide: res.data.banner,
|
|
|
cate: res.data.cate,
|
|
|
china_city: res.data.city.city,
|
|
|
city: res.data.city,
|
|
|
noticeList: res.data.extra,
|
|
|
meal_banner: res.data.meal,
|
|
|
items: res.data.active,
|
...
|
...
|
@@ -428,14 +447,26 @@ Page({ |
|
|
})
|
|
|
},
|
|
|
onLoad: function () {
|
|
|
this.getCityList();
|
|
|
this.getAbroadList();
|
|
|
// this.getCityList();
|
|
|
// this.getAbroadList();
|
|
|
this._doRefreshMasonry(this.data.items)
|
|
|
},
|
|
|
onShow() {
|
|
|
if(wx.getStorageSync('isLogin') === true) {
|
|
|
this.getLat();//获取经纬度
|
|
|
}
|
|
|
if(wx.getStorageSync('lat') !== '' &&
|
|
|
wx.getStorageSync('lng') !== '' &&
|
|
|
wx.getStorageSync('addr') !== '') {
|
|
|
console.log('已选择城市');
|
|
|
this.setData({
|
|
|
is_city_change:true,
|
|
|
lat:wx.getStorageSync('lat'),
|
|
|
lng: wx.getStorageSync('lng'),
|
|
|
addr:wx.getStorageSync('addr'),
|
|
|
});
|
|
|
this.getIndex()
|
|
|
}
|
|
|
// wx.chooseLocation({
|
|
|
// success(res) {
|
|
|
// console.log(res);
|
...
|
...
|
|