天波h5前端应用
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

337 lines
6.9KB

  1. <template>
  2. <div
  3. class="psychologicalScale-detail"
  4. :style="`padding-top: ${showLeftArrow ? '10vw' : '0'};`"
  5. >
  6. <van-nav-bar
  7. title="测评结果"
  8. :border="true"
  9. :left-arrow="true"
  10. @click-left="onNavBack"
  11. v-if="showLeftArrow"
  12. style="position: fixed; left: 0; top: 0; width: 100vw"
  13. >
  14. <template #left>
  15. <van-icon name="arrow-left" size="23" style="padding: 0" />返回
  16. </template>
  17. </van-nav-bar>
  18. <div class="content">
  19. <div class="result-title">您的测评结果为:</div>
  20. <div class="result" :style="{ color: levels[`${resultLevel}`].color }">
  21. {{ levels[`${resultLevel}`].title }}
  22. </div>
  23. <div class="result-label">
  24. <span>您的焦虑得分:</span>
  25. <div
  26. class="result-color"
  27. :style="{ background: levels[`${resultLevel}`].color }"
  28. ></div>
  29. </div>
  30. <div class="result-details">
  31. <div
  32. class="result-details-item"
  33. v-for="(item, index) in showLevels"
  34. :key="index"
  35. :style="{ width: `${100 / showLevels.length}%` }"
  36. >
  37. <div
  38. class="result-details-item-icon"
  39. :style="{ background: item.color }"
  40. ></div>
  41. <div
  42. class="result-details-item-title"
  43. :style="{
  44. color: resultLevel == index + 1 ? 'black' : 'gray',
  45. }"
  46. >
  47. {{ item.title }}
  48. </div>
  49. </div>
  50. </div>
  51. <div class="result-label">总体评分:</div>
  52. <div class="result-content">{{ result.Explain }}</div>
  53. <div class="result-label">结果解释:</div>
  54. <div class="result-content">{{ result.Advice }}</div>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import axios from 'axios'
  60. import APICore from '@/api/core'
  61. export default {
  62. name: 'PsychologicalScaleDetail',
  63. data() {
  64. return {
  65. id: '',
  66. uid: '',
  67. showLeftArrow: false,
  68. fromSsjl: this.$store.getters.fromSsjl,
  69. result: {
  70. Advice: '',
  71. Explain: '',
  72. ScaleName: '',
  73. Score: 15,
  74. Summary: '',
  75. SummaryLevel: '-1',
  76. Time: '',
  77. },
  78. levels: [
  79. {
  80. show: false,
  81. color: '#dfe4ea',
  82. title: '暂无测评结果',
  83. },
  84. {
  85. color: '#60B977',
  86. title: '没有抑郁症状',
  87. },
  88. {
  89. color: '#FFB600',
  90. title: '轻度抑郁',
  91. },
  92. {
  93. color: '#CC0003',
  94. title: '重度抑郁',
  95. },
  96. ],
  97. }
  98. },
  99. computed: {
  100. resultLevel() {
  101. return parseInt(this.result.SummaryLevel) + 1
  102. },
  103. showLevels() {
  104. return this.levels.filter((item) => {
  105. if (!(item.show === false)) {
  106. return true
  107. }
  108. })
  109. },
  110. },
  111. watch: {},
  112. mounted() {
  113. //页面标题
  114. window.document.title = '测评结果'
  115. //页面传参
  116. let params = { ...this.$route.query }
  117. if (params.id && params.uid) {
  118. this.id = params.id
  119. this.uid = params.uid
  120. // 缓存从随手精灵传过来的token
  121. this.$store.commit('ssjlToken', params.accessToken || '')
  122. if (params.appType) {
  123. this.$store.commit('appType', params.appType)
  124. }
  125. // 缓存从随手精灵传过来的标识
  126. if (params.fromSsjl) {
  127. this.$store.commit('fromSsjl', params.fromSsjl)
  128. }
  129. // 是否显示 返回标签
  130. if (params.showLeftArrow) {
  131. this.showLeftArrow = true
  132. }
  133. this.fromUrl = params.fromUrl
  134. console.log('fromUrl', this.fromUrl)
  135. //初始化
  136. this.init()
  137. } else {
  138. this.$toast('参数错误')
  139. }
  140. },
  141. methods: {
  142. async init() {
  143. if (!this.$route.query.accessToken) {
  144. // 如果当前url没有 accessToken, 获取token,并且存储到本地缓存里面
  145. let authToken = await this.getAuth()
  146. this.$store.commit('ssjlToken', authToken)
  147. }
  148. this.$toast.loading({
  149. message: '',
  150. forbidClick: true,
  151. duration: 0,
  152. })
  153. let re = await this.api(
  154. '/api/Question/GetScaleFillingRecord',
  155. {
  156. method: 'GET',
  157. sslVerify: false,
  158. withCredentials: false,
  159. params: {
  160. uid: this.uid,
  161. },
  162. },
  163. this.$store.getters.ssjlToken
  164. )
  165. if (re.success) {
  166. if (re.response && re.response.length) {
  167. re.response.forEach((item) => {
  168. if (item.Id === this.id) {
  169. this.result = item
  170. }
  171. })
  172. } else {
  173. // this.$toast('暂无测评结果')
  174. }
  175. } else {
  176. this.$toast(re.msg)
  177. }
  178. },
  179. onNavBack() {
  180. let fromSsjl = this.$store.getters.fromSsjl === 'true'
  181. if (fromSsjl) {
  182. let baseUrl = this.fromUrl
  183. window.location.href = `${baseUrl}/#/${
  184. this.$route.query.fromMenu || 'device'
  185. }`
  186. } else {
  187. window.history.go(-1)
  188. }
  189. },
  190. // 获取b端token
  191. getAuth() {
  192. let manufactorId = '5bf13062-a41e-4d00-ba14-1101aad12650'
  193. let that = this
  194. return new Promise((resolve, reject) => {
  195. APICore.getAuth({ manufactorId: manufactorId }).then((res) => {
  196. let data = res.data
  197. if (data.code === 0) {
  198. resolve(res.data.data)
  199. } else {
  200. that.$toast.fail(`${data.message}`)
  201. reject('')
  202. }
  203. })
  204. })
  205. },
  206. api(url, config, token) {
  207. setTimeout(() => {
  208. this.$toast.loading({
  209. message: '',
  210. forbidClick: true,
  211. duration: 1500,
  212. })
  213. }, 100)
  214. let baseUrl =
  215. process.env.NODE_ENV === 'production'
  216. ? 'https://dbmq.rzliot.com/auth_heart'
  217. : 'https://dbmq.rzliot.com/heart'
  218. return new Promise((res) => {
  219. axios({
  220. url: `${baseUrl}${url}`,
  221. ...config,
  222. // 增加请求头部 token
  223. headers: {
  224. AccessToken: token,
  225. },
  226. })
  227. .then((re) => {
  228. if (re) {
  229. if (re.data) {
  230. console.log(re.data)
  231. res(re.data)
  232. this.$toast.clear()
  233. return
  234. }
  235. this.$toast(`信息获取失败-${re.status}`)
  236. res(true)
  237. this.$toast.clear()
  238. return
  239. }
  240. this.$toast(`信息获取失败-${url}`)
  241. res(true)
  242. this.$toast.clear()
  243. })
  244. .catch((e) => {
  245. this.$toast(`信息获取失败-${url}`)
  246. res(true)
  247. this.$toast.clear()
  248. console.log(e)
  249. })
  250. })
  251. },
  252. },
  253. }
  254. </script>
  255. <style lang="scss">
  256. .psychologicalScale-detail {
  257. width: 100vw;
  258. min-height: 100vh;
  259. box-sizing: border-box;
  260. font-size: 3.6vw;
  261. text-align: left;
  262. background: #f4f4f4;
  263. padding-bottom: 8vw;
  264. .van-nav-bar__content {
  265. height: 10vw !important;
  266. .van-nav-bar__left,
  267. .van-nav-bar__title {
  268. font-size: 4vw !important;
  269. line-height: initial !important;
  270. .van-icon-arrow-left {
  271. font-size: 4vw !important;
  272. }
  273. }
  274. }
  275. .content {
  276. padding: 4vw;
  277. .result-title {
  278. font-size: 4vw;
  279. text-align: center;
  280. }
  281. .result {
  282. font-size: 6vw;
  283. text-align: center;
  284. font-weight: bold;
  285. margin-top: 4vw;
  286. }
  287. .result-label {
  288. display: flex;
  289. align-items: center;
  290. justify-content: space-between;
  291. font-size: 4.5vw;
  292. font-weight: bold;
  293. margin-top: 6vw;
  294. }
  295. .result-color {
  296. width: 5.5vw;
  297. height: 5.5vw;
  298. border-radius: 1vw;
  299. }
  300. .result-details {
  301. display: flex;
  302. margin-top: 4vw;
  303. .result-details-item {
  304. .result-details-item-icon {
  305. width: 100%;
  306. height: 5.5vw;
  307. }
  308. .result-details-item-title {
  309. font-weight: bold;
  310. text-align: center;
  311. margin-top: 2vw;
  312. }
  313. }
  314. }
  315. .result-content {
  316. font-size: 3.6vw;
  317. margin-top: 2vw;
  318. }
  319. }
  320. }
  321. </style>