[FIX]影像上传-请求上传接口错误情况,增加校验、抛出错误并提示

This commit is contained in:
yuweiqi
2020-04-21 10:11:38 +08:00
parent c451c20c7d
commit db4a685ccf
2 changed files with 336 additions and 268 deletions

View File

@@ -275,50 +275,72 @@ export default {
let formdata = new FormData() let formdata = new FormData()
formdata.append('imgPath', that.dataURLtoFile(that.file, that.imgName)) formdata.append('imgPath', that.dataURLtoFile(that.file, that.imgName))
uploadImg(formdata).then(res => { uploadImg(formdata).then(
if (res.result == '0') { res => {
this.$toast.clear() if (res.result == '0') {
let imageInfoType = '' this.$toast.clear()
let subBusinessType = '' let imageInfoType = ''
let name = '' let subBusinessType = ''
let name = ''
if (that.type == 'fileListBank01') { if (that.type == 'fileListBank01') {
//身份证正面 //身份证正面
name = 'fileListBank01' name = 'fileListBank01'
imageInfoType = '1' imageInfoType = '1'
subBusinessType = '3' subBusinessType = '3'
} else if (that.type == 'fileListBank03') { } else if (that.type == 'fileListBank03') {
//学历 //学历
name = 'fileListBank03' name = 'fileListBank03'
imageInfoType = '12' imageInfoType = '12'
subBusinessType = '3' subBusinessType = '3'
} else if (that.type == 'fileListBank04') { } else if (that.type == 'fileListBank04') {
//免冠 //免冠
name = 'fileListBank04' name = 'fileListBank04'
imageInfoType = '13' imageInfoType = '13'
subBusinessType = '3' subBusinessType = '3'
} else if (that.type == 'fileListBank05') { } else if (that.type == 'fileListBank05') {
//银行卡 //银行卡
name = 'fileListBank05' name = 'fileListBank05'
imageInfoType = '3' imageInfoType = '3'
subBusinessType = '3' subBusinessType = '3'
} else if (that.type == 'fileListBank06') { } else if (that.type == 'fileListBank06') {
//担保人 //担保人
name = 'fileListBank06' name = 'fileListBank06'
imageInfoType = '1' imageInfoType = '1'
subBusinessType = '4' subBusinessType = '4'
} }
let obj = { let obj = {
name: name, name: name,
imageInfoType: imageInfoType, imageInfoType: imageInfoType,
subBusinessType: subBusinessType, subBusinessType: subBusinessType,
fileName: that.imgName, fileName: that.imgName,
rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B') rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B')
}
that.list.push(obj)
} else {
that.$toast(res.resultMessage || '图片上传失败,请重新上传图片')
switch (that.type) {
case 'fileListBank01':
this.fileListBank01.pop()
break
case 'fileListBank03': //学历
this.fileListBank03 = []
break
case 'fileListBank04': //免冠
this.fileListBank04 = []
break
case 'fileListBank05':
this.fileListBank05.pop()
break
case 'fileListBank06':
this.fileListBank06.pop()
break
}
} }
that.list.push(obj) },
} else { error => {
that.$toast(res.resultMessage || '请重新上传图片') that.$toast('网络错误')
switch (that.type) { switch (that.type) {
case 'fileListBank01': case 'fileListBank01':
this.fileListBank01.pop() this.fileListBank01.pop()
@@ -337,7 +359,7 @@ export default {
break break
} }
} }
}) )
}, },
// 删除图片 // 删除图片
deleteImg(file, nameList) { deleteImg(file, nameList) {

View File

@@ -285,7 +285,16 @@
</van-radio-group> </van-radio-group>
</div> </div>
<div class="bg-white bottom-btn"> <div class="bg-white bottom-btn">
<van-button type="danger" class="attachmentManagement-next" size="large" :disabled="isDisabled" @click="next" @touchstart="beforeNext(isDisabled)" v-no-more-click="1000">下一步</van-button> <van-button
type="danger"
class="attachmentManagement-next"
size="large"
:disabled="isDisabled"
@click="next"
@touchstart="beforeNext(isDisabled)"
v-no-more-click="1000"
>下一步</van-button
>
</div> </div>
</div> </div>
</template> </template>
@@ -722,228 +731,269 @@ export default {
}) })
let formdata = new FormData() let formdata = new FormData()
formdata.append('imgPath', that.dataURLtoFile(that.file, that.imgName)) formdata.append('imgPath', that.dataURLtoFile(that.file, that.imgName))
uploadImg(formdata).then(res => { uploadImg(formdata).then(
// console.log(res) res => {
if (res.result == '0') { // console.log(res)
this.$toast.clear() if (res.result == '0') {
// res.responseObject.imgList.map(item => { this.$toast.clear()
if ( // res.responseObject.imgList.map(item => {
that.type == 'fileListIdFront' || if (
that.type == 'fileListIdBack' || that.type == 'fileListIdFront' ||
that.type == 'fileLIstImg' || that.type == 'fileListIdBack' ||
that.type == 'fileListBank' || that.type == 'fileLIstImg' ||
// that.type == 'fileListBankBack' || that.type == 'fileListBank' ||
that.type == 'saleInsuredInfoOther' // that.type == 'fileListBankBack' ||
) { that.type == 'saleInsuredInfoOther'
// 是投保人 ) {
// console.log(that.file) // 是投保人
// 证件类型 // console.log(that.file)
let imageInfoType = '' // 证件类型
let name = '' let imageInfoType = ''
// if (that.type == 'fileListIdFront' && that.id == '1') { let name = ''
// imageInfoType = '1' // if (that.type == 'fileListIdFront' && that.id == '1') {
// } else if (that.type == 'fileListIdBack' && that.id == '1') { // imageInfoType = '1'
// imageInfoType = '2' // } else if (that.type == 'fileListIdBack' && that.id == '1') {
// } else if (that.type == 'fileListBank') { // imageInfoType = '2'
// imageInfoType = '3' // } else if (that.type == 'fileListBank') {
// } else if (that.type == 'fileListIdFront' && that.id == '2') { // imageInfoType = '3'
// imageInfoType = '5' // } else if (that.type == 'fileListIdFront' && that.id == '2') {
// } else if (that.type == 'fileListIdBack' && that.id == '2') { // imageInfoType = '5'
// imageInfoType = '6' // } else if (that.type == 'fileListIdBack' && that.id == '2') {
// } else if (that.type == 'fileLIstImg' && that.id == '3') { // imageInfoType = '6'
// imageInfoType = '7' // } else if (that.type == 'fileLIstImg' && that.id == '3') {
// } else if (that.type == 'fileLIstImg' && that.id == '4') { // imageInfoType = '7'
// imageInfoType = '8' // } else if (that.type == 'fileLIstImg' && that.id == '4') {
// } else if (that.type == 'fileLIstImg' && that.id == '5') { // imageInfoType = '8'
// imageInfoType = '9' // } else if (that.type == 'fileLIstImg' && that.id == '5') {
// } else if (that.type == 'fileLIstImg' && that.id == '6') { // imageInfoType = '9'
// imageInfoType = '10' // } else if (that.type == 'fileLIstImg' && that.id == '6') {
// } else if (that.type == 'saleInsuredInfoOther' && that.id == '7') { // imageInfoType = '10'
// imageInfoType = '11' // } else if (that.type == 'saleInsuredInfoOther' && that.id == '7') {
// } // imageInfoType = '11'
if (that.type == 'fileListIdFront' && that.id == '1') { // }
//身份证正面 if (that.type == 'fileListIdFront' && that.id == '1') {
name = 'fileListIdFront' //身份证正面
imageInfoType = '1' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '1') { imageInfoType = '1'
//身份证反面 } else if (that.type == 'fileListIdBack' && that.id == '1') {
name = 'fileListIdBack' //身份证反面
imageInfoType = '2' name = 'fileListIdBack'
} else if (that.type == 'fileListIdFront' && that.id == '2') { imageInfoType = '2'
//户口本正面 } else if (that.type == 'fileListIdFront' && that.id == '2') {
name = 'fileListIdFront' //户口本正面
imageInfoType = '5' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '2') { imageInfoType = '5'
//户口本反面 } else if (that.type == 'fileListIdBack' && that.id == '2') {
name = 'fileListIdBack' //户口本反面
imageInfoType = '6' name = 'fileListIdBack'
} else if (that.type == 'fileListIdFront' && that.id == '3') { imageInfoType = '6'
//出生证正面 } else if (that.type == 'fileListIdFront' && that.id == '3') {
name = 'fileListIdFront' //出生证正面
imageInfoType = '7' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '3') { imageInfoType = '7'
//出生证反面 } else if (that.type == 'fileListIdBack' && that.id == '3') {
name = 'fileListIdBack' //出生证反面
imageInfoType = '12' name = 'fileListIdBack'
} else if (that.type == 'fileLIstImg' && that.id == '4') { imageInfoType = '12'
//护照面 } else if (that.type == 'fileLIstImg' && that.id == '4') {
name = 'fileLIstImg' //护照面
imageInfoType = '8' name = 'fileLIstImg'
} else if (that.type == 'fileListIdFront' && that.id == '5') { imageInfoType = '8'
//港澳居民来往内地通行证正面 } else if (that.type == 'fileListIdFront' && that.id == '5') {
name = 'fileListIdFront' //港澳居民来往内地通行证正面
imageInfoType = '9' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '5') { imageInfoType = '9'
//港澳居民来往内地通行证反面 } else if (that.type == 'fileListIdBack' && that.id == '5') {
name = 'fileListIdBack' //港澳居民来往内地通行证反面
imageInfoType = '13' name = 'fileListIdBack'
} else if (that.type == 'fileListIdFront' && that.id == '6') { imageInfoType = '13'
//台湾居民来往大陆通行证正面 } else if (that.type == 'fileListIdFront' && that.id == '6') {
name = 'fileListIdFront' //台湾居民来往大陆通行证正面
imageInfoType = '10' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '6') { imageInfoType = '10'
//台湾居民来往大陆通行证反面 } else if (that.type == 'fileListIdBack' && that.id == '6') {
name = 'fileListIdBack' //台湾居民来往大陆通行证反面
imageInfoType = '14' name = 'fileListIdBack'
} else if (that.type == 'fileListIdFront' && that.id == '8') { imageInfoType = '14'
//外国人永久居留身份证正面 } else if (that.type == 'fileListIdFront' && that.id == '8') {
name = 'fileListIdFront' //外国人永久居留身份证正面
imageInfoType = '15' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '8') { imageInfoType = '15'
//外国人永久居留身份证反面 } else if (that.type == 'fileListIdBack' && that.id == '8') {
name = 'fileListIdBack' //外国人永久居留身份证反面
imageInfoType = '16' name = 'fileListIdBack'
} else if (that.type == 'fileListIdFront' && that.id == '9') { imageInfoType = '16'
//港澳台居民居住证正面 } else if (that.type == 'fileListIdFront' && that.id == '9') {
name = 'fileListIdFront' //港澳台居民居住证正面
imageInfoType = '17' name = 'fileListIdFront'
} else if (that.type == 'fileListIdBack' && that.id == '9') { imageInfoType = '17'
//港澳台居民居住证反面 } else if (that.type == 'fileListIdBack' && that.id == '9') {
name = 'fileListIdBack' //港澳台居民居住证反面
imageInfoType = '18' name = 'fileListIdBack'
} else if (that.type == 'fileListBank') { imageInfoType = '18'
//银行卡正面 } else if (that.type == 'fileListBank') {
name = 'fileListBank' //银行卡正面
imageInfoType = '3' name = 'fileListBank'
// } else if (that.type == 'fileListBankBack') { imageInfoType = '3'
// //银行卡反面 // } else if (that.type == 'fileListBankBack') {
// imageInfoType = '19' // //银行卡反面
} // imageInfoType = '19'
let obj = { }
name: name, let obj = {
businessNo: that.orderNo, name: name,
businessType: '', businessNo: that.orderNo,
imageInfoType: imageInfoType, businessType: '',
// window.localStorage.setItem('bankCardUrlInsuredPath', encodeURI(JSON.parse(data).path).replace(/\+/g, '%2B')) imageInfoType: imageInfoType,
rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'), // window.localStorage.setItem('bankCardUrlInsuredPath', encodeURI(JSON.parse(data).path).replace(/\+/g, '%2B'))
subBusinessType: '0', rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'),
subBusinessNo: that.saleInsuredInfo.appntId, subBusinessType: '0',
fileName: that.imgName subBusinessNo: that.saleInsuredInfo.appntId,
} fileName: that.imgName
that.list.push(obj) }
} else if ( that.list.push(obj)
that.type == 'fileListIdFrontInsured' || } else if (
that.type == 'fileListIdBackInsured' || that.type == 'fileListIdFrontInsured' ||
that.type == 'fileListBankInsured' || that.type == 'fileListIdBackInsured' ||
that.type == 'fileLIstImgInsured' || that.type == 'fileListBankInsured' ||
that.type == 'saleInsuredPersonInfoOther' that.type == 'fileLIstImgInsured' ||
) { that.type == 'saleInsuredPersonInfoOther'
// 是被保险人 ) {
// 证件类型 // 是被保险人
// 证件类型
let imageInfoType = '' let imageInfoType = ''
let name = '' let name = ''
if (that.type == 'fileListIdFrontInsured' && that.id == '1') { if (that.type == 'fileListIdFrontInsured' && that.id == '1') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '1' imageInfoType = '1'
} else if (that.type == 'fileListIdBackInsured' && that.id == '1') { } else if (that.type == 'fileListIdBackInsured' && that.id == '1') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '2' imageInfoType = '2'
} else if (that.type == 'fileListIdFrontInsured' && that.id == '2') { } else if (that.type == 'fileListIdFrontInsured' && that.id == '2') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '5' imageInfoType = '5'
} else if (that.type == 'fileListIdBackInsured' && that.id == '2') { } else if (that.type == 'fileListIdBackInsured' && that.id == '2') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '6' imageInfoType = '6'
} else if (that.type == 'fileListIdFrontInsured' && that.id == '3') { } else if (that.type == 'fileListIdFrontInsured' && that.id == '3') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '7' imageInfoType = '7'
} else if (that.type == 'fileListIdBackInsured' && that.id == '3') { } else if (that.type == 'fileListIdBackInsured' && that.id == '3') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '12' imageInfoType = '12'
} else if (that.type == 'fileLIstImgInsured' && that.id == '4') { } else if (that.type == 'fileLIstImgInsured' && that.id == '4') {
name = 'fileLIstImgInsured' name = 'fileLIstImgInsured'
imageInfoType = '8' imageInfoType = '8'
} else if (that.type == 'fileListIdFrontInsured' && that.id == '5') { } else if (that.type == 'fileListIdFrontInsured' && that.id == '5') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '9' imageInfoType = '9'
} else if (that.type == 'fileListIdBackInsured' && that.id == '5') { } else if (that.type == 'fileListIdBackInsured' && that.id == '5') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '13' imageInfoType = '13'
} else if (that.type == 'fileListIdFrontInsured' && that.id == '6') { } else if (that.type == 'fileListIdFrontInsured' && that.id == '6') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '10' imageInfoType = '10'
} else if (that.type == 'fileListIdBackInsured' && that.id == '6') { } else if (that.type == 'fileListIdBackInsured' && that.id == '6') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '14' imageInfoType = '14'
} else if (that.type == 'fileListIdFrontInsured' && that.id == '8') { } else if (that.type == 'fileListIdFrontInsured' && that.id == '8') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '15' imageInfoType = '15'
} else if (that.type == 'fileListIdBackInsured' && that.id == '8') { } else if (that.type == 'fileListIdBackInsured' && that.id == '8') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '16' imageInfoType = '16'
} else if (that.type == 'fileListIdFrontInsured' && that.id == '9') { } else if (that.type == 'fileListIdFrontInsured' && that.id == '9') {
name = 'fileListIdFrontInsured' name = 'fileListIdFrontInsured'
imageInfoType = '17' imageInfoType = '17'
} else if (that.type == 'fileListIdBackInsured' && that.id == '9') { } else if (that.type == 'fileListIdBackInsured' && that.id == '9') {
name = 'fileListIdBackInsured' name = 'fileListIdBackInsured'
imageInfoType = '18' imageInfoType = '18'
}
let obj = {
name: name,
businessNo: that.orderNo,
businessType: '',
imageInfoType: imageInfoType,
rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'),
subBusinessType: '1',
subBusinessNo: that.saleInsuredPersonInfo.insuredId,
fileName: that.imgName
}
that.list.push(obj)
} else if (that.type == 'fileListOther') {
// 是其他
let type = '2'
let name = 'fileListOther'
let obj = {
name: name,
businessNo: that.orderNo,
businessType: name,
imageInfoType: '11',
rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'),
subBusinessType: type,
subBusinessNo: '',
fileName: that.imgName
}
that.list.push(obj)
// } else if (that.type == 'fileListtypebeneficiary') {
// // 是受益人
// let type = '3'
// let obj = {
// businessNo: that.orderNo,
// businessType: '',
// imageInfoType: '21',
// rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'),
// subBusinessType: type,
// subBusinessNo: '',
// fileName: that.imgName
// }
// that.list.push(obj)
} }
} else {
let obj = { switch (that.type) {
name: name, case 'fileListIdFront':
businessNo: that.orderNo, that.fileListIdFront = []
businessType: '', break
imageInfoType: imageInfoType, case 'fileListIdBack':
rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'), that.fileListIdBack = []
subBusinessType: '1', break
subBusinessNo: that.saleInsuredPersonInfo.insuredId, case 'fileLIstImg':
fileName: that.imgName that.fileLIstImg = []
break
case 'fileListBank':
that.fileListBank = []
break
case 'fileListOther':
that.fileListOther = []
break
case 'fileListIdFrontInsured':
that.fileListIdFrontInsured = []
break
case 'fileListIdBackInsured':
that.fileListIdBackInsured = []
break
case 'fileListBankInsured':
that.fileListBankInsured = []
break
case 'fileLIstImgInsured':
that.fileLIstImgInsured = []
break
case 'saleInsuredInfoOther':
that.saleInsuredInfoOther = []
break
case 'saleInsuredPersonInfoOther':
that.saleInsuredPersonInfoOther = []
break
} }
this.$toast.clear()
that.list.push(obj) this.$toast(res.resultMessage)
} else if (that.type == 'fileListOther') {
// 是其他
let type = '2'
let name = 'fileListOther'
let obj = {
name: name,
businessNo: that.orderNo,
businessType: name,
imageInfoType: '11',
rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'),
subBusinessType: type,
subBusinessNo: '',
fileName: that.imgName
}
that.list.push(obj)
// } else if (that.type == 'fileListtypebeneficiary') {
// // 是受益人
// let type = '3'
// let obj = {
// businessNo: that.orderNo,
// businessType: '',
// imageInfoType: '21',
// rgssUrl: encodeURI(res.path).replace(/\+/g, '%2B'),
// subBusinessType: type,
// subBusinessNo: '',
// fileName: that.imgName
// }
// that.list.push(obj)
} }
} else { },
error => {
switch (that.type) { switch (that.type) {
case 'fileListIdFront': case 'fileListIdFront':
that.fileListIdFront = [] that.fileListIdFront = []
@@ -957,9 +1007,6 @@ export default {
case 'fileListBank': case 'fileListBank':
that.fileListBank = [] that.fileListBank = []
break break
// case 'fileListBankBack':
// that.fileListBankBack = []
// break
case 'fileListOther': case 'fileListOther':
that.fileListOther = [] that.fileListOther = []
break break
@@ -982,13 +1029,12 @@ export default {
that.saleInsuredPersonInfoOther = [] that.saleInsuredPersonInfoOther = []
break break
} }
this.$toast.clear() this.$toast('网络错误')
this.$toast(res.resultMessage)
} }
}) )
}, },
beforeNext(isDis){ beforeNext(isDis) {
if(isDis && this.fileListBank.length > 0 && this.fileListIdBack.length > 0 && this.fileListIdFront.length > 0){ if (isDis && this.fileListBank.length > 0 && this.fileListIdBack.length > 0 && this.fileListIdFront.length > 0) {
this.$toast('请勾选确认销售人员已见证各证件原件并拍照上传') this.$toast('请勾选确认销售人员已见证各证件原件并拍照上传')
} }
}, },