鸿宇研学生前端代码
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.

260 lines
5.4 KiB

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