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.

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