|
@@ -5,6 +5,11 @@ import {
|
|
|
import states from './json/states'
|
|
import states from './json/states'
|
|
|
import cities from './json/cities'
|
|
import cities from './json/cities'
|
|
|
var wxaSortPicker = require('../../utils/wxaSortPicker/wxaSortPicker.js');
|
|
var wxaSortPicker = require('../../utils/wxaSortPicker/wxaSortPicker.js');
|
|
|
|
|
+import {
|
|
|
|
|
+ saveHistoryCity,
|
|
|
|
|
+ loadHistoryCity,
|
|
|
|
|
+ removeHistoryCity
|
|
|
|
|
+} from "../../utils/storage";
|
|
|
const app = getApp();
|
|
const app = getApp();
|
|
|
const CHINA = {}
|
|
const CHINA = {}
|
|
|
let _animation; // 动画实体
|
|
let _animation; // 动画实体
|
|
@@ -28,12 +33,18 @@ Page({
|
|
|
apl_posArr: [],
|
|
apl_posArr: [],
|
|
|
apl_index: 0,
|
|
apl_index: 0,
|
|
|
b_top: 0,
|
|
b_top: 0,
|
|
|
|
|
+ sliderHeight:0,
|
|
|
|
|
+ historyCity: [],
|
|
|
|
|
+ clientHeight:0
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
this.fetchCityList()
|
|
this.fetchCityList()
|
|
|
this.set_new_alphabet(this.data.all_cities)
|
|
this.set_new_alphabet(this.data.all_cities)
|
|
|
-
|
|
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ city: app.globalData.city,
|
|
|
|
|
+ historyCity: app.globalData.historyCity
|
|
|
|
|
+ })
|
|
|
// var that = this
|
|
// var that = this
|
|
|
//初始化
|
|
//初始化
|
|
|
|
|
|
|
@@ -41,12 +52,20 @@ Page({
|
|
|
// wxaSortPicker.init(this.data.cities, that);
|
|
// wxaSortPicker.init(this.data.cities, that);
|
|
|
},
|
|
},
|
|
|
onReady() {
|
|
onReady() {
|
|
|
-
|
|
|
|
|
|
|
+ wx.getSystemInfo({
|
|
|
|
|
+ success: (res)=> {
|
|
|
|
|
+ // 获取可使用窗口宽度
|
|
|
|
|
+ let clientHeight = res.windowHeight;
|
|
|
|
|
+ // 设置高度
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ clientHeight: clientHeight
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
- this.setData({
|
|
|
|
|
- city: app.globalData.city
|
|
|
|
|
- })
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
_animation = wx.createAnimation({
|
|
_animation = wx.createAnimation({
|
|
|
duration: 1000,
|
|
duration: 1000,
|
|
|
timingFunction: 'linear', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
|
|
timingFunction: 'linear', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
|
|
@@ -61,9 +80,10 @@ Page({
|
|
|
})
|
|
})
|
|
|
wx.createSelectorQuery().select('.select-box').boundingClientRect((res_b) => {
|
|
wx.createSelectorQuery().select('.select-box').boundingClientRect((res_b) => {
|
|
|
// let b_top = res_b.top
|
|
// let b_top = res_b.top
|
|
|
|
|
+
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- b_top: res_b.top
|
|
|
|
|
-
|
|
|
|
|
|
|
+ b_top: res_b.top,
|
|
|
|
|
+ sliderHeight:this.data.clientHeight - res_b.top
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
let tab = this.data.new_cities
|
|
let tab = this.data.new_cities
|
|
@@ -71,7 +91,7 @@ Page({
|
|
|
|
|
|
|
|
for (let i = 0; i < tab.length; i++) {
|
|
for (let i = 0; i < tab.length; i++) {
|
|
|
wx.createSelectorQuery().select('#item' + i).boundingClientRect((res_i) => {
|
|
wx.createSelectorQuery().select('#item' + i).boundingClientRect((res_i) => {
|
|
|
- console.log(res_i)
|
|
|
|
|
|
|
+ // console.log(res_i)
|
|
|
tab[i].top = res_i.top - this.data.b_top;
|
|
tab[i].top = res_i.top - this.data.b_top;
|
|
|
this.setData({
|
|
this.setData({
|
|
|
new_cities: tab,
|
|
new_cities: tab,
|
|
@@ -95,7 +115,6 @@ Page({
|
|
|
// console.log(e.detail.scrollTop)
|
|
// console.log(e.detail.scrollTop)
|
|
|
let scrollTop = e.detail.scrollTop
|
|
let scrollTop = e.detail.scrollTop
|
|
|
let tabs = this.data.new_cities
|
|
let tabs = this.data.new_cities
|
|
|
- console.log(scrollTop, this.data.b_top, tabs[tabs.length - 1].top)
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < tabs.length; i++) {
|
|
for (let i = 0; i < tabs.length; i++) {
|
|
|
if (scrollTop > tabs[i].top && scrollTop < tabs[i + 1].top) {
|
|
if (scrollTop > tabs[i].top && scrollTop < tabs[i + 1].top) {
|
|
@@ -103,7 +122,7 @@ Page({
|
|
|
apl_index: tabs[i].alphabetIndex
|
|
apl_index: tabs[i].alphabetIndex
|
|
|
})
|
|
})
|
|
|
// console.log(tabs[i].alphabetIndex)
|
|
// console.log(tabs[i].alphabetIndex)
|
|
|
- } else if (scrollTop + this.data.b_top+30 >= tabs[tabs.length - 1].top) {
|
|
|
|
|
|
|
+ } else if (scrollTop + this.data.b_top + 30 >= tabs[tabs.length - 1].top) {
|
|
|
console.log('到底了')
|
|
console.log('到底了')
|
|
|
this.setData({
|
|
this.setData({
|
|
|
apl_index: tabs[tabs.length - 1].alphabetIndex
|
|
apl_index: tabs[tabs.length - 1].alphabetIndex
|
|
@@ -187,6 +206,7 @@ Page({
|
|
|
} = e.currentTarget.dataset
|
|
} = e.currentTarget.dataset
|
|
|
// app.globalData.city = city.replace('市', '')
|
|
// app.globalData.city = city.replace('市', '')
|
|
|
app.globalData.city = city
|
|
app.globalData.city = city
|
|
|
|
|
+ this.set_historyCity(city)
|
|
|
wx.navigateBack()
|
|
wx.navigateBack()
|
|
|
},
|
|
},
|
|
|
selectLocation() {
|
|
selectLocation() {
|
|
@@ -279,5 +299,22 @@ Page({
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+ set_historyCity(city) {
|
|
|
|
|
+ if (!app.globalData.historyCity.includes(city)) {
|
|
|
|
|
+ app.globalData.historyCity.push(city)
|
|
|
|
|
+ saveHistoryCity(app.globalData.historyCity)
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ historyCity: app.globalData.historyCity
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ remove_historyCity() {
|
|
|
|
|
+ removeHistoryCity()
|
|
|
|
|
+ app.globalData.historyCity = loadHistoryCity() || []
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ historyCity: loadHistoryCity() || []
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
})
|
|
})
|