zs 2 年 前
コミット
6a6eba2622
2 ファイル変更75 行追加35 行削除
  1. 58 26
      pagesMy/order/appraise.vue
  2. 17 9
      pagesMy/order/index.vue

+ 58 - 26
pagesMy/order/appraise.vue

@@ -9,13 +9,13 @@
 					<uni-forms-item label="上传评论图片" name="file">
 						<upload :list="file" name="file" :count="6" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
 					</uni-forms-item>
-					<uni-forms-item label="商品评分" name="goods_score">
+					<uni-forms-item v-if="!rate_id" label="商品评分" name="goods_score">
 						<uni-rate size="18" v-model="form.goods_score" />
 					</uni-forms-item>
-					<uni-forms-item label="发货评分" name="transport_score">
+					<uni-forms-item v-if="!rate_id" label="发货评分" name="transport_score">
 						<uni-rate size="18" v-model="form.transport_score" />
 					</uni-forms-item>
-					<uni-forms-item label="店铺评分" name="shop_score">
+					<uni-forms-item v-if="!rate_id" label="店铺评分" name="shop_score">
 						<uni-rate size="18" v-model="form.shop_score" />
 					</uni-forms-item>
 				</uni-forms>
@@ -37,6 +37,8 @@
 		data() {
 			return {
 				id: '',
+				// 追加
+				rate_id: '',
 				user: {},
 				form: {},
 				info: {},
@@ -60,6 +62,7 @@
 		onLoad: function(e) {
 			const that = this;
 			that.$set(that, `id`, e.id || '');
+			that.$set(that, `rate_id`, e.rate_id || '');
 			// 监听用户是否登录
 			that.watchLogin();
 		},
@@ -80,30 +83,59 @@
 			async onSubmit(ref) {
 				const that = this;
 				that.$refs[ref].validate().then(async 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
-						})
+					if (that.rate_id) {
+						let res = await that.$api(`/goodsRate/${that.rate_id}`);
+						if (res.errcode == '0') {
+							let reply = res.data;
+							let obj = {
+								file: that.file,
+								content: params.content,
+								time: moment().format('YYYY-MM-DD HH:mm:ss')
+							}
+							reply.reply.push(obj)
+							const arr = await that.$api(`/goodsRate/${that.rate_id}`, 'POST', reply)
+							if (arr.errcode == '0') {
+								uni.showToast({
+									title: `追加成功`,
+									icon: 'success',
+								});
+								uni.navigateBack({
+									detail: 1
+								})
+							} else {
+								uni.showToast({
+									title: arr.errmsg,
+									icon: 'none',
+								})
+							}
+						}
 					} else {
-						uni.showToast({
-							title: arr.errmsg,
-							icon: 'none',
-						})
+						let reply = [{
+							file: that.file,
+							content: params.content,
+							time: moment().format('YYYY-MM-DD HH:mm:ss')
+						}];
+						params.orderDetail = that.id
+						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',
+							})
+						}
 					}
 				})
 			},

+ 17 - 9
pagesMy/order/index.vue

@@ -64,8 +64,10 @@
 											@tap.stop="toConfirm(item)">确认收货</button>
 										<button v-if="item.status!='0'" type="default" size="mini"
 											@tap.stop="toAfter(item)">申请售后</button>
-										<button v-if="item.status=='3'" type="default" size="mini"
+										<button v-if="item.status=='3'&&!item.rate" type="default" size="mini"
 											@tap.stop="toAppraise(item)">立即评价</button>
+										<button v-if="item.status=='3'&&item.rate" type="default" size="mini"
+											@tap.stop="toAppraise(item)">追加评价</button>
 									</view>
 								</view>
 								<view class="list_2 list_3" v-for="(item,index) in list" :key="index"
@@ -85,9 +87,7 @@
 										<view class="goods_2">
 											<view class="market">
 												<view class="url">
-													<image class="image"
-														:src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:''"
-														mode=""></image>
+													<image class="image" :src="tag.url" mode=""></image>
 												</view>
 												<view class="goodsname">
 													{{tag.goods.name}}
@@ -111,7 +111,7 @@
 									</view>
 									<view class="other">
 										<text>共{{item.buy_num_total||0}}件商品</text>
-										<text>总价¥{{item.total_detail.goods_total}}</text>
+										<text>总价¥{{item.real_pay}}</text>
 									</view>
 									<view class="btn">
 										<button v-if="item.status=='2'||item.status=='3'" type="default" size="mini"
@@ -124,8 +124,10 @@
 											@tap.stop="toConfirm(item)">确认收货</button>
 										<button v-if="item.status!='0'" type="default" size="mini"
 											@tap.stop="toAfter(item)">申请售后</button>
-										<button v-if="item.status=='3'" type="default" size="mini"
+										<button v-if="item.status=='3'&&!item.rate" type="default" size="mini"
 											@tap.stop="toAppraise(item)">立即评价</button>
+										<button v-if="item.status=='3'&&item.rate" type="default" size="mini"
+											@tap.stop="toAppraise(item)">追加评价</button>
 									</view>
 								</view>
 							</view>
@@ -410,9 +412,15 @@
 			},
 			// 立即评价
 			toAppraise(e) {
-				uni.navigateTo({
-					url: `/pagesMy/order/appraise?id=${e._id}`
-				})
+				if(e.rate){
+					uni.navigateTo({
+						url: `/pagesMy/order/appraise?id=${e._id}&rate_id=${e.rate}`
+					})
+				}else{
+					uni.navigateTo({
+						url: `/pagesMy/order/appraise?id=${e._id}`
+					})
+				}
 			},
 			// 选择选项卡
 			tabsChange(e) {