// pages/home/tab2/index.js const storage = require('../../../utils/storage') import regions from '../../../utils/region' Page({ /** * 页面的初始数据 */ data: { options: regions, region: [440000, '', ''], form: { bidType: 1, imgList: [], secondCategoryId: null, stock: null, dopantRate: null, waterRate: null }, cateName: '', dopantName: '', waterName: '', intervalName: '', sumAmount: 0, keyboard: 0, toView: '', focus: false, picking: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader') this.pickerView = this.pickerView || this.selectComponent('#picker-view') }, toNextTab: function () { wx.redirectTo({ url: '/pages/home/tab3/index' }) }, toMyInfo: function () { storage.put('userIsLoginFirst', '1') wx.redirectTo({ url: '/pages/index/index' }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, backspace: function () { console.log('点击返回被触发2') wx.redirectTo({ url: '/pages/home/tab1/index' }) }, showRegion: function () { if (this.data.disabled) { return } this.cascaderView.showPicker(this.data.region) this.setData({ picking: true }) }, onRegionChange: function (e) { if (e.detail && e.detail.options) { this.setData({ ['form.areaStr']: e.detail.options.map((n) => n.label).join(' '), region: e.detail.value }) this.data.form['locProvinceId'] = e.detail.value[0] this.data.form['locProvinceName'] = e.detail.options[0].label this.data.form['locCityId'] = e.detail.value[1] this.data.form['locCityName'] = e.detail.options[1].label this.data.form['locDistrictId'] = e.detail.value[2] this.data.form['locDistrictName'] = e.detail.options[2].label } this.setData({ picking: false }) }, })