1 line
8.8 KiB
Plaintext
1 line
8.8 KiB
Plaintext
{"version":3,"file":"cart.js","sources":["../../../../../../src/modules/mall/index/cart.vue","../../../../../../uniPage:/bW9kdWxlcy9tYWxsL2luZGV4L2NhcnQudnVl"],"sourcesContent":["<template>\r\n <s-layout title=\"购物车\" tabbar=\"/modules/mall/index/cart\" :bgStyle=\"{ color: '#fff' }\">\r\n <s-empty\r\n v-if=\"state.list.length === 0\"\r\n text=\"购物车空空如也,快去逛逛吧~\"\r\n icon=\"/static/cart-empty.png\"\r\n />\r\n\r\n <!-- 头部 -->\r\n <view class=\"cart-box ss-flex ss-flex-col ss-row-between\" v-if=\"state.list.length\">\r\n <view class=\"cart-header ss-flex ss-col-center ss-row-between ss-p-x-30\">\r\n <view class=\"header-left ss-flex ss-col-center ss-font-26\">\r\n 共\r\n <text class=\"goods-number ui-TC-Main ss-flex\">{{ state.list.length }}</text>\r\n 件商品\r\n </view>\r\n <view class=\"header-right\">\r\n <button v-if=\"state.editMode\" class=\"ss-reset-button\" @tap=\"state.editMode = false\">\r\n 取消\r\n </button>\r\n <button v-else class=\"ss-reset-button ui-TC-Main\" @tap=\"state.editMode = true\">\r\n 编辑\r\n </button>\r\n </view>\r\n </view>\r\n <!-- 内容 -->\r\n <view class=\"cart-content ss-flex-1 ss-p-x-30 ss-m-b-40\">\r\n <view class=\"goods-box ss-r-10 ss-m-b-14\" v-for=\"item in state.list\" :key=\"item.id\">\r\n <view class=\"ss-flex ss-col-center\">\r\n <label class=\"check-box ss-flex ss-col-center ss-p-l-10\" @tap=\"onSelectSingle(item.id)\">\r\n <radio\r\n :checked=\"state.selectedIds.includes(item.id)\"\r\n color=\"var(--ui-BG-Main)\"\r\n style=\"transform: scale(0.8)\"\r\n @tap.stop=\"onSelectSingle(item.id)\"\r\n />\r\n </label>\r\n <s-goods-item\r\n :title=\"item.spu.name\"\r\n :img=\"item.spu.picUrl || item.goods.image\"\r\n :price=\"item.sku.price\"\r\n :skuText=\"\r\n item.sku.properties.length > 1\r\n ? item.sku.properties.reduce(\r\n (items2, items) => items2.valueName + ' ' + items.valueName,\r\n )\r\n : item.sku.properties[0].valueName\r\n \"\r\n priceColor=\"#FF3000\"\r\n :titleWidth=\"400\"\r\n >\r\n <template v-if=\"!state.editMode\" v-slot:tool>\r\n <su-number-box\r\n :min=\"0\"\r\n :max=\"item.sku.stock\"\r\n :step=\"1\"\r\n v-model=\"item.count\"\r\n @change=\"onNumberChange($event, item)\"\r\n />\r\n </template>\r\n </s-goods-item>\r\n </view>\r\n </view>\r\n </view>\r\n <!-- 底部 -->\r\n <su-fixed bottom :val=\"48\" placeholder v-if=\"state.list.length > 0\" :isInset=\"false\">\r\n <view class=\"cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom\">\r\n <view class=\"footer-left ss-flex ss-col-center\">\r\n <label class=\"check-box ss-flex ss-col-center ss-p-r-30\" @tap=\"onSelectAll\">\r\n <radio\r\n :checked=\"state.isAllSelected\"\r\n color=\"var(--ui-BG-Main)\"\r\n style=\"transform: scale(0.8)\"\r\n @tap.stop=\"onSelectAll\"\r\n />\r\n <view class=\"ss-m-l-8\">全选</view>\r\n </label>\r\n <text>合计:</text>\r\n <view class=\"text-price price-text\">\r\n {{ fen2yuan(state.totalPriceSelected) }}\r\n </view>\r\n </view>\r\n <view class=\"footer-right\">\r\n <button\r\n v-if=\"state.editMode\"\r\n class=\"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main\"\r\n @tap=\"onDelete\"\r\n >\r\n 删除\r\n </button>\r\n <button\r\n v-else\r\n class=\"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main\"\r\n @tap=\"onConfirm\"\r\n >\r\n 去结算\r\n {{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}\r\n </button>\r\n </view>\r\n </view>\r\n </su-fixed>\r\n </view>\r\n </s-layout>\r\n</template>\r\n\r\n<script setup>\r\nimport sheep from '@/sheep'\r\nimport { computed, reactive } from 'vue'\r\nimport { fen2yuan } from '@/sheep/hooks/useGoods'\r\n\r\nconst sys_navBar = sheep.$platform.navbar\r\nconst cart = sheep.$store('cart')\r\n\r\nconst state = reactive({\r\n editMode: false,\r\n list: computed(() => cart.list),\r\n selectedList: [],\r\n selectedIds: computed(() => cart.selectedIds),\r\n isAllSelected: computed(() => cart.isAllSelected),\r\n totalPriceSelected: computed(() => cart.totalPriceSelected),\r\n})\r\n\r\n// 单选选中\r\nfunction onSelectSingle(id) {\r\n cart.selectSingle(id)\r\n}\r\n\r\n// 全选\r\nfunction onSelectAll() {\r\n cart.selectAll(!state.isAllSelected)\r\n}\r\n\r\n// 结算\r\nfunction onConfirm() {\r\n const items = []\r\n const goods_list = []\r\n state.selectedList = state.list.filter((item) => state.selectedIds.includes(item.id))\r\n state.selectedList.map((item) => {\r\n // 此处前端做出修改\r\n items.push({\r\n skuId: item.sku.id,\r\n count: item.count,\r\n cartId: item.id,\r\n categoryId: item.spu.categoryId,\r\n })\r\n goods_list.push({\r\n // goods_id: item.goods_id,\r\n goods_id: item.spu.id,\r\n // goods_num: item.goods_num,\r\n goods_num: item.count,\r\n // 商品价格id真没有\r\n // goods_sku_price_id: item.goods_sku_price_id,\r\n })\r\n })\r\n // return;\r\n if (goods_list.length === 0) {\r\n sheep.$helper.toast('请选择商品')\r\n return\r\n }\r\n sheep.$router.go('/modules/mall/order/confirm', {\r\n data: JSON.stringify({\r\n items,\r\n }),\r\n })\r\n}\r\n\r\nfunction onNumberChange(e, cartItem) {\r\n if (e === 0) {\r\n cart.delete(cartItem.id)\r\n return\r\n }\r\n if (cartItem.goods_num === e) return\r\n cartItem.goods_num = e\r\n cart.update({\r\n goods_id: cartItem.id,\r\n goods_num: e,\r\n goods_sku_price_id: cartItem.goods_sku_price_id,\r\n })\r\n}\r\nasync function onDelete() {\r\n cart.delete(state.selectedIds)\r\n}\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n \r\n \r\n:deep(.ui-fixed) {\r\n height: 72rpx;\r\n}\r\n\r\n.cart-box {\r\n width: 100%;\r\n\r\n .cart-header {\r\n position: fixed;\r\n top: v-bind('sys_navBar') rpx;\r\n left: 0;\r\n z-index: 1000;\r\n box-sizing: border-box;\r\n width: 100%;\r\n height: 70rpx;\r\n background-color: #f6f6f6;\r\n }\r\n\r\n .cart-footer {\r\n height: 100rpx;\r\n background-color: #fff;\r\n\r\n .pay-btn {\r\n width: 180rpx;\r\n height: 70rpx;\r\n font-size: 28rpx;\r\n font-weight: 500;\r\n line-height: 28rpx;\r\n border-radius: 40rpx;\r\n }\r\n }\r\n\r\n .cart-content {\r\n margin-top: 70rpx;\r\n\r\n .goods-box {\r\n background-color: #fff;\r\n }\r\n }\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/App/Work/addr/acdr-ui/src/modules/mall/index/cart.vue'\nwx.createPage(MiniProgramPage)"],"names":["sheep","reactive","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GA,UAAA,aAAAA,YAAAA,MAAA,UAAA;AACA,UAAA,OAAAA,YAAAA,MAAA,OAAA,MAAA;AAEA,UAAA,QAAAC,cAAAA,SAAA;AAAA,MACA,UAAA;AAAA,MACA,MAAAC,cAAA,SAAA,MAAA,KAAA,IAAA;AAAA,MACA,cAAA,CAAA;AAAA,MACA,aAAAA,cAAA,SAAA,MAAA,KAAA,WAAA;AAAA,MACA,eAAAA,cAAA,SAAA,MAAA,KAAA,aAAA;AAAA,MACA,oBAAAA,cAAA,SAAA,MAAA,KAAA,kBAAA;AAAA,IACA,CAAA;AAGA,aAAA,eAAA,IAAA;AACA,WAAA,aAAA,EAAA;AAAA,IACA;AAGA,aAAA,cAAA;AACA,WAAA,UAAA,CAAA,MAAA,aAAA;AAAA,IACA;AAGA,aAAA,YAAA;AACA,YAAA,QAAA,CAAA;AACA,YAAA,aAAA,CAAA;AACA,YAAA,eAAA,MAAA,KAAA,OAAA,CAAA,SAAA,MAAA,YAAA,SAAA,KAAA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