纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

147 lines
3.2 KiB

// pages/home/tab2/index.js
import {
updateUserInfo,
getBaseInfo
} from '../../api/ztb'
const storage = require('../../../utils/storage')
import regions from '../../../utils/region'
Page({
/**
* 页面的初始数据
*/
data: {
options: regions,
region: [440000, ''],
form: {
bidType: 1,
areaStr:''
},
cateName: '',
dopantName: '',
waterName: '',
intervalName: '',
sumAmount: 0,
keyboard: 0,
toView: '',
focus: false,
picking: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getUerInfoFct()
this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader')
this.pickerView = this.pickerView || this.selectComponent('#picker-view')
},
toNextTab: function () {
wx.navigateTo({
url: '/pages/home/tab3/index'
})
},
toMyInfo: function () {
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.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 })
this.setData({
'form.areaStr':e.detail.options[0].label+e.detail.options[1].label
})
this.submitForm({locateCityTag:this.data.form.locCityId})
}
},
submitForm: function (model) {
console.log(model)
updateUserInfo(model).then(result => {
this.data.loopRequesting = false
setTimeout(() => this.toNextTab(), 200)
}).catch(err => {
this.data.loopRequesting = false
})
},
getUerInfoFct: function () {
getBaseInfo().then(res => {
this.setData({
region:[res.data.locateCityTag.provinceId,res.data.locateCityTag.cityId,res.data.locateCityTag.districtId],
'form.areaStr':res.data.locateCityTag.provinceName+res.data.locateCityTag.cityName
})
console.log(this.data.region)
})
}
})