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.
130 lines
4.0 KiB
130 lines
4.0 KiB
import { commitBusiness, getPaperList } from "../../../api/ztb"
|
|
const util = require('../../../utils/util')
|
|
const math = require('../../../utils/math')
|
|
const wxmap = require('../../../libs/wxmap.js')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
cateList: [],
|
|
form: {},
|
|
imgList: [null, null],
|
|
requesting: false,
|
|
cateString: '',
|
|
cateArray: [],
|
|
focus: false,
|
|
visible: false
|
|
},
|
|
onLoad: function (options) {
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
if(app.nowLocation){
|
|
this.setForm()
|
|
} else {
|
|
var that = this
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success (res) {
|
|
app.nowLocation = res
|
|
wxmap.geocoder(app.nowLocation.latitude, app.nowLocation.longitude).then(resp => {
|
|
app.nowLocation.cityName = resp.result.address_component.city.replace('市', '')
|
|
app.nowLocation.cityCode = resp.result.ad_info.city_code.replace('156', '')
|
|
app.nowLocation.address = resp.result.address
|
|
app.nowLocation.districtCode = resp.result.ad_info.adcode
|
|
that.setForm()
|
|
})
|
|
}
|
|
})
|
|
}
|
|
var sHeight = parseInt(math.times(app.globalData.fragmentHeight, 0.5))
|
|
getPaperList({ type: 2 }).then(result => {
|
|
this.setData({ cateList: result.data, sHeight })
|
|
}).catch(err => {
|
|
this.setData({ sHeight })
|
|
})
|
|
},
|
|
setForm: function(){
|
|
this.data.form.latitude = parseFloat(app.nowLocation.latitude.toFixed(6))
|
|
this.data.form.longitude = parseFloat(app.nowLocation.longitude.toFixed(6))
|
|
this.data.form.locCityName = app.nowLocation.cityName
|
|
this.data.form.locCityId = app.nowLocation.cityCode
|
|
this.data.form.locDistrictId = app.nowLocation.districtCode
|
|
this.data.form.address = app.nowLocation.address
|
|
},
|
|
bindInput: function(e){
|
|
this.data.form.name = e.detail.value
|
|
},
|
|
onImageLoad: function({detail}){
|
|
console.log(detail)
|
|
if(detail && detail.width){
|
|
var radio = math.divide(detail.width, 750)
|
|
var height = parseInt(math.divide(detail.height, radio))
|
|
this.setData({ height })
|
|
}
|
|
wx.hideLoading()
|
|
},
|
|
selectCategroy: function(){
|
|
this.setData({ visible: true, focus: false })
|
|
},
|
|
clickItem: function(e){
|
|
var index = Number(e.currentTarget.dataset.index)
|
|
var item = this.data.cateList[index]
|
|
this.setData({ ['cateList[' + index + '].checked']: !item.checked })
|
|
},
|
|
onClose: function(){
|
|
this.setData({ visible: false })
|
|
},
|
|
onConfirm: function(){
|
|
var cateString = null
|
|
this.data.form.categoryIds = []
|
|
for (let index = 0; index < this.data.cateList.length; index++) {
|
|
const element = this.data.cateList[index]
|
|
if(element.checked){
|
|
this.data.form.categoryIds.push(element.id)
|
|
if(util.isEmpty(cateString)){
|
|
cateString = element.name
|
|
} else {
|
|
cateString += ';' + element.name
|
|
}
|
|
}
|
|
}
|
|
this.setData({ cateString, visible: false })
|
|
},
|
|
submitForm: function(){
|
|
if(this.data.requesting){
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.name)){
|
|
util.showToast('请输入你的打包站名称')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.categoryIds)){
|
|
util.showToast('请选择你的主营品类')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.factoryPhotoUrls)){
|
|
util.showToast('请上传门头、招牌、场地等照片')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.weightNotePhotoUrls)){
|
|
util.showToast('请上传3天内的磅单照片')
|
|
return
|
|
}
|
|
this.setData({ requesting: true })
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
commitBusiness(this.data.form).then(res => {
|
|
wx.hideLoading()
|
|
app.userInfo.isCommittedPackingFactoryClue = 1
|
|
util.showBackToast('信息完善成功')
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
this.setData({ requesting: false })
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
beforeChoose: function(e){
|
|
this.setData({ focus: false })
|
|
},
|
|
onImageUpload: function(e){
|
|
console.log(e)
|
|
}
|
|
})
|