From a7e18f3eba7a5bd2008e9aeac9cf4edcc995749a Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期日, 06 十月 2024 23:12:16 +0800
Subject: [PATCH] 1.商品评论

---
 sub_pages/customer/shop/shop.vue |  189 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 179 insertions(+), 10 deletions(-)

diff --git a/sub_pages/customer/shop/shop.vue b/sub_pages/customer/shop/shop.vue
index 14f0a17..e7b63b0 100644
--- a/sub_pages/customer/shop/shop.vue
+++ b/sub_pages/customer/shop/shop.vue
@@ -159,12 +159,63 @@
 				</view>
 			</view>
 
-			<!-- <view v-show="flg==='1'" class="brand-info-1">
-				<trade :hidefooter="true" :supplierId="id" :catgoryTree="catgoryTree" v-if="catgoryTree" ref="trade">
-				</trade>
+			<view v-show="flg==='2'" class="brand-info-1">
+				<!-- <trade :hidefooter="true" :supplierId="id" :catgoryTree="catgoryTree" v-if="catgoryTree" ref="trade">
+				</trade> -->
+						
+				<view class="m-t-12" style="text-align: center;">
+					
+					<span style="">综合评分<span style="color: #F8353A; margin-left: 5px;">{{comment.avg}}</span> </span>
+					
+				</view>
+				<view class="m-t-12">
+				
+					<view v-for="(item,index) of commentList" >
+						<u-row justify="space-between"  >
+							<u-col span="1">
+								<u--image v-if="item.anonymityFalg==1 " :showLoading="true" 
+								src="https://youzhen123.oss-cn-huhehaote.aliyuncs.com/WechatOwnerProperty/images/mrtx.png" width="30px" height="30px"  shape="circle"></u--image>
+								<u--image v-else :showLoading="true" :src="item.customerCover" width="30px" height="30px"  shape="circle"></u--image>
+							
+							</u-col>
+							<u-col span="4">
+								<view v-if="item.anonymityFalg==1 " >匿名用户</view>
+								<view v-else>{{item.customerName}}</view>
+							</u-col>
+							<u-col span="2">
+								<u-rate count="5" v-model="item.commentGrade" readonly></u-rate>
+							</u-col>
+							<u-col span="4">
+								<view style="font-size: 12px;">{{item.updateTime}}</view>
+							</u-col>
+						</u-row>
+						<u-row justify="space-between"  >
+							<u-col span="2"></u-col>
+							<u-col span="10">
+								<view> 		
+									<span style="color:#3E9FFB;border: 1px solid #3E9FFB; padding:2px 2px ;font-size: 12px;">
+										{{item.flowerName}}({{item.flowerColor}}){{item.flowerLevel}}
+									</span>
+									{{item.comment}}
+									<view class="flex" >
+										<u--image v-for="(commentImg,index2) of item.commentImagesList" :key="index2" style="margin:10px;"
+										:showLoading="true" :src="commentImg"></u--image>
+									</view>
+								
+								 </view>
+							</u-col>
+						</u-row>
+						
+					</view>
+					
+					
+				
+				
+				</view>
+				
 			</view>
-			 -->
-			<view v-if="flg==='2'" class="brand-info-3">
+			
+			<view v-if="flg==='3'" class="brand-info-3">
 				<view class="title">
 					基础信息
 				</view>
@@ -252,6 +303,16 @@
 		},
 		data() {
 			return {
+				comment:{
+					avg:0,
+					commentAmount:0,
+				},
+				commentList:[],
+				commentPage:{
+					size: 10,
+					current: 1,
+					total: 0,
+				},
 				// search_flow: '',
 				flg: '0',
 				tabs: [{
@@ -260,9 +321,9 @@
 					{
 						name: '分类'
 					},
-					// {
-					// 	name: '评价'
-					// },
+					{
+						name: '评价'
+					},
 					{
 						name: '商家'
 					},
@@ -278,6 +339,7 @@
 					level: '',
 					name: '',
 					categoryRoot: '',
+					
 				},
 				level_show: false,
 				level_columns: [
@@ -287,7 +349,8 @@
 				order_show: false,
 				order_columns: [
 					[]
-				]
+				],
+				
 			}
 		},
 		onShow() {
@@ -300,9 +363,19 @@
 			}
 			await this.refreshList('post')
 			uni.stopPullDownRefresh()
-
+			
+			if(this.flg=="2"){
+				// 评论相关下拉刷新
+				this.getCommentsStatis()
+				
+				this.commentList=[]
+				this.commentPage.current=1
+				this.getComments()
+			}
+			
 		},
 		onLoad(options) {
+			
 			this.id = options.id || ''
 			this.page.size = 300
 			if (this.id) {
@@ -335,6 +408,11 @@
 					value: ''
 				})
 			})
+			
+			
+			this.getCommentsStatis()
+			
+			
 		},
 		// #ifdef PUB_CUSTOMER
 		onShareAppMessage() {
@@ -361,11 +439,96 @@
 		},
 		// #endif
 		onReachBottom() {
+			console.log("下拉")
 			// if (this.flg === '0') {
 			// 	this.getMore('post')
 			// }
+			if (this.flg ==2) {
+				// debugger;
+				// this.listApi="/api/v2/flower-comment/page"
+				// this.query={
+				// 	supplierId:this.id 
+				// }
+				// this.getMore()
+				this.commentPage.current++
+				this.getComments()
+			}
 		},
 		methods: {
+			
+			async getCommentsStatis() {
+				{
+					this.$message.showLoading()
+			
+					const {
+						code,
+						data
+					} = await this.$http.request('get', `/api/v2/flower-comment/statis/${this.id}`, {
+						params: {}
+					})
+					if (code === 0) {
+						this.comment=data
+						this.tabs[2].name=`评价(${this.comment.commentAmount})`
+					}
+			
+					this.$message.hideLoading()
+				}
+			
+			},
+			
+			async getComments() {
+			
+				{
+					this.$message.showLoading()
+					const params={
+						supplierId:this.id ,
+						...this.commentPage,
+					}
+					const {
+						code,
+						data
+					} = await this.$http.request('get', `/api/v2/flower-comment/page`, {
+						params: params
+					})
+					if (code === 0) {
+						// this.commentList=data.records
+						this.commentPage.current=data.current
+						this.commentPage.pages=data.pages
+						this.commentPage.size=data.size
+						this.commentPage.total=data.total
+						// this.commentList = data.records.map(item => {
+						//   return {
+						//     ...item,
+						//     commentImagesList: item.commentImages ? JSON.parse(item.commentImages) : [] // 将字符串转换成数组
+						//   };
+						// });
+						data.records.forEach(item => {
+						    const commentImagesList = item.commentImages ? JSON.parse(item.commentImages) : [];
+						    const existingCommentIndex = this.commentList.findIndex(comment => comment.id === item.id);
+						    
+						    if (existingCommentIndex !== -1) {
+						        // 更新已存在的评论
+						        this.commentList[existingCommentIndex] = {
+						            ...this.commentList[existingCommentIndex],
+						            ...item,
+						            commentImagesList
+						        };
+						    } else {
+						        // 新增评论
+						        this.commentList.push({
+						            ...item,
+						            commentImagesList
+						        });
+						    }
+						 });
+
+					}
+			
+					this.$message.hideLoading()
+				}
+			
+			},
+			
 			getList_after() {
 				if (this.list) {
 					for (var item of this.list) {
@@ -482,6 +645,12 @@
 					}
 
 				}
+			
+				if(flg=="2"){
+					this.getCommentsStatis()
+					this.getComments()
+				}
+				
 				this.flg = '' + flg
 				//如果没有加载数据,需要加载一下
 

--
Gitblit v1.9.3