You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 weeks ago
4 months ago
4 months ago
4 months ago
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const config_site_config = require("../config/site.config.js");
  4. let goPage = (url, params = {}, type = "navigateTo") => {
  5. common_vendor.index.$u.route({
  6. url,
  7. params,
  8. type
  9. });
  10. };
  11. let { H5_API, WX_API, httpPrefix } = config_site_config.obj;
  12. var _url = H5_API + WX_API + httpPrefix;
  13. function uploadImgApi(filePath, imgName, imgLink = "image") {
  14. console.log(filePath);
  15. let token = "Bearer " + common_vendor.index.getStorageSync("token");
  16. let timer = /* @__PURE__ */ new Date() * 1;
  17. return new Promise((reslove, reject) => {
  18. common_vendor.index.uploadFile({
  19. url: _url + "infra/file/upload",
  20. //接口
  21. filePath,
  22. //要上传的图片的本地路径
  23. name: "file",
  24. // complain
  25. formData: {
  26. path: imgLink + "/" + common_vendor.index.$u.date(timer, "yyyy-mm-dd") + "/" + timer + "-" + imgName,
  27. type: 1,
  28. fileSuffix: "png"
  29. },
  30. header: {
  31. Authorization: token
  32. // 'tenant-id': '1704459882232553474'
  33. },
  34. success(res) {
  35. console.log("上传成功??");
  36. console.log(res);
  37. let res2 = JSON.parse(res.data);
  38. reslove(res2.data);
  39. },
  40. fail(error) {
  41. return Promise.reject(error);
  42. },
  43. complete: (err) => {
  44. common_vendor.index.hideLoading();
  45. }
  46. });
  47. });
  48. }
  49. exports.goPage = goPage;
  50. exports.uploadImgApi = uploadImgApi;