index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. const common_vendor = require("../../../../../common/vendor.js");
  3. const sheep_components_sShareModal_canvasPoster_poster_user = require("./user.js");
  4. const sheep_components_sShareModal_canvasPoster_poster_goods = require("./goods.js");
  5. const sheep_components_sShareModal_canvasPoster_poster_groupon = require("./groupon.js");
  6. const sheep_index = require("../../../../index.js");
  7. const sheep_api_infra_file = require("../../../../api/infra/file.js");
  8. let locaImage = common_vendor.ref("");
  9. async function getFileURL(file) {
  10. await sheep_api_infra_file.FileApi.getFileIO(file).then((res) => {
  11. locaImage.value = `data:image/png;base64,${res}`;
  12. console.log(locaImage.value);
  13. });
  14. }
  15. async function getPosterData(options) {
  16. const userInfo = sheep_index.sheep.$store("user").userInfo;
  17. console.log(JSON.parse(common_vendor.index.getStorageSync("user-store")).userInfo);
  18. let avatar = userInfo.avatar;
  19. switch (options.shareInfo.poster.type) {
  20. case "user":
  21. await getFileURL(avatar);
  22. options.avatar = locaImage.value;
  23. return sheep_components_sShareModal_canvasPoster_poster_user.user(options);
  24. case "goods":
  25. await getFileURL(avatar);
  26. options.avatar = locaImage.value;
  27. await getFileURL(options.shareInfo.poster.image);
  28. options.shareInfo.poster.image = locaImage.value;
  29. return sheep_components_sShareModal_canvasPoster_poster_goods.goods(options);
  30. case "groupon":
  31. return sheep_components_sShareModal_canvasPoster_poster_groupon.groupon(options);
  32. }
  33. }
  34. function formatImageUrlProtocol(url) {
  35. if (url.indexOf("http:") === 0) {
  36. url = url.replace("http:", "https:");
  37. }
  38. return url;
  39. }
  40. exports.formatImageUrlProtocol = formatImageUrlProtocol;
  41. exports.getPosterData = getPosterData;