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

View File

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