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.

175 lines
4.1 KiB

4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
1 day ago
3 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks 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 carStore from '@/store/modules/car.js'
  24. let usecarStore = carStore()
  25. import {
  26. ref,
  27. reactive
  28. } from 'vue';
  29. import { loginApi, questbanktypeApi, } from '@/config/api.js'
  30. import {
  31. onLoad,
  32. onReady,
  33. onPullDownRefresh
  34. } from "@dcloudio/uni-app"
  35. const rightClick = () => {
  36. console.log('rightClick');
  37. };
  38. const tabData = ref([
  39. {name: '小车', type: 'C1/C2/C3', style: 'width: 114rpx;height: 61rpx;', icon: new URL('@/static/images/car4.png', import.meta.url).href, id: '1'},
  40. {name: '货车', type: 'A2/B2', style: 'width: 106rpx;height: 68rpx;', icon: new URL('@/static/images/car2.png', import.meta.url).href, id: '1'},
  41. {name: '客车', type: 'A1/B1/A3', style: 'width: 106rpx;height: 68rpx;', icon: new URL('@/static/images/car1.png', import.meta.url).href, id: '1'},
  42. {name: '摩托车', type: 'D/E/F', style: 'width: 102rpx;height: 73rpx;', icon: new URL('@/static/images/car3.png', import.meta.url).href, id: '1'},
  43. ])
  44. const currentCar = ref('')
  45. function chooseCar(item) {
  46. currentCar.value = item
  47. usecarStore.setCar('carType', item.carType)
  48. usecarStore.setCar('carTypeName', item.title)
  49. }
  50. function oneBtnClick() {
  51. uni.navigateTo({
  52. url: '/pages/exercises/theoryStudy/theoryStudy'
  53. })
  54. }
  55. onLoad(async (option)=>{
  56. let phone = option.phone?option.phone:'18267103167'
  57. await loginFn(phone)
  58. questbanktypeFn()
  59. })
  60. // 请求登录
  61. async function loginFn(phone) {
  62. const res = await loginApi({
  63. "type": 1,
  64. "username": phone,
  65. })
  66. console.log(res)
  67. res.data.phone = phone
  68. uni.setStorageSync('loginInfo', res.data);
  69. }
  70. // 车型请求
  71. async function questbanktypeFn() {
  72. const {data: res} = await questbanktypeApi()
  73. let arr = res.map(item=>{
  74. item.descriptionArr = item.description.split(':')
  75. return item
  76. })
  77. tabData.value = arr
  78. currentCar.value = res[0]
  79. }
  80. onPullDownRefresh(()=>{
  81. questbanktypeFn().then(()=>{
  82. uni.stopPullDownRefresh()
  83. }).catch(()=>{
  84. uni.stopPullDownRefresh()
  85. })
  86. })
  87. </script>
  88. <style lang="scss" scoped>
  89. image {
  90. display: block;
  91. width: 100%;
  92. height: 100%;
  93. }
  94. .btnBox {
  95. position: fixed;
  96. bottom: 70rpx;
  97. left: 0;
  98. padding: 20px;
  99. width: 100%;
  100. }
  101. .content {
  102. width: 100%;
  103. padding-top: 100rpx;
  104. up-navbar {
  105. }
  106. .tit {
  107. padding: 40rpx 20rpx;
  108. font-size: 36rpx;
  109. color: #333;
  110. font-weight: 700;
  111. }
  112. .ul {
  113. display: flex;
  114. flex-wrap: wrap;
  115. padding: 0 20px;
  116. justify-content: space-between;
  117. .li {
  118. width: 190rpx;
  119. // height: 190rpx;
  120. padding: 20rpx 0;
  121. border-radius: 10rpx;
  122. position: relative;
  123. display: flex;align-items: center;margin: 30rpx 0rpx 0 0 ;flex-direction: column;
  124. &.active {
  125. background: #EDF8FF;
  126. }
  127. .checkBox {
  128. position: absolute;
  129. top: 0;
  130. right: 0;
  131. width: 36rpx;
  132. height: 36rpx;
  133. background: #4DBEFF;
  134. border-radius: 0px 10rpx 0px 10rpx;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. image {
  139. display: block;
  140. width: 32rpx;
  141. height: 23rpx;
  142. }
  143. }
  144. .icon {
  145. width: 106rpx;
  146. height: 68rpx;
  147. }
  148. .name {
  149. font-size: 28rpx;
  150. margin: 4rpx 0;
  151. }
  152. .carType {
  153. font-size: 24rpx;
  154. color: #ccc;
  155. padding: 4rpx;
  156. }
  157. }
  158. }
  159. }
  160. </style>