|
|
|
// pages/chooseArea/chooseArea.js
|
|
|
|
var app = getApp();
|
|
|
|
var WXAPI = require('../../utils/server.js');
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
searchKey: '',
|
|
|
|
city_list: {},
|
|
|
|
area_list: [],
|
|
|
|
choose_area: [],
|
|
|
|
seeAreaFlag: false,
|
|
|
|
filterKey: '',
|
|
|
|
level: 0,
|
|
|
|
region: '',
|
|
|
|
GroupID: 111,
|
|
|
|
titleKey: 'A',
|
|
|
|
scrollKey: 'A',
|
|
|
|
},
|
|
|
|
getLocation(groupID) {
|
|
|
|
var that = this;
|
|
|
|
var groupID = groupID
|
|
|
|
if (!groupID) {
|
|
|
|
groupID = that.data.GroupID
|
|
|
|
}
|
|
|
|
WXAPI.getLocation({
|
|
|
|
accessId: app.globalData.accessId,
|
|
|
|
GroupID: groupID
|
|
|
|
}).then(res => {
|
|
|
|
if (res.code == 200) {
|
|
|
|
var data = res.data
|
|
|
|
that.setData({
|
|
|
|
city_list: data.list,
|
|
|
|
area_list: data.xian,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
seeAreaClick(){
|
|
|
|
var that = this;
|
|
|
|
that.setData({
|
|
|
|
seeAreaFlag: !that.data.seeAreaFlag
|
|
|
|
})
|
|
|
|
},
|
|
|
|
searchInput: function(e) {
|
|
|
|
this.setData({
|
|
|
|
searchKey: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
cleardata() {
|
|
|
|
console.log('1111')
|
|
|
|
this.setData({
|
|
|
|
searchKey: ''
|
|
|
|
})
|
|
|
|
},
|
|
|
|
search() {
|
|
|
|
var that = this;
|
|
|
|
var result_list = []
|
|
|
|
var city_list = that.data.city_list
|
|
|
|
for (var i = 0; i < city_list.length; i++) {
|
|
|
|
city_list[i].filter(item=>{
|
|
|
|
if(item.G_CName.includes(that.data.searchKey)) {
|
|
|
|
result_list.push(item)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
that.setData({
|
|
|
|
filterKey: that.data.searchKey,
|
|
|
|
city_list: result_list
|
|
|
|
})
|
|
|
|
},
|
|
|
|
changeTitle(e){
|
|
|
|
var that = this;
|
|
|
|
that.setData({
|
|
|
|
titleKey: e.currentTarget.dataset.key,
|
|
|
|
scrollKey: e.currentTarget.dataset.key,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
clickArea(e){
|
|
|
|
var that = this;
|
|
|
|
var data = e.currentTarget.dataset
|
|
|
|
// var choose_area = []
|
|
|
|
// that.setData({
|
|
|
|
// choose_area: choose_area.splice(0,1,data.item),
|
|
|
|
// GroupID: data.item.GroupID
|
|
|
|
// })
|
|
|
|
// that.data.choose_area = choose_area.splice(0,1,data.item)
|
|
|
|
var region = {
|
|
|
|
city: data.item.G_CName,
|
|
|
|
city_GroupID: data.item.GroupID,
|
|
|
|
// district: that.data.choose_area[1].G_CName,
|
|
|
|
// district_GroupID: that.data.choose_area[1].GroupID,
|
|
|
|
}
|
|
|
|
wx.setStorageSync('region',region)
|
|
|
|
// that.getLocation(that.data.choose_area[1].GroupID)
|
|
|
|
wx.navigateBack()
|
|
|
|
},
|
|
|
|
contentScroll(e){
|
|
|
|
var offset = e.detail.scrollTop;
|
|
|
|
var lineHeight;
|
|
|
|
var that = this;
|
|
|
|
var cityarr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Y', 'Z']
|
|
|
|
var city_list = that.data.city_list
|
|
|
|
// for (var i in cityarr) {
|
|
|
|
// lineHeight = city_list[cityarr[i]].length*40;
|
|
|
|
// }
|
|
|
|
var index = parseInt(offset / 660);
|
|
|
|
that.setData({
|
|
|
|
titleKey: cityarr[index]
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
var that = this;
|
|
|
|
var region = wx.getStorageSync('region')
|
|
|
|
that.setData({
|
|
|
|
region: region,
|
|
|
|
})
|
|
|
|
that.getLocation(region.city_GroupID)
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|