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.
212 lines
7.5 KiB
212 lines
7.5 KiB
// pages/home/authory/index.js
|
|
import { ocrLicense, checkLicense } from "../../api/user"
|
|
import { zconfig } from'../../api/ztb'
|
|
import { updateUserInfo, identifyEnterprise } from '../../api/ztb'
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
let monthList = [{ text: '1000吨以下', value: 1 }, { text: '1000-2000吨', value: 2 }, { text: '2000吨以上', value: 3 }]
|
|
let expriseList = [{ text: '1年以下', value: 1 }, { text: '1-5年', value: 2 }, { text: '5-10年', value: 3 }, { text: '10年以上', value: 4 }]
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
form: { },
|
|
flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑
|
|
disabled: true,
|
|
editable: true,
|
|
imgList: [null]
|
|
},
|
|
onLoad: function (options) {
|
|
this.setData({ safeBottom: app.globalData.safeBottom, form: app.globalData.userInfo })
|
|
},
|
|
bindForm: function (e) {
|
|
// var form_data = 'form.' + e.target.id
|
|
this.data.form[e.currentTarget.id] = e.detail.value
|
|
},
|
|
showPicker: function (e) {
|
|
this.pickerView = this.pickerView || this.selectComponent('#picker-view')
|
|
if(e.currentTarget.id == 'shipmentPerMonth'){
|
|
this.pickerView.showPicker(monthList, null, 1)
|
|
} else if(e.currentTarget.id == 'experienceTag'){
|
|
this.pickerView.showPicker(expriseList, null, 2)
|
|
}
|
|
},
|
|
onPickerChange: function ({detail}) {
|
|
if(detail.type == 1){
|
|
this.setData({ ['form.shipmentPerMonth']: detail.text })
|
|
} else if(detail.type == 2){
|
|
this.setData({ ['form.experienceTag']: detail.text })
|
|
}
|
|
},
|
|
submitForm: function () {
|
|
if (util.isEmpty(this.data.form.businessLicenseImg)) {
|
|
util.showToast('请上传营业执照')
|
|
return
|
|
}
|
|
if (util.isEmpty(this.data.form.name)) {
|
|
util.showToast('请输入公司名称')
|
|
return
|
|
}
|
|
if (util.isEmpty(this.data.form.uniformSocialCreditCode)) {
|
|
util.showToast('请输社会入统一信用代码')
|
|
return
|
|
}
|
|
if (util.isEmpty(this.data.form.legalPersonName)) {
|
|
util.showToast('请输法人姓名')
|
|
return
|
|
}
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
var params = {name: this.data.form.name}
|
|
params.uniformSocialCreditCode = this.data.form.uniformSocialCreditCode
|
|
params.legalPersonName = this.data.form.legalPersonName
|
|
params.packageFactoryArea = this.data.form.packageFactoryArea
|
|
params.shipmentPerMonth = this.data.form.shipmentPerMonth
|
|
params.numberOfFactoryEmployee = this.data.form.numberOfFactoryEmployee
|
|
params.numberOfFactoryPackageMachine = this.data.form.numberOfPackageMachine
|
|
params.locDetail = this.data.form.locDetail
|
|
params.experienceTag = this.data.form.experienceTag
|
|
params.businessLicenseImg = this.data.form.businessLicenseImg
|
|
|
|
identifyEnterprise(params).then(result => {
|
|
// 修改个人信息
|
|
var data = { numberOfFactoryPackageMachine: this.data.form.numberOfFactoryPackageMachine }
|
|
data.numberOfFactoryEmployee = this.data.form.numberOfFactoryEmployee
|
|
data.shipmentPerMonth = this.data.form.shipmentPerMonth
|
|
data.packageFactoryArea = this.data.form.packageFactoryArea
|
|
data.experienceTag = this.data.form.experienceTag
|
|
updateUserInfo(data).then(result => {
|
|
wx.hideLoading()
|
|
if(!app.globalData.userInfo.isAuth){
|
|
util.showToast('企业验证成功')
|
|
wx.redirectTo({ url: '/pages/home/idcard/index' })
|
|
} else {
|
|
util.showBackToast('企业验证成功')
|
|
}
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
util.showToast(error)
|
|
})
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
util.showToast(error)
|
|
})
|
|
},
|
|
onImageChange: function (e) {
|
|
if (e.detail) {
|
|
var list = []
|
|
e.detail.forEach(element => {
|
|
if (!util.isEmpty(element.url)) {
|
|
list.push(element.url)
|
|
}
|
|
})
|
|
if(list.length > 0){
|
|
this.data.form['businessLicenseImg'] = list[0]
|
|
wx.showLoading({ title: '识别中', mask: true })
|
|
ocrLicense({businessLicenseUrl: list[0]}).then(result => {
|
|
this.setData({
|
|
['form.name']: result.data.name,
|
|
['form.uniformSocialCreditCode']: result.data.uniformSocialCreditCode,
|
|
['form.legalPersonName']: result.data.legalPersonName,
|
|
['form.locDetail']: result.data.locDetail,
|
|
})
|
|
wx.hideLoading()
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
util.showToast(error)
|
|
})
|
|
}
|
|
}
|
|
},
|
|
checkLicense: function(url){
|
|
this.data.form['businessLicenseImg'] = url
|
|
wx.showLoading({ title: '识别中', mask: true })
|
|
ocrLicense({businessLicenseUrl: url}).then(result => {
|
|
this.setData({
|
|
['form.name']: result.data.name,
|
|
['form.uniformSocialCreditCode']: result.data.uniformSocialCreditCode,
|
|
['form.legalPersonName']: result.data.legalPersonName,
|
|
['form.locDetail']: result.data.locDetail,
|
|
})
|
|
result.data.enterpriseName = result.data.name
|
|
checkLicense(result.data).then(res => {
|
|
if(res.data.checkStatus != 0){
|
|
this.setData({ editable : false })
|
|
}
|
|
wx.hideLoading()
|
|
util.showToast(res.data.checkStatusExplain)
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
this.setData({ editable : false })
|
|
util.showToast(error)
|
|
})
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
util.showToast('图片识别失败,请重新上传')
|
|
})
|
|
},
|
|
/*******************************************************图片上传************************************************************/
|
|
chooseImage: function(e) {
|
|
var index = 0
|
|
var that = this
|
|
wx.chooseImage({
|
|
count: 1, //默认9
|
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], //从相册选择
|
|
success: (res) => {
|
|
that.setData({ ['imgList[' + index + ']']: res.tempFilePaths[0] })
|
|
that.uploadFile(res.tempFilePaths[0])
|
|
}
|
|
})
|
|
},
|
|
uploadFile: function (path) {
|
|
var that = this
|
|
var header = { ...zconfig.header, 'X-APP-ID': app.xAppId, appversion: app.version, 'Content-Type': 'multipart/form-data' }
|
|
wx.uploadFile({
|
|
url: zconfig.baseUrl + '/recycle-user-center/file-uploading/upload/image',
|
|
filePath: path,
|
|
name: 'image',
|
|
header,
|
|
success: function (result) {
|
|
var resp = null
|
|
if (!util.isEmpty(result.data)) {
|
|
resp = JSON.parse(result.data)
|
|
}
|
|
if (resp && resp.code === 0) {
|
|
that.checkLicense(resp.data)
|
|
} else {
|
|
util.showToast('图片上传失败,请重新上传')
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
util.showToast('图片上传失败,请重新上传')
|
|
}
|
|
})
|
|
},
|
|
suffixImage: function(path){
|
|
return path.substring(path.lastIndexOf('.') + 1)
|
|
},
|
|
viewImage: function(e) {
|
|
var urlList = []
|
|
for (var i = 0; i < this.data.imgList.length; i++) {
|
|
if (!util.isEmpty(this.data.imgList[i])) {
|
|
urlList.push(this.data.imgList[i])
|
|
}
|
|
}
|
|
wx.previewImage({ urls: urlList, current: e.currentTarget.dataset.url })
|
|
},
|
|
deleteImg: function(e) {
|
|
var index = e.currentTarget.dataset.index
|
|
this.data.imgList[index] = null;
|
|
this.data.form.businessLicenseImg = null
|
|
this.data.form.locDetail = null
|
|
this.setData({
|
|
imgList: this.data.imgList,
|
|
['form.name']: '',
|
|
['form.uniformSocialCreditCode']: null,
|
|
['form.legalPersonName']: null,
|
|
editable: true
|
|
})
|
|
}
|
|
})
|