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.

301 lines
7.4 KiB

4 months ago
1 week ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
1 month ago
2 weeks ago
2 weeks ago
3 weeks ago
1 week ago
1 month ago
1 month ago
1 week ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
1 month ago
2 weeks ago
1 week ago
1 month ago
2 weeks ago
1 month ago
3 weeks ago
2 weeks ago
1 month ago
1 month ago
2 weeks ago
3 weeks ago
2 weeks ago
1 week ago
2 weeks ago
4 months ago
2 weeks ago
1 month ago
1 week ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="content">
  3. <up-navbar title="选择类型" @leftClick="rightClick" :autoBack="false"></up-navbar>
  4. <view class="padding">
  5. <view class="tit">请选择城市</view>
  6. <view class="ard_row">
  7. <view class="leftBox" @click="getWarpweft">
  8. <up-icon name="map" size="20"></up-icon>
  9. <view class="text" v-if="usecarStore.carInfo.cityName">{{ usecarStore.carInfo.cityName}} <text style="font-size: 20rpx;color: blue;margin-left: 10rpx;">(包函当地题库)</text></view>
  10. <view class="text" v-else>选择城市</view>
  11. </view>
  12. <view class="moreBox" @click="$goPage('/pages/index/comp/city')">
  13. <view class="txt">选择城市</view>
  14. <u-icon name="arrow-right" color="#1989FA" size="14"></u-icon>
  15. </view>
  16. </view>
  17. <view class="tit">请选择需要学习的题库类型</view>
  18. <view class="ul">
  19. <view class="li" v-for="(item,index) in tabData" :key="index" @click="chooseCar(item)" :class="{active: item.id==currentCar.id}">
  20. <view class="checkBox" v-if="item.id==currentCar.id">
  21. <image src="@/static/images/dg.png" mode=""></image>
  22. </view>
  23. <view class="icon">
  24. <image :src="item.cover" mode=""></image>
  25. </view>
  26. <view class="name">{{item.title}}</view>
  27. <view class="carType" v-for="(item2,index2) in item.descriptionArr" :key="index2">{{ item2 }}</view>
  28. </view>
  29. </view>
  30. <view class="btnBox">
  31. <oneBtn text="确 定" @oneBtnClick="oneBtnClick"></oneBtn>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import carStore from '@/store/modules/car.js'
  38. let usecarStore = carStore()
  39. import allCity from './comp/allCity.js'
  40. import setObj from '@/config/site.config.js';
  41. let {
  42. mapKey
  43. } = setObj
  44. import {
  45. jsonp
  46. } from 'vue-jsonp'
  47. import {
  48. ref,
  49. reactive
  50. } from 'vue';
  51. import { loginApi, questbanktypeApi, treeSelect} from '@/config/api.js'
  52. import {
  53. onLoad,
  54. onReady,
  55. onPullDownRefresh
  56. } from "@dcloudio/uni-app"
  57. const rightClick = () => {
  58. console.log('11')
  59. goApp()
  60. // uni.navigateBack()
  61. };
  62. const tabData = ref([
  63. {name: '小车', type: 'C1/C2/C3', style: 'width: 114rpx;height: 61rpx;', icon: new URL('@/static/images/car4.png', import.meta.url).href, id: '1'},
  64. {name: '货车', type: 'A2/B2', style: 'width: 106rpx;height: 68rpx;', icon: new URL('@/static/images/car2.png', import.meta.url).href, id: '1'},
  65. {name: '客车', type: 'A1/B1/A3', style: 'width: 106rpx;height: 68rpx;', icon: new URL('@/static/images/car1.png', import.meta.url).href, id: '1'},
  66. {name: '摩托车', type: 'D/E/F', style: 'width: 102rpx;height: 73rpx;', icon: new URL('@/static/images/car3.png', import.meta.url).href, id: '1'},
  67. ])
  68. const currentCar = ref('')
  69. function chooseCar(item) {
  70. currentCar.value = item
  71. usecarStore.setCar('carType', item.carType)
  72. usecarStore.setCar('carTypeName', item.title)
  73. }
  74. function goApp() {
  75. console.log( uni.webView)
  76. uni.webView.postMessage({
  77. data: {
  78. action: 'goApp'
  79. }
  80. });
  81. uni.webView.navigateBack()
  82. }
  83. function oneBtnClick() {
  84. uni.navigateTo({
  85. url: '/pages/exercises/theoryStudy/theoryStudy'
  86. })
  87. }
  88. onLoad(async (option)=>{
  89. // 登录来源:1:洛阳学车APP;2:浙里学车APP
  90. let phone = option.phone?option.phone:'18267103167'
  91. let type = option.type?option.type:'1'
  92. if(!phone) return uni.$u.toast('未查到您的手机号')
  93. await loginFn(phone, type)
  94. questbanktypeFn()
  95. })
  96. // loginFn()
  97. // 请求登录
  98. async function loginFn(phone, type) {
  99. console.log('会执行吗??')
  100. const res = await loginApi({
  101. "username": phone,
  102. type
  103. })
  104. console.log(res)
  105. res.data.phone = phone
  106. res.data.type = type
  107. uni.setStorageSync('loginInfo', res.data);
  108. }
  109. // 车型请求
  110. async function questbanktypeFn() {
  111. const {data: res} = await questbanktypeApi()
  112. let arr = res.map(item=>{
  113. item.descriptionArr = item.description.split(':')
  114. return item
  115. })
  116. tabData.value = arr
  117. currentCar.value = res[0]
  118. }
  119. async function treeSelectFn() {
  120. const res = await treeSelect()
  121. console.log(res)
  122. }
  123. // treeSelectFn()
  124. onPullDownRefresh(()=>{
  125. questbanktypeFn().then(()=>{
  126. uni.stopPullDownRefresh()
  127. }).catch(()=>{
  128. uni.stopPullDownRefresh()
  129. })
  130. })
  131. let citys = []
  132. function initcity() {
  133. let cityArr = allCity.map(arr => {
  134. return arr.cityInfoList.map(item => {
  135. let obj = {
  136. cityName: item.cityName,
  137. pinYin: item.cityPinyin,
  138. py: item.cityAcronym.toLocaleLowerCase(),
  139. code: item.cityCode,
  140. cityInitial: item.cityInitial
  141. }
  142. return obj
  143. })
  144. })
  145. citys = cityArr.flat()
  146. console.log(citys)
  147. }
  148. initcity()
  149. function getWarpweft() {
  150. uni.getLocation({
  151. type: 'wgs84',
  152. success: function(res) {
  153. console.log('当前位置的经度:' + res.longitude);
  154. console.log('当前位置的纬度:' + res.latitude);
  155. let url = 'https://apis.map.qq.com/ws/geocoder/v1/'
  156. jsonp(url, {
  157. key: mapKey,
  158. location: res.latitude + ',' + res.longitude,
  159. output: 'jsonp'
  160. }).then(res => {
  161. console.log('jsonp', res.result.address_component);
  162. let {
  163. province,
  164. city,
  165. district
  166. } = res.result.address_component;
  167. console.log(province, city, district);
  168. let currentCity = citys.find(item=>item.cityName==city)
  169. if(!currentCity) {
  170. return uni.$u.toast('获取定位失败,请手动选择城市')
  171. }
  172. usecarStore.setCar('city', currentCity.code)
  173. usecarStore.setCar('cityName', currentCity.cityName)
  174. console.log(currentCity, '当前城市')
  175. }).catch(()=>{
  176. uni.$u.toast('获取定位失败,请手动选择城市')
  177. })
  178. },
  179. fail() {
  180. uni.$u.toast('获取定位失败,请手动选择城市')
  181. }
  182. })
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .ard_row {
  187. display: flex;
  188. align-items: center;
  189. justify-content: space-between;
  190. padding: 20rpx;
  191. border-radius: 10rpx;
  192. background: #EDF8FF;
  193. .leftBox {
  194. display: flex;
  195. align-items: center;
  196. .text {
  197. color: #333;
  198. font-size: 28rpx;
  199. margin-left: 6rpx;
  200. }
  201. }
  202. }
  203. .moreBox {
  204. display: flex;
  205. align-items: center;
  206. .txt {
  207. font-size: 28rpx;
  208. color: $themC;
  209. margin-right: 8rpx;
  210. }
  211. }
  212. image {
  213. display: block;
  214. width: 100%;
  215. height: 100%;
  216. }
  217. .btnBox {
  218. position: fixed;
  219. bottom: 70rpx;
  220. left: 0;
  221. padding: 20px;
  222. width: 100%;
  223. }
  224. .content {
  225. width: 100%;
  226. padding-top: 100rpx;
  227. up-navbar {
  228. }
  229. .tit {
  230. padding: 60rpx 0rpx 30rpx 0;
  231. font-size: 28rpx;
  232. color: #333;
  233. font-weight: 700;
  234. }
  235. .ul {
  236. display: flex;
  237. flex-wrap: wrap;
  238. justify-content: space-between;
  239. .li {
  240. width: 190rpx;
  241. // height: 190rpx;
  242. padding: 20rpx 0;
  243. border-radius: 10rpx;
  244. position: relative;
  245. display: flex;align-items: center;margin: 30rpx 0rpx 0 0 ;flex-direction: column;
  246. &.active {
  247. background: #EDF8FF;
  248. }
  249. .checkBox {
  250. position: absolute;
  251. top: 0;
  252. right: 0;
  253. width: 36rpx;
  254. height: 36rpx;
  255. background: #4DBEFF;
  256. border-radius: 0px 10rpx 0px 10rpx;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. image {
  261. display: block;
  262. width: 32rpx;
  263. height: 23rpx;
  264. }
  265. }
  266. .icon {
  267. width: 106rpx;
  268. height: 68rpx;
  269. }
  270. .name {
  271. font-size: 28rpx;
  272. margin: 4rpx 0;
  273. }
  274. .carType {
  275. font-size: 24rpx;
  276. color: #ccc;
  277. padding: 4rpx;
  278. }
  279. }
  280. }
  281. }
  282. </style>