作者 wumengyu

拼单列表和分类列表页添加国际城市页

... ... @@ -91,8 +91,17 @@ Page({
goTypeDetail(e) {
const id = +e.currentTarget.dataset.id;
const name = e.currentTarget.dataset.name;
let city = null;
if(this.data.is_city_change) {
city = JSON.stringify({
// name:this.data.cityList[this.data.current_city].title,
name:this.data.addr,
lat: this.data.lat,
lng: this.data.lng,
})
}
wx.navigateTo({
url: '/pages/index/type-detail/type-detail?id=' + id + '&name=' + name,
url: '/pages/index/type-detail/type-detail?id=' + id + '&name=' + name + '&city=' + city,
})
},
//进入号外公告详情
... ...
... ... @@ -11,7 +11,7 @@
<!--<view class="iconfont icon-arrow-down"></view>-->
<!--</view>-->
<!--</picker>-->
<view class="picker" bindtap="chooseCity" value="{{current_city}}" range="{{city_picker_list}}"
<view class="picker" bindtap="chooseCity"
class="picker">
<view class="left">
<view class="iconfont icon-location"></view>
... ...
... ... @@ -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();
},
/**
... ...
... ... @@ -2,13 +2,21 @@
<view class="fix-box">
<view class="head">
<view class="position">
<picker class="picker" bindchange="cityPickerChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">
<!--<picker class="picker" bindchange="cityPickerChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">-->
<!--<view class="left">-->
<!--<view class="iconfont icon-location"></view>-->
<!--<text>{{city_picker_list[current_city] || city}}</text>-->
<!--<view class="iconfont icon-arrow-down"></view>-->
<!--</view>-->
<!--</picker>-->
<view class="picker" bindtap="chooseCity"
class="picker">
<view class="left">
<view class="iconfont icon-location"></view>
<text>{{city_picker_list[current_city] || city}}</text>
<text>{{addr}}</text>
<view class="iconfont icon-arrow-down"></view>
</view>
</picker>
</view>
<view class="right" bindtap="search">
<view class="input"></view>
<image src="../../../images/search@2x.png"></image>
... ...
... ... @@ -57,35 +57,35 @@ 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,
});
}
})
},
// //获取城市列表
// 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});
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});
// this.getTypeList();
// },
//是否填写个人信息
getIsWrite() {
const self = this;
... ... @@ -388,9 +388,9 @@ Page({
console.log('拼活动');
}
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,// 浮点型 非必填 - - 筛选开始时间
... ... @@ -414,6 +414,11 @@ Page({
})
},
//打开城市列表页面
chooseCity() {
// this.setData({is_show_city:!this.data.is_show_city})
wx.navigateTo({url:'/pages/index/city-list/city-list'})
},
getCity() {
const self = this;
let url = '/portal/Index/findCity';
... ... @@ -428,7 +433,7 @@ Page({
console.log('获取城市', res);
if (+res.code === 1) {
self.setData({
city: res.data.city.city,
addr: res.data.city.city,
});
self.getTypeList();
}
... ... @@ -437,15 +442,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();
}
})
}
},
/**
* 生命周期函数--监听页面加载
... ... @@ -469,7 +478,19 @@ Page({
const self = this;
self.getLocation();
self.getIsWrite();
self.getCityList();
// 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();
}
},
/**
... ...
... ... @@ -2,13 +2,21 @@
<view class="fix-box">
<view class="head">
<view class="position">
<picker class="picker" bindchange="cityPickerChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">
<!--<picker class="picker" bindchange="cityPickerChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">-->
<!--<view class="left">-->
<!--<view class="iconfont icon-location"></view>-->
<!--<text>{{city_picker_list[current_city] || city}}</text>-->
<!--<view class="iconfont icon-arrow-down"></view>-->
<!--</view>-->
<!--</picker>-->
<view class="picker" bindtap="chooseCity"
class="picker">
<view class="left">
<view class="iconfont icon-location"></view>
<text>{{city_picker_list[current_city] || city}}</text>
<text>{{addr}}</text>
<view class="iconfont icon-arrow-down"></view>
</view>
</picker>
</view>
<view class="right" bindtap="search">
<view class="input"></view>
<image src="../../images/search@2x.png"></image>
... ...