qrcode-share.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_components_sShareModal_canvasPoster_useCanvas = require("../../sheep/components/s-share-modal/canvas-poster/useCanvas.js");
  5. require("../../sheep/store/index.js");
  6. require("../../sheep/helper/index.js");
  7. require("../../sheep/request/index.js");
  8. const sheep_api_distri_share = require("../../sheep/api/distri/share.js");
  9. require("../../sheep/url/index.js");
  10. require("../../sheep/config/index.js");
  11. require("../../sheep/router/index.js");
  12. require("../../sheep/hooks/useModal.js");
  13. require("../../sheep/helper/test.js");
  14. require("../../sheep/api/member/auth.js");
  15. require("../../sheep/api/member/signin.js");
  16. require("../../sheep/helper/throttle.js");
  17. require("../../sheep/platform/index.js");
  18. require("../../sheep/platform/provider/wechat/index.js");
  19. require("../../sheep/platform/provider/wechat/miniProgram.js");
  20. require("../../sheep/api/member/social.js");
  21. require("../../sheep/api/member/user.js");
  22. require("../../sheep/platform/provider/apple/index.js");
  23. require("../../sheep/platform/share.js");
  24. require("../../sheep/platform/pay.js");
  25. require("../../sheep/api/pay/order.js");
  26. require("../../sheep/config/zIndex.js");
  27. require("../../sheep/components/s-share-modal/canvas-poster/poster/index.js");
  28. require("../../sheep/components/s-share-modal/canvas-poster/poster/user.js");
  29. require("../../sheep/components/s-share-modal/canvas-poster/poster/goods.js");
  30. require("../../sheep/components/s-share-modal/canvas-poster/poster/groupon.js");
  31. require("../../sheep/api/infra/file.js");
  32. require("../../sheep/store/app.js");
  33. require("../../sheep/api/promotion/diy.js");
  34. require("../../sheep/store/user.js");
  35. require("../../sheep/store/cart.js");
  36. require("../../sheep/api/trade/cart.js");
  37. require("../../sheep/api/pay/wallet.js");
  38. require("../../sheep/api/trade/order.js");
  39. require("../../sheep/api/promotion/coupon.js");
  40. require("../../sheep/store/sys.js");
  41. require("../../sheep/store/modal.js");
  42. require("../../sheep/helper/digit.js");
  43. if (!Array) {
  44. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  45. _easycom_s_layout2();
  46. }
  47. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  48. if (!Math) {
  49. _easycom_s_layout();
  50. }
  51. const _sfc_main = {
  52. __name: "qrcode-share",
  53. setup(__props) {
  54. const state = common_vendor.reactive({
  55. linkId: 0
  56. });
  57. const poster = common_vendor.reactive({
  58. canvasId: "canvasId",
  59. width: sheep_index.sheep.$platform.device.windowWidth * 0.9,
  60. height: 600,
  61. src: ""
  62. });
  63. const vm = common_vendor.getCurrentInstance();
  64. async function getPoster(params) {
  65. poster.src = "";
  66. poster.shareInfo = {
  67. "title": "",
  68. "desc": "",
  69. "image": "",
  70. "path": "",
  71. "link": "https://zxgz.newfeifan.cn/#/pages/index/user?linkId=" + state.linkId,
  72. "poster": {
  73. "type": "user"
  74. }
  75. };
  76. const canvas = await sheep_components_sShareModal_canvasPoster_useCanvas.useCanvas(poster, vm);
  77. return canvas;
  78. }
  79. async function getLink() {
  80. sheep_api_distri_share.ShareApi.getLinkId(1).then((res) => {
  81. if (res.code !== 0) {
  82. return;
  83. }
  84. state.linkId = res.data.linkId;
  85. getPoster();
  86. });
  87. }
  88. const onSavePoster = () => {
  89. if (["WechatOfficialAccount", "H5"].includes(sheep_index.sheep.$platform.name)) {
  90. sheep_index.sheep.$helper.toast("请长按图片保存");
  91. return;
  92. }
  93. common_vendor.index.saveImageToPhotosAlbum({
  94. filePath: poster.src,
  95. success: (res) => {
  96. onClosePoster();
  97. sheep_index.sheep.$helper.toast("保存成功");
  98. },
  99. fail: (err) => {
  100. sheep_index.sheep.$helper.toast("保存失败");
  101. console.log("图片保存失败:", err);
  102. }
  103. });
  104. };
  105. common_vendor.onLoad(async () => {
  106. await getLink();
  107. });
  108. return (_ctx, _cache) => {
  109. return common_vendor.e({
  110. a: poster.src === ""
  111. }, poster.src === "" ? {
  112. b: poster.height + "px",
  113. c: poster.width + "px"
  114. } : {
  115. d: poster.src,
  116. e: poster.height + "px",
  117. f: poster.width + "px"
  118. }, {
  119. g: poster.canvasId,
  120. h: poster.canvasId,
  121. i: poster.height + "px",
  122. j: poster.width + "px",
  123. k: common_vendor.t(["wechatOfficialAccount", "H5"].includes(common_vendor.unref(sheep_index.sheep).$platform.name) ? "长按图片保存" : "长按图片保存"),
  124. l: common_vendor.o(onSavePoster),
  125. m: common_vendor.p({
  126. title: "我的二维码/分享页"
  127. })
  128. });
  129. };
  130. }
  131. };
  132. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-845d3787"], ["__file", "D:/zx/mall-front-app/pages/user/qrcode-share.vue"]]);
  133. wx.createPage(MiniProgramPage);