|
@@ -1,17 +1,106 @@
|
|
|
<script setup>
|
|
|
+import { reactive } from "vue";
|
|
|
import DiscussCard from "@/components/discuss-card";
|
|
|
import UserDiscuss from "@/components/user-discuss";
|
|
|
-import CommonButton from "@/components/common-button";
|
|
|
+import FooterButton from "@/components/footer-button";
|
|
|
+import { fetchCommentInfo, submitComment } from "@/services/modules/comment";
|
|
|
+import { showToast } from "@/utils/interactive-feedback";
|
|
|
+import { onLoad } from "@dcloudio/uni-app";
|
|
|
+const data = reactive({
|
|
|
+ list1: [], // 菜品评价
|
|
|
+ list2: [], // 商家评价
|
|
|
+});
|
|
|
+const formData = reactive({
|
|
|
+ list1: [],
|
|
|
+ list2: [],
|
|
|
+});
|
|
|
+// 提交数据
|
|
|
+const postInfo = reactive({
|
|
|
+ orderId: "1772480007187632128",
|
|
|
+ orderMealReviews: [],
|
|
|
+});
|
|
|
+// 获取页面参数
|
|
|
+onLoad((options) => {
|
|
|
+ if (options && options.id) {
|
|
|
+ postInfo.id = options.id;
|
|
|
+ }
|
|
|
+});
|
|
|
+function addFormData(item, list) {
|
|
|
+ const newItem = JSON.parse(JSON.stringify(item));
|
|
|
+ list.push(newItem);
|
|
|
+}
|
|
|
+// 获取数据
|
|
|
+async function getData() {
|
|
|
+ const res = await fetchCommentInfo(postInfo.orderId);
|
|
|
+ const resData = res.data;
|
|
|
+ const list1 = [];
|
|
|
+ const list2 = [];
|
|
|
+ for (let item of resData) {
|
|
|
+ if (item.reviewType === 1) {
|
|
|
+ list1.push(item);
|
|
|
+ addFormData(item, formData.list1);
|
|
|
+ } else {
|
|
|
+ list2.push(item);
|
|
|
+ addFormData(item, formData.list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 分别设置菜品评价与商家评价
|
|
|
+ data.list1 = list1;
|
|
|
+ data.list2 = list2;
|
|
|
+}
|
|
|
+getData();
|
|
|
+
|
|
|
+// 提交
|
|
|
+function submit() {
|
|
|
+ const info = [...formData.list1, ...formData.list2];
|
|
|
+ postInfo.orderMealReviews = info;
|
|
|
+ submitComment(postInfo).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ uni.showModal({
|
|
|
+ title: "Prompt",
|
|
|
+ content: "Registered successfully",
|
|
|
+ showCancel: false,
|
|
|
+ confirmText: "confirm",
|
|
|
+ success() {
|
|
|
+ window.opener = null;
|
|
|
+ window.open("", "_self");
|
|
|
+ window.close();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ showToast(res.msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<view class="discuss">
|
|
|
- <DiscussCard>
|
|
|
- <UserDiscuss />
|
|
|
- </DiscussCard>
|
|
|
- <view class="discuss-footer">
|
|
|
- <CommonButton>确定</CommonButton>
|
|
|
+ <view class="card-list">
|
|
|
+ <DiscussCard title="Dishes evaluation">
|
|
|
+ <!-- 菜品评论内容列表 -->
|
|
|
+ <UserDiscuss
|
|
|
+ v-for="(item, index) in data.list1"
|
|
|
+ :key="index"
|
|
|
+ v-model="formData.list1[index]"
|
|
|
+ :avatarUrl="item.link"
|
|
|
+ :cardName="item.nameEn"
|
|
|
+ placeholder="Please enter a review"
|
|
|
+ />
|
|
|
+ </DiscussCard>
|
|
|
+ <DiscussCard title="Business reviews">
|
|
|
+ <!-- 商家评论列表 -->
|
|
|
+ <UserDiscuss
|
|
|
+ v-for="(item, index) in data.list2"
|
|
|
+ :key="index"
|
|
|
+ :avatarUrl="item.link"
|
|
|
+ :cardName="item.nameEn"
|
|
|
+ v-model="formData.list2[index]"
|
|
|
+ placeholder="Please enter a review"
|
|
|
+ />
|
|
|
+ </DiscussCard>
|
|
|
</view>
|
|
|
+ <FooterButton @click="submit">confirm</FooterButton>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -24,11 +113,4 @@ page {
|
|
|
.discuss {
|
|
|
background: #f5f5f5;
|
|
|
}
|
|
|
-.discuss-footer {
|
|
|
- position: fixed;
|
|
|
- padding: 0 40rpx;
|
|
|
- bottom: 40rpx;
|
|
|
- left: 0;
|
|
|
- right: 0;
|
|
|
-}
|
|
|
</style>
|