天波h5前端应用
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

323 linhas
6.7KB

  1. <template>
  2. <div class="page" :style="`padding-top: ${showLeftArrow ? '46px' : '0'};`">
  3. <van-nav-bar
  4. title="测评结果"
  5. :border="true"
  6. :left-arrow="true"
  7. @click-left="onNavBack"
  8. v-if="showLeftArrow"
  9. style="position: fixed; left: 0; top: 0;width: 100vw;"
  10. >
  11. <template #left>
  12. <van-icon name="arrow-left" size="23" style="padding: 0" />返回
  13. </template>
  14. </van-nav-bar>
  15. <div class="content">
  16. <div class="result-title">您的测评结果为:</div>
  17. <div
  18. class="result"
  19. :style="{ color: levels[`${resultLevel}`].color }"
  20. >
  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. isError: null, //是否是答题错误
  68. showLeftArrow: false,
  69. fromSsjl: this.$store.getters.fromSsjl,
  70. result: {
  71. Advice: '',
  72. Explain: '',
  73. ScaleName: '',
  74. Score: 15,
  75. Summary: '',
  76. SummaryLevel: '-1',
  77. Time: '',
  78. },
  79. levels: [
  80. {
  81. show: false,
  82. color: '#dfe4ea',
  83. title: '暂无测评结果',
  84. },
  85. {
  86. color: '#60B977',
  87. title: '没有抑郁症状',
  88. },
  89. {
  90. color: '#FFB600',
  91. title: '轻度抑郁',
  92. },
  93. {
  94. color: '#CC0003',
  95. title: '重度抑郁',
  96. },
  97. ],
  98. }
  99. },
  100. computed: {
  101. resultLevel(){
  102. return parseInt(this.result.SummaryLevel) + 1
  103. },
  104. showLevels() {
  105. return this.levels.filter((item) => {
  106. if (!(item.show === false)) {
  107. return true
  108. }
  109. })
  110. },
  111. },
  112. watch: {},
  113. mounted() {
  114. //页面标题
  115. window.document.title = '测评结果'
  116. //页面传参
  117. let params = { ...this.$route.query }
  118. if (params.id && params.uid) {
  119. this.id = params.id
  120. this.uid = params.uid
  121. // 缓存从随手精灵传过来的token
  122. this.$store.commit('ssjlToken', params.accessToken || '')
  123. if (params.appType) {
  124. this.$store.commit('appType', params.appType)
  125. }
  126. // 缓存从随手精灵传过来的标识
  127. if(params.fromSsjl){
  128. this.$store.commit('fromSsjl', params.fromSsjl)
  129. }
  130. // 是否显示 返回标签
  131. if (params.showLeftArrow) {
  132. this.showLeftArrow = true
  133. }
  134. this.fromUrl = params.fromUrl
  135. console.log('fromUrl', this.fromUrl)
  136. //初始化
  137. this.init()
  138. } else {
  139. this.$toast('参数错误')
  140. }
  141. },
  142. methods: {
  143. async init() {
  144. if (!this.$route.query.accessToken) {
  145. // 如果当前url没有 accessToken, 获取token,并且存储到本地缓存里面
  146. let authToken = await this.getAuth()
  147. this.$store.commit('ssjlToken', authToken)
  148. }
  149. this.$toast.loading({
  150. message: '',
  151. forbidClick: true,
  152. duration: 0,
  153. })
  154. let re = await this.api(
  155. '/api/Question/GetScaleFillingRecord',
  156. {
  157. method: 'GET',
  158. sslVerify: false,
  159. withCredentials: false,
  160. params: {
  161. uid: this.uid,
  162. },
  163. },
  164. this.$store.getters.ssjlToken
  165. )
  166. if (re.success) {
  167. if (re.response && re.response.length) {
  168. re.response.forEach((item) => {
  169. if (item.Id === this.id) {
  170. this.result = item
  171. }
  172. })
  173. } else {
  174. // this.$toast('暂无测评结果')
  175. }
  176. } else {
  177. this.$toast(re.msg)
  178. }
  179. },
  180. onNavBack() {
  181. let fromSsjl = this.$store.getters.fromSsjl === "true";
  182. if (fromSsjl) {
  183. let baseUrl = this.fromUrl;
  184. window.location.href = `${baseUrl}/#/${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" scoped>
  256. .page {
  257. width: 100%;
  258. min-height: 100%;
  259. box-sizing: border-box;
  260. font-size: 3.6vw;
  261. text-align: left;
  262. background: #f4f4f4;
  263. padding-bottom: 8vw;
  264. .content {
  265. padding: 4vw;
  266. .result-title {
  267. font-size: 4vw;
  268. text-align: center;
  269. }
  270. .result {
  271. font-size: 6vw;
  272. text-align: center;
  273. font-weight: bold;
  274. margin-top: 4vw;
  275. }
  276. .result-label {
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. font-size: 4.5vw;
  281. font-weight: bold;
  282. margin-top: 6vw;
  283. }
  284. .result-color {
  285. width: 5.5vw;
  286. height: 5.5vw;
  287. border-radius: 1vw;
  288. }
  289. .result-details {
  290. display: flex;
  291. margin-top: 4vw;
  292. .result-details-item {
  293. .result-details-item-icon {
  294. width: 100%;
  295. height: 5.5vw;
  296. }
  297. .result-details-item-title {
  298. font-weight: bold;
  299. text-align: center;
  300. margin-top: 2vw;
  301. }
  302. }
  303. }
  304. .result-content {
  305. font-size: 3.6vw;
  306. margin-top: 2vw;
  307. }
  308. }
  309. }
  310. </style>