Selaa lähdekoodia

新增获取code页面

zhangyujun 3 vuotta sitten
vanhempi
commit
78e9a70d25

+ 80 - 0
code.html

@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+
+<body>
+    <div>code:</div>
+    <div id="code"></div>
+    <button style="margin-top: 15px;">
+        <a
+            href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h51.zzxcx.net/code.html&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect">
+            重新获取code</a>
+    </button>
+    <script>
+        function getAllUrlParams(urls) {
+            var url = urls || location.href
+            // 用JS拿到URL,如果函数接收了URL,那就用函数的参数。如果没传参,就使用当前页面的URL
+            var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
+            // 用来存储我们所有的参数
+            var obj = {};
+            // 如果没有传参,返回一个空对象
+            if (!queryString) {
+                return obj;
+            }
+            // stuff after # is not part of query string, so get rid of it
+            queryString = queryString.split('#')[0];
+            // 将参数分成数组
+            var arr = queryString.split('&');
+            for (var i = 0; i < arr.length; i++) {
+                // 分离成key:value的形式
+                var a = arr[i].split('=');
+                // 将undefined标记为true
+                var paramName = a[0];
+                var paramValue = typeof (a[1]) === 'undefined' ? true : a[1];
+                if (paramName.match(/\[(\d+)?\]$/)) {
+                    // 如果paramName不存在,则创建key
+                    var key = paramName.replace(/\[(\d+)?\]/, '');
+                    if (!obj[key]) obj[key] = [];
+                    // 如果是索引数组 e.g. colors[2]
+                    if (paramName.match(/\[\d+\]$/)) {
+                        // 获取索引值并在对应的位置添加值
+                        var index = /\[(\d+)\]/.exec(paramName)[1];
+                        obj[key][index] = paramValue;
+                    } else {
+                        // 如果是其它的类型,也放到数组中
+                        obj[key].push(paramValue);
+                    }
+                } else {
+                    // 处理字符串类型
+                    if (!obj[paramName]) {
+                        // 如果如果paramName不存在,则创建对象的属性
+                        obj[paramName] = paramValue;
+                    } else if (obj[paramName] && typeof obj[paramName] === 'string') {
+                        // 如果属性存在,并且是个字符串,那么就转换为数组
+                        obj[paramName] = [obj[paramName]];
+                        obj[paramName].push(paramValue);
+                    } else {
+                        // 如果是其它的类型,还是往数组里丢
+                        obj[paramName].push(paramValue);
+                    }
+                }
+            }
+            return obj;
+        }
+        function getCode() {
+            if (getAllUrlParams()["code"]) {
+                document.getElementById("code").textContent = getAllUrlParams()["code"]
+            }
+        }
+        // console.log(getAllUrlParams()["code"])
+        getCode()
+    </script>
+</body>
+
+</html>

+ 1 - 3
src/api/request.ts

@@ -22,9 +22,7 @@ request.interceptors.response.use((res) => {
 	if (res && res.data) {
 		switch (res.data.code) {
 			case 401:
-				Toast("登录失败,需要再次登录")
-				
-
+				// Toast("登录失败,需要再次登录")
 				window.setTimeout(() => {
 
 					switch (import.meta.env.MODE) {

+ 1 - 1
src/route/guard.ts

@@ -20,7 +20,7 @@ const guard = (router: Router) => {
 				message: "登陆中",
 			});
 			await useLogin(to.query);
-			Toast("登录成功")
+			// Toast("登录成功")
 			next("./")
 			// try {
 			// 	await useLogin(to.query);

+ 0 - 1
src/store/index.ts

@@ -35,7 +35,6 @@ const store = createStore({
     },
     getRealName(state) {
       return state.userData.realName
-
     },
     getCarType(state) {
       return state.carType;

+ 1 - 1
src/views/lightMock/components/examTopicList.vue

@@ -185,7 +185,7 @@ export default defineComponent({
 		randSingleList(): lightingItemListResRow[] {},
 		comTitle(): string {
 			if (this.comList && this.comList.length > 0 && this.randComlistIndex < this.comList.length) {
-				return this.comList[this.randComlistIndex].titile;
+				return this.newComList[this.randComlistIndex].titile;
 			} else {
 				return "";
 			}

+ 1 - 1
vite.config.ts

@@ -30,7 +30,7 @@ export default defineConfig({
 		},
 		proxy: {
 			"/dev-api": {
-				target: "https://jpcj-admin.zzxcx.net/twzd-admin",
+				target: "https://jpcj-admin1.zzxcx.net/twzd-admin",
 				changeOrigin: true,
 				rewrite: (path) => path.replace(/^\/dev-api/, ""),
 			},