普兆健康管家前端代码仓库
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.

165 lines
3.7 KiB

  1. <template>
  2. <view class="flex view report-score__view">
  3. <view class="flex flex-column left" :class="[scoreAlign == 'left' ? 'align-left' : '']">
  4. <template v-if="score">
  5. <view class="flex">
  6. <text class="score-value">{{ score }}</text><text class="score-full">/100</text>
  7. </view>
  8. <view class="flex">
  9. <view class="flex change" v-if="change > 0 || change < 0">
  10. <text>{{ change }}</text>
  11. <image :class="['change-icon', change > 0 ? 'is-up' : '']" src="@/pages_order/static/report/arrow-down.png" mode="widthFix"></image>
  12. </view>
  13. <!-- todo: check key -->
  14. <view class="tag" v-if="data.tag">
  15. {{ data.tag }}
  16. </view>
  17. </view>
  18. </template>
  19. <template v-else>
  20. <view class="flex">
  21. <text class="score-value is-empty">--</text><text class="score-full">/100</text>
  22. </view>
  23. </template>
  24. </view>
  25. <view class="divider"></view>
  26. <view class="flex flex-column right">
  27. <view><view class="highlight">{{ userInfo.name }}</view></view>
  28. <view>专属检测方案</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { mapState } from 'vuex'
  34. export default {
  35. props: {
  36. reports: {
  37. type: Array,
  38. default() {
  39. return []
  40. }
  41. },
  42. scoreAlign: {
  43. type: String,
  44. default: 'center'
  45. }
  46. },
  47. computed : {
  48. ...mapState(['userInfo']),
  49. score() {
  50. const [currentReport] = this.reports || []
  51. if (!currentReport?.score) {
  52. return null
  53. }
  54. return parseInt(currentReport.score)
  55. },
  56. change() {
  57. const [currentReport, lastReport] = this.reports || []
  58. if (lastReport) {
  59. return parseInt(currentReport.score - lastReport.score)
  60. }
  61. return 0
  62. },
  63. },
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. .view {
  68. .left {
  69. flex: 1;
  70. &.align-left {
  71. align-items: flex-start;
  72. }
  73. .score {
  74. &-value {
  75. font-family: PingFang SC;
  76. line-height: 1.4;
  77. font-weight: 600;
  78. font-size: 40rpx;
  79. color: $uni-color;
  80. &.is-empty {
  81. color: #989898;
  82. }
  83. }
  84. &-full {
  85. margin-left: 8rpx;
  86. font-size: 26rpx;
  87. font-weight: 400;
  88. line-height: 1.4;
  89. font-family: PingFang SC;
  90. color: transparent;
  91. background-image: linear-gradient(to right, #4B348F, #845CFA);
  92. background-clip: text;
  93. display: inline-block;
  94. }
  95. }
  96. .change {
  97. font-family: PingFang SC;
  98. font-weight: 400;
  99. font-size: 24rpx;
  100. line-height: 1.4;
  101. color: #F79205;
  102. &-icon {
  103. width: 24rpx;
  104. height: auto;
  105. &.is-up {
  106. transform: rotate(180deg);
  107. }
  108. }
  109. }
  110. .tag {
  111. margin-left: 16rpx;
  112. padding: 6rpx 16rpx;
  113. font-family: PingFang SC;
  114. font-weight: 400;
  115. font-size: 20rpx;
  116. line-height: 1.4;
  117. color: #FFFFFF;
  118. background-image: linear-gradient(135deg, #4B348F, #845CFA);
  119. border-top-left-radius: 24rpx;
  120. border-bottom-right-radius: 24rpx;
  121. }
  122. }
  123. .right {
  124. flex: 1;
  125. text-align: center;
  126. font-size: 26rpx;
  127. font-weight: 400;
  128. line-height: 1.4;
  129. font-family: PingFang SC;
  130. color: transparent;
  131. background-image: linear-gradient(to right, #4B348F, #845CFA);
  132. background-clip: text;
  133. display: inline-block;
  134. .highlight {
  135. display: inline-block;
  136. margin-right: 10rpx;
  137. border-bottom: 2rpx solid #4B348F;
  138. }
  139. }
  140. .divider {
  141. width: 2rpx;
  142. height: 32rpx;
  143. background: #B5B8CE;
  144. }
  145. }
  146. </style>