wangzhibo
4 天以前 10595d8632f959d0954d1939243196f4eed02372
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<template>
    <cl-popup
        v-model="visible"
        direction="bottom"
        :border-radius="[32, 32, 0, 0]"
        :padding="0"
        title="商品评价"
        show-close-btn
    >
        <view class="order-comment">
            <view class="list">
                <view class="item" v-for="(item, index) in list" :key="index">
                    <cl-image
                        :src="resizeImage(item.mainPic!, 200)"
                        :size="[140, 140]"
                        :radius="24"
                    />
 
                    <cl-row :margin="[0, 0, 0, 32]">
                        <cl-text
                            block
                            bold
                            :size="28"
                            :margin="[0, 0, 10, 0]"
                            :line-height="1.2"
                            :ellipsis="2"
                        >
                            {{ item.title }}
                        </cl-text>
 
                        <cl-button disabled type="info" size="small" v-if="item.isComment">
                            已评价
                        </cl-button>
 
                        <cl-button type="primary" size="small" @tap="toComment(item)" v-else>
                            去评价
                        </cl-button>
                    </cl-row>
                </view>
            </view>
        </view>
    </cl-popup>
</template>
 
<script lang="ts" setup>
import { computed, nextTick, ref } from "vue";
import { useCool, useUpload } from "/@/cool";
import { uniqBy } from "lodash-es";
 
const emit = defineEmits(["success"]);
 
const { router } = useCool();
const { resizeImage } = useUpload();
 
// 是否可见
const visible = ref(false);
 
// 订单详情
const info = ref<OrderInfo>();
 
// 商品列表
const list = computed(() => {
    return uniqBy(info.value?.goodsList, "goodsId").map((e) => {
        return {
            isComment: e.isComment,
            ...e?.goodsInfo,
        };
    });
});
 
// 打开弹窗
function open(data: OrderInfo) {
    info.value = data;
 
    nextTick(() => {
        // 只有一个的时候直接去提交页面
        if (list.value.length == 1) {
            toComment(list.value[0]);
        } else {
            visible.value = true;
        }
    });
}
 
// 关闭弹窗
function close() {
    visible.value = false;
}
 
// 去评价
function toComment(item: Eps.GoodsInfoEntity) {
    close();
 
    router.push({
        path: "/pages/order/comment",
        query: {
            goodsId: item.id,
            orderId: info.value?.id,
        },
    });
}
 
defineExpose({
    open,
    close,
});
</script>
 
<style lang="scss" scoped>
.order-comment {
    .list {
        padding: 0 32rpx;
 
        .item {
            display: flex;
            align-items: center;
            margin-bottom: 32rpx;
        }
    }
}
</style>