diff --git a/pages/home/certificate/index.js b/pages/home/certificate/index.js index 5b429d6..ce069c3 100644 --- a/pages/home/certificate/index.js +++ b/pages/home/certificate/index.js @@ -1,5 +1,6 @@ // 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' const util = require('../../../utils/util') const app = getApp() @@ -14,7 +15,7 @@ Page({ form: { }, flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑 disabled: true, - fileList: [] + imgList: [null] }, onLoad: function (options) { 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 }) } }) \ No newline at end of file diff --git a/pages/home/certificate/index.wxml b/pages/home/certificate/index.wxml index bcde835..f266f87 100644 --- a/pages/home/certificate/index.wxml +++ b/pages/home/certificate/index.wxml @@ -2,22 +2,31 @@ 企业认证 + 公司信息 - - + + *公司名称: diff --git a/pages/home/certificate/index.wxss b/pages/home/certificate/index.wxss index 6bf45ad..9d6e457 100644 --- a/pages/home/certificate/index.wxss +++ b/pages/home/certificate/index.wxss @@ -11,6 +11,8 @@ list-style: none; background-size: cover; border-radius: 6rpx; + margin-left: 24rpx; + border: 1rpx solid #f3f3f3 } .tspan{ @@ -19,7 +21,7 @@ .image-reader-item .md-icon { position: absolute; - top: 45%; + top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0.5;