From f07322ab1fd24214a231f8bcc02d2e896572dc2e Mon Sep 17 00:00:00 2001 From: caorui <3165079241@qq.com> Date: Wed, 25 Sep 2024 11:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=8D=95=E7=82=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/loginAuthen/authenWeChat.vue | 53 +++++++++++++++++---------- pages/loginAuthen/loginWeChat.vue | 57 ++++++++++++++++-------------- 2 files changed, 64 insertions(+), 46 deletions(-) diff --git a/pages/loginAuthen/authenWeChat.vue b/pages/loginAuthen/authenWeChat.vue index 53da946..2ea71b9 100644 --- a/pages/loginAuthen/authenWeChat.vue +++ b/pages/loginAuthen/authenWeChat.vue @@ -12,6 +12,7 @@ import { WeChatSSO } from "@/api/login.js"; import logo from "@/static/logo.png"; import localStorage from "@/utils/localStorage"; +import { authApi } from "@/api/login"; export default { data() { return { @@ -27,7 +28,7 @@ export default { if (code == "" || code == null || code == undefined) { //重定向回当前页面 var redirect = encodeURIComponent( - "http://ufidahz.com.cn:9085/app/index.html#/pages/loginAuthen/authenWeChat" + "http://ufidahz.com.cn:9067/V3/app/index.html#/pages/loginAuthen/authenWeChat" ); var url = "https://open.weixin.qq.com/connect/oauth2/authorize" + @@ -57,27 +58,41 @@ export default { async WXLogin(code) { let params = { code: code, + appType: "weChat", //移动端类型 + appId: "800046", //请求的APIID 默认 + userApiCode: "8000460000", //请求认证的API编码 默认 + corpid: "wwb46c3f5e6ffe3e2b", //企业微信企业id + corpsecret: "oON2ELxNVyl7wc37LeA9bNOsv_jyuFXdrvD9e0yogbQ", //企业微信密钥 }; - let res = await WeChatSSO(params); - if (res.code == 1) { - localStorage.set("MIDDLEGROUND-TOKEN", res.data[0]); - localStorage.set("MIDDLEGROUND-USERINFO", res.data[1]); - this.$nextTick(()=>{ - uni.reLaunch({ - url: "/pages/loginAuthen/selectCompany", - }); - }) - } else if (res.code == "1005") { - this.$refs.uToast.show({ - type: "warning", - message: "您尚未进行登录认证,请先认证!", + let res = await authApi("loginService", "", "appDoLogin", "", params); + if (res.status === "200") { + localStorage.set("MIDDLEGROUND-TOKEN", res.attribute.token); + localStorage.set("MIDDLEGROUND-USERINFO", res.attribute.userInfo); + uni.switchTab({ + url: "/pages/homePage/index", }); - setTimeout(() => { - localStorage.set("MIDDLEGROUND-USERID", res.data[0]); - uni.reLaunch({ - url: "/pages/loginAuthen/loginWeChat", + } else if (res.status == "1005") { + if ( + res.attribute.userid == "" || + res.attribute.userid == null || + res.attribute.userid == undefined + ) { + this.$refs.uToast.show({ + type: "warning", + message: "登录时获取的 code 为空, 请联系管理员处理!", }); - }, 1000); + } else { + this.$refs.uToast.show({ + type: "warning", + message: "您尚未进行登录认证,请先认证!", + }); + setTimeout(() => { + localStorage.set("MIDDLEGROUND-USERID", res.attribute.userid); + uni.reLaunch({ + url: "/pages/loginAuthen/loginWeChat", + }); + }, 1000); + } } else { localStorage.remove("MIDDLEGROUND-TOKEN"); localStorage.remove("MIDDLEGROUND-USERINFO"); diff --git a/pages/loginAuthen/loginWeChat.vue b/pages/loginAuthen/loginWeChat.vue index c2aba5c..ac45625 100644 --- a/pages/loginAuthen/loginWeChat.vue +++ b/pages/loginAuthen/loginWeChat.vue @@ -1,7 +1,7 @@