123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- // pages/home/location/location.js
- var city = require('../../../libs/city.js');
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- city: app.globalData.city,
- cityData: {},//所有城市
- hotCityData: [],//热门城市
- _py: ["hot", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "W", "X", "Y", "Z"],//字母索引
- hidden: true,
- showPy: '★',
- },
- //选择城市
- selectCity: function (e) {
- app.globalData.city = e.currentTarget.dataset.name;
- wx.reLaunch({
- url: '/pages/home/index?city=' + e.currentTarget.dataset.name,
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- that.setData({
- cityData: city.all,
- hotCityData: city.hot
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.setData({
- city: app.globalData.city
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- //获取文字信息
- getPy: function (e) {
- this.setData({
- hidden: false,
- showPy: e.target.id,
- })
- },
- setPy: function (e) {
- this.setData({
- hidden: true,
- scrollTopId:e.target.id
- // scrollTopId: this.data.showPy
- })
- },
- //触发全部开始选择
- tStart: function () {
- this.setData({
- hidden: false
- })
- },
- //滑动选择城市
- tMove: function (e) {
- var y = e.touches[0].clientY;//触摸点Y坐标
- var offsettop = e.currentTarget.offsetTop;//节点Y坐标
- //判断选择区域,只有在选择区才会生效
- if (y > offsettop && y < offsettop+276) {
- var num = parseInt((y - offsettop) / 12);
- this.setData({
- showPy: this.data._py[num]
- })
- };
- },
- //触发结束选择
- tEnd: function () {
- this.setData({
- hidden: true,
- scrollTopId: this.data.showPy
- })
- },
- })
|