su-image.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../index.js");
  4. require("../../api/index.js");
  5. require("../../api/distri/score.js");
  6. require("../../request/index.js");
  7. require("../../config/index.js");
  8. require("../../store/index.js");
  9. require("../../store/app.js");
  10. require("../../api/promotion/diy.js");
  11. require("../../platform/index.js");
  12. require("../../platform/provider/wechat/index.js");
  13. require("../../platform/provider/wechat/miniProgram.js");
  14. require("../../api/member/auth.js");
  15. require("../../api/member/social.js");
  16. require("../../api/member/user.js");
  17. require("../../platform/provider/apple/index.js");
  18. require("../../platform/share.js");
  19. require("../../router/index.js");
  20. require("../../hooks/useModal.js");
  21. require("../../helper/index.js");
  22. require("../../helper/test.js");
  23. require("../../helper/digit.js");
  24. require("../../api/member/signin.js");
  25. require("../../helper/throttle.js");
  26. require("../../url/index.js");
  27. require("../../platform/pay.js");
  28. require("../../api/pay/order.js");
  29. require("../../store/user.js");
  30. require("../../store/cart.js");
  31. require("../../api/trade/cart.js");
  32. require("../../api/pay/wallet.js");
  33. require("../../api/trade/order.js");
  34. require("../../api/promotion/coupon.js");
  35. require("../../store/sys.js");
  36. require("../../store/modal.js");
  37. require("../../api/distri/share.js");
  38. require("../../api/distri/team.js");
  39. require("../../api/infra/file.js");
  40. require("../../api/member/address.js");
  41. require("../../api/member/point.js");
  42. require("../../api/migration/app.js");
  43. require("../../api/migration/chat.js");
  44. require("../../api/migration/index.js");
  45. require("../../api/migration/third.js");
  46. require("../../api/pay/channel.js");
  47. require("../../api/product/category.js");
  48. require("../../api/product/comment.js");
  49. require("../../api/product/favorite.js");
  50. require("../../api/product/history.js");
  51. require("../../api/product/spu.js");
  52. require("../../api/promotion/activity.js");
  53. require("../../api/promotion/article.js");
  54. require("../../api/promotion/bargain.js");
  55. require("../../api/promotion/combination.js");
  56. require("../../api/promotion/rewardActivity.js");
  57. require("../../api/promotion/seckill.js");
  58. require("../../api/system/area.js");
  59. require("../../api/system/voice.js");
  60. require("../../api/trade/afterSale.js");
  61. require("../../api/trade/brokerage.js");
  62. require("../../api/trade/config.js");
  63. require("../../api/trade/delivery.js");
  64. require("../../config/zIndex.js");
  65. const _sfc_main = {
  66. __name: "su-image",
  67. props: {
  68. src: {
  69. type: String,
  70. default: ""
  71. },
  72. errorSrc: {
  73. type: String,
  74. default: "/static/img/shop/empty_network.png"
  75. },
  76. mode: {
  77. type: String,
  78. default: "widthFix"
  79. },
  80. isPreview: {
  81. type: Boolean,
  82. default: false
  83. },
  84. previewList: {
  85. type: Array,
  86. default() {
  87. return [];
  88. }
  89. },
  90. current: {
  91. type: Number,
  92. default: -1
  93. },
  94. height: {
  95. type: Number,
  96. default: 0
  97. },
  98. width: {
  99. type: Number,
  100. default: 0
  101. },
  102. radius: {
  103. type: Number,
  104. default: 0
  105. }
  106. },
  107. emits: ["load", "error"],
  108. setup(__props, { emit: __emit }) {
  109. const state = common_vendor.reactive({
  110. isError: false,
  111. imgHeight: 600
  112. });
  113. const props = __props;
  114. const emits = __emit;
  115. const customStyle = common_vendor.computed(() => {
  116. return {
  117. height: (props.height || state.imgHeight) + "rpx",
  118. width: props.width ? props.width + "rpx" : "100%",
  119. borderRadius: props.radius ? props.radius + "rpx" : ""
  120. };
  121. });
  122. function onImgLoad(e) {
  123. if (props.height === 0) {
  124. state.imgHeight = e.detail.height / e.detail.width * 750;
  125. }
  126. }
  127. function onImgError(e) {
  128. state.isError = true;
  129. emits("error", e);
  130. }
  131. function onImgPreview() {
  132. if (!props.isPreview)
  133. return;
  134. common_vendor.index.previewImage({
  135. urls: props.previewList.length < 1 ? [props.src] : props.previewList,
  136. current: props.current,
  137. longPressActions: {
  138. itemList: ["发送给朋友", "保存图片", "收藏"],
  139. success: function(data) {
  140. console.log("选中了第" + (data.tapIndex + 1) + "个按钮,第" + (data.index + 1) + "张图片");
  141. },
  142. fail: function(err) {
  143. console.log(err.errMsg);
  144. }
  145. }
  146. });
  147. }
  148. return (_ctx, _cache) => {
  149. return common_vendor.e({
  150. a: !state.isError
  151. }, !state.isError ? {
  152. b: common_vendor.s(customStyle.value),
  153. c: __props.mode,
  154. d: common_vendor.unref(sheep_index.sheep).$url.cdn(__props.src),
  155. e: common_vendor.o(onImgPreview),
  156. f: common_vendor.o(onImgLoad),
  157. g: common_vendor.o(onImgError)
  158. } : {});
  159. };
  160. }
  161. };
  162. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ed9e576c"], ["__file", "D:/zx/mall-front-app/sheep/ui/su-image/su-image.vue"]]);
  163. wx.createComponent(Component);