123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <!-- 用户信息展示 -->
- <userData />
- <!-- 轮播图 -->
- <swiper />
- <!-- 用户做题预选界面 -->
- <van-tabs class="car-type" line-width="0" animated ref="carTypeRef" @click="carTypeChange">
- <van-tab v-for="(carTypeItem, index) in carTypeList" :key="index" :name="carTypeItem.name">
- <template #title>
- <div class="car-choose">
- <m-icon :type="carTypeItem.icon" class="img" />
- <span>{{ carTypeItem.cert }}</span>
- <span>{{ carTypeItem.name }}</span>
- </div>
- </template>
- <van-tabs class="test-type" animated>
- <van-tab :title="sujectItem.name" v-for="(sujectItem, index) in carTypeItem.sujectList" :key="index" :name="sujectItem.name">
- <sujectOne v-if="index == 0" :query="{ ...carTypeItem.query, ...sujectItem.query, title: '模拟考试' }"></sujectOne>
- <sujectTwo v-if="index == 1" ></sujectTwo>
- <sujectThree v-if="index == 2" :query="{ ...carTypeItem.query, ...sujectItem.query, title: '模拟考试' }"></sujectThree>
- <sujectOne v-if="index == 3" :query="{ ...carTypeItem.query, ...sujectItem.query, title: '模拟考试' }"></sujectOne>
- </van-tab>
- </van-tabs>
- </van-tab>
- </van-tabs>
- </template>
- <script lang="ts" setup>
- import sujectOne from "./components/sujectOne.vue";
- import sujectTwo from "./components/sujectTwo.vue";
- import sujectThree from "./components/sujectThree.vue";
- import userData from "./components/userData.vue";
- import swiper from "./components/swiper.vue";
- import { ref, nextTick, onBeforeMount } from "vue";
- import { useLogin, useUpdateUserInfo } from "@/hooks";
- import { useStore } from "vuex";
- import useWxSign from "@/hooks/wx/sign";
- import { Toast } from "vant";
- import { useRouter } from "vue-router";
- import { openApi } from "@/api/index";
- import wx from "weixin-js-sdk-ts";
- const store = useStore();
- const carTypeRef = ref<any>(null);
- const { createWxConfig } = useWxSign();
- openApi
- .jspapi({
- url: '',
- })
- .then((res) => {
- // let wxConfig = {
- // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
- // appId: res.data.data.appId as string, // 必填,公众号的唯一标识
- // timestamp: res.data.data.timestamp as number, // 必填,生成签名的时间戳
- // nonceStr: res.data.data.nonceStr as string, // 必填,生成签名的随机串
- // signature: res.data.data.signature as string, // 必填,签名
- // jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
- // openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
- // };
- wx.config({
- debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
- appId: res.data.data.appId as string, // 必填,公众号的唯一标识
- ...createWxConfig(res.data.data.ticket as string),
- jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
- openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
- });
- wx.error(({errMsg})=>{
- // alert('灯光模拟和视频无法跳转')
- })
- });
- //打印环境变量
- console.log(import.meta.env.MODE, "环境变量");
- nextTick(() => {
- carTypeRef.value.scrollTo(store.state.carType);
- });
- const carTypeChange = (e: string) => {
- store.commit("setCatType", e);
- };
- onBeforeMount(() => {
- useUpdateUserInfo()
- // const router = useRouter();
- // console.log(router.currentRoute.value);
- });
- const carTypeList = ref([
- {
- name: "轿车",
- cert: "C1/C2/C3",
- icon: "jiaoche",
- query: { model:"cart",liceCar:1 },
- sujectList: [
- {
- name: "科目一",
- query: {
- name: "科目一",
- cert: "C1/C2/C3",
- vehicle: "小车",
- subject: 1,
- model:"cart"
- },
- },
- {
- name: "科目二",
- query: {
- name: "科目二",
- cert: "C1/C2/C3",
- vehicle: "小车",
- subject: 2,
- model:"cart"
- },
- },
- {
- name: "科目三",
- query: {
- name: "科目三",
- cert: "C1/C2/C3",
- vehicle: "小车",
- subject: 3,
- model:"cart"
- },
- },
- {
- name: "科目四",
- query: {
- name: "科目四",
- cert: "C1/C2/C3",
- vehicle: "小车",
- subject: 4,
- model:"cart"
- },
- },
- ],
- },
- {
- name: "客车",
- cert: "A1/A3/B1",
- icon: "keche",
- query: { liceBus: 1,model:"bus" },
- sujectList: [
- {
- name: "科目一",
- query: {
- name: "科目一",
- cert: "A1/A3/B1",
- vehicle: "客车",
- subject: 1,
- model:"bus"
- },
- },
- {
- name: "科目二",
- query: {
- name: "科目二",
- cert: "A1/A3/B1",
- vehicle: "客车",
- subject: 1,
- model:"bus"
- },
- },
- {
- name: "科目三",
- query: {
- name: "科目三",
- cert: "A1/A3/B1",
- vehicle: "客车",
- subject: 4,
- model:"bus"
- },
- },
- {
- name: "科目四",
- query: {
- name: "科目四",
- cert: "A1/A3/B1",
- vehicle: "客车",
- subject: 4,
- model:"bus"
- },
- },
- ],
- },
- {
- name: "货车",
- cert: "A2/B2",
- icon: "huoche",
- query: { liceTruck: 1,model:"truck" },
- sujectList: [
- {
- name: "科目一",
- query: {
- name: "科目一",
- cert: "A2/B2",
- vehicle: "货车",
- subject: 1,
- model:"truck"
- },
- },
- {
- name: "科目二",
- query: {
- name: "科目二",
- cert: "A2/B2",
- vehicle: "货车",
- subject: 2,
- model:"truck"
- },
- },
- {
- name: "科目三",
- query: {
- name: "科目三",
- cert: "A2/B2",
- vehicle: "货车",
- subject: 3,
- model:"truck"
- },
- },
- {
- name: "科目四",
- query: {
- name: "科目四",
- cert: "A2/B2",
- vehicle: "货车",
- subject: 4,
- model:"truck"
- },
- },
- ],
- },
- {
- name: "摩托车",
- cert: "D/E/F",
- icon: "motuoche",
- query: { liceMoto: 1,model:"mtc" },
- sujectList: [
- {
- name: "科目一",
- query: {
- name: "科目一",
- cert: "D/E/F",
- vehicle: "摩托车",
- subject: 1,
- model:"mtc"
- },
- },
- {
- name: "科目二",
- query: {
- name: "科目二",
- cert: "D/E/F",
- vehicle: "摩托车",
- subject: 2,
- model:"mtc"
- },
- },
- {
- name: "科目三",
- query: {
- name: "科目三",
- cert: "D/E/F",
- vehicle: "摩托车",
- subject: 3,
- model:"mtc"
- },
- },
- {
- name: "科目四",
- query: {
- name: "科目四",
- cert: "D/E/F",
- vehicle: "摩托车",
- subject: 4,
- model:"mtc"
- },
- },
- ],
- },
- ]);
- </script>
- <style lang="scss">
- .car-type {
- margin: 21px 15px;
- --van-tabs-line-height: 88px;
- .van-tab--active {
- .car-choose {
- &::after {
- content: "";
- width: 100%;
- height: 78px;
- background-color: royalblue;
- position: absolute;
- top: 0;
- left: 0;
- opacity: 0.2;
- }
- &::before {
- content: "";
- width: 0px;
- height: 0px;
- border: 10px solid #000;
- border-top-color: royalblue;
- border-bottom-color: transparent;
- border-left-color: transparent;
- border-right-color: transparent;
- position: absolute;
- bottom: 0;
- transform: translateY(50%);
- opacity: 0.2;
- }
- }
- }
- .test-type {
- --van-tabs-line-height: 44px;
- }
- .car-choose {
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- .img {
- width: 66px;
- height: 22px;
- }
- }
- }
- </style>
|