移动端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

52
utils/uploadImg.js Normal file
View File

@@ -0,0 +1,52 @@
import uploadFile from "@/plugins/upload.js";
import {
checkPic
} from "@/utils/checkPic.js"
export function uploadImg(uploadUrl, photo, tempImgs, baseUrl, callback) {
uni.chooseImage({
count: 3,
success: async (img) => {
let bool = await checkPic(img.tempFiles[0]);
if (bool) {
uploadFile(uploadUrl, img.tempFilePaths[0]).then((res) => {
let fileName = JSON.parse(res).fileName;
if (photo) {
photo += "," + fileName
} else {
photo = fileName
}
tempImgs.push({
path: baseUrl + fileName
});
// 调用回调函数
callback && callback(null, {
photo,
tempImgs
});
})
}
},
fail: (error) => {}
});
}
export function previewImg(imgs,index=0) {
let urls = [];
urls = imgs.map(img => img.path);
uni.previewImage({
urls: urls,
current:index
})
}
export function removeImg(index,path,photo,tempImgs,baseUrl,callback) {
tempImgs.splice(index, 1);
let newImgs = tempImgs.filter(fileName => fileName.path !== path);
newImgs = newImgs.map(img => img.path.replace(baseUrl, ''))
newImgs = newImgs.join(",");
photo = newImgs;
// 调用回调函数
callback && callback(null, {
photo
});
}