From e4233b5c4e123c4b79a38d0a9b0c8b60631e1683 Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期二, 30 七月 2024 10:40:24 +0800
Subject: [PATCH] update

---
 sub_pages/customer/shopping/shopping.vue |   65 ++++++++++++++++++++++++++------
 1 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/sub_pages/customer/shopping/shopping.vue b/sub_pages/customer/shopping/shopping.vue
index 30d8998..e9aaf14 100644
--- a/sub_pages/customer/shopping/shopping.vue
+++ b/sub_pages/customer/shopping/shopping.vue
@@ -1,6 +1,6 @@
 <template>
 	<view class="shopping-container">
-		<view class="top-title"><span class="t-red">*</span> 苏州市一价全含,市区内包邮派送到店
+		<view class="top-title"><span class="t-red">*</span> 花满芫报价已包含打包材料费、交易佣金
 		</view>
 		<view class="top-desc">
 			全程鲜花冷链专线,时效快,损耗小
@@ -27,26 +27,27 @@
 						<u-swipe-action-item :options="options1" @click="(e)=>{clickSwipeButton(dto)}">
 							<view class="item-each flex">
 								<radio :checked="ids.indexOf(dto.id)>=0" @click="changeItem(dto,'flower')"></radio>
-								<image class="img img100 m-r-6" :src="dto.url||dto.cover"></image>
+								<image class="img img100 m-r-6 br-4" :src="dto.url||dto.cover"></image>
 								<view class="flex1">
-									<view class="title"><span class="m-r-5"
-											style="display: inline-block;">{{item.categoryStr||''}}</span><span
-											v-if="item.levelStr" class="m-r-5"
-											style="display: inline-block;">{{ item.levelStr || '' }}</span>{{ dto.name || '-' }}
+									<view class="title" @click.stop="toDetail(dto)"><span class="m-r-5"
+											style="display: inline-block;">{{dto.categoryStr||''}}</span><span
+											v-if="dto.levelStr" class="m-r-5"
+											style="display: inline-block;">{{ dto.levelStr || '' }}</span>{{ dto.name || '-' }}
 									</view>
-									<view class="price">
+									<view class="price" @click.stop="toDetail(dto)">
 										{{ dto.price || '-' }}元/扎
 									</view>
 									<view class="flex">
-										<view class="desc m-t-12 flex">
+										<view class="desc  flex p-t-5" @click.stop="toDetail(dto)">
 											<view class="m-r-15">剩余:{{ dto.stock || 0 }}</view>
 											<view class="m-r-15">颜色:{{ dto.color || '-' }}</view>
 										</view>
 										<view class="button-icons flex m-l-a m-r-0">
 											<uni-icons v-if="dto.num&&dto.num>=1" type="minus" size="32"
-												@click="addnum(dto,-1)"></uni-icons>
+												@click.stop="addnum(dto,-1)"></uni-icons>
 											<view class="curnums" v-if="dto.num&&dto.num>=1">{{ dto.num }}</view>
-											<uni-icons type="plus-filled" size="32" @click="addnum(dto,1)"></uni-icons>
+											<uni-icons type="plus-filled" size="32"
+												@click.stop="addnum(dto,1)"></uni-icons>
 										</view>
 									</view>
 								</view>
@@ -174,8 +175,8 @@
 						this.ids.splice(this.ids.indexOf(item.id), 1)
 					}
 					for (var i = 0; i < this.list.length; i++) {
-						if (this.list[i].id === item.supplierId) {
-							this.list[i].splice(i, 1)
+						if (this.list[i].supplierId === item.supplierId) {
+							// this.list[i].flowerList.splice(i, 1)
 							if (this.list[i].flowerList.length === 1) {
 								if (this.ids.indexOf('supplier@' + this.list[i].supplierId) >= 0) {
 									this.ids.splice(this.ids.indexOf('supplier@' + this.list[i].supplierId), 1)
@@ -186,16 +187,18 @@
 								//只需要清楚这个元素
 								var k = -1
 								for (var j = 0; j < this.list[i].flowerList.length; j++) {
-									if (this.list[i][j].id === item.id) {
+									if (this.list[i].flowerList[j].id === item.id) {
 										k = j;
 										break
 									}
 								}
 								this.list[i].flowerList.splice(k, 1)
 							}
+							this.$forceUpdate()
 							break
 						}
 					}
+					console.log('this.list', this.list)
 				}
 			},
 
@@ -242,6 +245,25 @@
 					//更换个人的
 					if (this.ids.indexOf(dto.id) < 0) {
 						this.ids.push(dto.id)
+						var has = true
+
+						//判断如果都有,那么顶部的按钮也勾选上
+						for (var i = 0; i < this.list.length; i++) {
+							if (this.list[i].supplierId === dto.supplierId) {
+								for (var j = 0; j < this.list[i].flowerList.length; j++) {
+									if (this.ids.indexOf(this.list[i].flowerList[j].id) < 0) {
+										has = false
+										break
+									}
+								}
+								break
+							}
+						}
+						if (has) {
+							this.ids.push(dto.supplierId)
+
+						}
+
 					} else {
 						this.checkall = false
 
@@ -258,6 +280,13 @@
 				} else {
 					return
 				}
+				if (!dto.stock) {
+					dto.stock = 0
+				}
+				if (dto.num + addnum > dto.stock) {
+					this.$message.showToast('库存不足,无法添加')
+					return
+				}
 				this.$message.showLoading()
 				const {
 					code
@@ -270,6 +299,11 @@
 				this.$message.hideLoading()
 				if (code === 0) {
 					dto.num += addnum
+					if (dto.num < 1) {
+						//id删除清空,并且
+						await this.clickSwipeButton(dto)
+						// await this.init()
+					}
 				}
 			},
 			async init() {
@@ -293,6 +327,11 @@
 					this.list = data || []
 
 				}
+			},
+			toDetail(dto) {
+				uni.navigateTo({
+					url: '/sub_pages/customer/trade/detail?id=' + dto.id
+				})
 			}
 		}
 	}

--
Gitblit v1.9.3