apiUpload.js 833 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { get, upload } from "./http";
  2. const prefix = 'devicesApi/picture/upload/';
  3. export default {
  4. /**
  5. * 上传图片
  6. * @param {*} uri 图片地址
  7. * @param {*} mime 图片类型
  8. * @param {*} type 图片分类 ↓
  9. * USER_PROFILE 用户头像
  10. * FEEDBACK 用户反馈
  11. * SERVICE_LOGO 服务提供商logo
  12. * SITE 站点
  13. * PDVL 驾驶证
  14. * @returns 服务器路径
  15. */
  16. uploadImage(uri, mime, type) {
  17. let data = new FormData();
  18. data.append('file', {
  19. uri: uri,
  20. type: mime,
  21. name: getFileName(uri)
  22. });
  23. return upload(prefix, data, {photoSubDir: type});
  24. },
  25. testNotification() {
  26. return get('devicesApi/googleNotification/doNotification');
  27. }
  28. }
  29. const getFileName = (path) => {
  30. var pos = path.lastIndexOf("/");
  31. var name = path.substring(pos+1);
  32. return name;
  33. }