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

176 lines
3.6 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar bgColor="#FFFFFF" >
  4. <image class="nav-icon" :src="configList.icon_nav_dark" mode="widthFix"></image>
  5. </navbar>
  6. <view class="content">
  7. <report-summary :data="summaryData"></report-summary>
  8. <view class="section">
  9. <recommend-test></recommend-test>
  10. </view>
  11. <view id="paperList" class="section">
  12. <view class="filter">
  13. <view class="filter-item"
  14. v-for="item in filters"
  15. :key="item.value"
  16. :class="['filter-item', item.value === queryParams.type ? 'is-active' : '']"
  17. @click="onSelectFilter(item.value)"
  18. >
  19. {{ item.label }}
  20. </view>
  21. </view>
  22. <view>
  23. <report-record-card v-for="item in list" :key="item.id" :data="item" :type="queryParams.type"></report-record-card>
  24. </view>
  25. </view>
  26. </view>
  27. <tabber select="report" />
  28. </view>
  29. </template>
  30. <script>
  31. import mixinsList from '@/mixins/list.js'
  32. import tabber from '@/components/base/tabbar.vue'
  33. import reportSummary from '@/pages_order/report/reportSummary/index.vue'
  34. import recommendTest from '@/pages_order/report/recommendTest.vue'
  35. import reportRecordCard from '@/pages_order/report/reportRecordCard.vue'
  36. export default {
  37. mixins: [mixinsList],
  38. components: {
  39. reportSummary,
  40. recommendTest,
  41. reportRecordCard,
  42. tabber,
  43. },
  44. data() {
  45. return {
  46. summaryData: {},
  47. // type 类型(0已完成,1未完成)
  48. filters: [
  49. { value: 0, label: '已完成的检测' },
  50. { value: 1, label: '未完成的检测' },
  51. ],
  52. queryParams: {
  53. pageNo: 1,
  54. pageSize: 10,
  55. type: 0,
  56. },
  57. mixinsListApi: 'getPaperList',
  58. }
  59. },
  60. onShow() {
  61. if(uni.getStorageSync('token')){
  62. this.$store.commit('getUserInfo')
  63. this.initData()
  64. }
  65. },
  66. methods: {
  67. async initData() {
  68. try {
  69. const result = await this.$fetch('getRecentReport')
  70. if (result?.length) {
  71. const [currentReport, lastReport] = result
  72. let change = 0
  73. if (lastReport) {
  74. change = parseInt(currentReport.score - lastReport.score)
  75. }
  76. this.summaryData = {
  77. id: currentReport.id,
  78. paperId: currentReport.paperId,
  79. score: parseInt(currentReport.score),
  80. change,
  81. }
  82. this.getData()
  83. return
  84. }
  85. this.queryParams.type = 1 // 未完成
  86. await this.getData()
  87. this.summaryData = {
  88. id: null,
  89. paperId: this.list[0]?.id,
  90. score: 0,
  91. change: 0,
  92. }
  93. this.$nextTick(() => {
  94. uni.pageScrollTo({
  95. // scrollTop: 600, // 滚动到页面的顶部
  96. duration: 300, // 动画时长(单位 ms)
  97. selector: '#paperList' // 通过选择器指定滚动目标(H5 端支持)
  98. })
  99. })
  100. } catch (err) {
  101. }
  102. },
  103. onSelectFilter(val) {
  104. // type 类型【选填】(0已完成,1未完成)
  105. this.queryParams.type = val
  106. this.getData()
  107. },
  108. },
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. .page__view {
  113. width: 100vw;
  114. min-height: 100vh;
  115. background-color: $uni-bg-color;
  116. position: relative;
  117. }
  118. .nav-icon {
  119. width: 200rpx;
  120. height: auto;
  121. vertical-align: top;
  122. }
  123. .content {
  124. padding: 0 32rpx 32rpx 32rpx;
  125. }
  126. .section {
  127. margin-top: 48rpx;
  128. }
  129. .filter {
  130. &-item {
  131. display: inline-block;
  132. padding: 12rpx 40rpx;
  133. border-radius: 32rpx;
  134. font-size: 28rpx;
  135. line-height: 1.5;
  136. font-family: PingFang SC;
  137. font-weight: 400;
  138. color: #252545;
  139. background: #E5E4EB;
  140. & + & {
  141. margin-left: 32rpx;
  142. }
  143. &.is-active {
  144. font-weight: 600;
  145. color: #FFFFFF;
  146. background: #252545;
  147. }
  148. }
  149. }
  150. </style>