You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
3.7 KiB

4 months ago
1 month ago
1 month ago
1 month ago
4 months ago
1 month ago
1 month ago
1 month ago
1 month ago
4 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="content">
  3. <up-navbar title="选择类型" @rightClick="rightClick" :autoBack="true"></up-navbar>
  4. <view class="tit">请选择需要学习的题库类型</view>
  5. <view class="ul">
  6. <view class="li" v-for="(item,index) in tabData" :key="index" @click="chooseCar(item)" :class="{active: item.id==currentCar.id}">
  7. <view class="checkBox" v-if="item.id==currentCar.id">
  8. <image src="@/static/images/dg.png" mode=""></image>
  9. </view>
  10. <view class="icon">
  11. <image :src="item.cover" mode=""></image>
  12. </view>
  13. <view class="name">{{item.title}}</view>
  14. <view class="carType" v-for="(item2,index2) in item.descriptionArr" :key="index2">{{ item2 }}</view>
  15. </view>
  16. </view>
  17. <view class="btnBox">
  18. <oneBtn text="确 定" @oneBtnClick="oneBtnClick"></oneBtn>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import {
  24. ref,
  25. reactive
  26. } from 'vue';
  27. import { loginApi, questbanktypeApi, } from '@/config/api.js'
  28. import {
  29. onLoad,
  30. onReady
  31. } from "@dcloudio/uni-app"
  32. const rightClick = () => {
  33. console.log('rightClick');
  34. };
  35. const tabData = ref([
  36. {name: '小车', type: 'C1/C2/C3', style: 'width: 114rpx;height: 61rpx;', icon: new URL('@/static/images/car4.png', import.meta.url).href, id: '1'},
  37. {name: '货车', type: 'A2/B2', style: 'width: 106rpx;height: 68rpx;', icon: new URL('@/static/images/car2.png', import.meta.url).href, id: '1'},
  38. {name: '客车', type: 'A1/B1/A3', style: 'width: 106rpx;height: 68rpx;', icon: new URL('@/static/images/car1.png', import.meta.url).href, id: '1'},
  39. {name: '摩托车', type: 'D/E/F', style: 'width: 102rpx;height: 73rpx;', icon: new URL('@/static/images/car3.png', import.meta.url).href, id: '1'},
  40. ])
  41. const currentCar = ref('')
  42. function chooseCar(item) {
  43. currentCar.value = item
  44. }
  45. function oneBtnClick() {
  46. uni.navigateTo({
  47. url: '/pages/exercises/theoryStudy/theoryStudy'
  48. })
  49. }
  50. // 请求登录
  51. async function loginFn() {
  52. const res = await loginApi({
  53. "type": 1,
  54. "username": "18267103167",
  55. })
  56. console.log(res)
  57. uni.setStorageSync('loginInfo', res.data);
  58. }
  59. // if(uni.)
  60. // loginFn()
  61. async function questbanktypeFn() {
  62. const {data: res} = await questbanktypeApi()
  63. let arr = res.map(item=>{
  64. item.descriptionArr = item.description.split(':')
  65. return item
  66. })
  67. tabData.value = arr
  68. currentCar.value = res[0]
  69. console.log(tabData.value)
  70. }
  71. questbanktypeFn()
  72. </script>
  73. <style lang="scss" scoped>
  74. image {
  75. display: block;
  76. width: 100%;
  77. height: 100%;
  78. }
  79. .btnBox {
  80. position: fixed;
  81. bottom: 70rpx;
  82. left: 0;
  83. padding: 20px;
  84. width: 100%;
  85. }
  86. .content {
  87. width: 100%;
  88. padding-top: 100rpx;
  89. up-navbar {
  90. }
  91. .tit {
  92. padding: 40rpx 20rpx;
  93. font-size: 36rpx;
  94. color: #333;
  95. font-weight: 700;
  96. }
  97. .ul {
  98. display: flex;
  99. flex-wrap: wrap;
  100. padding: 0 20px;
  101. justify-content: space-between;
  102. .li {
  103. width: 190rpx;
  104. // height: 190rpx;
  105. padding: 20rpx 0;
  106. border-radius: 10rpx;
  107. position: relative;
  108. display: flex;align-items: center;margin: 30rpx 0rpx 0 0 ;flex-direction: column;
  109. &.active {
  110. background: #EDF8FF;
  111. }
  112. .checkBox {
  113. position: absolute;
  114. top: 0;
  115. right: 0;
  116. width: 36rpx;
  117. height: 36rpx;
  118. background: #4DBEFF;
  119. border-radius: 0px 10rpx 0px 10rpx;
  120. display: flex;
  121. align-items: center;
  122. justify-content: center;
  123. image {
  124. display: block;
  125. width: 32rpx;
  126. height: 23rpx;
  127. }
  128. }
  129. .icon {
  130. width: 106rpx;
  131. height: 68rpx;
  132. }
  133. .name {
  134. font-size: 28rpx;
  135. margin: 4rpx 0;
  136. }
  137. .carType {
  138. font-size: 24rpx;
  139. color: #ccc;
  140. padding: 4rpx;
  141. }
  142. }
  143. }
  144. }
  145. </style>