From 567732d51e12d78396dc6381cfb6e307cb55e5a6 Mon Sep 17 00:00:00 2001 From: zhouzy062 Date: Fri, 26 Jan 2024 19:11:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86=E5=89=8D=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgzb-ui/src/api/login.js | 19 +++- sgzb-ui/src/router/index.js | 2 +- sgzb-ui/src/store/modules/user.js | 31 +++++- sgzb-ui/src/views/loginSso.vue | 175 ++++++++++++++++++++++++++++++ sgzb-ui/vue.config.js | 4 +- 5 files changed, 223 insertions(+), 8 deletions(-) create mode 100644 sgzb-ui/src/views/loginSso.vue diff --git a/sgzb-ui/src/api/login.js b/sgzb-ui/src/api/login.js index f0a80bce..42c46cef 100644 --- a/sgzb-ui/src/api/login.js +++ b/sgzb-ui/src/api/login.js @@ -83,4 +83,21 @@ export function checkCode(data) { method: 'post', data: data }) -} \ No newline at end of file +} + + + +//南网机具认证中心登录 +export function SsoLogin(data) { + return request({ + url: '/user/onlineApprove', + headers: { + isToken: false + }, + method: 'post', + data: data + }) +} + + + diff --git a/sgzb-ui/src/router/index.js b/sgzb-ui/src/router/index.js index 71907b69..14b05487 100644 --- a/sgzb-ui/src/router/index.js +++ b/sgzb-ui/src/router/index.js @@ -43,7 +43,7 @@ export const constantRoutes = [ }, { path: '/login', - component: () => import('@/views/login'), + component: () => import('@/views/loginSso'), hidden: true }, { diff --git a/sgzb-ui/src/store/modules/user.js b/sgzb-ui/src/store/modules/user.js index 937df7f5..c170ec71 100644 --- a/sgzb-ui/src/store/modules/user.js +++ b/sgzb-ui/src/store/modules/user.js @@ -1,6 +1,6 @@ -import { login, logout, getInfo, refreshToken,checkCode } from '@/api/login' +import { login, logout, getInfo, refreshToken,checkCode,SsoLogin } from '@/api/login' import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth' - +import { Notification, MessageBox, Message, Loading } from 'element-ui' const user = { state: { token: getToken(), @@ -55,8 +55,8 @@ const user = { }) }) }, - // 验证码 登录 - textLogin({ commit }, userInfo) { + // 验证码 登录 + textLogin({ commit }, userInfo) { console.log(userInfo) let params = { phone:userInfo.phone, @@ -79,6 +79,29 @@ const user = { }) }, + ssoLogin({ commit }, param) { + return new Promise((resolve, reject) => { + SsoLogin(param).then(res => { + console.log(res) + let data = res.data + if(res.code==200){ + console.log('登录成功1111111') + setToken(data.access_token) + commit('SET_TOKEN', data.access_token) + setExpiresIn(data.expires_in) + commit('SET_EXPIRES_IN', data.expires_in) + }else{ + console.log('登录失败22222222') + this.$modal.msgError('登录失败22222222'); + } + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 获取用户信息 GetInfo({ commit, state }) { return new Promise((resolve, reject) => { diff --git a/sgzb-ui/src/views/loginSso.vue b/sgzb-ui/src/views/loginSso.vue new file mode 100644 index 00000000..0b8d0191 --- /dev/null +++ b/sgzb-ui/src/views/loginSso.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/sgzb-ui/vue.config.js b/sgzb-ui/vue.config.js index cf7148c7..8e089d4d 100644 --- a/sgzb-ui/vue.config.js +++ b/sgzb-ui/vue.config.js @@ -38,9 +38,9 @@ module.exports = { // target: `http://112.29.103.165:21626`,//线上环境-重庆 // target: `http://112.29.103.165:21624`,//线上环境-宁夏 // target: `http://192.168.0.14:21624`,//线上环境 - // target: `http://10.40.92.21:8080`, + target: `http://10.40.92.21:9201`, // target: `http://10.40.92.13:8080`, - target: `http://10.40.92.219:8080`, + // target: `http://10.40.92.219:8080`, changeOrigin: true, pathRewrite: {