hookehuyr

检测图片格式

<!--
* @Date: 2022-09-26 14:36:57
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-28 17:56:57
* @LastEditTime: 2022-10-28 18:02:43
* @FilePath: /swx/src/pages/activityDetail/index.vue
* @Description: 活动详情页
-->
......@@ -206,6 +206,7 @@ const start = async () => {
const qrcode = await qrCodeActivityAPI({ i: getCurrentPageParam().id });
if (qrcode.code) {
qrcode_url = qrcode.data.qrcode_url;
// 图片格式不对可能导致渲染失败
base = {
width: 1024,
height: 1334,
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-28 16:30:35
* @LastEditTime: 2022-10-28 18:07:32
* @FilePath: /swx/src/pages/apxUserInfo/index.vue
* @Description: 补充资料
-->
......@@ -54,6 +54,9 @@ const afterRead = (event) => {
mask: true
});
const { file } = event.detail;
const fileName = file.url;
const ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "png" || ext == "PNG"){
// 获取上传URL
wx.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
......@@ -80,6 +83,13 @@ const afterRead = (event) => {
});
}
});
} else {
wx.showToast({
icon: 'error',
title: '请检查图片格式!',
mask: true
})
}
}
const removeUploadImage = () => {
has_image.value = false;
......