Browse Source

fix:网页登录

sunChengjie 11 months ago
parent
commit
2dea335d04
3 changed files with 12 additions and 10 deletions
  1. 4 4
      src/api/login.js
  2. 6 5
      src/pages/index.vue
  3. 2 1
      src/script/common.js

+ 4 - 4
src/api/login.js

@@ -1,20 +1,20 @@
 import request from '../utils/request';
 
-export function getWxUserInfo(data, config) {
+export function getWxUserInfo(data) {
     return request({
         url: '/tianzong/weixin/getWxUserInfo',
         method: 'post',
         data: data,
-        ...config
+        emulateJSON: true
     })
 }
 
 // 获取appid
-export function getWxConfig(data, config) {
+export function getWxConfig(data) {
     return request({
         url: '/tianzong/weixin/getWxConfig',
         method: 'post',
         data: data,
-        ...config
+        emulateJSON: true
     })
 }

+ 6 - 5
src/pages/index.vue

@@ -49,11 +49,12 @@ export default {
 	},
 	created: async function () {
 		this.getOpenid("index.html");
-		const code = getUrlParam('code');
-		if (code) {
-			const res = await getWxUserInfo({ code: code, userId: localStorage.getItem("userId") })
-			console.log(res, '==========res')
-		}
+
+		// const code = getUrlParam('code');
+		// if (code) {
+		// 	const res = await getWxUserInfo({ code: code, userId: localStorage.getItem("userId") })
+		// 	console.log(res, '==========res')
+		// }
 
 
 	},

+ 2 - 1
src/script/common.js

@@ -15,7 +15,7 @@ export default {
 			}
 
 			const res = await getWxUserInfo({ code: code, userId: localStorage.getItem("userId") })
-			console.log(res, '================================')
+			console.log(res, '================================getWxUserInfo')
 			if (res.body.code == '0') {
 				console.log('直接走+======', res)
 				localStorage.setItem("openid", res.body.openId);
@@ -29,6 +29,7 @@ export default {
 		Vue.prototype.urlredirect = async function (page) {
 			const res = await getWxConfig({})
 			const href = window.location.href
+			// const href = 'https://tianzong.info666.com/'
 			window.location.href =
 				`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.wxConfig.appId}&redirect_uri=${encodeURIComponent(href)}` + `&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect`;
 		}