登陆页面完成,首页完成一半

This commit is contained in:
田岩
2025-06-12 21:02:03 +08:00
parent 8a71d40686
commit a3060cb959
716 changed files with 17180 additions and 35015 deletions
+42
View File
@@ -0,0 +1,42 @@
import {
get_base_url
} from '@/api/request'
import {
getToken
} from '@/common/common.js'
export const uploadFile = (file, data) => {
const url = '/plimg/fileUpload/stuMgrUploadImg';
const base_url = get_base_url(url);
const token = getToken();
const header = {};
if (token)
header['summary'] = token
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${base_url}${url}`,
header: header,
filePath: file,
name: 'file',
formData: data,
success(result) {
try {
const res = JSON.parse(result.data);
if (res.rtnCode === '0000') {
resolve(res.body);
} else {
reject(new Error(res.msg));
}
} catch (error) {
reject(new Error('Failed to parse response'));
}
},
fail(error) {
reject(new Error('Upload failed'));
}
});
});
};