appraise.uvue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view class="page-scroll">
  4. <!-- #endif -->
  5. <view class="page">
  6. <view class="header-card">
  7. <text class="header-score">5.0</text>
  8. <text class="header-text">客户评价</text>
  9. <text class="header-subtext">高于 98% 的同类服务者</text>
  10. </view>
  11. <view class="tag-section">
  12. <view v-for="item in tagList" :key="item.text" class="tag-item">
  13. <text class="tag-text">{{ item.text }}</text>
  14. <text class="tag-count">{{ item.countText }}</text>
  15. </view>
  16. </view>
  17. <view v-for="item in commentList" :key="item.id" class="comment-card">
  18. <view class="comment-row">
  19. <text class="comment-user">{{ item.userName }}</text>
  20. <text class="comment-time">{{ item.createdAt }}</text>
  21. </view>
  22. <text class="comment-project">{{ item.projectName }}</text>
  23. <text class="comment-content">{{ item.content }}</text>
  24. </view>
  25. </view>
  26. <!-- #ifdef APP -->
  27. </scroll-view>
  28. <!-- #endif -->
  29. </template>
  30. <script setup lang="uts">
  31. import { ref } from 'vue'
  32. import { getCommentList } from '@/utils/api/order.uts'
  33. type TagItem = {
  34. text: string
  35. countText: string
  36. }
  37. type CommentItem = {
  38. id: string
  39. userName: string
  40. createdAt: string
  41. projectName: string
  42. content: string
  43. }
  44. const tagList = ref<TagItem[]>([])
  45. const commentList = ref<CommentItem[]>([])
  46. const loadComments = async () : Promise<void> => {
  47. try {
  48. const response = await getCommentList({} as UTSJSONObject) as UTSJSONObject
  49. const code = (response['code'] as number | null) ?? -1
  50. if (code != 0 && code != 200) {
  51. return
  52. }
  53. const data = response['data'] as UTSJSONObject | null
  54. const tags = (data?.['tags_list'] as UTSArray<UTSJSONObject> | null)
  55. const items = (data?.['items'] as UTSArray<UTSJSONObject> | null)
  56. const nextTags : TagItem[] = []
  57. if (tags != null) {
  58. for (let i = 0; i < tags.length; i++) {
  59. const tag = tags[i]
  60. nextTags.push({
  61. text: (tag['text'] as string | null) ?? '标签',
  62. countText: `${(tag['count'] as number | null) ?? 0}`,
  63. })
  64. }
  65. }
  66. tagList.value = nextTags
  67. const nextComments : CommentItem[] = []
  68. if (items != null) {
  69. for (let i = 0; i < items.length; i++) {
  70. const item = items[i]
  71. const userInfo = item['user_info'] as UTSJSONObject | null
  72. nextComments.push({
  73. id: `${i}`,
  74. userName: (userInfo?.['nickname'] as string | null) ?? '匿名用户',
  75. createdAt: (item['created_at'] as string | null) ?? '',
  76. projectName: (item['project_name'] as string | null) ?? '服务项目',
  77. content: (item['content'] as string | null) ?? '暂无评价内容',
  78. })
  79. }
  80. }
  81. commentList.value = nextComments
  82. } catch (error) {
  83. uni.showToast({ title: '评价加载失败', icon: 'none' })
  84. }
  85. }
  86. onLoad(() => {
  87. loadComments()
  88. })
  89. </script>
  90. <style>
  91. .page-scroll {
  92. flex: 1;
  93. }
  94. .page {
  95. min-height: 1000rpx;
  96. padding: 24rpx;
  97. box-sizing: border-box;
  98. background-color: #f5f3ef;
  99. flex-direction: column;
  100. }
  101. .header-card {
  102. padding: 28rpx;
  103. border-radius: 24rpx;
  104. background-color: #fff09a;
  105. flex-direction: column;
  106. }
  107. .header-score {
  108. font-size: 56rpx;
  109. font-weight: 700;
  110. color: #2f2a22;
  111. }
  112. .header-text {
  113. margin-top: 10rpx;
  114. font-size: 28rpx;
  115. color: #5e5648;
  116. }
  117. .header-subtext {
  118. margin-top: 6rpx;
  119. font-size: 22rpx;
  120. color: #7e7564;
  121. }
  122. .tag-section {
  123. margin-top: 20rpx;
  124. flex-direction: row;
  125. flex-wrap: wrap;
  126. }
  127. .tag-item {
  128. padding: 12rpx 18rpx;
  129. margin-right: 12rpx;
  130. margin-bottom: 12rpx;
  131. border-radius: 999rpx;
  132. background-color: #ffffff;
  133. flex-direction: row;
  134. align-items: center;
  135. }
  136. .tag-text {
  137. font-size: 24rpx;
  138. color: #4d473c;
  139. }
  140. .tag-count {
  141. margin-left: 8rpx;
  142. font-size: 24rpx;
  143. color: #999999;
  144. }
  145. .comment-card {
  146. margin-top: 16rpx;
  147. padding: 24rpx;
  148. border-radius: 20rpx;
  149. background-color: #ffffff;
  150. flex-direction: column;
  151. border-width: 1px;
  152. border-style: solid;
  153. border-color: #efebe4;
  154. }
  155. .comment-row {
  156. flex-direction: row;
  157. justify-content: space-between;
  158. align-items: center;
  159. }
  160. .comment-user {
  161. font-size: 28rpx;
  162. font-weight: 700;
  163. color: #2f2a22;
  164. }
  165. .comment-time {
  166. font-size: 22rpx;
  167. color: #9a9a9a;
  168. }
  169. .comment-project {
  170. margin-top: 10rpx;
  171. font-size: 24rpx;
  172. color: #db6d3a;
  173. }
  174. .comment-content {
  175. margin-top: 12rpx;
  176. font-size: 26rpx;
  177. line-height: 38rpx;
  178. color: #555555;
  179. }
  180. </style>