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

193 lines
4.3 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"></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" v-if="mode == 'edit'">
  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>
  53. </template>
  54. <script>
  55. export default {
  56. props: {
  57. data: {
  58. type: Object,
  59. default() {
  60. return {}
  61. }
  62. },
  63. mode: {
  64. type: String,
  65. default: 'read' // read | edit
  66. }
  67. },
  68. computed: {
  69. images() {
  70. const { image } = this.data || {}
  71. return image?.split?.(',')
  72. }
  73. },
  74. methods: {
  75. onComment() {
  76. // todo
  77. this.$emit('change')
  78. },
  79. onLike() {
  80. // todo
  81. this.$emit('change')
  82. },
  83. onCancelLike() {
  84. // todo
  85. this.$emit('change')
  86. },
  87. },
  88. }
  89. </script>
  90. <style scoped lang="scss">
  91. .card {
  92. width: 100%;
  93. padding: 32rpx;
  94. box-sizing: border-box;
  95. background: #FAFAFF;
  96. border: 2rpx solid #FFFFFF;
  97. border-radius: 32rpx;
  98. }
  99. .header {
  100. .left {
  101. flex: 1;
  102. justify-content: flex-start;
  103. column-gap: 24rpx;
  104. }
  105. .avatar {
  106. width: 100rpx;
  107. height: 100rpx;
  108. border: 4rpx solid #FFFFFF;
  109. border-radius: 50%;
  110. overflow: hidden;
  111. &-img {
  112. width: 100%;
  113. height: 100%;
  114. }
  115. }
  116. .info {
  117. font-family: PingFang SC;
  118. font-weight: 400;
  119. font-size: 24rpx;
  120. line-height: 1.5;
  121. color: #8B8B8B;
  122. .name {
  123. font-weight: 600;
  124. font-size: 36rpx;
  125. line-height: 1.2;
  126. color: #252545;
  127. margin-bottom: 8rpx;
  128. }
  129. }
  130. .btn {
  131. &-icon {
  132. width: 44rpx;
  133. height: auto;
  134. }
  135. }
  136. }
  137. .section {
  138. margin-top: 24rpx;
  139. }
  140. .content {
  141. font-family: PingFang SC;
  142. font-weight: 400;
  143. font-size: 32rpx;
  144. line-height: 1.4;
  145. color: #181818;
  146. }
  147. .imgs {
  148. justify-content: flex-start;
  149. flex-wrap: wrap;
  150. gap: 24rpx;
  151. .img {
  152. width: 190rpx;
  153. height: 190rpx;
  154. }
  155. }
  156. .score {
  157. &-item {
  158. padding: 12rpx 0;
  159. justify-content: space-between;
  160. & + & {
  161. margin-top: 4rpx;
  162. }
  163. &-label {
  164. font-family: PingFang SC;
  165. font-weight: 400;
  166. font-size: 26rpx;
  167. line-height: 1.4;
  168. color: #181818;
  169. }
  170. }
  171. }
  172. </style>