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.
133 lines
3.9 KiB
133 lines
3.9 KiB
// pages/shop/apply/index.js
|
|
const request = require('../../../utils/request')//导入模块
|
|
const util = require('../../../utils/util')
|
|
import regions from '../../../utils/region'
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
options: regions,
|
|
theme: 'energized',
|
|
warning: '注意:店铺资料审核后不可修改,请谨慎填写',
|
|
region: [440000, 440100, 440106],
|
|
form: {
|
|
contactPhoneNo: '',
|
|
name: '',
|
|
contacts: '',
|
|
locProvinceId: '',
|
|
locCityId: '',
|
|
locDistrictId: '',
|
|
locDetails: ''
|
|
},
|
|
imgList: [],
|
|
requesting: false
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader')
|
|
if(options.storeId){
|
|
this.data.form['storeId'] = options.storeId
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
// /paperCategoryList 获取纸品列表
|
|
request.get('/recycle-service/get/store-information/' + options.storeId).then(result => {
|
|
//成功回调
|
|
var fileList = []
|
|
if(result.data.coverImgUrlList && result.data.coverImgUrlList.length){
|
|
result.data.coverImgUrlList.forEach(element => {
|
|
fileList.push({ url: element, status: 8 })
|
|
})
|
|
}
|
|
this.setData({
|
|
form: result.data,
|
|
imgList: fileList,
|
|
['form.areaStr']: result.data.locProvinceName + ' ' + result.data.locCityName + ' ' + result.data.locDistrictName,
|
|
region: [result.data.locProvinceId, result.data.locCityId, result.data.locDistrictId]
|
|
})
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
})
|
|
}
|
|
},
|
|
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['locDistrictId'] = e.detail.value[2]
|
|
}
|
|
},
|
|
onUploadChange: function(e){
|
|
if(e.detail && e.detail.length){
|
|
var list = []
|
|
e.detail.forEach(element => {
|
|
if(!util.isEmpty(element.url)){
|
|
list.push(element.url)
|
|
}
|
|
})
|
|
this.data.form['coverImgUrlList'] = list
|
|
}
|
|
},
|
|
submitForm: function(){
|
|
if(util.isEmpty(this.data.form.name)){
|
|
util.showToast('请输入店铺名称')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.contacts)){
|
|
util.showToast('请输入店主昵称')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.contactPhoneNo)){
|
|
util.showToast('请输入联系电话')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.locDistrictId)){
|
|
util.showToast('请选择店铺所在区域')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.locDetails)){
|
|
util.showToast('请输入店铺详细地址')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.coverImgUrlList) || this.data.form.coverImgUrlList.length <= 0){
|
|
util.showToast('请上传一张店铺图片')
|
|
return
|
|
}
|
|
this.setData({requesting: true})
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
// /paperCategoryList 获取纸品列表
|
|
var url = '/recycle-service/update/store-information'
|
|
if(!util.isEmpty(this.data.form.storeId)){
|
|
url = '/recycle-service/edit/store-information'
|
|
}
|
|
request.post(url, this.data.form).then(result => {
|
|
//成功回调
|
|
wx.hideLoading()
|
|
util.showBackToast('店铺完善成功')
|
|
}).catch(err => {
|
|
//异常回调
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
this.setData({requesting: false})
|
|
})
|
|
}
|
|
|
|
})
|