diff --git a/src/services/trxLogin.js b/src/services/trxLogin.js
index 5f0520c..8f6d388 100644
--- a/src/services/trxLogin.js
+++ b/src/services/trxLogin.js
@@ -4,6 +4,14 @@ export function getLoginRandom(ngxCookie) {
return request.get('/sms/v1/trx/randomstr', { params: { ngxCookie } })
}
+export function getSoftLoginRandom(ngxCookie,account) { //多传一个账号,这个接口返回的结果,作为randoms
+ return request.get('/sms/v1/trx/soft/randomstr', { params: { ngxCookie,account } })
+}
+
+export function trxSoftLogin(params) {
+ return request.post('/sms/v1/trx/softlogin', params)
+}
+
export function trxLogin(params) {
return request.post('/sms/v1/trx/login', params)
}
@@ -12,6 +20,14 @@ export function offlineToken(trxToken) {
return request.post('/sms/v1/trx/logout', { trxToken })
}
+export function getSoftLoginRandom(ngxCookie,account) { //多传一个账号,这个接口返回的结果,作为randoms
+ return request.get('/sms/v1/trx/soft/randomstr', { params: { ngxCookie,account } })
+}
+
+export function trxSoftLogin(params) {
+ return request.post('/sms/v1/trx/softlogin', params)
+}
+
// 理想那边给的代码调用 getAuthToken 时需要传 ip,云管目前不传
export function getIp() {
return request({
diff --git a/src/store/modules/skey.js b/src/store/modules/skey.js
new file mode 100644
index 0000000..ed766a5
--- /dev/null
+++ b/src/store/modules/skey.js
@@ -0,0 +1,68 @@
+import { getClientHello } from 'services/ukeyAuth.js'
+import { getSoftLoginRandom, trxSoftLogin } from 'services/trxLogin.js'
+import Cookies from 'js-cookie'
+import { ElMessage } from 'element-plus'
+const state = {}
+const mutations = {}
+const actions = {
+ // 登录
+ Login({ commit }, loginParam) {
+ return new Promise((resolve, reject) => {
+ // 调用 skey 获取 clientHello
+ console.log('执行 store.dispatch(skey/Login)开始,传参为password:', loginParam.password)
+ getClientHello(loginParam.password).then(checkRes => {
+ console.log('调用 skey getClientHello 方法,接口返回结果为:', checkRes)
+ if (checkRes.result !== 0) {
+ console.log('调用 skey getClientHello 方法失败,接口返回结果为:', checkRes)
+ Cookies.remove('ngx_cookie')
+ ElMessage({ message: checkRes.message, type: 'error' })
+ resolve({
+ success: false
+ })
+ }
+ const clientHello = checkRes.clientHello
+ console.log('clientHello:', clientHello)
+ Cookies.set('ngx_cookie', clientHello)
+ // 调用天融信单点登录获取 serverHello
+ getSoftLoginRandom(clientHello, loginParam.account)
+ .then(randomRes => {
+ console.log('调用 getSoftLoginRandom 方法,接口返回结果为:', randomRes)
+ if (!randomRes.success) {
+ console.log('调用 getSoftLoginRandom 方法失败,接口返回结果为:', randomRes)
+ resolve({
+ success: false
+ })
+ return
+ }
+ const randoms = randomRes.result
+ console.log('loginRandom:', randoms)
+ trxSoftLogin({clientHello, randoms, password: loginParam.password}).then(loginRes=>{
+ console.log('调用 trxSoftLogin 方法,接口返回结果为:', loginRes)
+ if (!loginRes.success) {
+ console.log('调用 trxSoftLogin 方法失败,接口返回结果为:', loginRes)
+ resolve({
+ success: false
+ })
+ return
+ }
+ resolve(loginRes)
+ return
+ }).catch(err => {
+ console.log('调用 trxSoftLogin 方法 [catch] ,接口返回结果为:', err)
+ reject(err)
+ })
+ })
+ .catch(err => {
+ console.log('调用 getSoftLoginRandom 方法 [catch] ,接口返回结果为:', err)
+ reject(err)
+ })
+ })
+ })
+ }
+}
+export default {
+ namespaced: true,
+ state,
+ mutations,
+ actions
+}
diff --git a/src/views/login/login.vue b/src/views/login/login.vue
index 1bfbaa5..9e03f45 100644
--- a/src/views/login/login.vue
+++ b/src/views/login/login.vue
@@ -62,6 +62,39 @@
登录
+
+
+
账号登录
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
登录
+
+
@@ -144,6 +177,27 @@ function handleLogin() {
}
})
}
+// 软key 登录
+function handleLogin4sKey() {
+ if (!loginFormRef.value) return
+ loginFormRef.value.validate(async valid => {
+ if (valid) {
+ loading.value = true
+ const { saccount, spassword } = loginForm
+ const res = await store
+ .dispatch('skey/Login', {account: saccount, password: spassword})
+ .finally(() => (loading.value = false))
+ .catch(() => (loading.value = false))
+ if (res && res.success) {
+ console.log('SKEY: 登录成功,云管融合登录接口返回', res)
+ goLogin(res.data)
+ } else {
+ console.log('SKEY: 登录失败,云管融合登录接口返回', res)
+ }
+ }
+ })
+
+
// ukey 登录
async function handleUkeyLogin() {
if (!loginFormRef.value) return