86 lines
3.5 KiB
JavaScript
86 lines
3.5 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const store_cart = require("../../store/cart.js");
|
|
if (!Math) {
|
|
CustomerServiceBtn();
|
|
}
|
|
const CustomerServiceBtn = () => "../../components/CustomerServiceBtn.js";
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "index",
|
|
setup(__props) {
|
|
const cartStore = store_cart.useCartStore();
|
|
const showQrcode = common_vendor.ref(false);
|
|
const isAllChecked = common_vendor.computed(
|
|
() => cartStore.items.length > 0 && cartStore.items.every((item) => item.checked)
|
|
);
|
|
function handleMinus(item) {
|
|
if (item.quantity > 1) {
|
|
cartStore.updateQuantity(item.id, item.quantity - 1);
|
|
}
|
|
}
|
|
function handleSettle() {
|
|
if (cartStore.checkedItems.length === 0) {
|
|
common_vendor.index.showToast({ title: "请先选择商品", icon: "none" });
|
|
return;
|
|
}
|
|
const token = common_vendor.index.getStorageSync("token");
|
|
if (!token) {
|
|
common_vendor.index.navigateTo({ url: "/pages/login/index" });
|
|
return;
|
|
}
|
|
common_vendor.index.navigateTo({ url: "/pages/order/submit" });
|
|
}
|
|
function goHome() {
|
|
common_vendor.index.switchTab({ url: "/pages/index/index" });
|
|
}
|
|
common_vendor.onMounted(() => {
|
|
cartStore.fetchCart();
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.unref(cartStore).items.length > 0
|
|
}, common_vendor.unref(cartStore).items.length > 0 ? {
|
|
b: common_vendor.f(common_vendor.unref(cartStore).items, (item, k0, i0) => {
|
|
var _a;
|
|
return {
|
|
a: item.checked ? 1 : "",
|
|
b: common_vendor.o(($event) => common_vendor.unref(cartStore).toggleCheck(item.id), item.id),
|
|
c: ((_a = item.product.bannerImages) == null ? void 0 : _a[0]) || "/static/logo.png",
|
|
d: common_vendor.t(item.product.name),
|
|
e: common_vendor.t(item.specData.fineness),
|
|
f: common_vendor.t(item.specData.mainStone),
|
|
g: common_vendor.t(item.specData.ringSize),
|
|
h: common_vendor.t(item.specData.totalPrice),
|
|
i: common_vendor.o(($event) => handleMinus(item), item.id),
|
|
j: common_vendor.t(item.quantity),
|
|
k: common_vendor.o(($event) => common_vendor.unref(cartStore).updateQuantity(item.id, item.quantity + 1), item.id),
|
|
l: common_vendor.o(($event) => common_vendor.unref(cartStore).removeFromCart(item.id), item.id),
|
|
m: item.id
|
|
};
|
|
})
|
|
} : {
|
|
c: common_vendor.o(goHome)
|
|
}, {
|
|
d: common_vendor.unref(cartStore).items.length > 0
|
|
}, common_vendor.unref(cartStore).items.length > 0 ? {
|
|
e: isAllChecked.value ? 1 : "",
|
|
f: common_vendor.o(($event) => common_vendor.unref(cartStore).toggleCheckAll()),
|
|
g: common_vendor.t(common_vendor.unref(cartStore).totalAmount.toFixed(2)),
|
|
h: common_vendor.t(common_vendor.unref(cartStore).checkedItems.length),
|
|
i: common_vendor.unref(cartStore).checkedItems.length === 0 ? 1 : "",
|
|
j: common_vendor.o(handleSettle)
|
|
} : {}, {
|
|
k: showQrcode.value
|
|
}, showQrcode.value ? {
|
|
l: common_vendor.o(($event) => showQrcode.value = false),
|
|
m: common_vendor.p({
|
|
mode: "qrcode"
|
|
})
|
|
} : {});
|
|
};
|
|
}
|
|
});
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8039fbf1"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/cart/index.js.map
|