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

255 lines
5.5 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. <uv-rate :value="data.productNum" size="48rpx" gutter="16rpx" activeColor="#F7BA1E" :allowHalf="true" :minCount="0.5" readonly></uv-rate>
  28. </view>
  29. <view class="flex score-item">
  30. <view class="score-item-label">问卷体验</view>
  31. <uv-rate :value="data.paperNum" size="48rpx" gutter="16rpx" activeColor="#F7BA1E" :allowHalf="true" :minCount="0.5" readonly></uv-rate>
  32. </view>
  33. <view class="flex score-item">
  34. <view class="score-item-label">物流速度</view>
  35. <uv-rate :value="data.logisticsNum" size="48rpx" gutter="16rpx" activeColor="#F7BA1E" :allowHalf="true" :minCount="0.5" readonly></uv-rate>
  36. </view>
  37. </view>
  38. <view class="section operate">
  39. <button class="flex btn" @click="onComment">
  40. <image class="icon" src="@/static/image/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="@/static/image/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="@/static/image/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. export default {
  70. props: {
  71. data: {
  72. type: Object,
  73. default() {
  74. return {}
  75. }
  76. },
  77. mode: {
  78. type: String,
  79. default: 'read' // read | edit
  80. }
  81. },
  82. computed: {
  83. images() {
  84. const { image } = this.data || {}
  85. return image?.split?.(',')
  86. },
  87. disabled() {
  88. return this.mode !== 'edit'
  89. },
  90. },
  91. methods: {
  92. onComment() {
  93. if (this.disabled) {
  94. return
  95. }
  96. // todo
  97. this.$emit('change')
  98. },
  99. onLike() {
  100. if (this.disabled) {
  101. return
  102. }
  103. // todo
  104. this.$emit('change')
  105. },
  106. onCancelLike() {
  107. if (this.disabled) {
  108. return
  109. }
  110. // todo
  111. this.$emit('change')
  112. },
  113. },
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .card {
  118. width: 100%;
  119. padding: 32rpx;
  120. box-sizing: border-box;
  121. background: #FAFAFF;
  122. border: 2rpx solid #FFFFFF;
  123. border-radius: 32rpx;
  124. }
  125. .header {
  126. .left {
  127. flex: 1;
  128. justify-content: flex-start;
  129. column-gap: 24rpx;
  130. }
  131. .avatar {
  132. width: 100rpx;
  133. height: 100rpx;
  134. border: 4rpx solid #FFFFFF;
  135. border-radius: 50%;
  136. overflow: hidden;
  137. &-img {
  138. width: 100%;
  139. height: 100%;
  140. }
  141. }
  142. .info {
  143. font-family: PingFang SC;
  144. font-weight: 400;
  145. font-size: 24rpx;
  146. line-height: 1.5;
  147. color: #8B8B8B;
  148. .name {
  149. font-weight: 600;
  150. font-size: 36rpx;
  151. line-height: 1.2;
  152. color: #252545;
  153. margin-bottom: 8rpx;
  154. }
  155. }
  156. .btn {
  157. &-icon {
  158. width: 44rpx;
  159. height: auto;
  160. }
  161. }
  162. }
  163. .section {
  164. margin-top: 24rpx;
  165. }
  166. .content {
  167. font-family: PingFang SC;
  168. font-weight: 400;
  169. font-size: 32rpx;
  170. line-height: 1.4;
  171. color: #181818;
  172. }
  173. .imgs {
  174. justify-content: flex-start;
  175. flex-wrap: wrap;
  176. gap: 24rpx;
  177. .img {
  178. width: 190rpx;
  179. height: 190rpx;
  180. }
  181. }
  182. .score {
  183. &-item {
  184. padding: 12rpx 0;
  185. justify-content: space-between;
  186. & + & {
  187. margin-top: 4rpx;
  188. }
  189. &-label {
  190. font-family: PingFang SC;
  191. font-weight: 400;
  192. font-size: 26rpx;
  193. line-height: 1.4;
  194. color: #181818;
  195. }
  196. }
  197. }
  198. .comment {
  199. &-user {
  200. column-gap: 16rpx;
  201. .avatar {
  202. width: 48rpx;
  203. height: 48rpx;
  204. border-radius: 50%;
  205. &-img {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. }
  210. .name {
  211. font-size: 26rpx;
  212. font-weight: 600;
  213. color: #000000;
  214. }
  215. .time {
  216. flex: 1;
  217. text-align: right;
  218. font-size: 24rpx;
  219. color: #999999;
  220. }
  221. }
  222. &-content {
  223. margin-top: 28rpx;
  224. font-size: 26rpx;
  225. color: #666666;
  226. }
  227. }
  228. </style>