|
@@ -46,7 +46,9 @@ const beforeUploadImg = () => {
|
|
|
}
|
|
|
uploadImg()
|
|
|
},
|
|
|
- fail: function (res) {}
|
|
|
+ fail: function (res) {
|
|
|
+ console.log('res', res)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -83,6 +85,8 @@ const uploadImg = async () => {
|
|
|
sizeType: ['original', 'compressed'],
|
|
|
sourceType: sourceType.value,
|
|
|
async success(res: any) {
|
|
|
+ console.log('res', res)
|
|
|
+
|
|
|
let tempFiles = res.tempFiles
|
|
|
// 当前相片来源为拍照
|
|
|
if (sourceType.value[0] === 'camera') {
|
|
@@ -92,6 +96,19 @@ const uploadImg = async () => {
|
|
|
tempFiles[0].path = path
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ let flag = res.tempFilePaths.every((item: string) => {
|
|
|
+ return item.includes('.jpg') || item.includes('.jpeg') || item.includes('.png')
|
|
|
+ })
|
|
|
+ if (!flag) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '暂不支持该格式照片,请更换为png或jpg格式',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 保存上传成功的数据
|
|
|
const imageValue: imgType[] = []
|
|
|
// 使用map而不是forEach,因为map会返回一个Promise数组
|