"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const api_cart = require("../../api/cart.js"); require("../../utils/request.js"); require("../../config/app.js"); require("../../store/user.js"); if (!Array) { const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar"); const _easycom_u__icon2 = common_vendor.resolveComponent("u--icon"); const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty"); const _easycom_up_button2 = common_vendor.resolveComponent("up-button"); const _easycom_up_transition2 = common_vendor.resolveComponent("up-transition"); (_easycom_up_navbar2 + _easycom_u__icon2 + _easycom_up_empty2 + _easycom_up_button2 + _easycom_up_transition2)(); } const _easycom_up_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js"; const _easycom_u__icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js"; const _easycom_up_empty = () => "../../uni_modules/uview-plus/components/u-empty/u-empty.js"; const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js"; const _easycom_up_transition = () => "../../uni_modules/uview-plus/components/u-transition/u-transition.js"; if (!Math) { (_easycom_up_navbar + _easycom_u__icon + _easycom_up_empty + _easycom_up_button + _easycom_up_transition + goodPopup)(); } const goodPopup = () => "../../components/goodPopup.js"; const _sfc_main = { __name: "cart", setup(__props) { const list = common_vendor.ref(["购物车", "常买"]); const tabsActive = common_vendor.ref(0); const changeTab = (e) => { tabsActive.value = e; swiperCurrent.value = e; }; const swiperCurrent = common_vendor.ref(0); const animationfinish = ({ detail: { current } }) => { swiperCurrent.value = current; tabsActive.value = current; }; const settleAccounts = () => { common_vendor.index.navigateTo({ url: "/pagesOrder/settle/settle" }); }; const addCart = (id, cart_num) => { api_cart.cartChangeApi({ cart_num, is_new: 0, // 是否直接购买0否1是 cart_id: id }).then((res) => { getcartList(); }); }; const showGoodPopup = common_vendor.ref(false); const goodRef = common_vendor.ref(null); const goodData = common_vendor.ref({}); const openGoodPopup = (item) => { goodData.value = item; goodRef.value.setData(item); showGoodPopup.value = true; }; const changeGood = (data) => { showGoodPopup.value = false; addCart(data.cart_id, data.cart_num); }; const cartList = common_vendor.ref([]); const cartInfo = common_vendor.ref({}); const getcartList = () => { api_cart.cartListApi().then((res) => { var _a, _b; res.data.lists = res.data.lists.map((item) => { item.check = true; return item; }); cartList.value = res.data.lists; cartInfo.value = ((_b = (_a = res.data) == null ? void 0 : _a.extend) == null ? void 0 : _b.total_price) || "0.00"; }); }; const c_price = (price = 0, index = 0) => { price = price + ""; return price.split(".")[index] || 0; }; common_vendor.onShow(() => { getcartList(); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.f(list.value, (item, index, i0) => { return { a: common_vendor.t(item), b: tabsActive.value == index ? 1 : "", c: index, d: common_vendor.o(($event) => changeTab(index), index) }; }), b: common_vendor.p({ placeholder: true, autoBack: true }), c: common_vendor.t(cartList.value.length) }, {}, { d: common_vendor.f(cartList.value, (item, index, i0) => { return common_vendor.e({ a: !item.check }, !item.check ? { b: common_assets._imports_1$1 } : { c: common_assets._imports_0$1 }, { d: item.imgs, e: common_vendor.t(item.goods_name), f: common_vendor.t(item.unit_name), g: common_vendor.t(item.goods_total_price), h: common_vendor.t(item.cart_num), i: "da603134-1-" + i0, j: index, k: common_vendor.o(($event) => openGoodPopup(item), index) }); }), e: common_vendor.p({ name: "plus-circle-fill", size: "20", color: "#20b128" }) }, { g: common_vendor.f(20, (item, index, i0) => { return { a: "da603134-3-" + i0, b: index }; }), h: common_vendor.p({ size: "small", plain: true, color: "#20b128", shape: "circle" }) }, { j: swiperCurrent.value, k: common_vendor.o(animationfinish) }, { m: common_assets._imports_0$1 }, { n: common_vendor.t(c_price(cartInfo.value.total_price, 0)), o: common_vendor.t(c_price(cartInfo.value.total_price, 1)), p: common_vendor.o(settleAccounts), q: common_vendor.p({ color: "#20b128", shape: "circle", disabled: false }) }, { s: common_vendor.p({ show: tabsActive.value == 0 }), t: common_vendor.sr(goodRef, "da603134-8", { "k": "goodRef" }), v: common_vendor.o(($event) => showGoodPopup.value = false), w: common_vendor.o(changeGood), x: common_vendor.p({ show: showGoodPopup.value }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/里海数字乡村/purchase-let/pages/cart/cart.vue"]]); wx.createPage(MiniProgramPage);