|
@@ -23,7 +23,7 @@
|
|
<view class="content-text">{{item.intro}}</view>
|
|
<view class="content-text">{{item.intro}}</view>
|
|
<view class="content-row">
|
|
<view class="content-row">
|
|
<view class="content-yuanjia">原价:{{item.yuanjia}}</view>
|
|
<view class="content-yuanjia">原价:{{item.yuanjia}}</view>
|
|
- <view class="shop-car-box" @click="addProduct(item.id)">
|
|
|
|
|
|
+ <view class="shop-car-box" @click="addProduct(item)">
|
|
<icon v-if="productData.selectedIds.includes(item.id)" class="car-change">
|
|
<icon v-if="productData.selectedIds.includes(item.id)" class="car-change">
|
|
</icon>
|
|
</icon>
|
|
</view>
|
|
</view>
|
|
@@ -52,7 +52,7 @@
|
|
<!-- 需要换成从接口中取得 wgy -->
|
|
<!-- 需要换成从接口中取得 wgy -->
|
|
<view class="price-icon-box">
|
|
<view class="price-icon-box">
|
|
<text class="red-price fh-text">¥</text>
|
|
<text class="red-price fh-text">¥</text>
|
|
- <text class="red-price">1999.8</text>明细
|
|
|
|
|
|
+ <text class="red-price">{{totalPrice}}</text>明细
|
|
<icon :class="mxjtClass"></icon>
|
|
<icon :class="mxjtClass"></icon>
|
|
</view>
|
|
</view>
|
|
<view>购买即同意虚拟产品不支持退订</view>
|
|
<view>购买即同意虚拟产品不支持退订</view>
|
|
@@ -80,6 +80,7 @@
|
|
<script setup>
|
|
<script setup>
|
|
import {
|
|
import {
|
|
reactive,
|
|
reactive,
|
|
|
|
+ computed,
|
|
nextTick,
|
|
nextTick,
|
|
ref
|
|
ref
|
|
} from "vue";
|
|
} from "vue";
|
|
@@ -111,6 +112,12 @@
|
|
list: [],
|
|
list: [],
|
|
selectedIds: [] // 新增选中状态存储
|
|
selectedIds: [] // 新增选中状态存储
|
|
})
|
|
})
|
|
|
|
+ const totalPrice = computed(() => {
|
|
|
|
+ return productData.list
|
|
|
|
+ .filter(item => productData.selectedIds.includes(item.id))
|
|
|
|
+ .reduce((sum, item) => sum + parseFloat(item.xianjia || 0), 0)
|
|
|
|
+ .toFixed(2)
|
|
|
|
+ })
|
|
|
|
|
|
function switchPayWay() {
|
|
function switchPayWay() {
|
|
showPayWay.value = !showPayWay.value
|
|
showPayWay.value = !showPayWay.value
|
|
@@ -140,7 +147,8 @@
|
|
|
|
|
|
function onChangeTab(e) {
|
|
function onChangeTab(e) {
|
|
console.log('e', e);
|
|
console.log('e', e);
|
|
- productData.current = e.currentIndex
|
|
|
|
|
|
+ productData.current = e.currentIndex
|
|
|
|
+ productData.selectedIds = [] // 清空选中
|
|
getMore()
|
|
getMore()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -183,23 +191,14 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- function addProduct(id) {
|
|
|
|
- // 当存在外部cardId时禁止操作
|
|
|
|
- // if (productData.cardId) return
|
|
|
|
- // const index = productData.selectedIds.indexOf(id)
|
|
|
|
- // if (index > -1) {
|
|
|
|
- // productData.selectedIds.splice(index, 1)
|
|
|
|
- // } else {
|
|
|
|
- // productData.selectedIds.push(id)
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ function addProduct(item) {
|
|
|
|
+ console.log('item', item);
|
|
|
|
+
|
|
const temp = [...productData.selectedIds]
|
|
const temp = [...productData.selectedIds]
|
|
- const index = temp.indexOf(id)
|
|
|
|
- index > -1 ? temp.splice(index, 1) : temp.push(id)
|
|
|
|
- productData.selectedIds = temp
|
|
|
|
- console.log('productData.selectedIds',productData.selectedIds);
|
|
|
|
|
|
+ const index = temp.indexOf(item.id)
|
|
|
|
+ index > -1 ? temp.splice(index, 1) : temp.push(item.id)
|
|
|
|
+ productData.selectedIds = temp
|
|
|
|
+ console.log('productData.selectedIds', productData.selectedIds);
|
|
}
|
|
}
|
|
|
|
|
|
function isItemSelected(id) {
|
|
function isItemSelected(id) {
|
|
@@ -221,10 +220,15 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- onLoad((options) => {
|
|
|
|
- productData.current = Number(options.subjectId) - 1
|
|
|
|
- productData.cardId = options.cardId
|
|
|
|
- productData.from = options.from
|
|
|
|
|
|
+ onLoad((options) => {
|
|
|
|
+ if(options.from =='daoPage'){
|
|
|
|
+ productData.current = Number(options.subjectId) - 1
|
|
|
|
+ productData.cardId = options.cardId
|
|
|
|
+ productData.from = options.from
|
|
|
|
+ }else{
|
|
|
|
+ productData.current = Number(cacheManager.get('auth').subjectId)-1
|
|
|
|
+ }
|
|
|
|
+
|
|
getMore();
|
|
getMore();
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|