zs 2 years ago
parent
commit
7e6275e887
3 changed files with 207 additions and 52 deletions
  1. 149 44
      pagesHome/order/appraise.vue
  2. 14 2
      pagesHome/order/detail.vue
  3. 44 6
      pagesMy/order/appraise.vue

+ 149 - 44
pagesHome/order/appraise.vue

@@ -7,8 +7,8 @@
 					<view class="text2">好评率 <text>{{info.rate||100}}%</text></view>
 				</view>
 				<view class="one_2">
-					<view class="one_2_1" v-for="(item,index) in btnlist" :key="index">
-						<text>{{item.name}}</text><text>({{item.num||0}})</text>
+					<view class="one_2_1" v-for="(item,index) in btnlist" :key="index" @tap="toSelect(item)">
+						<text>{{item.name}}</text><text>({{item.total||0}})</text>
 					</view>
 				</view>
 			</view>
@@ -16,20 +16,35 @@
 				<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
 					<view class="list-scroll-view">
 						<view class="list" v-for="(item, index) in list" :key="index">
-							<image v-if="item.file&&item.file.length>0" class="image"
-								:src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
+							<image v-if="item.customer.icon&&item.customer.icon.length>0" class="image"
+								:src="item.customer.icon&&item.customer.icon.length>0?item.customer.icon[0].url:''"
+								mode="">
 							</image>
 							<text v-else class="iconfont icon-top"></text>
 							<view class="list_1">
 								<view class="other">
-									<text>{{item.phone}}</text>
-									<text>{{item.time}}</text>
+									<text>{{item.customer.phone}}</text>
+									<text>{{item.reply[0].time||'暂无'}}</text>
+								</view>
+								<view class="flie">
+									<view v-for="(tag, indexs) in item.reply[0].file" :key="indexs">
+										<image @click="toLarge(item,indexs)" class="images" :src="tag.url" mode="">
+										</image>
+									</view>
 								</view>
 								<view class="stars">
-									<uni-rate size="18" :readonly="true" :value="5" />
+									<uni-rate size="18" :readonly="true" :value="item.goods_score" />
+								</view>
+								<view class="other1">{{item.reply[0].content||'暂无'}}</view>
+								<view class="other2">规格:{{item.goodsSpec.name}}</view>
+								<view class="other2" v-for="(itm, indexx) in item.reply" :key="indexx">
+									<view class="reply">
+										<text>用户评论:{{itm.content||'暂无'}}</text>
+										<text v-if="itm.reply">商家回复:{{itm.reply||'暂无'}}</text>
+									</view>
+									<view @tap="toReply(item)">回复</view>
 								</view>
-								<view class="other1">{{item.content}}</view>
-								<view class="other2">规格:{{item.specs}}</view>
+								<input v-if="reply.reply" @confirm="confirm" class="input" placeholder="回复商家" />
 							</view>
 						</view>
 					</view>
@@ -40,6 +55,7 @@
 </template>
 
 <script>
+	import moment from 'moment';
 	export default {
 		data() {
 			return {
@@ -47,55 +63,36 @@
 				user: {},
 				btnlist: [{
 						name: '全部好评',
-						num: '10',
+						total: '0',
 						code: '0'
 					},
 					{
 						name: '好评',
-						num: '10',
-						code: '0'
+						total: '0',
+						code: '1'
 					},
 					{
 						name: '中评',
-						num: '0',
-						code: '0'
+						total: '0',
+						code: '2'
 					},
 					{
 						name: '差评',
-						num: '0',
-						code: '0'
+						total: '0',
+						code: '3'
 					}
 				],
 				info: {},
-				list: [{
-						phone: '150********',
-						content: '好评!',
-						specs: '标准',
-						time: '2022-10-04 06:35:10'
-					},
-					{
-						phone: '132********',
-						content: '好评!',
-						specs: '标准',
-						time: '2022-10-06 16:09:20'
-					},
-					{
-						phone: '188********',
-						content: '好评!',
-						specs: '标准',
-						time: '2022-10-07 16:15:08'
-					},
-					{
-						phone: '137********',
-						content: '好评!',
-						specs: '标准',
-						time: '2022-10-07 14:26:10'
-					}
-				],
+				list: [],
 				total: 0,
 				skip: 0,
 				limit: 6,
-				page: 0
+				page: 0,
+				one: [],
+				two: [],
+				thr: [],
+				// 回复数据
+				reply: {},
 			};
 		},
 		onLoad: function(e) {
@@ -104,6 +101,55 @@
 			that.watchLogin()
 		},
 		methods: {
+			async confirm(e) {
+				const that = this;
+				let reply = that.reply
+				let obj = {
+					content: e.detail.value,
+					time: moment().format('YYYY-MM-DD HH:mm:ss')
+				}
+				reply.reply.push(obj)
+				const arr = await that.$api(`/goodsRate/${that.reply._id}`, 'POST', reply)
+				if (arr.errcode == '0') {
+					uni.showToast({
+						title: `回复成功`,
+						icon: 'success',
+					});
+					that.$set(that, `reply`, {});
+				} else {
+					uni.showToast({
+						title: arr.errmsg,
+						icon: 'none',
+					})
+				}
+			},
+			// 回复
+			toReply(e) {
+				const that = this;
+				that.$set(that, `reply`, e);
+			},
+			// 放大
+			toLarge(e, index) {
+				let url = e.reply[0].file.map(item => item.url)
+				uni.previewImage({
+					current: index,
+					urls: url
+				})
+			},
+			// 选择
+			toSelect(e) {
+				const that = this;
+				if (e.code == '0') {
+					that.clearPage();
+					that.search()
+				} else if (e.code == '1') {
+					that.$set(that, `list`, that.one);
+				} else if (e.code == '2') {
+					that.$set(that, `list`, that.two);
+				} else {
+					that.$set(that, `list`, that.thr);
+				}
+			},
 			// 监听用户是否登录
 			watchLogin() {
 				const that = this;
@@ -125,12 +171,43 @@
 			async search() {
 				const that = this;
 				let user = that.user;
-				let res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
+				let res;
+				res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
 					id: that.id
 				});
 				if (res.errcode == '0') {
 					that.$set(that, `info`, res.data)
 				}
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					goods: that.id
+				}
+				res = await that.$api(`/goodsRate`, `GET`, {
+					...info,
+				})
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data]
+					for (let val of list) {
+						val.customer.phone = val.customer.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
+					}
+					let one = list.filter(item => item.goods_score == 5);
+					that.$set(that, `one`, one)
+					that.$set(that.btnlist[1], `total`, one.length);
+					let two = list.filter(item => item.goods_score < 5 && item.goods_score > 2)
+					that.$set(that, `two`, two)
+					that.$set(that.btnlist[2], `total`, two.length);
+					let thr = list.filter(item => item.goods_score <= 2)
+					that.$set(that, `thr`, thr)
+					that.$set(that.btnlist[3], `total`, thr.length);
+					that.$set(that, `list`, list)
+					that.$set(that, `total`, res.total)
+					that.$set(that.btnlist[0], `total`, res.total)
+				} else {
+					uni.showToast({
+						title: res.errmsg,
+					});
+				}
 			},
 			// 分页
 			toPage(e) {
@@ -149,7 +226,8 @@
 					that.search();
 					uni.hideLoading();
 				} else uni.showToast({
-					title: '没有更多数据了'
+					title: '没有更多数据了',
+					icon: 'none'
 				});
 			},
 			// 清空列表
@@ -218,6 +296,13 @@
 				margin: 0 0 2vw 0;
 				padding: 4vw;
 
+				.image {
+					width: 10vw;
+					height: 10vw;
+					border-radius: 10vw;
+
+				}
+
 				.iconfont {
 					font-size: 30px;
 				}
@@ -241,10 +326,30 @@
 						margin: 1vw 0 0 0;
 					}
 
+					.flie {
+						display: flex;
+						flex-wrap: wrap;
+						margin: 1vw 0;
+
+						.images {
+							width: 20vw;
+							height: 20vw;
+							margin: 0 1vw 0 0;
+						}
+					}
+
 					.other2 {
+						display: flex;
+						justify-content: space-between;
 						font-size: var(--font12Size);
 						color: var(--f85Color);
 						margin: 2vw 0 0 0;
+
+						.reply {
+							display: flex;
+							flex-direction: column;
+							width: 70vw;
+						}
 					}
 				}
 			}

+ 14 - 2
pagesHome/order/detail.vue

@@ -37,8 +37,12 @@
 								<view class="title">选择规格</view>
 								<text class="iconfont icon-jiantouyou"></text>
 							</view>
-							<view class="thr_1" @click="toAppraise(info)">
-								<view class="title">商品评价({{info.comment||0}})</view>
+							<view v-if="comment" class="thr_1" @click="toAppraise(info)">
+								<view class="title">商品评价({{comment||0}})</view>
+								<text class="iconfont icon-jiantouyou"></text>
+							</view>
+							<view v-else class="thr_1">
+								<view class="title">暂无评价</view>
 								<text class="iconfont icon-jiantouyou"></text>
 							</view>
 						</view>
@@ -221,6 +225,8 @@
 				num: 1,
 				// 分享
 				share: {},
+				// 评论数
+				comment: '',
 			};
 		},
 		onLoad: async function(e) {
@@ -456,6 +462,12 @@
 					if (res.data.specs.length > 0) that.$set(that.specsInfo, `sell_money`, res.data.specs[0]
 						.sell_money)
 					that.$set(that, `bannerList`, res.data.goods.file)
+					let con = await that.$api(`/goodsRate`, `GET`, {
+						goods: res.data.goods._id
+					})
+					if (con.errcode == '0') {
+						that.$set(that, `comment`, con.total)
+					}
 				}
 			},
 			async searchOther() {

+ 44 - 6
pagesMy/order/appraise.vue

@@ -12,11 +12,11 @@
 					<uni-forms-item label="商品评分" name="goods_score">
 						<uni-rate size="18" v-model="form.goods_score" />
 					</uni-forms-item>
-					<uni-forms-item label="发货评分" name="send_score">
-						<uni-rate size="18" v-model="form.send_score" />
+					<uni-forms-item label="发货评分" name="transport_score">
+						<uni-rate size="18" v-model="form.transport_score" />
 					</uni-forms-item>
-					<uni-forms-item label="店铺评分" name="service_score">
-						<uni-rate size="18" v-model="form.service_score" />
+					<uni-forms-item label="店铺评分" name="shop_score">
+						<uni-rate size="18" v-model="form.shop_score" />
 					</uni-forms-item>
 				</uni-forms>
 				<view class="btn">
@@ -28,6 +28,7 @@
 </template>
 
 <script>
+	import moment from 'moment';
 	import upload from '@/components/upload/index.vue';
 	export default {
 		components: {
@@ -38,6 +39,7 @@
 				id: '',
 				user: {},
 				form: {},
+				info: {},
 				file: [],
 				rules: {
 					content: {
@@ -78,7 +80,31 @@
 			async onSubmit(ref) {
 				const that = this;
 				that.$refs[ref].validate().then(async params => {
-					console.log(params);
+					let reply = [{
+						file: that.file,
+						content: params.content,
+						time: moment().format('YYYY-MM-DD HH:mm:ss')
+					}];
+					params.reply = reply;
+					params.customer = that.user?._id;
+					params.shop = that.info?.goods[0]?.shop;
+					params.goods = that.info?.goods[0]?.goods[0]?.goods?._id;
+					params.goodsSpec = that.info?.goods[0]?.goods[0]?._id;
+					const arr = await that.$api(`/goodsRate`, 'POST', params);
+					if (arr.errcode == '0') {
+						uni.showToast({
+							title: `评论成功`,
+							icon: 'success',
+						});
+						uni.navigateBack({
+							detail: 1
+						})
+					} else {
+						uni.showToast({
+							title: arr.errmsg,
+							icon: 'none',
+						})
+					}
 				})
 			},
 			// 监听用户是否登录
@@ -89,7 +115,7 @@
 					success: function(res) {
 						let user = that.$jwt(res.data);
 						if (user) that.$set(that, `user`, user);
-						// that.search();
+						that.search();
 					},
 					fail: function(err) {
 						uni.navigateTo({
@@ -98,6 +124,18 @@
 					}
 				});
 			},
+			// 查询列表
+			async search() {
+				const that = this;
+				let user = that.user;
+				if (that.id) {
+					let res = await that.$api(`/orderDetail/${that.id}`);
+					if (res.errcode == '0') {
+						that.$set(that, `info`, res.data.order);
+						uni.hideLoading();
+					}
+				}
+			},
 		}
 	}
 </script>