|
|
@ -1,6 +1,6 @@ |
|
|
// pages/home/authory/index.js
|
|
|
// pages/home/authory/index.js
|
|
|
import { ocrLicense, checkLicense } from "../../api/user" |
|
|
import { ocrLicense, checkLicense } from "../../api/user" |
|
|
import { updateUserInfo } from '../../api/ztb' |
|
|
|
|
|
|
|
|
import { updateUserInfo, identifyEnterprise } from '../../api/ztb' |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
|
|
|
|
|
|
@ -14,11 +14,10 @@ Page({ |
|
|
form: { }, |
|
|
form: { }, |
|
|
flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑
|
|
|
flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑
|
|
|
disabled: true, |
|
|
disabled: true, |
|
|
fileList: [], |
|
|
|
|
|
imgList: [null] |
|
|
|
|
|
|
|
|
fileList: [] |
|
|
}, |
|
|
}, |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
this.setData({ form: app.globalData.userInfo }) |
|
|
|
|
|
|
|
|
this.setData({ safeBottom: app.globalData.safeBottom, form: app.globalData.userInfo }) |
|
|
}, |
|
|
}, |
|
|
bindForm: function (e) { |
|
|
bindForm: function (e) { |
|
|
// var form_data = 'form.' + e.target.id
|
|
|
// var form_data = 'form.' + e.target.id
|
|
|
@ -40,11 +39,11 @@ Page({ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
submitForm: function () { |
|
|
submitForm: function () { |
|
|
if (util.isEmpty(this.data.form.businessLicenseUrl)) { |
|
|
|
|
|
|
|
|
if (util.isEmpty(this.data.form.businessLicenseImg)) { |
|
|
util.showToast('请上传营业执照') |
|
|
util.showToast('请上传营业执照') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if (util.isEmpty(this.data.form.enterpriseName)) { |
|
|
|
|
|
|
|
|
if (util.isEmpty(this.data.form.name)) { |
|
|
util.showToast('请输入公司名称') |
|
|
util.showToast('请输入公司名称') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
@ -57,12 +56,31 @@ Page({ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
checkLicense(this.data.form).then(result => { |
|
|
|
|
|
|
|
|
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 => { |
|
|
// 修改个人信息
|
|
|
// 修改个人信息
|
|
|
updateUserInfo(this.data.form).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() |
|
|
wx.hideLoading() |
|
|
if(!app.globalData.userInfo.isAuth){ |
|
|
if(!app.globalData.userInfo.isAuth){ |
|
|
|
|
|
util.showToast('企业验证成功') |
|
|
wx.redirectTo({ url: '/pages/home/idcard/index' }) |
|
|
wx.redirectTo({ url: '/pages/home/idcard/index' }) |
|
|
|
|
|
} else { |
|
|
|
|
|
util.showBackToast('企业验证成功') |
|
|
} |
|
|
} |
|
|
}).catch(error => { |
|
|
}).catch(error => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
@ -82,61 +100,21 @@ Page({ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
if(list.length > 0){ |
|
|
if(list.length > 0){ |
|
|
this.data.form['businessLicenseUrl'] = list[0] |
|
|
|
|
|
|
|
|
this.data.form['businessLicenseImg'] = list[0] |
|
|
|
|
|
wx.showLoading({ title: '识别中', mask: true }) |
|
|
ocrLicense({businessLicenseUrl: list[0]}).then(result => { |
|
|
ocrLicense({businessLicenseUrl: list[0]}).then(result => { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
['form.enterpriseName']: result.data.company, |
|
|
|
|
|
['form.uniformSocialCreditCode']: result.data.regNum, |
|
|
|
|
|
['form.legalPersonName']: result.data.legalPerson |
|
|
|
|
|
|
|
|
['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) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
/*******************************************************图片上传************************************************************/ |
|
|
|
|
|
chooseImage: function(e) { |
|
|
|
|
|
if (this.data.flag) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var index = e.currentTarget.dataset.index |
|
|
|
|
|
var that = this |
|
|
|
|
|
wx.chooseImage({ |
|
|
|
|
|
count: 1, //默认9
|
|
|
|
|
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
|
|
|
sourceType: ['album', 'camera'], //从相册选择
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
that.setData({ ['imgList[' + index + ']']: res.tempFilePaths[0] }) |
|
|
|
|
|
const fileSystemManager = wx.getFileSystemManager() |
|
|
|
|
|
var type = that.suffixImage(res.tempFilePaths[0]) |
|
|
|
|
|
fileSystemManager.readFile({ |
|
|
|
|
|
filePath: that.data.imgList[index], // 例如图片临时路径
|
|
|
|
|
|
encoding: 'base64', |
|
|
|
|
|
success(res) { |
|
|
|
|
|
let { data } = res // 编码后的数据
|
|
|
|
|
|
if(index == 0){ |
|
|
|
|
|
that.data.form.frontImg = {base64: data, type} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
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.setData({ imgList: this.data.imgList }) |
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |