qrcode-share.js 6.0 KB

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