goods.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_platform_share = require("../../sheep/platform/share.js");
  5. const sheep_hooks_useModal = require("../../sheep/hooks/useModal.js");
  6. const sheep_api_product_spu = require("../../sheep/api/product/spu.js");
  7. const sheep_api_trade_brokerage = require("../../sheep/api/trade/brokerage.js");
  8. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  9. require("../../sheep/url/index.js");
  10. require("../../sheep/store/index.js");
  11. require("../../sheep/store/app.js");
  12. require("../../sheep/api/promotion/diy.js");
  13. require("../../sheep/request/index.js");
  14. require("../../sheep/config/index.js");
  15. require("../../sheep/platform/index.js");
  16. require("../../sheep/platform/provider/wechat/index.js");
  17. require("../../sheep/platform/provider/wechat/miniProgram.js");
  18. require("../../sheep/api/member/auth.js");
  19. require("../../sheep/api/member/social.js");
  20. require("../../sheep/api/member/user.js");
  21. require("../../sheep/platform/provider/apple/index.js");
  22. require("../../sheep/platform/pay.js");
  23. require("../../sheep/helper/index.js");
  24. require("../../sheep/helper/test.js");
  25. require("../../sheep/helper/digit.js");
  26. require("../../sheep/api/pay/order.js");
  27. require("../../sheep/router/index.js");
  28. require("../../sheep/helper/throttle.js");
  29. require("../../sheep/store/user.js");
  30. require("../../sheep/store/cart.js");
  31. require("../../sheep/api/trade/cart.js");
  32. require("../../sheep/api/pay/wallet.js");
  33. require("../../sheep/api/trade/order.js");
  34. require("../../sheep/api/promotion/coupon.js");
  35. require("../../sheep/store/sys.js");
  36. require("../../sheep/store/modal.js");
  37. require("../../sheep/config/zIndex.js");
  38. require("../../sheep/util/index.js");
  39. if (!Array) {
  40. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  41. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  42. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  43. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  44. (_easycom_s_goods_item2 + _easycom_s_empty2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  45. }
  46. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  47. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  48. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  49. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  50. if (!Math) {
  51. (_easycom_s_goods_item + _easycom_s_empty + _easycom_uni_load_more + _easycom_s_layout)();
  52. }
  53. const _sfc_main = {
  54. __name: "goods",
  55. setup(__props) {
  56. const state = common_vendor.reactive({
  57. pagination: {
  58. list: [],
  59. total: 0,
  60. pageNo: 1,
  61. pageSize: 1
  62. },
  63. loadStatus: "",
  64. shareInfo: {}
  65. });
  66. function onShareGoods(goodsInfo) {
  67. state.shareInfo = sheep_platform_share.$share.getShareInfo(
  68. {
  69. title: goodsInfo.title,
  70. image: sheep_index.sheep.$url.cdn(goodsInfo.image),
  71. desc: goodsInfo.subtitle,
  72. params: {
  73. page: "2",
  74. query: goodsInfo.id
  75. }
  76. },
  77. {
  78. type: "goods",
  79. // 商品海报
  80. title: goodsInfo.title,
  81. // 商品标题
  82. image: sheep_index.sheep.$url.cdn(goodsInfo.image),
  83. // 商品主图
  84. price: goodsInfo.price[0],
  85. // 商品价格
  86. original_price: goodsInfo.original_price
  87. // 商品原价
  88. }
  89. );
  90. sheep_hooks_useModal.showShareModal();
  91. }
  92. async function getGoodsList() {
  93. state.loadStatus = "loading";
  94. let { code, data } = await sheep_api_product_spu.SpuApi.getSpuPage({
  95. pageSize: state.pagination.pageSize,
  96. pageNo: state.pagination.pageNo
  97. });
  98. if (code !== 0) {
  99. return;
  100. }
  101. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  102. state.pagination.total = data.total;
  103. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  104. data.list.forEach((item) => {
  105. sheep_api_trade_brokerage.BrokerageApi.getProductBrokeragePrice(item.id).then((res) => {
  106. item.brokerageMinPrice = res.data.brokerageMinPrice;
  107. item.brokerageMaxPrice = res.data.brokerageMaxPrice;
  108. });
  109. });
  110. }
  111. common_vendor.onLoad(() => {
  112. getGoodsList();
  113. });
  114. function loadMore() {
  115. if (state.loadStatus === "noMore") {
  116. return;
  117. }
  118. state.pagination.pageNo++;
  119. getGoodsList();
  120. }
  121. common_vendor.onReachBottom(() => {
  122. loadMore();
  123. });
  124. return (_ctx, _cache) => {
  125. return common_vendor.e({
  126. a: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  127. return common_vendor.e({
  128. a: item.brokerageMinPrice === void 0
  129. }, item.brokerageMinPrice === void 0 ? {} : item.brokerageMinPrice === item.brokerageMaxPrice ? {
  130. c: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMinPrice))
  131. } : {
  132. d: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMinPrice)),
  133. e: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMaxPrice))
  134. }, {
  135. b: item.brokerageMinPrice === item.brokerageMaxPrice,
  136. f: common_vendor.o(($event) => onShareGoods(item), item.id),
  137. g: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  138. id: item.id
  139. }), item.id),
  140. h: "1b0a4b5d-1-" + i0 + ",1b0a4b5d-0",
  141. i: common_vendor.p({
  142. size: "lg",
  143. img: item.picUrl,
  144. title: item.name,
  145. subTitle: item.introduction,
  146. price: item.price,
  147. originPrice: item.marketPrice,
  148. priceColor: "#333"
  149. }),
  150. j: item.id
  151. });
  152. }),
  153. b: state.pagination.total === 0
  154. }, state.pagination.total === 0 ? {
  155. c: common_vendor.p({
  156. icon: "/static/goods-empty.png",
  157. text: "暂无推广商品"
  158. })
  159. } : {}, {
  160. d: state.pagination.total > 0
  161. }, state.pagination.total > 0 ? {
  162. e: common_vendor.o(loadMore),
  163. f: common_vendor.p({
  164. status: state.loadStatus,
  165. ["content-text"]: {
  166. contentdown: "上拉加载更多"
  167. }
  168. })
  169. } : {}, {
  170. g: common_vendor.p({
  171. title: "推广商品",
  172. onShareAppMessage: state.shareInfo
  173. })
  174. });
  175. };
  176. }
  177. };
  178. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1b0a4b5d"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/commission/goods.vue"]]);
  179. _sfc_main.__runtimeHooks = 2;
  180. wx.createPage(MiniProgramPage);