quWeiCePing.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content">
  3. <view :style="{ paddingTop: statusBarHeight + 'px' }">
  4. <view class="pdy-60 pdx-28 mgt-100 radio-20 bg-white w border-0_1 box">
  5. <template v-if="!finishStatus">
  6. <view class="title mgb-50" >
  7. {{ curIndex + 1 }}、{{ QList[curIndex].title }}
  8. </view>
  9. <view class="Aitem flex" v-for="(a,key) in QList[curIndex].Alist"
  10. @click="chooseA(key)" :class="chooseList[curIndex] == key ?'active':''">
  11. <view class="">{{ key }}、</view>
  12. <view class="">{{ a }}</view>
  13. </view>
  14. </template>
  15. <view v-else>
  16. {{ generatePersonality() }}
  17. </view>
  18. <view class="next_btn cursor" @click="nextFn">{{ curIndex == QList.length - 1 ? '显示结果' : '下一题'}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import { ref, onMounted } from "vue";
  25. import { onShow } from "@dcloudio/uni-app";
  26. var statusBarHeight = uni.getStorageSync('statusBarHeight')
  27. const finishStatus = ref(false)
  28. const QList = ref([
  29. { title:'你更喜欢哪种社交场合?',Alist:{'A':'大型会所','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} },
  30. { title:'你在做决定时更倾向于?',Alist:{'A':'依靠逻辑和事实','B':'依靠直觉和感觉','C':'参考别人的意见','D':'随机应变'} },
  31. { title:'你更喜欢哪种工作环境?',Alist:{'A':'有条不紊的办公室','B':'灵活自由的环境','C':'家庭办公','D':'合作共享的空间'} },
  32. { title:'在团队中,你通常扮演什么角色?',Alist:{'A':'领导者','B':'执行者','C':'协调者','D':'创新者'} },
  33. { title:'你更喜欢哪种娱乐方式?',Alist:{'A':'阅读书籍','B':'参加派对','C':'看电影','D':'运动健身'} }
  34. ])
  35. const curIndex = ref(0)
  36. const curChoose = ref(null)
  37. const chooseList = ref([]) // 选择的数组 AABCD
  38. const chooseA = (key) =>{
  39. chooseList.value[curIndex.value] = key
  40. }
  41. const nextFn = ()=>{
  42. if(!chooseList.value[curIndex.value]){
  43. uni.showToast({
  44. title:'请先选择选项',
  45. icon:'none'
  46. })
  47. return
  48. }
  49. if(curIndex.value < QList.value.length - 1){
  50. curIndex.value += 1
  51. }else{
  52. console.log('generatePersonality',generatePersonality())
  53. finishStatus.value = true
  54. // 完成答题
  55. uni.showToast({
  56. title:'提交成功!',
  57. })
  58. }
  59. }
  60. // 生成性格描述的方法
  61. const generatePersonality = () =>{
  62. if (chooseList.value.length !== 5) return "请完成所有问题";
  63. // 各维度得分计算
  64. const dimensionScores = {
  65. energy: 0, // 精力来源 (外向/内向)
  66. decision: 0, // 决策方式 (理性/感性)
  67. structure: 0, // 结构化程度
  68. role: 0 // 团队角色倾向
  69. };
  70. // 第一题:社交倾向
  71. if (chooseList.value[0] === 'A' || chooseList.value[0] === 'B') dimensionScores.energy += 2;
  72. if (chooseList.value[0] === 'C') dimensionScores.energy += 1;
  73. // 第二题:决策方式
  74. if (chooseList.value[1] === 'A') dimensionScores.decision += 2;
  75. if (chooseList.value[1] === 'B') dimensionScores.decision += 1;
  76. // 第三题:结构化偏好
  77. if (chooseList.value[2] === 'A') dimensionScores.structure += 2;
  78. if (chooseList.value[2] === 'B' || chooseList.value[2] === 'D') dimensionScores.structure += 1;
  79. // 第四题:团队角色
  80. if (chooseList.value[3] === 'A' || chooseList.value[3] === 'D') dimensionScores.role += 2;
  81. if (chooseList.value[3] === 'B') dimensionScores.role += 1;
  82. // 第五题:社交补充
  83. if (chooseList.value[4] === 'B') dimensionScores.energy += 2;
  84. if (chooseList.value[4] === 'D') dimensionScores.energy += 1;
  85. // 性格类型判断
  86. const energyType = dimensionScores.energy >= 3 ? "E" : "I"; // 外向/内向
  87. const decisionType = dimensionScores.decision >= 2 ? "T" : "F"; // 理性/感性
  88. // 性格特征描述
  89. const personalities = {
  90. // 外向型组合
  91. "ET": {
  92. name: "开拓型领袖",
  93. desc: "你是个充满活力的决策者!善于社交并理性分析问题,天生的领导者,擅长在大型社交场合中主导方向,偏好结构化的工作环境"
  94. },
  95. "EF": {
  96. name: "魅力型协调者",
  97. desc: "你是个热情洋溢的沟通专家!善于在社交中感知他人情绪,喜欢团队合作,在灵活的环境中能发挥创造力,是优秀的协调者"
  98. },
  99. // 内向型组合
  100. "IT": {
  101. name: "分析型专家",
  102. desc: "你是个专注的思考者!偏好深度工作与理性分析,在小范围社交中表现出色,适合需要精密思考的结构化工作环境"
  103. },
  104. "IF": {
  105. name: "关怀型创造者",
  106. desc: "你是个富有洞察力的创造者!重视内心感受和亲密关系,在自由环境中灵感迸发,常扮演团队中的创新者角色"
  107. }
  108. };
  109. // 添加特质修饰词
  110. const traits = [];
  111. if (dimensionScores.structure >= 2) traits.push("有条理");
  112. if (chooseList.value[3] === 'C') traits.push("善于调解");
  113. if (chooseList.value[1] === 'D') traits.push("灵活应变");
  114. if (chooseList.value[4] === 'A') traits.push("思想深刻");
  115. const personalityKey = energyType + decisionType;
  116. const result = personalities[personalityKey] || {
  117. name: "平衡型人才",
  118. desc: "你具有适应多种环境的优秀能力!能在不同情境中灵活调整自己的行为模式"
  119. };
  120. // 构建最终描述
  121. let finalDesc = `${result.name}:${result.desc}`;
  122. if (traits.length > 0) {
  123. finalDesc += `,特别具有${traits.join('、')}的特质`;
  124. }
  125. return finalDesc;
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .content{
  130. height: 100vh;
  131. padding: 28rpx;
  132. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  133. }
  134. .box{
  135. height: 75vh;
  136. border: 1rpx solid #000;
  137. position: relative;
  138. .Aitem{
  139. border: 1rpx solid #000;
  140. height: 80rpx;
  141. line-height: 80rpx;
  142. border-radius: 22rpx;
  143. margin-bottom: 20rpx;
  144. padding: 0 20rpx;
  145. cursor: pointer;
  146. }
  147. .next_btn{
  148. width: 320rpx;
  149. height: 60rpx;
  150. line-height: 60rpx;
  151. text-align: center;
  152. color: #fff;
  153. background-color: #399bfc;
  154. border-radius: 20rpx;
  155. border: 1px solid #000;
  156. transform: translate(50%);
  157. position: absolute;
  158. bottom: 60rpx;
  159. }
  160. .active{
  161. border: 1px solid #399bfc;
  162. color: #399bfc;
  163. }
  164. }
  165. </style>