// pages/shop/apply/index.js import { updateUserInfoZtb } from "../../api/ztb" const util = require('../../../utils/util') import regions from '../../../utils/region' const app = getApp() Page({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, options: regions, region: [], form: {}, requesting: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ safeBottom: app.globalData.safeBottom }) }, bindInput: function(e){ this.data.form[e.target.id] = e.detail.value }, showRegion: function(){ this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader') this.cascaderView.showPicker(this.data.region) }, 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['locCityId'] = e.detail.value[1] this.data.form['districtId'] = e.detail.value[2] } }, submitForm: function(){ if(this.data.requesting){ return } if(util.isEmpty(this.data.form.packageFactoryName)){ util.showToast('请输入工厂全称') return } if(util.isEmpty(this.data.form.districtId)){ util.showToast('请选择所在区域') return } if(util.isEmpty(this.data.form.details)){ util.showToast('请输入详细地址') return } if(util.isEmpty(this.data.form.phone)){ util.showToast('请输入发货人姓名') return } this.data.requesting = true wx.showLoading({ title: '处理中', mask: true }) updateUserInfoZtb(this.data.form).then(res => { wx.hideLoading() util.showBackToast('新增地址成功') }).catch(err => { wx.hideLoading() this.data.requesting = false util.showToast(err) }) } })