[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,7 +275,8 @@ export default {
let formdata = new FormData()
formdata.append('imgPath', that.dataURLtoFile(that.file, that.imgName))
uploadImg(formdata).then(res => {
uploadImg(formdata).then(
res => {
if (res.result == '0') {
this.$toast.clear()
let imageInfoType = ''
@@ -318,7 +319,7 @@ export default {
}
that.list.push(obj)
} else {
that.$toast(res.resultMessage || '请重新上传图片')
that.$toast(res.resultMessage || '图片上传失败,请重新上传图片')
switch (that.type) {
case 'fileListBank01':
this.fileListBank01.pop()
@@ -337,7 +338,28 @@ export default {
break
}
}
})
},
error => {
that.$toast('网络错误')
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
}
}
)
},
// 删除图片
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,7 +731,8 @@ export default {
})
let formdata = new FormData()
formdata.append('imgPath', that.dataURLtoFile(that.file, that.imgName))
uploadImg(formdata).then(res => {
uploadImg(formdata).then(
res => {
// console.log(res)
if (res.result == '0') {
this.$toast.clear()
@@ -957,9 +967,6 @@ export default {
case 'fileListBank':
that.fileListBank = []
break
// case 'fileListBankBack':
// that.fileListBankBack = []
// break
case 'fileListOther':
that.fileListOther = []
break
@@ -985,10 +992,49 @@ export default {
this.$toast.clear()
this.$toast(res.resultMessage)
}
})
},
beforeNext(isDis){
if(isDis && this.fileListBank.length > 0 && this.fileListIdBack.length > 0 && this.fileListIdFront.length > 0){
error => {
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
}
this.$toast('网络错误')
}
)
},
beforeNext(isDis) {
if (isDis && this.fileListBank.length > 0 && this.fileListIdBack.length > 0 && this.fileListIdFront.length > 0) {
this.$toast('请勾选确认销售人员已见证各证件原件并拍照上传')
}
},