index.ts 527 B

12345678910111213141516171819
  1. import { BASE_URL } from '@/utils/request';
  2. import { useUserStoreWithOut } from '@/store/index.js';
  3. const userStore = useUserStoreWithOut()
  4. const token = userStore.token || uni.getStorageSync('token')
  5. export const uploadImg = (filePath, callBack, failHandle) => uni.uploadFile({
  6. url: BASE_URL + '/api/yt/fileStorage/upload', //上传图片的后端接口
  7. filePath: filePath,
  8. name: 'file',
  9. header: {
  10. 'X-Authorization': `Bearer ${token}`
  11. },
  12. success: res => {
  13. callBack(res)
  14. },
  15. fail: (res) => {
  16. failHandle(res)
  17. }
  18. })