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

427 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>
  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">
  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. list: [],
  121. axis: ['饮食', '运动', '心理', '体质', '作息']
  122. }
  123. },
  124. onLoad(arg) {
  125. console.log('onLoad', arg)
  126. const ids = JSON.parse(arg.ids)
  127. this.getData(ids)
  128. },
  129. methods: {
  130. async fetchReportData(id) {
  131. console.log('fetchReportData', id)
  132. try {
  133. const result = await this.$fetch('getReportDetail', { id })
  134. const {
  135. createTime,
  136. score,
  137. scoreDetail,
  138. json,
  139. } = result
  140. const obj = {
  141. id,
  142. createTime: this.$dayjs(createTime).format('YYYY-MM-DD'),
  143. score: parseInt(score),
  144. scoreDetail: JSON.parse(scoreDetail).map(item => ({ name: item.name, score: parseInt(item.score) })),
  145. children: JSON.parse(json)
  146. }
  147. return obj
  148. } catch (err) {
  149. console.log('getReportDetail err', err)
  150. return {}
  151. }
  152. },
  153. async getData(ids) {
  154. console.log('ids', ids)
  155. const results = await Promise.allSettled(ids.map(id => { return this.fetchReportData(id) }))
  156. console.log('results', results)
  157. this.list = results.map(item => item.value)
  158. console.log('list', this.list)
  159. },
  160. },
  161. }
  162. </script>
  163. <style scoped lang="scss">
  164. .page__view {
  165. width: 100vw;
  166. min-height: 100vh;
  167. background-color: $uni-bg-color;
  168. position: relative;
  169. /deep/ .nav-bar__view {
  170. position: fixed;
  171. top: 0;
  172. left: 0;
  173. }
  174. }
  175. .main {
  176. padding: calc(var(--status-bar-height) + 152rpx) 32rpx 64rpx 32rpx;
  177. /deep/ .report-card__view {
  178. .card-content {
  179. padding-top: 232rpx;
  180. padding-left: 0;
  181. padding-right: 0;
  182. }
  183. }
  184. }
  185. .section {
  186. align-items: flex-start;
  187. width: 100%;
  188. & + & {
  189. .section-item {
  190. padding-top: 32rpx;
  191. border-top: 2rpx dashed #989898;
  192. }
  193. }
  194. &-item {
  195. padding-bottom: 32rpx;
  196. &-box {
  197. flex: 1;
  198. padding: 0 32rpx;
  199. &-left {
  200. padding-left: 24rpx;
  201. }
  202. &-right {
  203. padding-right: 24rpx;
  204. background: #FBFCFE;
  205. }
  206. }
  207. }
  208. &-header {
  209. font-family: PingFang SC;
  210. line-height: 1.4;
  211. color: #252545;
  212. &-zh {
  213. font-weight: 600;
  214. font-size: 32rpx;
  215. }
  216. &-en {
  217. font-weight: 400;
  218. font-size: 24rpx;
  219. }
  220. }
  221. &-content {
  222. padding-top: 18rpx;
  223. &-item {
  224. font-family: PingFang SC;
  225. font-weight: 400;
  226. line-height: 1.5;
  227. color: #252545;
  228. & + & {
  229. margin-top: 24rpx;
  230. }
  231. &-header {
  232. align-items: flex-start;
  233. justify-content: flex-start;
  234. }
  235. &-index {
  236. display: inline-block;
  237. width: 44rpx;
  238. font-size: 24rpx;
  239. text-align: right;
  240. line-height: 44rpx;
  241. padding-right: 10rpx;
  242. box-sizing: border-box;
  243. }
  244. &-title {
  245. font-size: 28rpx;
  246. }
  247. &-detail {
  248. margin-top: 8rpx;
  249. font-size: 24rpx;
  250. color: #989898;
  251. }
  252. }
  253. &-tag {
  254. margin-bottom: 24rpx;
  255. padding: 16rpx 0;
  256. background: #E5E4EB8C;
  257. border-radius: 16rpx;
  258. column-gap: 16rpx;
  259. &-icon {
  260. width: 40rpx;
  261. height: 40rpx;
  262. }
  263. &-text {
  264. font-family: PingFang SC;
  265. font-weight: 400;
  266. font-size: 28rpx;
  267. line-height: 1.5;
  268. color: #252545;
  269. }
  270. }
  271. }
  272. }
  273. .tags {
  274. display: flex;
  275. flex-wrap: wrap;
  276. gap: 16rpx;
  277. .tag {
  278. padding: 8rpx 40rpx;
  279. font-family: PingFang SC;
  280. font-weight: 400;
  281. font-size: 28rpx;
  282. line-height: 1.5;
  283. color: #252545;
  284. background: #E5E4EB;
  285. border-radius: 30rpx;
  286. &.highlight {
  287. font-weight: 600;
  288. color: #FFFFFF;
  289. background: #252545;
  290. }
  291. }
  292. }
  293. .info {
  294. &-score {
  295. padding: 40rpx 0;
  296. .time {
  297. display: inline-flex;
  298. width: auto;
  299. padding: 8rpx 16rpx;
  300. font-family: PingFang SC;
  301. font-weight: 400;
  302. font-size: 28rpx;
  303. line-height: 1.5;
  304. color: #252545;
  305. border: 2rpx solid #252545;
  306. border-radius: 30rpx;
  307. }
  308. .score {
  309. margin-top: 4rpx;
  310. justify-content: flex-start;
  311. column-gap: 8rpx;
  312. font-family: PingFang SC;
  313. font-weight: 400;
  314. font-size: 36rpx;
  315. line-height: 1.2;
  316. color: #252545CC;
  317. &-value {
  318. font-weight: 600;
  319. font-size: 64rpx;
  320. line-height: 1.4;
  321. color: transparent;
  322. background-image: linear-gradient(to right, #4B348F, #845CFA);
  323. background-clip: text;
  324. display: inline-block;
  325. }
  326. &-unit {
  327. font-weight: 600;
  328. font-size: 40rpx;
  329. line-height: 1.4;
  330. color: #252545;
  331. }
  332. }
  333. .score-detail {
  334. margin-top: 20rpx;
  335. &-item {
  336. padding-top: 10rpx;
  337. &-score {
  338. padding: 10rpx 0 0 16rpx;
  339. font-family: PingFang SC;
  340. font-weight: 400;
  341. font-size: 24rpx;
  342. line-height: 1;
  343. color: #8B8B8B;
  344. .highlight {
  345. margin-left: 12rpx;
  346. font-weight: 500;
  347. font-size: 28rpx;
  348. line-height: 1.4;
  349. color: #000000;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. &-BMI {
  356. .label {
  357. white-space: nowrap;
  358. font-family: PingFang SC;
  359. font-weight: 400;
  360. font-size: 36rpx;
  361. line-height: 1.2;
  362. color: #252545CC;
  363. .highlight {
  364. margin-left: 8rpx;
  365. font-size: 64rpx;
  366. font-weight: 600;
  367. line-height: 1.4;
  368. font-family: PingFang SC;
  369. color: transparent;
  370. background-image: linear-gradient(to right, #4B348F, #845CFA);
  371. background-clip: text;
  372. display: inline-block;
  373. }
  374. }
  375. .progress {
  376. margin: 18rpx 0 34rpx 0;
  377. width: 100%;
  378. }
  379. }
  380. }
  381. </style>