[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() 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(
res => {
if (res.result == '0') { if (res.result == '0') {
this.$toast.clear() this.$toast.clear()
let imageInfoType = '' let imageInfoType = ''
@@ -318,7 +319,7 @@ export default {
} }
that.list.push(obj) that.list.push(obj)
} else { } else {
that.$toast(res.resultMessage || '请重新上传图片') that.$toast(res.resultMessage || '图片上传失败,请重新上传图片')
switch (that.type) { switch (that.type) {
case 'fileListBank01': case 'fileListBank01':
this.fileListBank01.pop() this.fileListBank01.pop()
@@ -337,7 +338,28 @@ export default {
break 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) { 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,7 +731,8 @@ 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(
res => {
// console.log(res) // console.log(res)
if (res.result == '0') { if (res.result == '0') {
this.$toast.clear() this.$toast.clear()
@@ -957,9 +967,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
@@ -985,7 +992,46 @@ export default {
this.$toast.clear() this.$toast.clear()
this.$toast(res.resultMessage) this.$toast(res.resultMessage)
} }
}) },
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) { 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) {