123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const sheep_index = require("../../sheep/index.js");
- const sheep_util_index = require("../../sheep/util/index.js");
- const sheep_api_product_spu = require("../../sheep/api/product/spu.js");
- require("../../sheep/api/index.js");
- require("../../sheep/api/distri/score.js");
- require("../../sheep/request/index.js");
- require("../../sheep/config/index.js");
- require("../../sheep/store/index.js");
- require("../../sheep/store/app.js");
- require("../../sheep/api/promotion/diy.js");
- require("../../sheep/platform/index.js");
- require("../../sheep/platform/provider/wechat/index.js");
- require("../../sheep/platform/provider/wechat/miniProgram.js");
- require("../../sheep/api/member/auth.js");
- require("../../sheep/api/member/social.js");
- require("../../sheep/api/member/user.js");
- require("../../sheep/platform/provider/apple/index.js");
- require("../../sheep/platform/share.js");
- require("../../sheep/router/index.js");
- require("../../sheep/hooks/useModal.js");
- require("../../sheep/helper/index.js");
- require("../../sheep/helper/test.js");
- require("../../sheep/helper/digit.js");
- require("../../sheep/api/member/signin.js");
- require("../../sheep/helper/throttle.js");
- require("../../sheep/url/index.js");
- require("../../sheep/platform/pay.js");
- require("../../sheep/api/pay/order.js");
- require("../../sheep/store/user.js");
- require("../../sheep/store/cart.js");
- require("../../sheep/api/trade/cart.js");
- require("../../sheep/api/pay/wallet.js");
- require("../../sheep/api/trade/order.js");
- require("../../sheep/api/promotion/coupon.js");
- require("../../sheep/store/sys.js");
- require("../../sheep/store/modal.js");
- require("../../sheep/api/distri/share.js");
- require("../../sheep/api/distri/team.js");
- require("../../sheep/api/infra/file.js");
- require("../../sheep/api/member/address.js");
- require("../../sheep/api/member/point.js");
- require("../../sheep/api/migration/app.js");
- require("../../sheep/api/migration/chat.js");
- require("../../sheep/api/migration/index.js");
- require("../../sheep/api/migration/third.js");
- require("../../sheep/api/pay/channel.js");
- require("../../sheep/api/product/category.js");
- require("../../sheep/api/product/comment.js");
- require("../../sheep/api/product/favorite.js");
- require("../../sheep/api/product/history.js");
- require("../../sheep/api/promotion/activity.js");
- require("../../sheep/api/promotion/article.js");
- require("../../sheep/api/promotion/bargain.js");
- require("../../sheep/api/promotion/combination.js");
- require("../../sheep/api/promotion/rewardActivity.js");
- require("../../sheep/api/promotion/seckill.js");
- require("../../sheep/api/system/area.js");
- require("../../sheep/api/system/voice.js");
- require("../../sheep/api/trade/afterSale.js");
- require("../../sheep/api/trade/brokerage.js");
- require("../../sheep/api/trade/config.js");
- require("../../sheep/api/trade/delivery.js");
- require("../../sheep/config/zIndex.js");
- if (!Array) {
- const _easycom_su_tabs2 = common_vendor.resolveComponent("su-tabs");
- const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
- const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup");
- const _easycom_s_goods_column2 = common_vendor.resolveComponent("s-goods-column");
- const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
- const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
- const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
- (_easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_su_popup2 + _easycom_s_goods_column2 + _easycom_uni_load_more2 + _easycom_s_empty2 + _easycom_s_layout2)();
- }
- const _easycom_su_tabs = () => "../../sheep/ui/su-tabs/su-tabs.js";
- const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
- const _easycom_su_popup = () => "../../sheep/ui/su-popup/su-popup.js";
- const _easycom_s_goods_column = () => "../../sheep/components/s-goods-column/s-goods-column.js";
- const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
- const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
- const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
- if (!Math) {
- (_easycom_su_tabs + _easycom_su_sticky + _easycom_su_popup + _easycom_s_goods_column + _easycom_uni_load_more + _easycom_s_empty + _easycom_s_layout)();
- }
- const _sfc_main = {
- __name: "list",
- emits: ["close", "change"],
- setup(__props, { emit: __emit }) {
- const sys_navBar = sheep_index.sheep.$platform.navbar;
- const state = common_vendor.reactive({
- pagination: {
- list: [],
- total: 0,
- pageNo: 1,
- pageSize: 6
- },
- currentSort: void 0,
- currentOrder: void 0,
- currentTab: 0,
- // 当前选中的 tab
- curFilter: 0,
- // 当前选中的 list 筛选项
- showFilter: false,
- iconStatus: false,
- // true - 单列布局;false - 双列布局
- keyword: "",
- categoryId: 0,
- tabList: [
- {
- name: "综合推荐",
- list: [
- {
- label: "综合推荐"
- },
- {
- label: "价格升序",
- sort: "price",
- order: true
- },
- {
- label: "价格降序",
- sort: "price",
- order: false
- }
- ]
- },
- {
- name: "销量",
- sort: "salesCount",
- order: false
- },
- {
- name: "新品优先",
- value: "createTime",
- order: false
- }
- ],
- loadStatus: "",
- leftGoodsList: [],
- // 双列布局 - 左侧商品
- rightGoodsList: []
- // 双列布局 - 右侧商品
- });
- let count = 0;
- let leftHeight = 0;
- let rightHeight = 0;
- function mountMasonry(height = 0, where = "left") {
- if (!state.pagination.list[count]) {
- return;
- }
- if (where === "left") {
- leftHeight += height;
- } else {
- rightHeight += height;
- }
- if (leftHeight <= rightHeight) {
- state.leftGoodsList.push(state.pagination.list[count]);
- } else {
- state.rightGoodsList.push(state.pagination.list[count]);
- }
- count++;
- }
- function emptyList() {
- sheep_util_index.resetPagination(state.pagination);
- state.leftGoodsList = [];
- state.rightGoodsList = [];
- count = 0;
- leftHeight = 0;
- rightHeight = 0;
- }
- function onSearch(e) {
- state.keyword = e;
- emptyList();
- getList(state.currentSort, state.currentOrder);
- }
- function onTabsChange(e) {
- if (state.tabList[e.index].list) {
- state.currentTab = e.index;
- state.showFilter = !state.showFilter;
- return;
- }
- state.showFilter = false;
- if (e.index === state.currentTab) {
- return;
- }
- state.currentTab = e.index;
- state.currentSort = e.sort;
- state.currentOrder = e.order;
- emptyList();
- getList(e.sort, e.order);
- }
- const onFilterItem = (val) => {
- if (state.currentSort === state.tabList[0].list[val].sort && state.currentOrder === state.tabList[0].list[val].order) {
- state.showFilter = false;
- return;
- }
- state.showFilter = false;
- state.curFilter = val;
- state.tabList[0].name = state.tabList[0].list[val].label;
- state.currentSort = state.tabList[0].list[val].sort;
- state.currentOrder = state.tabList[0].list[val].order;
- emptyList();
- getList();
- };
- async function getList() {
- state.loadStatus = "loading";
- const { code, data } = await sheep_api_product_spu.SpuApi.getSpuPage({
- pageNo: state.pagination.pageNo,
- pageSize: state.pagination.pageSize,
- sortField: state.currentSort,
- sortAsc: state.currentOrder,
- categoryId: state.categoryId,
- keyword: state.keyword
- });
- if (code !== 0) {
- return;
- }
- state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
- state.pagination.total = data.total;
- state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
- mountMasonry();
- }
- function loadMore() {
- if (state.loadStatus === "noMore") {
- return;
- }
- state.pagination.pageNo++;
- getList(state.currentSort, state.currentOrder);
- }
- common_vendor.onLoad((options) => {
- state.categoryId = options.categoryId;
- state.keyword = options.keyword;
- getList(state.currentSort, state.currentOrder);
- });
- common_vendor.onReachBottom(() => {
- loadMore();
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.o(onTabsChange),
- b: common_vendor.p({
- list: state.tabList,
- scrollable: false,
- current: state.currentTab
- }),
- c: state.iconStatus
- }, state.iconStatus ? {} : {}, {
- d: common_vendor.o(($event) => state.iconStatus = !state.iconStatus),
- e: common_vendor.p({
- bgColor: "#fff"
- }),
- f: common_vendor.f(state.tabList[state.currentTab].list, (item, index, i0) => {
- return {
- a: common_vendor.t(item.label),
- b: item.value,
- c: common_vendor.n({
- "filter-item-active": index === state.curFilter
- }),
- d: common_vendor.o(($event) => onFilterItem(index), item.value)
- };
- }),
- g: common_vendor.o(($event) => state.showFilter = false),
- h: common_vendor.p({
- show: state.showFilter,
- type: "top",
- round: "10",
- space: common_vendor.unref(sys_navBar) + 38,
- backgroundColor: "#F6F6F6",
- zIndex: 10
- }),
- i: state.iconStatus && state.pagination.total > 0
- }, state.iconStatus && state.pagination.total > 0 ? {
- j: common_vendor.f(state.pagination.list, (item, k0, i0) => {
- return {
- a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
- id: item.id
- }), item.id),
- b: "7f2f18c6-4-" + i0 + ",7f2f18c6-0",
- c: common_vendor.p({
- size: "lg",
- data: item,
- topRadius: 10,
- bottomRadius: 10
- }),
- d: item.id
- };
- })
- } : {}, {
- k: !state.iconStatus && state.pagination.total > 0
- }, !state.iconStatus && state.pagination.total > 0 ? {
- l: common_vendor.f(state.leftGoodsList, (item, k0, i0) => {
- return {
- a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
- id: item.id
- }), item.id),
- b: common_vendor.o(($event) => mountMasonry($event, "left"), item.id),
- c: "7f2f18c6-5-" + i0 + ",7f2f18c6-0",
- d: common_vendor.p({
- size: "md",
- data: item,
- topRadius: 10,
- bottomRadius: 10
- }),
- e: item.id
- };
- }),
- m: common_vendor.f(state.rightGoodsList, (item, k0, i0) => {
- return {
- a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
- id: item.id
- }), item.id),
- b: common_vendor.o(($event) => mountMasonry($event, "right"), item.id),
- c: "7f2f18c6-6-" + i0 + ",7f2f18c6-0",
- d: common_vendor.p({
- size: "md",
- topRadius: 10,
- bottomRadius: 10,
- data: item
- }),
- e: item.id
- };
- })
- } : {}, {
- n: state.pagination.total > 0
- }, state.pagination.total > 0 ? {
- o: common_vendor.o(loadMore),
- p: common_vendor.p({
- status: state.loadStatus,
- ["content-text"]: {
- contentdown: "上拉加载更多"
- }
- })
- } : {}, {
- q: state.pagination.total === 0
- }, state.pagination.total === 0 ? {
- r: common_vendor.p({
- icon: "/static/soldout-empty.png",
- text: "暂无商品"
- })
- } : {}, {
- s: common_vendor.o(onSearch),
- t: common_vendor.p({
- navbar: "normal",
- leftWidth: 0,
- rightWidth: 0,
- tools: "search",
- defaultSearch: state.keyword
- })
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7f2f18c6"], ["__file", "D:/zx/mall-front-app/pages/goods/list.vue"]]);
- wx.createPage(MiniProgramPage);
|