zhangyujun 3 tahun lalu
induk
melakukan
2ab6070037

File diff ditekan karena terlalu besar
+ 3150 - 11
package-lock.json


+ 25 - 1
src/api/request.ts

@@ -1,7 +1,7 @@
 import axios from "axios";
 import { requestLogger, responseLogger } from "axios-logger";
 import store from "@/store";
-
+import { Toast } from "vant";
 const request = axios.create({
 	baseURL: import.meta.env.MODE === "development" ? "/dev-api" : "/prod-api",
 });
@@ -11,10 +11,34 @@ request.interceptors.request.use((config) => {
 	if (config.headers.isToken !== false) {
 		config.headers["Authorization"] = "Bearer " + store.getters.getToken; // 让每个请求携带自定义token 请根据实际情况自行修改
 	}
+
 	return config;
+}, error => {
+
 });
 
 request.interceptors.response.use((res) => {
+	if (res && res.data) {
+		switch (res.data.code) {
+			case 401:
+				Toast("登录失败,需要再次登录")
+
+				window.setTimeout(() => {
+
+					location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
+				}, 2000)
+				break;
+			case 502:
+				if(res.data.msg=="微信授权无效,请重新授权"){
+					location.replace("https://jpcj-h5.zzxcx.net/home/test")
+				}
+
+				break;
+		}
+
+	}
+
+	// console.log(res)
 	return res;
 });
 

+ 2 - 0
src/api/types/test.d.ts

@@ -52,6 +52,8 @@ declare namespace Test {
 	}
 
 	interface getTopicClassParams {
+		
+
 		liceBus: string;
 		liceCar: string;
 		liceMoto: string;

+ 55 - 44
src/route/guard.ts

@@ -13,6 +13,7 @@ const guard = (router: Router) => {
 			return;
 		}
 
+
 		//监听到登陆事件
 		if (to.query.state === "LOGIN") {
 			const toast = Toast.loading({
@@ -20,52 +21,62 @@ const guard = (router: Router) => {
 				forbidClick: true,
 				message: "登陆中",
 			});
-			try {
-				await useLogin(to.query);
-				toast.message = `登陆成功`;
-				setTimeout(() => {
-					Toast.clear();
-				}, 500);
-			} catch (error) {
-				toast.message = `登陆失败`;
-				setTimeout(() => {
-					Toast.clear();
-					location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
-				}, 1000);
-			}
+			await useLogin(to.query);
+			toast.message = `登陆成功`;
+			setTimeout(() => {
+				Toast.clear();
+			})
+			next("./")
+			// try {
+			// 	await useLogin(to.query);
+			// 	toast.message = `登陆成功`;
+			// 	setTimeout(() => {
+			// 		Toast.clear();
+			// 	}, 500);
+			// } catch (error) {
+			// 	toast.message = `登陆失败`;
+			// 	setTimeout(() => {
+			// 		Toast.clear();
+			// 		location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
+			// 	}, 1000);
+			// }
 		}
+		//更新用户的信息
+		useUpdateUserInfo();
 		//检测token状态,token失效直接跳转至登陆链接
-		try {
-			useUpdateUserInfo();
-			const authTest = await userInfo();
-			if (authTest.data.code !== 200) {
-				throw authTest.data.msg;
-			}
-		} catch (error) {
-			//监听到登陆事件
-			if (to.query.state === "LOGIN") {
-				const toast = Toast.loading({
-					duration: 0, // 持续展示 toast
-					forbidClick: true,
-					message: "登陆中",
-				});
-				try {
-					await useLogin(to.query);
-					toast.message = `登陆成功`;
-					setTimeout(() => {
-						Toast.clear();
-					}, 500);
-				} catch (error) {
-					toast.message = `登陆失败`;
-					setTimeout(() => {
-						Toast.clear();
-						location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
-					}, 1000);
-				}
-			} else {
-				location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=${location.href}&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
-			}
-		}
+		// try {
+		// 	useUpdateUserInfo();
+		// 	const authTest = await userInfo();
+		// 	if (authTest.data.code !== 200) {
+		// 		throw authTest.data.msg;
+		// 	}
+		// } 
+		// catch (error) {
+		// 	//监听到登陆事件
+		// 	if (to.query.state === "LOGIN") {
+		// 		const toast = Toast.loading({
+		// 			duration: 0, // 持续展示 toast
+		// 			forbidClick: true,
+		// 			message: "登陆中",
+		// 		});
+		// 		try {
+		// 			await useLogin(to.query);
+		// 			toast.message = `登陆成功`;
+		// 			setTimeout(() => {
+		// 				Toast.clear();
+		// 			}, 500);
+		// 		} catch (error) {
+		// 			console.log(error)
+		// 			toast.message = `登陆失败`;
+		// 			setTimeout(() => {
+		// 				Toast.clear();
+		// 				location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
+		// 			}, 1000);
+		// 		}
+		// 	} else {
+		// 		location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=${location.href}&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
+		// 	}
+		// }
 
 		try {
 			const userTime = dayjs(store.getters.getUserData.expireTime).valueOf();

+ 1 - 1
src/store/index.ts

@@ -4,7 +4,7 @@ import createPersistedState from "vuex-persistedstate";
 const store = createStore({
   plugins: [createPersistedState()],
   state: () => ({
-    token: "",
+    token: "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjllNTU3NDk1LWQyOGQtNDMyNy1hYTBjLTdjOTk2OTk5NTk1YiJ9.GvGgys5erlFYJMLEhk2S1e7W_9CKDJohfXfW8fZpitkpZ8RWni5u9VvTGjl8dhD1916s-4MTM_7TsNaTNwsuPg",
     userData: {},
     carType: "0",
     suject: "0",

+ 1 - 1
src/views/buyVip/index.vue

@@ -6,7 +6,7 @@
 		<div class="item-box">
 			<van-cell class="cell-title" title="选择充值方式" />
 			<div class="radio-box">
-				<div v-for="(item, index) in goodsList" :class="{ select: index === goodsIndex }" @click="goodsIndex = index">
+				<div v-for="(item, index) in goodsList" :class="{ select: index === goodsIndex }" :key="index" @click="goodsIndex = index">
 					<span>{{ item.dictLabel }}</span>
 					<span>¥{{ item.dictValue.split(',')[0] }}</span>
 					<span>原价{{ item.dictValue.split(',')[1] }}元</span>

+ 2 - 2
src/views/classify/index.vue

@@ -44,8 +44,8 @@ const {
 } = new RouterBus();
 const classData = ref();
 getTopicClass(query.path as string, query).then(({ data }) => {
-  data.shift();
-  classData.value = data;
+   data.data.shift();
+  classData.value = data.data;
 });
 </script>
 

+ 151 - 145
src/views/home/children/test/index.vue

@@ -23,174 +23,180 @@
 </template>
 
 <script lang="ts" setup>
-	import sujectOne from "./components/sujectOne.vue";
-	import userData from "./components/userData.vue";
-	import swiper from "./components/swiper.vue";
-	import { ref, nextTick, onBeforeMount } from "vue";
-	import { useStore } from "vuex";
-	const store = useStore();
+import sujectOne from "./components/sujectOne.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 { Toast } from "vant";
+import { useRouter } from "vue-router";
+const store = useStore();
+const carTypeRef = ref<any>(null);
 
-	const carTypeRef = ref<any>(null);
-	nextTick(() => {
-		carTypeRef.value.scrollTo(store.state.carType);
-	});
+nextTick(() => {
+	carTypeRef.value.scrollTo(store.state.carType);
+});
 
-	const carTypeChange = (e: string) => {
-		store.commit("setCatType", e);
-	};
-
-	const carTypeList = ref([
-		{
-			name: "轿车",
-			cert: "C1/C2/C3",
-			icon: "jiaoche",
-			query: { liceCar: 1 },
-			sujectList: [
-				{
+const carTypeChange = (e: string) => {
+	store.commit("setCatType", e);
+};
+onBeforeMount(() => {
+	// const router = useRouter();
+	// console.log(router.currentRoute.value);
+});
+const carTypeList = ref([
+	{
+		name: "轿车",
+		cert: "C1/C2/C3",
+		icon: "jiaoche",
+		query: { liceCar: 1 },
+		sujectList: [
+			{
+				name: "科目一",
+				query: {
 					name: "科目一",
-					query: {
-						name: "科目一",
-						cert: "C1/C2/C3",
-						vehicle: "小车",
-						subject: 1,
-					},
+					cert: "C1/C2/C3",
+					vehicle: "小车",
+					subject: 1,
 				},
-				{
+			},
+			{
+				name: "科目四",
+				query: {
 					name: "科目四",
-					query: {
-						name: "科目四",
-						cert: "C1/C2/C3",
-						vehicle: "小车",
-						subject: 4,
-					},
+					cert: "C1/C2/C3",
+					vehicle: "小车",
+					subject: 4,
 				},
-			],
-		},
-		{
-			name: "客车",
-			cert: "A1/A3/B1",
-			icon: "keche",
-			query: { liceBus: 1 },
-			sujectList: [
-				{
+			},
+		],
+	},
+	{
+		name: "客车",
+		cert: "A1/A3/B1",
+		icon: "keche",
+		query: { liceBus: 1 },
+		sujectList: [
+			{
+				name: "科目一",
+				query: {
 					name: "科目一",
-					query: {
-						name: "科目一",
-						cert: "A1/A3/B1",
-						vehicle: "客车",
-						subject: 1,
-					},
+					cert: "A1/A3/B1",
+					vehicle: "客车",
+					subject: 1,
 				},
-				{
+			},
+			{
+				name: "科目四",
+				query: {
 					name: "科目四",
-					query: {
-						name: "科目四",
-						cert: "A1/A3/B1",
-						vehicle: "客车",
-						subject: 4,
-					},
+					cert: "A1/A3/B1",
+					vehicle: "客车",
+					subject: 4,
 				},
-			],
-		},
-		{
-			name: "货车",
-			cert: "A2/B2",
-			icon: "huoche",
-			query: { liceTruck: 1 },
-			sujectList: [
-				{
+			},
+		],
+	},
+	{
+		name: "货车",
+		cert: "A2/B2",
+		icon: "huoche",
+		query: { liceTruck: 1 },
+		sujectList: [
+			{
+				name: "科目一",
+				query: {
 					name: "科目一",
-					query: {
-						name: "科目一",
-						cert: "A2/B2",
-						vehicle: "货车",
-						subject: 1,
-					},
+					cert: "A2/B2",
+					vehicle: "货车",
+					subject: 1,
 				},
-				{
+			},
+			{
+				name: "科目四",
+				query: {
 					name: "科目四",
-					query: {
-						name: "科目四",
-						cert: "A2/B2",
-						vehicle: "货车",
-						subject: 4,
-					},
+					cert: "A2/B2",
+					vehicle: "货车",
+					subject: 4,
 				},
-			],
-		},
-		{
-			name: "摩托车",
-			cert: "D/E/F",
-			icon: "motuoche",
-			query: { liceMoto: 1 },
-			sujectList: [
-				{
+			},
+		],
+	},
+	{
+		name: "摩托车",
+		cert: "D/E/F",
+		icon: "motuoche",
+		query: { liceMoto: 1 },
+		sujectList: [
+			{
+				name: "科目一",
+				query: {
 					name: "科目一",
-					query: {
-						name: "科目一",
-						cert: "D/E/F",
-						vehicle: "摩托车",
-						subject: 1,
-					},
+					cert: "D/E/F",
+					vehicle: "摩托车",
+					subject: 1,
 				},
-				{
+			},
+			{
+				name: "科目四",
+				query: {
 					name: "科目四",
-					query: {
-						name: "科目四",
-						cert: "D/E/F",
-						vehicle: "摩托车",
-						subject: 4,
-					},
+					cert: "D/E/F",
+					vehicle: "摩托车",
+					subject: 4,
 				},
-			],
-		},
-	]);
+			},
+		],
+	},
+]);
 </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-type {
+	margin: 21px 15px;
+	--van-tabs-line-height: 88px;
+	.van-tab--active {
 		.car-choose {
-			display: flex;
-			justify-content: center;
-			align-items: center;
-			flex-direction: column;
-			.img {
-				width: 66px;
-				height: 22px;
+			&::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>

+ 3 - 1
src/views/wrongReview/index.vue

@@ -4,4 +4,6 @@
 
 <script></script>
 
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+
+</style>

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini