This commit is contained in:
2025-05-12 19:45:27 +08:00
parent 2e9c403632
commit ce0587d2b6
47 changed files with 1355 additions and 310 deletions

View File

@@ -1,3 +1,6 @@
import {BASEURL} from "./request.js";
import {useUserStore} from "../pinia/UserStore/index.js";
export const showToast = (options) => {
if (typeof options === 'string') {
uni.showToast({
@@ -25,6 +28,12 @@ export const toPage = async (url) => {
}
}
export const clearObject = (obj) => {
Object.keys(obj).forEach(key => {
delete obj[key];
});
};
export const backPage = () => {
uni.navigateBack().then();
}
@@ -117,3 +126,38 @@ export const download = (urls) => {
});
// #endif
}
export const numberToCharacter = (number) => {
return ['一', '二', '三', '四', '五'][number];
}
export const uploadFile = ({count}) => {
const UserStore = useUserStore();
return new Promise((resolve, reject) => {
uni.chooseImage({
count: count,
success: ({tempFilePaths}) => {
const file = tempFilePaths[0];
uni.uploadFile({
url: BASEURL + '/upload/upload',
filePath: file,
name: "file",
header: {
token: UserStore.token
},
success: ({data}) => {
resolve(JSON.parse(data));
},
fail: (err) => {
showToast(err.errMsg);
reject(err);
}
});
},
fail: (err) => {
showToast(err.errMsg);
reject(err);
}
});
});
}