quWeiCePing.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="content">
  3. <view class="pdy-60 pdx-28 mgt-100 radio-20 bg-white w border-0_1 box">
  4. <view class="title mgb-50" >
  5. {{ curIndex + 1 }}、{{ QList[curIndex].title }}
  6. </view>
  7. <view class="Aitem flex" v-for="(a,key) in QList[curIndex].Alist"
  8. @click="chooseA(key)" :class="chooseList[curIndex] == key ?'active':''">
  9. <view class="">{{ key }}、</view>
  10. <view class="">{{ a }}</view>
  11. </view>
  12. <view class="next_btn cursor" @click="nextFn">{{ curIndex == QList.length - 1 ? '提交' : '下一题'}}</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import { ref, onMounted } from "vue";
  18. import { onShow } from "@dcloudio/uni-app";
  19. const QList = ref([
  20. { title:'你更喜欢哪种社交场合1?',Alist:{'A':'大型会所1','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} },
  21. { title:'你更喜欢哪种社交场合2?',Alist:{'A':'大型会所2','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} },
  22. { title:'你更喜欢哪种社交场合3?',Alist:{'A':'大型会所3','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} },
  23. { title:'你更喜欢哪种社交场合4?',Alist:{'A':'大型会所4','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} },
  24. { title:'你更喜欢哪种社交场合5?',Alist:{'A':'大型会所5','B':'小型会所','C':'与几位亲朋密友聚会','D':'独自一人'} }
  25. ])
  26. const curIndex = ref(0)
  27. const curChoose = ref(null)
  28. const chooseList = ref([]) // 选择的数组 AABCD
  29. const chooseA = (key) =>{
  30. chooseList.value[curIndex.value] = key
  31. }
  32. const nextFn = ()=>{
  33. if(curIndex.value < QList.value.length - 1){
  34. curIndex.value += 1
  35. }else{
  36. // 完成答题
  37. uni.showToast({
  38. title:'提交成功!',
  39. })
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .content{
  45. height: 100vh;
  46. padding: 28rpx;
  47. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  48. }
  49. .box{
  50. height: 75vh;
  51. border: 1rpx solid #000;
  52. position: relative;
  53. .Aitem{
  54. border: 1rpx solid #000;
  55. height: 80rpx;
  56. line-height: 80rpx;
  57. border-radius: 22rpx;
  58. margin-bottom: 20rpx;
  59. padding: 0 20rpx;
  60. cursor: pointer;
  61. }
  62. .next_btn{
  63. width: 320rpx;
  64. height: 60rpx;
  65. line-height: 60rpx;
  66. text-align: center;
  67. color: #fff;
  68. background-color: #399bfc;
  69. border-radius: 20rpx;
  70. border: 1px solid #000;
  71. transform: translate(50%);
  72. position: absolute;
  73. bottom: 60rpx;
  74. }
  75. .active{
  76. border: 1px solid #399bfc;
  77. color: #399bfc;
  78. }
  79. }
  80. </style>