| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 | "use strict";const common_vendor = require("../../common/vendor.js");const sheep_index = require("../../sheep/index.js");const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.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/product/spu.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");require("../../sheep/util/index.js");if (!Array) {  const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");  const _easycom_su_number_box2 = common_vendor.resolveComponent("su-number-box");  const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");  const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");  (_easycom_s_empty2 + _easycom_su_number_box2 + _easycom_s_goods_item2 + _easycom_su_fixed2 + _easycom_s_layout2)();}const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";const _easycom_su_number_box = () => "../../sheep/ui/su-number-box/su-number-box.js";const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";if (!Math) {  (_easycom_s_empty + _easycom_su_number_box + _easycom_s_goods_item + _easycom_su_fixed + _easycom_s_layout)();}const _sfc_main = {  __name: "cart",  setup(__props) {    common_vendor.useCssVars((_ctx) => ({      "6cd98758": common_vendor.unref(sys_navBar)    }));    const sys_navBar = sheep_index.sheep.$platform.navbar;    const cart = sheep_index.sheep.$store("cart");    const state = common_vendor.reactive({      editMode: false,      list: common_vendor.computed(() => cart.list),      shopList: common_vendor.computed(() => cart.shopNameMap),      skuList: common_vendor.computed(() => cart.shopSkuMap),      selectedList: [],      selectedIds: common_vendor.computed(() => cart.selectedIds),      isAllSelected: common_vendor.computed(() => cart.isAllSelected),      totalPriceSelected: common_vendor.computed(() => cart.totalPriceSelected)    });    const processedValidList = common_vendor.computed(() => {      const groups = {};      state.list.forEach((item) => {        const shopId = Object.keys(state.skuList).find((key) => state.skuList[key].includes(item.sku.id));        const shopName = state.shopList[shopId] || "未知店铺";        if (!groups[shopName]) {          groups[shopName] = [];        }        groups[shopName].push(item);      });      return groups;    });    function onSelectSingle(id) {      console.log("单选");      cart.selectSingle(id);    }    function onSelectAll() {      cart.selectAll(!state.isAllSelected);    }    function onConfirm() {      let items = [];      let goods_list = [];      state.selectedList = state.list.filter((item) => state.selectedIds.includes(item.id));      state.selectedList.map((item) => {        items.push({          skuId: item.sku.id,          count: item.count,          cartId: item.id        });        goods_list.push({          // goods_id: item.goods_id,          goods_id: item.spu.id,          // goods_num: item.goods_num,          goods_num: item.count          // 商品价格id真没有          // goods_sku_price_id: item.goods_sku_price_id,        });      });      if (goods_list.length === 0) {        sheep_index.sheep.$helper.toast("请选择商品");        return;      }      sheep_index.sheep.$router.go("/pages/order/confirm", {        data: JSON.stringify({          // order_type: 'goods',          // goods_list,          items,          // from: 'cart',          pointStatus: false,          // 从购物车这里提交订单的 一定是实体商品和用人民币买的 所以可以直接写死          deliveryType: 1,          spuPayType: 1,          spuType: 1        })      });    }    function onNumberChange(e, cartItem) {      if (e === 0) {        cart.delete(cartItem.id);        return;      }      if (cartItem.goods_num === e)        return;      cartItem.goods_num = e;      cart.update({        goods_id: cartItem.id,        goods_num: e,        goods_sku_price_id: cartItem.goods_sku_price_id      });    }    async function onDelete() {      cart.delete(state.selectedIds);    }    return (_ctx, _cache) => {      var _a;      return common_vendor.e({        a: state.list.length === 0      }, state.list.length === 0 ? {        b: common_vendor.p({          text: "购物车空空如也,快去逛逛吧~",          icon: "/static/cart-empty.png"        })      } : {}, {        c: state.list.length      }, state.list.length ? common_vendor.e({        d: common_vendor.t(state.list.length),        e: state.editMode      }, state.editMode ? {        f: common_vendor.o(($event) => state.editMode = false)      } : {        g: common_vendor.o(($event) => state.editMode = true)      }, {        h: common_vendor.f(processedValidList.value, (shopItems, shopName, index) => {          return {            a: common_vendor.t(shopName),            b: common_vendor.f(shopItems, (product, productIndex, i1) => {              return common_vendor.e({                a: state.selectedIds.includes(product.id),                b: common_vendor.o(($event) => onSelectSingle(product.id), product.id),                c: common_vendor.o(($event) => onSelectSingle(product.id), product.id)              }, !state.editMode ? {                d: common_vendor.o(($event) => onNumberChange($event, product), product.id),                e: "c30a4c2b-3-" + index + "-" + i1 + "," + ("c30a4c2b-2-" + index + "-" + i1),                f: common_vendor.o(($event) => product.count = $event, product.id),                g: common_vendor.p({                  min: 0,                  max: product.sku.stock,                  step: 1,                  modelValue: product.count                })              } : {}, {                h: "c30a4c2b-2-" + index + "-" + i1 + ",c30a4c2b-0",                i: common_vendor.p({                  title: product.spu.name,                  img: product.spu.picUrl || product.goods.image,                  price: product.sku.price,                  skuText: product.sku.properties.length > 1 ? product.sku.properties.reduce((items2, items) => items2.valueName + " " + items.valueName) : product.sku.properties[0].valueName,                  priceColor: "#FF3000",                  titleWidth: 400                }),                j: product.id              });            }),            c: shopName          };        }),        i: !state.editMode,        j: state.list.length > 0      }, state.list.length > 0 ? common_vendor.e({        k: state.isAllSelected,        l: common_vendor.o(onSelectAll),        m: common_vendor.o(onSelectAll),        n: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.totalPriceSelected)),        o: state.editMode      }, state.editMode ? {        p: common_vendor.o(onDelete)      } : {        q: common_vendor.t(((_a = state.selectedIds) == null ? void 0 : _a.length) ? `(${state.selectedIds.length})` : ""),        r: common_vendor.o(onConfirm)      }, {        s: common_vendor.p({          bottom: true,          val: 48,          placeholder: true,          isInset: false        })      }) : {}) : {}, {        t: common_vendor.s(_ctx.__cssVars()),        v: common_vendor.p({          title: "购物车",          tabbar: "/pages/index/cart",          bgStyle: {            color: "#fff"          }        })      });    };  }};const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c30a4c2b"], ["__file", "D:/zx/mall-front-app/pages/index/cart.vue"]]);wx.createPage(MiniProgramPage);
 |