index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <!-- 用户信息展示 -->
  3. <userData />
  4. <!-- 轮播图 -->
  5. <swiper />
  6. <!-- 用户做题预选界面 -->
  7. <van-tabs class="car-type" line-width="0" animated ref="carTypeRef" @click="carTypeChange">
  8. <van-tab v-for="(carTypeItem, index) in carTypeList" :key="index" :name="carTypeItem.name">
  9. <template #title>
  10. <div class="car-choose">
  11. <m-icon :type="carTypeItem.icon" class="img" />
  12. <span>{{ carTypeItem.cert }}</span>
  13. <span>{{ carTypeItem.name }}</span>
  14. </div>
  15. </template>
  16. <van-tabs class="test-type" animated>
  17. <van-tab :title="sujectItem.name" v-for="(sujectItem, index) in carTypeItem.sujectList" :key="index" :name="sujectItem.name">
  18. <sujectOne v-if="index == 0" :query="{ ...carTypeItem.query, ...sujectItem.query, title: '模拟考试' }"></sujectOne>
  19. <sujectTwo v-if="index == 1" ></sujectTwo>
  20. <sujectThree v-if="index == 2" :query="{ ...carTypeItem.query, ...sujectItem.query, title: '模拟考试' }"></sujectThree>
  21. <sujectOne v-if="index == 3" :query="{ ...carTypeItem.query, ...sujectItem.query, title: '模拟考试' }"></sujectOne>
  22. </van-tab>
  23. </van-tabs>
  24. </van-tab>
  25. </van-tabs>
  26. </template>
  27. <script lang="ts" setup>
  28. import sujectOne from "./components/sujectOne.vue";
  29. import sujectTwo from "./components/sujectTwo.vue";
  30. import sujectThree from "./components/sujectThree.vue";
  31. import userData from "./components/userData.vue";
  32. import swiper from "./components/swiper.vue";
  33. import { ref, nextTick, onBeforeMount } from "vue";
  34. import { useLogin, useUpdateUserInfo } from "@/hooks";
  35. import { useStore } from "vuex";
  36. import useWxSign from "@/hooks/wx/sign";
  37. import { Toast } from "vant";
  38. import { useRouter } from "vue-router";
  39. import { openApi } from "@/api/index";
  40. import wx from "weixin-js-sdk-ts";
  41. const store = useStore();
  42. const carTypeRef = ref<any>(null);
  43. const { createWxConfig } = useWxSign();
  44. openApi
  45. .jspapi({
  46. url: '',
  47. })
  48. .then((res) => {
  49. // let wxConfig = {
  50. // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
  51. // appId: res.data.data.appId as string, // 必填,公众号的唯一标识
  52. // timestamp: res.data.data.timestamp as number, // 必填,生成签名的时间戳
  53. // nonceStr: res.data.data.nonceStr as string, // 必填,生成签名的随机串
  54. // signature: res.data.data.signature as string, // 必填,签名
  55. // jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
  56. // openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
  57. // };
  58. wx.config({
  59. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
  60. appId: res.data.data.appId as string, // 必填,公众号的唯一标识
  61. ...createWxConfig(res.data.data.ticket as string),
  62. jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
  63. openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
  64. });
  65. wx.error(({errMsg})=>{
  66. // alert('灯光模拟和视频无法跳转')
  67. })
  68. });
  69. //打印环境变量
  70. console.log(import.meta.env.MODE, "环境变量");
  71. nextTick(() => {
  72. carTypeRef.value.scrollTo(store.state.carType);
  73. });
  74. const carTypeChange = (e: string) => {
  75. store.commit("setCatType", e);
  76. };
  77. onBeforeMount(() => {
  78. useUpdateUserInfo()
  79. // const router = useRouter();
  80. // console.log(router.currentRoute.value);
  81. });
  82. const carTypeList = ref([
  83. {
  84. name: "轿车",
  85. cert: "C1/C2/C3",
  86. icon: "jiaoche",
  87. query: { model:"cart",liceCar:1 },
  88. sujectList: [
  89. {
  90. name: "科目一",
  91. query: {
  92. name: "科目一",
  93. cert: "C1/C2/C3",
  94. vehicle: "小车",
  95. subject: 1,
  96. model:"cart"
  97. },
  98. },
  99. {
  100. name: "科目二",
  101. query: {
  102. name: "科目二",
  103. cert: "C1/C2/C3",
  104. vehicle: "小车",
  105. subject: 2,
  106. model:"cart"
  107. },
  108. },
  109. {
  110. name: "科目三",
  111. query: {
  112. name: "科目三",
  113. cert: "C1/C2/C3",
  114. vehicle: "小车",
  115. subject: 3,
  116. model:"cart"
  117. },
  118. },
  119. {
  120. name: "科目四",
  121. query: {
  122. name: "科目四",
  123. cert: "C1/C2/C3",
  124. vehicle: "小车",
  125. subject: 4,
  126. model:"cart"
  127. },
  128. },
  129. ],
  130. },
  131. {
  132. name: "客车",
  133. cert: "A1/A3/B1",
  134. icon: "keche",
  135. query: { liceBus: 1,model:"bus" },
  136. sujectList: [
  137. {
  138. name: "科目一",
  139. query: {
  140. name: "科目一",
  141. cert: "A1/A3/B1",
  142. vehicle: "客车",
  143. subject: 1,
  144. model:"bus"
  145. },
  146. },
  147. {
  148. name: "科目二",
  149. query: {
  150. name: "科目二",
  151. cert: "A1/A3/B1",
  152. vehicle: "客车",
  153. subject: 1,
  154. model:"bus"
  155. },
  156. },
  157. {
  158. name: "科目三",
  159. query: {
  160. name: "科目三",
  161. cert: "A1/A3/B1",
  162. vehicle: "客车",
  163. subject: 4,
  164. model:"bus"
  165. },
  166. },
  167. {
  168. name: "科目四",
  169. query: {
  170. name: "科目四",
  171. cert: "A1/A3/B1",
  172. vehicle: "客车",
  173. subject: 4,
  174. model:"bus"
  175. },
  176. },
  177. ],
  178. },
  179. {
  180. name: "货车",
  181. cert: "A2/B2",
  182. icon: "huoche",
  183. query: { liceTruck: 1,model:"truck" },
  184. sujectList: [
  185. {
  186. name: "科目一",
  187. query: {
  188. name: "科目一",
  189. cert: "A2/B2",
  190. vehicle: "货车",
  191. subject: 1,
  192. model:"truck"
  193. },
  194. },
  195. {
  196. name: "科目二",
  197. query: {
  198. name: "科目二",
  199. cert: "A2/B2",
  200. vehicle: "货车",
  201. subject: 2,
  202. model:"truck"
  203. },
  204. },
  205. {
  206. name: "科目三",
  207. query: {
  208. name: "科目三",
  209. cert: "A2/B2",
  210. vehicle: "货车",
  211. subject: 3,
  212. model:"truck"
  213. },
  214. },
  215. {
  216. name: "科目四",
  217. query: {
  218. name: "科目四",
  219. cert: "A2/B2",
  220. vehicle: "货车",
  221. subject: 4,
  222. model:"truck"
  223. },
  224. },
  225. ],
  226. },
  227. {
  228. name: "摩托车",
  229. cert: "D/E/F",
  230. icon: "motuoche",
  231. query: { liceMoto: 1,model:"mtc" },
  232. sujectList: [
  233. {
  234. name: "科目一",
  235. query: {
  236. name: "科目一",
  237. cert: "D/E/F",
  238. vehicle: "摩托车",
  239. subject: 1,
  240. model:"mtc"
  241. },
  242. },
  243. {
  244. name: "科目二",
  245. query: {
  246. name: "科目二",
  247. cert: "D/E/F",
  248. vehicle: "摩托车",
  249. subject: 2,
  250. model:"mtc"
  251. },
  252. },
  253. {
  254. name: "科目三",
  255. query: {
  256. name: "科目三",
  257. cert: "D/E/F",
  258. vehicle: "摩托车",
  259. subject: 3,
  260. model:"mtc"
  261. },
  262. },
  263. {
  264. name: "科目四",
  265. query: {
  266. name: "科目四",
  267. cert: "D/E/F",
  268. vehicle: "摩托车",
  269. subject: 4,
  270. model:"mtc"
  271. },
  272. },
  273. ],
  274. },
  275. ]);
  276. </script>
  277. <style lang="scss">
  278. .car-type {
  279. margin: 21px 15px;
  280. --van-tabs-line-height: 88px;
  281. .van-tab--active {
  282. .car-choose {
  283. &::after {
  284. content: "";
  285. width: 100%;
  286. height: 78px;
  287. background-color: royalblue;
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. opacity: 0.2;
  292. }
  293. &::before {
  294. content: "";
  295. width: 0px;
  296. height: 0px;
  297. border: 10px solid #000;
  298. border-top-color: royalblue;
  299. border-bottom-color: transparent;
  300. border-left-color: transparent;
  301. border-right-color: transparent;
  302. position: absolute;
  303. bottom: 0;
  304. transform: translateY(50%);
  305. opacity: 0.2;
  306. }
  307. }
  308. }
  309. .test-type {
  310. --van-tabs-line-height: 44px;
  311. }
  312. .car-choose {
  313. display: flex;
  314. justify-content: center;
  315. align-items: center;
  316. flex-direction: column;
  317. .img {
  318. width: 66px;
  319. height: 22px;
  320. }
  321. }
  322. }
  323. </style>