From 4250e140336ac40e10ab4c3b650030f82098ca92 Mon Sep 17 00:00:00 2001
From: xuxy <1059738716@qq.com>
Date: 星期六, 27 七月 2024 21:37:07 +0800
Subject: [PATCH] update bug和样式

---
 sub_pages/customer/trade/detail.vue |   43 ++++++++++++++++++++++++++++---------------
 1 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/sub_pages/customer/trade/detail.vue b/sub_pages/customer/trade/detail.vue
index af290b5..12e11ce 100644
--- a/sub_pages/customer/trade/detail.vue
+++ b/sub_pages/customer/trade/detail.vue
@@ -3,7 +3,12 @@
 		<view class="top-img-container">
 			<image :src="dto.cover" class="top-img" mode="aspectFill"></image>
 			<view class="icon-container">
-				<image src="../../../static/common/icon-sc.png" @click="collectItem(dto)" class="icon-sc"></image>
+				<image v-if="!dto.collection" src="../../../static/common/icon-sc.png" @click="collectItem(dto)"
+					class="icon-sc"></image>
+				<image v-if="dto.collection" src="../../../static/common/icon-sc.png" @click="collectItem(dto)"
+					class="icon-sc"></image>
+
+
 				<!--        <view class="num">12</view>-->
 			</view>
 			<view class="icon-container">
@@ -14,7 +19,7 @@
 		</view>
 		<view class="trade-info-container">
 			<view class="title flex">
-				<view class="level m-r-15">{{ dto.levelStr || '-' }}级</view>
+				<view class="level m-r-15">{{ dto.levelStr || '-' }}</view>
 				<view class="">
 					{{ dto.name || '-' }}
 				</view>
@@ -133,21 +138,27 @@
 			}
 		},
 		methods: {
-			async collectItem(dto){
-				await this.$message.confirm('是否添加到收藏')
+			async collectItem(dto) {
+				await this.$message.confirm(`是否${dto.collection?'移除':'添加到'}收藏`)
 				this.$message.showLoading()
 				const {
 					code,
 					data
-				} = await this.$http.request('post', '/api/collect/add', {
-					data: {
-						flowerId: dto.id
-					}
-				})
+				} = await this.$http.request(dto.collection ? "get" : 'post', dto.collection ? '/api/collect/delete' :
+					'/api/collect/add', {
+						data: {
+							flowerId: dto.id
+						},
+						params: {
+							id: dto.id
+						}
+					})
 				if (code === 0) {
-					this.$message.showToast('收藏成功')
+					this.$message.showToast('操作成功')
+					dto.collection = !dto.collection
+					this.$forceUpdate()
 				}
-				
+
 				this.$message.hideLoading()
 			},
 			async submitShopping(dto) {
@@ -353,10 +364,12 @@
 				position: absolute;
 				top: 20rpx;
 				width: 80rpx;
-				left: 40rpx;
+				right: 140rpx;
 				height: 80rpx;
-				background: rgba(0, 0, 0, 0);
-
+				background: rgba(0, 0, 0, 0.42);
+				border-radius: 50%;
+				display:flex;
+				
 				.icon-sc {
 					width: 54rpx;
 					height: 54rpx;
@@ -386,7 +399,7 @@
 			}
 
 			.icon-container:last-child {
-				left: 100rpx;
+				right: 20rpx;
 			}
 
 			// .icon-container:first-child {

--
Gitblit v1.9.3