| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <template>
- <!-- #ifdef APP -->
- <scroll-view class="page-scroll">
- <!-- #endif -->
- <view class="page">
- <view class="header-card">
- <text class="header-score">5.0</text>
- <text class="header-text">客户评价</text>
- <text class="header-subtext">高于 98% 的同类服务者</text>
- </view>
- <view class="tag-section">
- <view v-for="item in tagList" :key="item.text" class="tag-item">
- <text class="tag-text">{{ item.text }}</text>
- <text class="tag-count">{{ item.countText }}</text>
- </view>
- </view>
- <view v-for="item in commentList" :key="item.id" class="comment-card">
- <view class="comment-row">
- <text class="comment-user">{{ item.userName }}</text>
- <text class="comment-time">{{ item.createdAt }}</text>
- </view>
- <text class="comment-project">{{ item.projectName }}</text>
- <text class="comment-content">{{ item.content }}</text>
- </view>
- </view>
- <!-- #ifdef APP -->
- </scroll-view>
- <!-- #endif -->
- </template>
- <script setup lang="uts">
- import { ref } from 'vue'
- import { getCommentList } from '@/utils/api/order.uts'
- type TagItem = {
- text: string
- countText: string
- }
- type CommentItem = {
- id: string
- userName: string
- createdAt: string
- projectName: string
- content: string
- }
- const tagList = ref<TagItem[]>([])
- const commentList = ref<CommentItem[]>([])
- const loadComments = async () : Promise<void> => {
- try {
- const response = await getCommentList({} as UTSJSONObject) as UTSJSONObject
- const code = (response['code'] as number | null) ?? -1
- if (code != 0 && code != 200) {
- return
- }
- const data = response['data'] as UTSJSONObject | null
- const tags = (data?.['tags_list'] as UTSArray<UTSJSONObject> | null)
- const items = (data?.['items'] as UTSArray<UTSJSONObject> | null)
- const nextTags : TagItem[] = []
- if (tags != null) {
- for (let i = 0; i < tags.length; i++) {
- const tag = tags[i]
- nextTags.push({
- text: (tag['text'] as string | null) ?? '标签',
- countText: `${(tag['count'] as number | null) ?? 0}`,
- })
- }
- }
- tagList.value = nextTags
- const nextComments : CommentItem[] = []
- if (items != null) {
- for (let i = 0; i < items.length; i++) {
- const item = items[i]
- const userInfo = item['user_info'] as UTSJSONObject | null
- nextComments.push({
- id: `${i}`,
- userName: (userInfo?.['nickname'] as string | null) ?? '匿名用户',
- createdAt: (item['created_at'] as string | null) ?? '',
- projectName: (item['project_name'] as string | null) ?? '服务项目',
- content: (item['content'] as string | null) ?? '暂无评价内容',
- })
- }
- }
- commentList.value = nextComments
- } catch (error) {
- uni.showToast({ title: '评价加载失败', icon: 'none' })
- }
- }
- onLoad(() => {
- loadComments()
- })
- </script>
- <style>
- .page-scroll {
- flex: 1;
- }
- .page {
- min-height: 1000rpx;
- padding: 24rpx;
- box-sizing: border-box;
- background-color: #f5f3ef;
- flex-direction: column;
- }
- .header-card {
- padding: 28rpx;
- border-radius: 24rpx;
- background-color: #fff09a;
- flex-direction: column;
- }
- .header-score {
- font-size: 56rpx;
- font-weight: 700;
- color: #2f2a22;
- }
- .header-text {
- margin-top: 10rpx;
- font-size: 28rpx;
- color: #5e5648;
- }
- .header-subtext {
- margin-top: 6rpx;
- font-size: 22rpx;
- color: #7e7564;
- }
- .tag-section {
- margin-top: 20rpx;
- flex-direction: row;
- flex-wrap: wrap;
- }
- .tag-item {
- padding: 12rpx 18rpx;
- margin-right: 12rpx;
- margin-bottom: 12rpx;
- border-radius: 999rpx;
- background-color: #ffffff;
- flex-direction: row;
- align-items: center;
- }
- .tag-text {
- font-size: 24rpx;
- color: #4d473c;
- }
- .tag-count {
- margin-left: 8rpx;
- font-size: 24rpx;
- color: #999999;
- }
- .comment-card {
- margin-top: 16rpx;
- padding: 24rpx;
- border-radius: 20rpx;
- background-color: #ffffff;
- flex-direction: column;
- border-width: 1px;
- border-style: solid;
- border-color: #efebe4;
- }
- .comment-row {
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- }
- .comment-user {
- font-size: 28rpx;
- font-weight: 700;
- color: #2f2a22;
- }
- .comment-time {
- font-size: 22rpx;
- color: #9a9a9a;
- }
- .comment-project {
- margin-top: 10rpx;
- font-size: 24rpx;
- color: #db6d3a;
- }
- .comment-content {
- margin-top: 12rpx;
- font-size: 26rpx;
- line-height: 38rpx;
- color: #555555;
- }
- </style>
|