quWeiCePing.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. <view class="title mgb-50" >
  6. {{ curIndex + 1 }}、{{ QList[curIndex].title }}
  7. </view>
  8. <view class="Aitem flex" v-for="(a,key) in QList[curIndex].Alist"
  9. @click="chooseA(key)" :class="chooseList[curIndex] == key ?'active':''">
  10. <view class="">{{ key }}、</view>
  11. <view class="">{{ a }}</view>
  12. </view>
  13. <view class="next_btn cursor" @click="nextFn">{{ curIndex == QList.length - 1 ? '显示结果' : '下一题'}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script setup>
  19. import { ref, onMounted } from "vue";
  20. import { onShow } from "@dcloudio/uni-app";
  21. var statusBarHeight = uni.getStorageSync('statusBarHeight')
  22. const QList = ref([
  23. { title:'你更喜欢哪种社交场合?',Alist:{'A':'大型会所','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} },
  24. { title:'你在做决定时更倾向于?',Alist:{'A':'依靠逻辑和事实','B':'依靠直觉和感觉','C':'参考别人的意见','D':'随机应变'} },
  25. { title:'你更喜欢哪种工作环境?',Alist:{'A':'有条不紊的办公室','B':'灵活自由的环境','C':'家庭办公','D':'合作共享的空间'} },
  26. { title:'在团队中,你通常扮演什么角色?',Alist:{'A':'领导者','B':'执行者','C':'协调者','D':'创新者'} },
  27. { title:'你更喜欢哪种娱乐方式?',Alist:{'A':'阅读书籍','B':'参加派对','C':'看电影','D':'运动健身'} }
  28. ])
  29. const curIndex = ref(0)
  30. const curChoose = ref(null)
  31. const chooseList = ref([]) // 选择的数组 AABCD
  32. const chooseA = (key) =>{
  33. chooseList.value[curIndex.value] = key
  34. }
  35. const nextFn = ()=>{
  36. if(!chooseList.value[curIndex.value]){
  37. uni.showToast({
  38. title:'请先选择选项',
  39. icon:'none'
  40. })
  41. return
  42. }
  43. if(curIndex.value < QList.value.length - 1){
  44. curIndex.value += 1
  45. }else{
  46. // 完成答题
  47. uni.showToast({
  48. title:'提交成功!',
  49. })
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .content{
  55. height: 100vh;
  56. padding: 28rpx;
  57. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  58. }
  59. .box{
  60. height: 75vh;
  61. border: 1rpx solid #000;
  62. position: relative;
  63. .Aitem{
  64. border: 1rpx solid #000;
  65. height: 80rpx;
  66. line-height: 80rpx;
  67. border-radius: 22rpx;
  68. margin-bottom: 20rpx;
  69. padding: 0 20rpx;
  70. cursor: pointer;
  71. }
  72. .next_btn{
  73. width: 320rpx;
  74. height: 60rpx;
  75. line-height: 60rpx;
  76. text-align: center;
  77. color: #fff;
  78. background-color: #399bfc;
  79. border-radius: 20rpx;
  80. border: 1px solid #000;
  81. transform: translate(50%);
  82. position: absolute;
  83. bottom: 60rpx;
  84. }
  85. .active{
  86. border: 1px solid #399bfc;
  87. color: #399bfc;
  88. }
  89. }
  90. </style>