移动端V1.0

This commit is contained in:
2025-07-16 15:34:34 +08:00
commit 194b0750fd
1083 changed files with 178295 additions and 0 deletions

30
utils/checkPic.js Normal file
View File

@@ -0,0 +1,30 @@
export function checkPic(file) {
return new Promise((resolve, reject) => {
// 获取图片的后缀名
const suffix = file.name.split('.').pop().toLowerCase();
const allowedTypes = ['jpg', 'png', 'jpeg'];
const maxSize = 5242880; // 5MB in bytes
// 判断后缀是否符合要求
if (!allowedTypes.includes(suffix)) {
uni.showToast({
title: "不支持" + suffix + "格式的图片",
icon: "none"
});
resolve(false);
} else if (file.size > maxSize) {
uni.showToast({
title: "最大只能上传5MB的图片",
icon: "none"
});
resolve(false);
} else {
resolve(true);
}
});
}
export function isImageUrl(url) {
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
const extension = url.split('.').pop().toLowerCase();
return imageExtensions.includes(extension);
}