goods.js 8.1 KB

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