goods.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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/api/member/signin.js");
  39. require("../../sheep/util/index.js");
  40. if (!Array) {
  41. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  42. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  43. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  44. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  45. (_easycom_s_goods_item2 + _easycom_s_empty2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  46. }
  47. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  48. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  49. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  50. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  51. if (!Math) {
  52. (_easycom_s_goods_item + _easycom_s_empty + _easycom_uni_load_more + _easycom_s_layout)();
  53. }
  54. const _sfc_main = {
  55. __name: "goods",
  56. setup(__props) {
  57. const state = common_vendor.reactive({
  58. pagination: {
  59. list: [],
  60. total: 0,
  61. pageNo: 1,
  62. pageSize: 1
  63. },
  64. loadStatus: "",
  65. shareInfo: {}
  66. });
  67. function onShareGoods(goodsInfo) {
  68. state.shareInfo = sheep_platform_share.$share.getShareInfo(
  69. {
  70. title: goodsInfo.title,
  71. image: sheep_index.sheep.$url.cdn(goodsInfo.image),
  72. desc: goodsInfo.subtitle,
  73. params: {
  74. page: "2",
  75. query: goodsInfo.id
  76. }
  77. },
  78. {
  79. type: "goods",
  80. // 商品海报
  81. title: goodsInfo.title,
  82. // 商品标题
  83. image: sheep_index.sheep.$url.cdn(goodsInfo.image),
  84. // 商品主图
  85. price: goodsInfo.price[0],
  86. // 商品价格
  87. original_price: goodsInfo.original_price
  88. // 商品原价
  89. }
  90. );
  91. sheep_hooks_useModal.showShareModal();
  92. }
  93. async function getGoodsList() {
  94. state.loadStatus = "loading";
  95. let { code, data } = await sheep_api_product_spu.SpuApi.getSpuPage({
  96. pageSize: state.pagination.pageSize,
  97. pageNo: state.pagination.pageNo
  98. });
  99. if (code !== 0) {
  100. return;
  101. }
  102. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  103. state.pagination.total = data.total;
  104. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  105. data.list.forEach((item) => {
  106. sheep_api_trade_brokerage.BrokerageApi.getProductBrokeragePrice(item.id).then((res) => {
  107. item.brokerageMinPrice = res.data.brokerageMinPrice;
  108. item.brokerageMaxPrice = res.data.brokerageMaxPrice;
  109. });
  110. });
  111. }
  112. common_vendor.onLoad(() => {
  113. getGoodsList();
  114. });
  115. function loadMore() {
  116. if (state.loadStatus === "noMore") {
  117. return;
  118. }
  119. state.pagination.pageNo++;
  120. getGoodsList();
  121. }
  122. common_vendor.onReachBottom(() => {
  123. loadMore();
  124. });
  125. return (_ctx, _cache) => {
  126. return common_vendor.e({
  127. a: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  128. return common_vendor.e({
  129. a: item.brokerageMinPrice === void 0
  130. }, item.brokerageMinPrice === void 0 ? {} : item.brokerageMinPrice === item.brokerageMaxPrice ? {
  131. c: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMinPrice))
  132. } : {
  133. d: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMinPrice)),
  134. e: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMaxPrice))
  135. }, {
  136. b: item.brokerageMinPrice === item.brokerageMaxPrice,
  137. f: common_vendor.o(($event) => onShareGoods(item), item.id),
  138. g: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  139. id: item.id
  140. }), item.id),
  141. h: "1b0a4b5d-1-" + i0 + ",1b0a4b5d-0",
  142. i: common_vendor.p({
  143. size: "lg",
  144. img: item.picUrl,
  145. title: item.name,
  146. subTitle: item.introduction,
  147. price: item.price,
  148. originPrice: item.marketPrice,
  149. priceColor: "#333"
  150. }),
  151. j: item.id
  152. });
  153. }),
  154. b: state.pagination.total === 0
  155. }, state.pagination.total === 0 ? {
  156. c: common_vendor.p({
  157. icon: "/static/goods-empty.png",
  158. text: "暂无推广商品"
  159. })
  160. } : {}, {
  161. d: state.pagination.total > 0
  162. }, state.pagination.total > 0 ? {
  163. e: common_vendor.o(loadMore),
  164. f: common_vendor.p({
  165. status: state.loadStatus,
  166. ["content-text"]: {
  167. contentdown: "上拉加载更多"
  168. }
  169. })
  170. } : {}, {
  171. g: common_vendor.p({
  172. title: "推广商品",
  173. onShareAppMessage: state.shareInfo
  174. })
  175. });
  176. };
  177. }
  178. };
  179. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1b0a4b5d"], ["__file", "D:/zx/mall-front-app/pages/commission/goods.vue"]]);
  180. _sfc_main.__runtimeHooks = 2;
  181. wx.createPage(MiniProgramPage);