Browse Source

fix party login upload company image

master
赵明涛 8 months ago
parent
commit
5788b74249
  1. 1
      src/subpackage/party/components/popup-content/miniapp-change-category.vue
  2. 18
      src/subpackage/party/pages/login/regist.vue
  3. 49
      src/utils/util.js

1
src/subpackage/party/components/popup-content/miniapp-change-category.vue

@ -366,6 +366,7 @@ export default {
let {exterList} = this let {exterList} = this
exterList[i].url = await this.getLocalImg(); exterList[i].url = await this.getLocalImg();
console.log("clickUploadImg-local:", exterList[i].url) console.log("clickUploadImg-local:", exterList[i].url)
exterList[i].mediaid = await this.getUploadImgMediaId(exterList[i].url); exterList[i].mediaid = await this.getUploadImgMediaId(exterList[i].url);
console.log("clickUploadImg-mediaid:", exterList[i].mediaid) console.log("clickUploadImg-mediaid:", exterList[i].mediaid)

18
src/subpackage/party/pages/login/regist.vue

@ -448,6 +448,7 @@
let ocr_type = 'BizLicenseOCR' let ocr_type = 'BizLicenseOCR'
console.log("clickUploadImg"); console.log("clickUploadImg");
let img = await this.getLocalImg(); let img = await this.getLocalImg();
let img_info = await util.checkFileInfo(img)
console.log("getLocalImg:", img) console.log("getLocalImg:", img)
let img_url = await this.getUploadImgURL(img); let img_url = await this.getUploadImgURL(img);
console.log("getUploadImgURL:", img_url) console.log("getUploadImgURL:", img_url)
@ -458,11 +459,13 @@
this.setOcrResult(ocr_type,ocr_res) this.setOcrResult(ocr_type,ocr_res)
this.submitData.business_license = img_url this.submitData.business_license = img_url
}, },
// IDCardOCR // IDCardOCR
async clickUploadIDCardImg() { async clickUploadIDCardImg() {
let ocr_type = 'IDCardOCR' let ocr_type = 'IDCardOCR'
console.log("clickUploadIDCardImg"); console.log("clickUploadIDCardImg");
let img = await this.getLocalImg(); let img = await this.getLocalImg();
let img_info = await util.checkFileInfo(img)
console.log("getLocalImg:", img) console.log("getLocalImg:", img)
let img_url = await this.getUploadImgURL(img); let img_url = await this.getUploadImgURL(img);
console.log("getUploadImgURL:", img_url) console.log("getUploadImgURL:", img_url)
@ -476,6 +479,7 @@
async clickUploadIDCardBackImg() { async clickUploadIDCardBackImg() {
console.log("clickUploadIDCardBackImg"); console.log("clickUploadIDCardBackImg");
let img = await this.getLocalImg(); let img = await this.getLocalImg();
let img_info = await util.checkFileInfo(img)
console.log("getLocalImg:", img) console.log("getLocalImg:", img)
let img_url = await this.getUploadImgURL(img); let img_url = await this.getUploadImgURL(img);
console.log("getUploadImgURL:", img_url) console.log("getUploadImgURL:", img_url)
@ -554,7 +558,8 @@
this.submitData.extension.legal_person_name = res.Response.Person; this.submitData.extension.legal_person_name = res.Response.Person;
this.submitData.agency_code = res.Response.RegNum; this.submitData.agency_code = res.Response.RegNum;
const t = this.company_types.find(item => item.label === res.Response.Type); const t = this.company_types.find(item => item.label === res.Response.Type);
this.submitData.extension.company_type = t.value;
if(t&&t.value)this.submitData.extension.company_type = t.value; //
if (res.Response.Capital) { if (res.Response.Capital) {
const num = res.Response.Capital.split('元')[0] const num = res.Response.Capital.split('元')[0]
this.submitData.extension.registered_capital = this.chineseToNumber(num) this.submitData.extension.registered_capital = this.chineseToNumber(num)
@ -574,7 +579,7 @@
this.submitData.extension.credit_end_date = `${year}-${month}-${day}` this.submitData.extension.credit_end_date = `${year}-${month}-${day}`
} }
} }
if(res.Response.Type){
if(res.Response.Type){//,
let _index = "" let _index = ""
const t = this.company_types.find((item,index) => { const t = this.company_types.find((item,index) => {
if(item.label === res.Response.Type){ if(item.label === res.Response.Type){
@ -583,9 +588,12 @@
return item return item
} }
}); });
this.submitData.extension.company_type = t.value
this.company_type_index = _index
this.company_type_show = this.company_types_arr[_index]
if(t&&t.value){
this.submitData.extension.company_type = t.value
this.company_type_index = _index
this.company_type_show = this.company_types_arr[_index]
}
} }
} else { } else {
this.submitData.extension.business_id_card = res.Response.IdNum this.submitData.extension.business_id_card = res.Response.IdNum

49
src/utils/util.js

@ -398,6 +398,52 @@ function order_pay_type_txt(status = ''){
return _obj[status] || '-' return _obj[status] || '-'
} }
function checkFileInfo(url){//获取文件信息, 超过2M时提醒太大, 文件格式要求JPG、JPEG、PNG
let util = this
return new Promise((rs,rj)=>{
try{
let MAX_SIZE = 2048; //最大size限制
let type = url.split(".")[1]||""
// JPG、JPEG、PNG
let need_type = [,'jpeg','jpg','png','JPG','JPEG','PNG']
if(need_type.indexOf(type)>0){
console.log("文件格式符合预期:",type)
}else{
util.showNone(`当前文件格式${type}不符合预期,请重新上传`)
rj(false)
}
rs(true)
console.log(wx.env.USER_DATA_PATH,123,url)
const fs = wx.getFileSystemManager()
// const fd = fs.openSync({
const fd = fs.openSync({
// filePath: `${wx.env.USER_DATA_PATH}/hello.txt`,
filePath:url,
flag: 'a+'
})
const stats = fs.fstatSync({fd: fd})
let size = stats.size||0
size = size/1024
if(size>MAX_SIZE){
util.showNone(`上传图片最大为${MAX_SIZE/1024}M,当前为:${(size/1024).toFixed(2)}M`)
rj(false)
}
if(!size){
util.showNone("请上传正确的图片")
rj(false)
}
rs(stats)
}catch(e){
util.showNone(e);
rj(e)
}
})
}
export default { export default {
formatTime, formatTime,
formatNumber, formatNumber,
@ -430,5 +476,6 @@ export default {
isProfile, isProfile,
$_once, $_once,
$_emit, $_emit,
order_pay_type_txt
order_pay_type_txt,
checkFileInfo,
} }
Loading…
Cancel
Save