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.
83 lines
2.1 KiB
83 lines
2.1 KiB
// pages/shop/apply/index.js
|
|
import { createAddress } 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: {
|
|
receiver:'',
|
|
phone:'',
|
|
details:'',
|
|
isDefault:'',
|
|
locProvinceId: '',
|
|
locCityId: '',
|
|
districtId: ''
|
|
},
|
|
requesting: false
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader')
|
|
this.setData({ safeBottom: app.globalData.safeBottom })
|
|
},
|
|
bindinput: function(e){
|
|
this.data.form[e.target.id] = e.detail.value
|
|
},
|
|
showRegion: function(){
|
|
if(this.data.disabled){
|
|
return
|
|
}
|
|
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(util.isEmpty(this.data.form.receiver)){
|
|
util.showToast('请输入收货人')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.phone)){
|
|
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.isDefault)){
|
|
util.showToast('请确定是否默认')
|
|
return
|
|
}
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
createAddress(this.data.form).then(res => {
|
|
wx.hideLoading()
|
|
util.showBackToast('新增地址成功')
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
})
|