hookehuyr

检测图片格式

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