// 公共图片上传方法 import { useCacheStore } from '@/stores/cache' export function uploadImage(tempFilePath: string, onSuccess?: (url: string) => void, onFail?: (err: any) => void) { const cache = useCacheStore() uni.uploadFile({ url: 'http://192.168.0.11:8080/jeecg-boot/sys/common/upload', filePath: tempFilePath, name: 'file', header: { 'x-access-token': cache.get('TOKEN') }, success: (res) => { const data =JSON.parse(res.data) if (res.statusCode == 200){ // uni.showToast({ title: '上传成功', icon: 'success' }) onSuccess && onSuccess(data.message) } else { uni.showToast({ title: '上传失败', icon: 'none' }) onFail && onFail(data) } }, fail: (err) => { console.log(err) uni.showToast({ title: '上传失败', icon: 'none' }) onFail && onFail(err) } }) }