wangguoyu 2 ngày trước cách đây
mục cha
commit
5dcb37356d
1 tập tin đã thay đổi với 13 bổ sung10 xóa
  1. 13 10
      pages/mall/mallPage.vue

+ 13 - 10
pages/mall/mallPage.vue

@@ -12,9 +12,9 @@
 				<view v-if="productData.current === 0">
 					<scroll-view scroll-y="true" :scroll-into-view="scrollIntoId" class="order-scroll-view">
 						<!--数学-->
-						<view :id="'item-' + item.id" v-for="item in productData.list" :key="`${item.id}-${isItemSelected(item.id)}`" class="mall-list-item">
+						<view :id="'item-' + item.id" v-for="item in productData.list" :key="item.id"
+							class="mall-list-item">
 							<view class="mall-content-box">
-								<!-- 需要换成从接口中取得 wgy -->
 								<img :src='item.cover' class="mall-image" />
 								<view class="content-body-box">
 									<view class="content-name">
@@ -24,14 +24,13 @@
 									<view class="content-row">
 										<view class="content-yuanjia">原价:{{item.yuanjia}}</view>
 										<view class="shop-car-box" @click="addProduct(item.id)">
-											<!-- 购物车上的对号需控制 wgy-->
-											<icon v-if="isItemSelected(item.id)" class="car-change"></icon>
+											<icon v-if="productData.selectedIds.includes(item.id)" class="car-change">
+											</icon>
 										</view>
 									</view>
 								</view>
 							</view>
 							<view class="mall-bottom-row">
-								<!-- 组合课程显示课程包明细按钮 wgy -->
 								<view v-if="item.type ==1" class="kcb-btn" @click="productBtn">课程包明细<icon>
 									</icon>
 								</view>
@@ -157,7 +156,7 @@
 				if (productData.cardId) {
 					const exist = res.data.some(item => item.id == productData.cardId)
 					if (exist) {
-						productData.selectedIds = [productData.cardId]
+						productData.selectedIds = [Number(productData.cardId)]
 					}
 				}
 				nextTick(() => {
@@ -193,10 +192,14 @@
 		// } else {
 		// 	productData.selectedIds.push(id)
 		// }
-		 const temp = [...productData.selectedIds]
-		  const index = temp.indexOf(id)
-		  index > -1 ? temp.splice(index, 1) : temp.push(id)
-		  productData.selectedIds = temp
+		
+		
+		
+		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);
 	}
 
 	function isItemSelected(id) {