"use strict"; var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; const common_vendor = require("../../../common/vendor.js"); const sheep_index = require("../../../sheep/index.js"); const sheep_platform_share = require("../../../sheep/platform/share.js"); const sheep_hooks_useModal = require("../../../sheep/hooks/useModal.js"); const sheep_api_product_spu = require("../../../sheep/api/product/spu.js"); const sheep_api_trade_brokerage = require("../../../sheep/api/trade/brokerage.js"); const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js"); if (!Array) { const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item"); const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty"); const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more"); const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout"); const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni"); (_easycom_s_goods_item2 + _easycom_s_empty2 + _easycom_uni_load_more2 + _easycom_s_layout2 + _component_layout_default_uni)(); } const _easycom_s_goods_item = () => "../../../sheep/components/s-goods-item/s-goods-item.js"; const _easycom_s_empty = () => "../../../sheep/components/s-empty/s-empty.js"; const _easycom_uni_load_more = () => "../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js"; const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js"; if (!Math) { (_easycom_s_goods_item + _easycom_s_empty + _easycom_uni_load_more + _easycom_s_layout)(); } const _sfc_main = { __name: "goods", setup(__props) { const state = common_vendor.reactive({ pagination: { list: [], total: 0, pageNo: 1, pageSize: 1 }, loadStatus: "", shareInfo: {} }); function onShareGoods(goodsInfo) { state.shareInfo = sheep_platform_share.$share.getShareInfo( { title: goodsInfo.title, image: sheep_index.sheep.$url.cdn(goodsInfo.image), desc: goodsInfo.subtitle, params: { page: "2", query: goodsInfo.id } }, { type: "goods", // 商品海报 title: goodsInfo.title, // 商品标题 image: sheep_index.sheep.$url.cdn(goodsInfo.image), // 商品主图 price: goodsInfo.price[0], // 商品价格 original_price: goodsInfo.original_price // 商品原价 } ); sheep_hooks_useModal.showShareModal(); } function getGoodsList() { return __async(this, null, function* () { state.loadStatus = "loading"; const { code, data } = yield sheep_api_product_spu.SpuApi.getSpuPage({ pageSize: state.pagination.pageSize, pageNo: state.pagination.pageNo }); if (code !== 0) { return; } state.pagination.list = common_vendor.lodash.concat(state.pagination.list, data.list); state.pagination.total = data.total; state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore"; data.list.forEach((item) => { sheep_api_trade_brokerage.BrokerageApi.getProductBrokeragePrice(item.id).then((res) => { item.brokerageMinPrice = res.data.brokerageMinPrice; item.brokerageMaxPrice = res.data.brokerageMaxPrice; }); }); }); } common_vendor.onLoad(() => { getGoodsList(); }); function loadMore() { if (state.loadStatus === "noMore") { return; } state.pagination.pageNo++; getGoodsList(); } common_vendor.onReachBottom(() => { loadMore(); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.f(state.pagination.list, (item, k0, i0) => { return common_vendor.e({ a: item.brokerageMinPrice === void 0 }, item.brokerageMinPrice === void 0 ? {} : item.brokerageMinPrice === item.brokerageMaxPrice ? { c: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMinPrice)) } : { d: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMinPrice)), e: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokerageMaxPrice)) }, { b: item.brokerageMinPrice === item.brokerageMaxPrice, f: common_vendor.o(($event) => onShareGoods(item), item.id), g: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/modules/mall/goods/index", { id: item.id }), item.id), h: "2bf339bf-2-" + i0 + ",2bf339bf-1", i: common_vendor.p({ size: "lg", img: item.picUrl, title: item.name, subTitle: item.introduction, price: item.price, originPrice: item.marketPrice, priceColor: "#333" }), j: item.id }); }), b: state.pagination.total === 0 }, state.pagination.total === 0 ? { c: common_vendor.p({ icon: "/static/goods-empty.png", text: "暂无推广商品" }) } : {}, { d: state.pagination.total > 0 }, state.pagination.total > 0 ? { e: common_vendor.o(loadMore), f: common_vendor.p({ status: state.loadStatus, ["content-text"]: { contentdown: "上拉加载更多" } }) } : {}, { g: common_vendor.p({ title: "推广商品", onShareAppMessage: state.shareInfo }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2bf339bf"]]); _sfc_main.__runtimeHooks = 2; wx.createPage(MiniProgramPage); //# sourceMappingURL=goods.js.map