testResult.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <view class="bg">
  3. <view class="process"></view>
  4. <view class="scale_name">测测你的睡眠质量吧!</view>
  5. <view class="test_time">测试时间:{{time}}</view>
  6. <view class="role_img">
  7. <image v-if="roleList[role]" :src="roleList[role].img" mode="widthFix"></image>
  8. </view>
  9. <view class="result_box">
  10. <view class="container100">
  11. <echarts class="my_echarts" ref="echarts" :option="option" canvasId="echartsT"></echarts>
  12. <view class="score_tips">注:得分越高,睡眠质量越差</view>
  13. </view>
  14. <view class="role_name">
  15. <image v-if="roleList[role]" :src="roleList[role].title" mode="widthFix"></image>
  16. </view>
  17. <view class="result_box_r">
  18. <view style="overflow: hidden;"></view>
  19. <view class="score_title">分析报告:</view>
  20. <view class="sm_box">
  21. <view class="c_item" v-for="item in (segmentation(explain))">
  22. <view class="list_style_bg"></view>
  23. <text style="flex: 1;">{{item}}</text>
  24. </view>
  25. </view>
  26. <!-- <template v-if="improvementSuggestions != '无'">
  27. <view class="score_title">建议:</view>
  28. <view class="sm_box">
  29. {{improvementSuggestions}}
  30. </view>
  31. </template> -->
  32. </view>
  33. <view class="result_box_bottom"></view>
  34. </view>
  35. <view class="report_desc">
  36. <view class="desc_title">报告阅读说明</view>
  37. <view class="stext">谢谢您的参与,阅读本报告时,请注意以下内容:</view>
  38. <view style="display: flex;">
  39. <view class="list_mark">·</view>
  40. <view class="desc_txt">本结果仅供参考,不可作为临床诊断的依据;</view>
  41. </view>
  42. <view style="display: flex;">
  43. <view class="list_mark">·</view>
  44. <view class="desc_txt">如对报告有不理解的地方,建议咨询专业人员;</view>
  45. </view>
  46. <view style="display: flex;">
  47. <view class="list_mark">·</view>
  48. <view class="desc_txt">如结果与你自己或他人的感受有出入,可回忆在测试时是否有事情影响到你,或自己回答时是否有所顾虑。</view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import echarts from "@/components/echarts-uniapp/echarts-uniapp.vue"
  55. import {
  56. getRecordById
  57. } from "@/api/index.js";
  58. import {
  59. photoUrl
  60. } from "@/common/config.js"
  61. import {
  62. getTestTime
  63. } from "@/utils/util.js"
  64. const photoUrls = `${photoUrl}api/show?filePath=./webo`
  65. export default {
  66. components: {
  67. echarts
  68. },
  69. data() {
  70. return {
  71. isChecked: true,
  72. isShake: false,
  73. scaleDetail: {},
  74. questionList: [],
  75. currentQuestion: {},
  76. currentAnswerList: [],
  77. currentIndex: 0,
  78. userAnswerList: [],
  79. resultId: '',
  80. isLoading: false,
  81. isDisbale: false,
  82. roleList: {
  83. '睡眠质量较好': {
  84. title: `${photoUrls}/Sleep/role/title1.png`,
  85. img: `${photoUrls}/Sleep/role/role1.png`,
  86. starNum: 2
  87. },
  88. '睡眠质量很好': {
  89. title: `${photoUrls}/Sleep/role/title2.png`,
  90. img: `${photoUrls}/Sleep/role/role2.png`,
  91. starNum: 4
  92. },
  93. '睡眠质量一般': {
  94. title: `${photoUrls}/Sleep/role/title3.png`,
  95. img: `${photoUrls}/Sleep/role/role3.png`,
  96. starNum: 3
  97. },
  98. '睡眠质量很差': {
  99. title: `${photoUrls}/Sleep/role/title4.png`,
  100. img: `${photoUrls}/Sleep/role/role4.png`,
  101. starNum: 1
  102. }
  103. },
  104. resultId: '',
  105. role: '',
  106. explain: '',
  107. improvementSuggestions: '',
  108. scoreNum: 0,
  109. time: '',
  110. }
  111. },
  112. computed: {
  113. option() {
  114. return {
  115. series: [{
  116. type: 'gauge',
  117. startAngle: 180,
  118. endAngle: 0,
  119. center: ['50%', '77%'],
  120. radius: '100%',
  121. min: 0,
  122. max: 54,
  123. splitNumber: 3,
  124. axisLine: {
  125. lineStyle: {
  126. width: 14,
  127. color: [
  128. [0.22, '#7CFFB2'],
  129. [0.48, '#58D9F9'],
  130. [0.74, '#FDDD60'],
  131. [1, '#FF6E76']
  132. ]
  133. }
  134. },
  135. pointer: {
  136. icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
  137. length: '12%',
  138. width: 10,
  139. offsetCenter: [0, '-60%'],
  140. itemStyle: {
  141. color: 'auto'
  142. }
  143. },
  144. axisTick: {
  145. length: 12,
  146. lineStyle: {
  147. color: 'auto',
  148. width: 2
  149. }
  150. },
  151. splitLine: {
  152. length: 10,
  153. lineStyle: {
  154. color: 'auto',
  155. width: 2
  156. }
  157. },
  158. // axisLabel: {
  159. // color: '#464646',
  160. // fontSize: 20,
  161. // distance: -60,
  162. // rotate: 'tangential',
  163. // formatter: function(value) {
  164. // if (value === 0.875) {
  165. // return 'Grade A';
  166. // } else if (value === 0.625) {
  167. // return 'Grade B';
  168. // } else if (value === 0.375) {
  169. // return 'Grade C';
  170. // } else if (value === 0.125) {
  171. // return 'Grade D';
  172. // }
  173. // return '';
  174. // }
  175. // },
  176. title: {
  177. offsetCenter: [0, '-10%'],
  178. fontSize: 20
  179. },
  180. detail: {
  181. fontSize: 30,
  182. offsetCenter: [0, '-35%'],
  183. valueAnimation: true,
  184. formatter: function(value) {
  185. return Math.round(value) + '';
  186. },
  187. color: 'inherit'
  188. },
  189. data: [{
  190. value: this.scoreNum,
  191. name: '得分'
  192. }]
  193. }]
  194. };
  195. }
  196. },
  197. onLoad(options) {
  198. if (options && options.resultId) {
  199. this.resultId = options.resultId
  200. this.getScaleTestResults(this.resultId);
  201. }
  202. },
  203. methods: {
  204. getScaleTestResults(id) {
  205. let _this = this;
  206. _this.$request
  207. .get({
  208. url: `${getRecordById}?id=${id}`,
  209. loadingTip: "加载中...",
  210. data: {},
  211. })
  212. .then(
  213. (res) => {
  214. console.log('222:', new Date().getTime());
  215. console.log("----测试结果--->", res);
  216. if (res.code == 200) {
  217. _this.testResult = JSON.parse(res.data?.userRecordEntity?.testResult)[0];
  218. _this.role = _this.testResult.newTableContext.result[0].symptom;
  219. _this.explain = _this.testResult.newTableContext.result[0]
  220. .improvementSuggestions;
  221. _this.improvementSuggestions = _this.testResult.newTableContext.result[0]
  222. .suggestion;
  223. _this.scoreNum = _this.testResult.newTableContext.result[0].score;
  224. this.time = getTestTime(res.data.userRecordEntity.testDate)
  225. } else if (res.code == 401) {} else {
  226. (res) => {
  227. console.log("世界上绝对绝对绝对绝对绝对的", res);
  228. }
  229. }
  230. })
  231. },
  232. getNameUrl() {
  233. console.log(`${photoUrls}/Sleep/role/role_name1.png`)
  234. return `${photoUrls}/Sleep/role/role_name1.png`
  235. },
  236. segmentation(str) {
  237. return str.split('\n');
  238. }
  239. }
  240. }
  241. </script>
  242. <style scoped>
  243. .bg {
  244. width: 100%;
  245. min-height: 1524rpx;
  246. padding-bottom: 100rpx;
  247. background: #223255 url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Sleep/test_result_bg.png) no-repeat top;
  248. background-size: 100% auto;
  249. }
  250. .role_name {
  251. width: 454rpx;
  252. position: absolute;
  253. top: -50rpx;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. }
  257. .role_name image {
  258. width: 100%;
  259. }
  260. .role_img {
  261. width: 469rpx;
  262. margin: 20rpx auto 0;
  263. }
  264. .role_img image {
  265. width: 100%;
  266. }
  267. .result_box {
  268. width: 706rpx;
  269. min-height: 548rpx;
  270. padding-top: 100rpx;
  271. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Sleep/result_bg_top.png) no-repeat top;
  272. background-size: 100% auto;
  273. margin: -100rpx auto 0;
  274. border-radius: 33rpx;
  275. position: relative;
  276. }
  277. .result_box_bottom {
  278. width: 100%;
  279. height: 90rpx;
  280. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Sleep/result_bg_bottom.png) no-repeat;
  281. background-size: 100% 100%;
  282. }
  283. .c_item {
  284. display: flex;
  285. align-items: flex-start;
  286. text-align: justify;
  287. letter-spacing: 2px;
  288. margin-bottom: 16rpx;
  289. }
  290. .list_style_bg {
  291. width: 41rpx;
  292. height: 46rpx;
  293. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Sleep/list_style_bg.png) no-repeat center;
  294. background-size: 100% auto;
  295. margin: 4rpx 8rpx 0 0;
  296. }
  297. .role_medal {
  298. position: absolute;
  299. right: 50rpx;
  300. top: 0;
  301. }
  302. .role_medal image {
  303. width: 155rpx;
  304. }
  305. .result_box_r {
  306. box-sizing: border-box;
  307. width: 100%;
  308. min-height: 283rpx;
  309. padding: 0 26rpx;
  310. background: #FFFFFF;
  311. font-family: 'Alibaba PuHuiTi 2.0';
  312. font-weight: normal;
  313. font-size: 32rpx;
  314. color: #333333;
  315. line-height: 46rpx;
  316. }
  317. .score_title {
  318. font-family: 'Alibaba PuHuiTi 2.0';
  319. font-weight: normal;
  320. font-size: 36rpx;
  321. color: #471705;
  322. line-height: 31rpx;
  323. margin: 36rpx 0 36rpx 5rpx;
  324. }
  325. .score_num {
  326. font-family: 'Alibaba PuHuiTi 2.0';
  327. font-weight: bold;
  328. font-size: 81rpx;
  329. color: #FF9C00;
  330. line-height: 51rpx;
  331. /* text-stroke: 4px #FFFFFF;
  332. background: linear-gradient(269deg, #FF443D 0%, #FF9C00 100%);
  333. -webkit-text-stroke: 4px #FFFFFF;
  334. -webkit-background-clip: text;
  335. -webkit-text-fill-color: transparent; */
  336. margin: 12rpx 0 7rpx 156rpx;
  337. }
  338. .score_percentage {
  339. display: flex;
  340. align-items: center;
  341. justify-content: space-between;
  342. width: 420rpx;
  343. height: 46rpx;
  344. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Sleep/score_percentage_bg.png) no-repeat center;
  345. background-size: cover;
  346. margin: 14rpx 0 8rpx 72rpx;
  347. }
  348. .score_wrap {
  349. width: 318rpx;
  350. height: 32rpx;
  351. margin: 0 0 0 12rpx;
  352. position: relative;
  353. overflow-x: hidden;
  354. border-radius: 25rpx;
  355. }
  356. .process {
  357. overflow: hidden;
  358. }
  359. .process_bar {
  360. width: 318rpx;
  361. position: absolute;
  362. left: -100rpx;
  363. }
  364. .score_text {
  365. font-family: Alibaba PuHuiTi 2.0;
  366. font-weight: normal;
  367. font-size: 18rpx;
  368. color: #FFFFFF;
  369. line-height: 16rpx;
  370. margin-right: 16rpx;
  371. }
  372. .sm_box {
  373. box-sizing: border-box;
  374. width: 100%;
  375. padding: 30rpx 24rpx;
  376. background: #FFF4E5;
  377. border-radius: 20rpx;
  378. border: 1px solid #F8C983;
  379. text-align: justify;
  380. }
  381. .report_desc {
  382. padding: 60rpx 38rpx;
  383. letter-spacing: 1px;
  384. }
  385. .desc_title {
  386. font-family: 'Alibaba PuHuiTi 2.0';
  387. font-weight: normal;
  388. font-size: 36rpx;
  389. color: #ffffff;
  390. line-height: 46rpx;
  391. }
  392. .stext {
  393. font-family: 'Alibaba PuHuiTi 2.0';
  394. font-weight: normal;
  395. font-size: 20rpx;
  396. color: #ffffff;
  397. line-height: 30rpx;
  398. }
  399. .desc_txt {
  400. font-family: 'Alibaba PuHuiTi 2.0';
  401. font-weight: normal;
  402. font-size: 24rpx;
  403. color: #ffffff;
  404. line-height: 36rpx;
  405. }
  406. .list_mark {
  407. line-height: 0.7;
  408. font-size: 36rpx;
  409. color: #ffffff;
  410. font-weight: 600;
  411. margin-right: 5rpx;
  412. }
  413. .scale_name {
  414. font-family: 'Alibaba PuHuiTi 2.0';
  415. font-weight: bold;
  416. font-size: 42rpx;
  417. color: #FFFFFF;
  418. margin: 48rpx 0 0 39rpx;
  419. }
  420. .test_time {
  421. font-family: 'Alibaba PuHuiTi 2.0';
  422. font-weight: normal;
  423. font-size: 28rpx;
  424. color: #ffffff;
  425. margin-left: 39rpx;
  426. }
  427. .star_wrap {
  428. text-align: center;
  429. }
  430. .star_wrap image {
  431. width: 34rpx;
  432. margin: 8rpx;
  433. }
  434. .container100 {
  435. width: 100%;
  436. height: 356rpx;
  437. background: #FFFFFF;
  438. position: relative;
  439. }
  440. .my_echarts {
  441. width: 356rpx;
  442. height: 356rpx;
  443. margin: 0 auto;
  444. }
  445. .score_tips {
  446. font-size: 24rpx;
  447. color: #F8C983;
  448. position: absolute;
  449. bottom: 20rpx;
  450. left: 50%;
  451. transform: translateX(-50%)
  452. }
  453. .container100 {
  454. width: 100%;
  455. height: 100%;
  456. }
  457. </style>