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

435 lines
12 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="报告对比" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />
  4. <view class="main">
  5. <reportCard :data="detail">
  6. <view class="report" v-if="list.length">
  7. <view class="flex section">
  8. <view
  9. v-for="(item, index) in list"
  10. :key="item.id"
  11. :class="['section-item-box', `section-item-box-${index == 0 ? 'left' : 'right'}`]"
  12. >
  13. <view class="section-item info-score">
  14. <view class="time">{{ item.createTime }}</view>
  15. <view class="flex score">
  16. 综合得分
  17. <text class="score-value">{{ item.score }}</text>
  18. <text class="score-unit"></text>
  19. </view>
  20. <view class="score-detail">
  21. <view class="score-detail-item" v-for="(scoreItem, sIdx) in item.scoreDetail" :key="sIdx">
  22. <progressBar :progress="scoreItem.score" :total="100"></progressBar>
  23. <view class="score-detail-item-score">{{ scoreItem.name }}<text class="highlight">{{ scoreItem.score }}</text></view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="flex section">
  30. <view
  31. v-for="(item, index) in list"
  32. :key="item.id"
  33. :class="['section-item-box', `section-item-box-${index == 0 ? 'left' : 'right'}`]"
  34. >
  35. <view class="section-item info-BMI">
  36. <view class="flex label">
  37. <text>BMI 指数</text>
  38. <text class="highlight">{{ item.bmi || '-' }}</text>
  39. </view>
  40. <view class="progress" v-if="item.bmi">
  41. <!-- todo: check -->
  42. <progressBar :progress="item.bmi" :total="30"></progressBar>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="flex section"
  48. v-for="(step, sIdx) in list[0].children" :key="step.key"
  49. >
  50. <view
  51. v-for="(report, rIdx) in list"
  52. :key="rIdx"
  53. :class="['section-item-box', `section-item-box-${rIdx == 0 ? 'left' : 'right'}`]"
  54. >
  55. <view class="section-item">
  56. <view class="section-header">
  57. <view class="section-header-zh">{{ `${sIdx + 1}.${step.name}` }}</view>
  58. <view class="section-header-en">{{ step.enTitle }}</view>
  59. </view>
  60. <view class="section-content">
  61. <!-- 普通标签 -->
  62. <template v-if="step.type == '0'">
  63. <view class="tags">
  64. <view class="tag" v-for="(item, tIdx) in report.children[sIdx].schemes" :key="tIdx">{{ item.title }}</view>
  65. </view>
  66. </template>
  67. <!-- 暗色标签 -->
  68. <template v-else-if="step.type === '1'">
  69. <view class="tags">
  70. <view class="tag highlight" v-for="(item, tIdx) in report.children[sIdx].schemes" :key="tIdx">{{ item.title }}</view>
  71. </view>
  72. </template>
  73. <!-- 有序文本 -->
  74. <template v-else-if="step.type === '2'">
  75. <!-- todo -->
  76. <!-- <view class="flex section-content-tag">
  77. <image class="section-content-tag-icon" :src="report.children[sIdx].tag.icon" mode="widthFix"></image>
  78. <text class="section-content-tag-text">{{ report.children[sIdx].tag.text }}</text>
  79. </view> -->
  80. <view>
  81. <view class="section-content-item" v-for="(item, idx) in report.children[sIdx].schemes" :key="idx">
  82. <view class="flex section-content-item-header">
  83. <view class="section-content-item-index">{{ `${idx + 1}.` }}</view>
  84. <view class="section-content-item-title">{{ item.title }}</view>
  85. </view>
  86. <view class="section-content-item-detail" v-if="item.info">{{ item.info }}</view>
  87. </view>
  88. </view>
  89. </template>
  90. <!-- 无序文本 -->
  91. <template v-else-if="step.type === '3'">
  92. <view>
  93. <view class="section-content-item" v-for="(item, idx) in report.children[sIdx].schemes" :key="idx">
  94. <view class="flex section-content-item-header">
  95. <view class="section-content-item-title">{{ item.title }}</view>
  96. </view>
  97. <view class="section-content-item-detail" v-if="item.info">{{ item.info }}</view>
  98. </view>
  99. </view>
  100. </template>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </reportCard>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import reportCard from '@/pages_order/components/reportCard.vue';
  112. import progressBar from '@/pages_order/components/progressBar.vue';
  113. export default {
  114. components: {
  115. reportCard,
  116. progressBar,
  117. },
  118. data() {
  119. return {
  120. detail: {},
  121. list: [],
  122. axis: ['饮食', '运动', '心理', '体质', '作息']
  123. }
  124. },
  125. onLoad(arg) {
  126. console.log('onLoad', arg)
  127. const ids = JSON.parse(arg.ids)
  128. this.getData(ids)
  129. },
  130. methods: {
  131. async fetchReportData(id) {
  132. console.log('fetchReportData', id)
  133. try {
  134. const result = await this.$fetch('getReportDetail', { id })
  135. const {
  136. realName,
  137. age,
  138. sex,
  139. createTime,
  140. score,
  141. scoreDetail,
  142. json,
  143. } = result
  144. const obj = {
  145. id,
  146. realName,
  147. age,
  148. sex,
  149. createTime: this.$dayjs(createTime).format('YYYY-MM-DD'),
  150. score: parseInt(score),
  151. scoreDetail: JSON.parse(scoreDetail).map(item => ({ name: item.name, score: parseInt(item.score) })),
  152. children: JSON.parse(json)
  153. }
  154. return obj
  155. } catch (err) {
  156. console.log('getReportDetail err', err)
  157. return {}
  158. }
  159. },
  160. async getData(ids) {
  161. console.log('ids', ids)
  162. const results = await Promise.allSettled(ids.map(id => { return this.fetchReportData(id) }))
  163. console.log('results', results)
  164. this.list = results.map(item => item.value)
  165. this.detail = this.list[0]
  166. console.log('list', this.list)
  167. },
  168. },
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .page__view {
  173. width: 100vw;
  174. min-height: 100vh;
  175. background-color: $uni-bg-color;
  176. position: relative;
  177. /deep/ .nav-bar__view {
  178. position: fixed;
  179. top: 0;
  180. left: 0;
  181. }
  182. }
  183. .main {
  184. padding: calc(var(--status-bar-height) + 152rpx) 32rpx 64rpx 32rpx;
  185. /deep/ .report-card__view {
  186. .card-content {
  187. padding-top: 232rpx;
  188. padding-left: 0;
  189. padding-right: 0;
  190. }
  191. }
  192. }
  193. .section {
  194. align-items: flex-start;
  195. width: 100%;
  196. & + & {
  197. .section-item {
  198. padding-top: 32rpx;
  199. border-top: 2rpx dashed #989898;
  200. }
  201. }
  202. &-item {
  203. padding-bottom: 32rpx;
  204. &-box {
  205. flex: 1;
  206. padding: 0 32rpx;
  207. &-left {
  208. padding-left: 24rpx;
  209. }
  210. &-right {
  211. padding-right: 24rpx;
  212. background: #FBFCFE;
  213. }
  214. }
  215. }
  216. &-header {
  217. font-family: PingFang SC;
  218. line-height: 1.4;
  219. color: #252545;
  220. &-zh {
  221. font-weight: 600;
  222. font-size: 32rpx;
  223. }
  224. &-en {
  225. font-weight: 400;
  226. font-size: 24rpx;
  227. }
  228. }
  229. &-content {
  230. padding-top: 18rpx;
  231. &-item {
  232. font-family: PingFang SC;
  233. font-weight: 400;
  234. line-height: 1.5;
  235. color: #252545;
  236. & + & {
  237. margin-top: 24rpx;
  238. }
  239. &-header {
  240. align-items: flex-start;
  241. justify-content: flex-start;
  242. }
  243. &-index {
  244. display: inline-block;
  245. width: 44rpx;
  246. font-size: 24rpx;
  247. text-align: right;
  248. line-height: 44rpx;
  249. padding-right: 10rpx;
  250. box-sizing: border-box;
  251. }
  252. &-title {
  253. font-size: 28rpx;
  254. }
  255. &-detail {
  256. margin-top: 8rpx;
  257. font-size: 24rpx;
  258. color: #989898;
  259. }
  260. }
  261. &-tag {
  262. margin-bottom: 24rpx;
  263. padding: 16rpx 0;
  264. background: #E5E4EB8C;
  265. border-radius: 16rpx;
  266. column-gap: 16rpx;
  267. &-icon {
  268. width: 40rpx;
  269. height: 40rpx;
  270. }
  271. &-text {
  272. font-family: PingFang SC;
  273. font-weight: 400;
  274. font-size: 28rpx;
  275. line-height: 1.5;
  276. color: #252545;
  277. }
  278. }
  279. }
  280. }
  281. .tags {
  282. display: flex;
  283. flex-wrap: wrap;
  284. gap: 16rpx;
  285. .tag {
  286. padding: 8rpx 40rpx;
  287. font-family: PingFang SC;
  288. font-weight: 400;
  289. font-size: 28rpx;
  290. line-height: 1.5;
  291. color: #252545;
  292. background: #E5E4EB;
  293. border-radius: 30rpx;
  294. &.highlight {
  295. font-weight: 600;
  296. color: #FFFFFF;
  297. background: #252545;
  298. }
  299. }
  300. }
  301. .info {
  302. &-score {
  303. padding: 40rpx 0;
  304. .time {
  305. display: inline-flex;
  306. width: auto;
  307. padding: 8rpx 16rpx;
  308. font-family: PingFang SC;
  309. font-weight: 400;
  310. font-size: 28rpx;
  311. line-height: 1.5;
  312. color: #252545;
  313. border: 2rpx solid #252545;
  314. border-radius: 30rpx;
  315. }
  316. .score {
  317. margin-top: 4rpx;
  318. justify-content: flex-start;
  319. column-gap: 8rpx;
  320. font-family: PingFang SC;
  321. font-weight: 400;
  322. font-size: 36rpx;
  323. line-height: 1.2;
  324. color: #252545CC;
  325. &-value {
  326. font-weight: 600;
  327. font-size: 64rpx;
  328. line-height: 1.4;
  329. color: transparent;
  330. background-image: linear-gradient(to right, #4B348F, #845CFA);
  331. background-clip: text;
  332. display: inline-block;
  333. }
  334. &-unit {
  335. font-weight: 600;
  336. font-size: 40rpx;
  337. line-height: 1.4;
  338. color: #252545;
  339. }
  340. }
  341. .score-detail {
  342. margin-top: 20rpx;
  343. &-item {
  344. padding-top: 10rpx;
  345. &-score {
  346. padding: 10rpx 0 0 16rpx;
  347. font-family: PingFang SC;
  348. font-weight: 400;
  349. font-size: 24rpx;
  350. line-height: 1;
  351. color: #8B8B8B;
  352. .highlight {
  353. margin-left: 12rpx;
  354. font-weight: 500;
  355. font-size: 28rpx;
  356. line-height: 1.4;
  357. color: #000000;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. &-BMI {
  364. .label {
  365. white-space: nowrap;
  366. font-family: PingFang SC;
  367. font-weight: 400;
  368. font-size: 36rpx;
  369. line-height: 1.2;
  370. color: #252545CC;
  371. .highlight {
  372. margin-left: 8rpx;
  373. font-size: 64rpx;
  374. font-weight: 600;
  375. line-height: 1.4;
  376. font-family: PingFang SC;
  377. color: transparent;
  378. background-image: linear-gradient(to right, #4B348F, #845CFA);
  379. background-clip: text;
  380. display: inline-block;
  381. }
  382. }
  383. .progress {
  384. margin: 18rpx 0 34rpx 0;
  385. width: 100%;
  386. }
  387. }
  388. }
  389. </style>