鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
5.6 KiB

  1. <template>
  2. <view class="card">
  3. <view class="flex header">
  4. <view class="flex left">
  5. <view class="avatar">
  6. <image class="avatar-img" :src="data.user.headImage" mode="scaleToFill"></image>
  7. </view>
  8. <view class="info">
  9. <view class="name">{{ data.user.nickName }}</view>
  10. <view>{{ $dayjs(data.createTime).format('YYYY-MM-DD') }}</view>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="section content">{{ data.content }}</view>
  15. <view class="flex section imgs">
  16. <image class="img"
  17. v-for="(url, iIdx) in images"
  18. :key="iIdx" :src="url"
  19. mode="scaleToFill"
  20. ></image>
  21. </view>
  22. <view class="section score">
  23. <view class="flex score-item">
  24. <view class="score-item-label">行程</view>
  25. <formRate :value="data.processScore" :readonly="true"></formRate>
  26. </view>
  27. <view class="flex score-item">
  28. <view class="score-item-label">景点</view>
  29. <formRate :value="data.spotScore" :readonly="true"></formRate>
  30. </view>
  31. <view class="flex score-item">
  32. <view class="score-item-label">导师</view>
  33. <formRate :value="data.teacherScore" :readonly="true"></formRate>
  34. </view>
  35. </view>
  36. <view class="flex section operate">
  37. <button class="flex btn" @click="onComment">
  38. <image class="icon" src="@/pages_order/static/comment/icon-comment.png" mode="widthFix"></image>
  39. <view>评论</view>
  40. </button>
  41. <button v-if="data.liked" class="flex btn" @click="onLike">
  42. <image class="icon" src="@/pages_order/static/comment/icon-like-active.png" mode="widthFix"></image>
  43. <view>点赞</view>
  44. </button>
  45. <button v-else class="flex btn" @click="onCancelLike">
  46. <image class="icon" src="@/pages_order/static/comment/icon-like.png" mode="widthFix"></image>
  47. <view>点赞</view>
  48. </button>
  49. </view>
  50. <view class="section comment"
  51. v-for="item in commentList"
  52. :key="item.id"
  53. >
  54. <view class="flex comment-user">
  55. <view class="avatar">
  56. <!-- todo: check key -->
  57. <image class="avatar-img" :src="item.avatar" mode="scaleToFill"></image>
  58. </view>
  59. <view class="name">{{ item.name }}</view>
  60. <view class="time">{{ item.createTime }}</view>
  61. </view>
  62. <view class="comment-content">{{ item.content }}</view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import formRate from '@/pages_order/components/formRate.vue'
  68. export default {
  69. components: {
  70. formRate,
  71. },
  72. props: {
  73. data: {
  74. type: Object,
  75. default() {
  76. return {}
  77. }
  78. },
  79. mode: {
  80. type: String,
  81. default: 'read' // read | edit
  82. }
  83. },
  84. computed: {
  85. images() {
  86. const { image } = this.data || {}
  87. return image?.split?.(',')?.filter(val => val)
  88. },
  89. disabled() {
  90. return this.mode !== 'edit'
  91. },
  92. },
  93. methods: {
  94. onComment() {
  95. if (this.disabled) {
  96. return
  97. }
  98. // todo
  99. this.$emit('change')
  100. },
  101. onLike() {
  102. if (this.disabled) {
  103. return
  104. }
  105. // todo
  106. this.$emit('change')
  107. },
  108. onCancelLike() {
  109. if (this.disabled) {
  110. return
  111. }
  112. // todo
  113. this.$emit('change')
  114. },
  115. },
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .card {
  120. width: 100%;
  121. padding: 32rpx;
  122. box-sizing: border-box;
  123. background: #FAFAFF;
  124. border: 2rpx solid #FFFFFF;
  125. border-radius: 32rpx;
  126. }
  127. .header {
  128. .left {
  129. flex: 1;
  130. justify-content: flex-start;
  131. column-gap: 24rpx;
  132. }
  133. .avatar {
  134. width: 100rpx;
  135. height: 100rpx;
  136. border: 4rpx solid #FFFFFF;
  137. border-radius: 50%;
  138. overflow: hidden;
  139. &-img {
  140. width: 100%;
  141. height: 100%;
  142. }
  143. }
  144. .info {
  145. font-family: PingFang SC;
  146. font-weight: 400;
  147. font-size: 24rpx;
  148. line-height: 1.5;
  149. color: #8B8B8B;
  150. .name {
  151. font-weight: 600;
  152. font-size: 36rpx;
  153. line-height: 1.2;
  154. color: #252545;
  155. margin-bottom: 8rpx;
  156. }
  157. }
  158. .btn {
  159. &-icon {
  160. width: 44rpx;
  161. height: auto;
  162. }
  163. }
  164. }
  165. .section {
  166. margin-top: 24rpx;
  167. }
  168. .content {
  169. font-family: PingFang SC;
  170. font-weight: 400;
  171. font-size: 32rpx;
  172. line-height: 1.4;
  173. color: #181818;
  174. }
  175. .imgs {
  176. justify-content: flex-start;
  177. flex-wrap: wrap;
  178. gap: 24rpx;
  179. .img {
  180. width: 190rpx;
  181. height: 190rpx;
  182. }
  183. }
  184. .score {
  185. &-item {
  186. padding: 12rpx 0;
  187. justify-content: space-between;
  188. & + & {
  189. margin-top: 4rpx;
  190. }
  191. &-label {
  192. font-family: PingFang SC;
  193. font-weight: 400;
  194. font-size: 26rpx;
  195. line-height: 1.4;
  196. color: #181818;
  197. }
  198. }
  199. }
  200. .operate {
  201. justify-content: flex-start;
  202. column-gap: 24rpx;
  203. .btn {
  204. column-gap: 8rpx;
  205. font-size: 24rpx;
  206. color: #999999;
  207. .icon {
  208. width: 32rpx;
  209. height: auto;
  210. }
  211. }
  212. }
  213. .comment {
  214. &-user {
  215. column-gap: 16rpx;
  216. .avatar {
  217. width: 48rpx;
  218. height: 48rpx;
  219. border-radius: 50%;
  220. &-img {
  221. width: 100%;
  222. height: 100%;
  223. }
  224. }
  225. .name {
  226. font-size: 26rpx;
  227. font-weight: 600;
  228. color: #000000;
  229. }
  230. .time {
  231. flex: 1;
  232. text-align: right;
  233. font-size: 24rpx;
  234. color: #999999;
  235. }
  236. }
  237. &-content {
  238. margin-top: 28rpx;
  239. font-size: 26rpx;
  240. color: #666666;
  241. }
  242. }
  243. </style>