|
|
@ -1,5 +1,6 @@ |
|
|
// pages/home/authory/index.js
|
|
|
// pages/home/authory/index.js
|
|
|
import { ocrLicense, checkLicense } from "../../api/user" |
|
|
|
|
|
|
|
|
import { ocrLicense } from "../../api/user" |
|
|
|
|
|
import { zconfig } from'../../api/ztb' |
|
|
import { updateUserInfo, identifyEnterprise } 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,7 +15,7 @@ Page({ |
|
|
form: { }, |
|
|
form: { }, |
|
|
flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑
|
|
|
flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑
|
|
|
disabled: true, |
|
|
disabled: true, |
|
|
fileList: [] |
|
|
|
|
|
|
|
|
imgList: [null] |
|
|
}, |
|
|
}, |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
this.setData({ safeBottom: app.globalData.safeBottom, form: app.globalData.userInfo }) |
|
|
this.setData({ safeBottom: app.globalData.safeBottom, form: app.globalData.userInfo }) |
|
|
@ -116,5 +117,76 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
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, |
|
|
|
|
|
}) |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}).catch(error => { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
util.showToast(error) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
/*******************************************************图片上传************************************************************/ |
|
|
|
|
|
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.setData({ imgList: this.data.imgList }) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |