mbti.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <step-paper type="mbti">
  3. <template #welcome>
  4. <view class="p-40 leading-6">
  5. <view class="text-main text-lg indent-50">
  6. MBTI(Myers-Briggs Type Indicator)是一种全球广泛应用的性格评估工具,根据荣格心理学理论,将人类性格分为16种类型。通过对
  7. 内外向(I/E)、感知/直觉(S/N)、思维/情感(T/F)、判断/感知(J/P) 四个维度的分析,MBTI 帮助你深刻认识自己的性格倾向和行为模式。
  8. </view>
  9. <view class="text-content mt-60 flex flex-col gap-10">
  10. <view class="indent-50">为什么需要 MBTI 测评?</view>
  11. <view>
  12. <text class="font-bold">发现你的天赋:</text>
  13. 了解自己的性格特点和潜在优势,找到适合的学习方法和职业领域。
  14. </view>
  15. <view>
  16. <text class="font-bold">规划职业未来:</text>
  17. 在面对专业选择、实习和就业时,更有方向感和信心。
  18. </view>
  19. <view>
  20. <text class="font-bold">提升沟通能力:</text>
  21. 更好地理解自己和他人的行为模式,提升人际交往与团队合作能力。
  22. </view>
  23. <view>
  24. <text class="font-bold">避开盲目选择:</text>
  25. 不再随波逐流,让你的每一步决策都符合自己的性格特点。
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <template #result>
  31. <character-result :code="mbtiCode" :scores="mbtiScores"/>
  32. </template>
  33. </step-paper>
  34. </template>
  35. <script setup>
  36. import {ref, onMounted} from 'vue';
  37. import StepPaper from "@/pages/test-center/components/step-paper/step-paper.vue";
  38. import {useTransfer} from "@/hooks/useTransfer";
  39. import {
  40. questionsFormatter,
  41. stepFormatter,
  42. useProvideStepPaper
  43. } from "@/pages/test-center/components/step-paper/useStepPaperInjection";
  44. import {useProvideQuestionService} from "@/components/mx-question/useQuestionInjection";
  45. import {
  46. useProvideStepPaperNavigationService
  47. } from "@/pages/test-center/components/step-paper/useProvideStepPaperNavigationService";
  48. import {useProvidePageScroll} from "@/hooks/usePageScrollInjection";
  49. import {
  50. mbtiDetail, mbtiSave,
  51. mbtiSteps,
  52. mbtiStepsQuestions
  53. } from "@/api/webApi/career-course";
  54. import mxConst from "@/common/mxConst";
  55. import CharacterResult from "@/pages/test-center/mbti/components/character-result.vue";
  56. import {useCacheStore} from "@/hooks/useCacheStore";
  57. const {prevData} = useTransfer()
  58. const {dispatchCache} = useCacheStore()
  59. const paperService = useProvideStepPaper('MBTI职业性格测评')
  60. const {welcomeShow, resultShow, steps, stepQuestionContainer, onBegin, onStepStart, onFinish} = paperService
  61. const questionService = useProvideQuestionService(paperService, 0, false)
  62. useProvideStepPaperNavigationService(paperService, questionService)
  63. useProvidePageScroll()
  64. const mbtiCode = ref('')
  65. const mbtiScores = ref([])
  66. onBegin(async () => {
  67. const res = await dispatchCache(mbtiSteps)
  68. steps.value = stepFormatter(res.data)
  69. })
  70. onStepStart(async (stepId) => {
  71. if (stepQuestionContainer.value.has(stepId)) return
  72. const res = await dispatchCache(mbtiStepsQuestions, {stepId})
  73. // 只有单选,选项模式一致
  74. const typeId = mxConst.question.radioTypes[0]
  75. const options = (q) => [{id: q.valueA, label: 'A、' + q.optionA}, {id: q.valueB, label: 'B、' + q.optionB}]
  76. stepQuestionContainer.value.set(stepId, questionsFormatter(res.rows, typeId, options))
  77. })
  78. onFinish(async (commits) => {
  79. uni.showLoading({
  80. title: '正在生成报告',
  81. mask: true
  82. })
  83. try {
  84. const {data: code} = await mbtiSave(commits)
  85. await loadReport(code)
  86. } finally {
  87. uni.hideLoading()
  88. }
  89. })
  90. onMounted(async () => {
  91. // prevData.value.code = 'e402b1ed58d9a35110f4bfbcc9f234f9'
  92. if (prevData.value.code) {
  93. welcomeShow.value = false
  94. resultShow.value = true
  95. try {
  96. uni.showLoading()
  97. await loadReport(prevData.value.code)
  98. } finally {
  99. uni.hideLoading()
  100. }
  101. }
  102. })
  103. const loadReport = async (code) => {
  104. const {data} = await mbtiDetail({code})
  105. const {scoreE, scoreI, scoreS, scoreN, scoreT, scoreF, scoreJ, scoreP} = data
  106. mbtiCode.value = data.ruleCode
  107. mbtiScores.value = [scoreE, scoreI, scoreS, scoreN, scoreT, scoreF, scoreJ, scoreP]
  108. }
  109. </script>
  110. <style lang="scss">
  111. </style>