From c29a4c8f6022e6cd5ff92d499c8db829c8c471aa Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 11 二月 2026 09:51:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
mini-program/pages/shopping-cart/shopping-cart.vue | 71 +++++++++++++++++++++++++++++++----
1 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/mini-program/pages/shopping-cart/shopping-cart.vue b/mini-program/pages/shopping-cart/shopping-cart.vue
index 5f52812..42aa730 100644
--- a/mini-program/pages/shopping-cart/shopping-cart.vue
+++ b/mini-program/pages/shopping-cart/shopping-cart.vue
@@ -1,9 +1,9 @@
<template>
<view class="cart">
<u-swipe-action>
- <u-swipe-action-item :options="options" v-for="(item, index) in list" :name="index" :key="index">
+ <u-swipe-action-item :options="options" v-for="(item, index) in list" :name="index" :key="index" @click="deleRow">
<view class="cart-item">
- <view class="cart-item-check">
+ <view class="cart-item-check" @click="select(item)">
<image src="/static/icon/ic_agree@2x.png" mode="widthFix" v-if="!item.active"></image>
<image src="/static/icon/cart_ic_sel@2x.png" mode="widthFix" v-else></image>
</view>
@@ -18,7 +18,7 @@
<text>{{item.price[0]}}</text>
<text>.{{item.price[1]}}</text>
</view>
- <u-number-box v-model="item.num"></u-number-box>
+ <u-number-box v-model="item.num" @change="changeNum(index)"></u-number-box>
</view>
</view>
</view>
@@ -26,15 +26,16 @@
</u-swipe-action>
<view class="footer">
<view class="edit">
- <view class="edit-left">
- <image src="/static/icon/ic_agree@2x.png" mode="widthFix"></image>
+ <view class="edit-left" @click="quanxuan">
+ <image src="/static/icon/cart_ic_sel@2x.png" mode="widthFix" v-if="selectAll"></image>
+ <image src="/static/icon/ic_agree@2x.png" mode="widthFix" v-else></image>
<text>鍏ㄩ��</text>
</view>
<view class="edit-right">
<view class="edit-right-label">鍚堣锛�</view>
<view class="edit-right-price">
- <text>499</text>
- <text>.00</text>
+ <text>{{totalPrice[0]}}</text>
+ <text>.{{totalPrice[1]}}</text>
</view>
<view class="edit-right-btn">缁撶畻</view>
</view>
@@ -45,7 +46,34 @@
</template>
<script>
+ import { mapState } from 'vuex'
export default {
+ computed: {
+ ...mapState(['userInfo']),
+ totalPrice() {
+ let price = 0
+ this.list.forEach((item, index) => {
+ if (item.active) {
+ price += Number(item.price[0] + '.' +item.price[1])
+ }
+ })
+ return price.toFixed(2).split('.')
+ },
+ // 鍏ㄩ��
+ selectAll() {
+ let open = true
+ if (this.list.length > 0) {
+ this.list.forEach(item => {
+ if (!item.active) {
+ open = false
+ }
+ })
+ return open;
+ } else {
+ return false;
+ }
+ }
+ },
data() {
return {
value: 1,
@@ -61,6 +89,32 @@
this.getList()
},
methods: {
+ // 鍏ㄩ��
+ quanxuan() {
+ this.list.forEach((item) => {
+ item.active = true
+ })
+ },
+ // 鍗曢��
+ select(item) {
+ item.active = !item.active
+ },
+ // 鏇存柊鍟嗗搧鏁伴噺
+ changeNum(index) {
+ this.$u.api.updateNum({
+ id: this.list[index].shopCartId,
+ memberId: this.userInfo.id,
+ num: this.list[index].num
+ })
+ },
+ deleRow(e) {
+ this.$u.api.deleteBatch({ ids: this.list[e.name].shopCartId })
+ .then(res => {
+ if (res.code === 200) {
+ this.list.splice(e.name, 1)
+ }
+ })
+ },
getList() {
if (!this.next) return;
this.$u.api.shopCartPage({
@@ -69,7 +123,6 @@
model: {}
}).then(res => {
if (res.code === 200) {
- console.log(res)
res.data.records.forEach(item => {
item.price = item.price.toFixed(2).split('.')
item.active = false
@@ -238,7 +291,7 @@
.bottom-price {
display: flex;
- align-items: center;
+ align-items: baseline;
justify-content: space-between;
text {
--
Gitblit v1.9.3