Commit f5ebea61 by 张立顺

feat 登录功能开发

1 parent ac123335
...@@ -24,10 +24,15 @@ const request = ( ...@@ -24,10 +24,15 @@ const request = (
apiName = "dj" apiName = "dj"
} else { } else {
apiName = params.method.split(".api")[0] apiName = params.method.split(".api")[0]
if (apiName == "scrm") {
// 使用split方法分割字符串
const parts = params.method.split(".")
// 提取服务字段 索引3对应服务字段
apiName = parts[2]
}
} }
console.log("params.method", params.method)
// console.log("params.method", params.method) console.log("apiName", apiName)
// console.log("apiName", apiName)
// 为空报错 // 为空报错
if (!apiName) { if (!apiName) {
throw new Error("apiName is null") throw new Error("apiName is null")
...@@ -35,19 +40,22 @@ const request = ( ...@@ -35,19 +40,22 @@ const request = (
const mappingName = { const mappingName = {
"dj.smartcarlife": "axios", "dj.smartcarlife": "axios",
dj: "axios", dj: "axios",
scrm: "axios2", shopmall: "axios2",
merchants: "axios3", merchants: "axios3",
reportExport: "axios4", reportExport: "axios4",
"glsx.accounts.biz.common.pictureUpload": "common", "glsx.accounts.biz.common.pictureUpload": "common",
clue:'axios5' clue: "axios5",
sso: "axios6",
ssoCenter: "axios7"
} }
const baseApiName = mappingName[apiName] const baseApiName = mappingName[apiName]
// console.log(baseApiName, "baseApiName") console.log(baseApiName, baseConfig, "baseApiName")
// params.appKey = baseConfig[baseApiName].appkey // params.appKey = baseConfig[baseApiName].appkey
if (baseApiName == "common") { if (baseApiName == "common") {
params.app_key = baseConfig[baseApiName].appkey params.app_key = baseConfig[baseApiName].appkey
} else { } else {
params.appKey = baseConfig[baseApiName].appkey params.appKey = baseConfig[baseApiName].appkey || ""
} }
// console.log("params.appKey", params.appKey) // console.log("params.appKey", params.appKey)
params.timestamp = new Date().getTime() params.timestamp = new Date().getTime()
...@@ -72,10 +80,10 @@ const request = ( ...@@ -72,10 +80,10 @@ const request = (
scrm: "sha1", scrm: "sha1",
glsx: "md5", glsx: "md5",
"glsx.accounts.biz.common.pictureUpload": "md5", "glsx.accounts.biz.common.pictureUpload": "md5",
clue:'sha1' clue: "sha1"
} }
// console.log(signWay[apiName], "baseApiName") // console.log(signWay[apiName], "baseApiName")
const secret = baseConfig[baseApiName].secret const secret = baseConfig[baseApiName].secret || ""
const CancelToken = axiosPackage.CancelToken const CancelToken = axiosPackage.CancelToken
var reqData = var reqData =
method === RequestMethods.POST method === RequestMethods.POST
......
...@@ -209,3 +209,11 @@ export function scrmLogin(data = {}) { ...@@ -209,3 +209,11 @@ export function scrmLogin(data = {}) {
data.method = `scrm.api.sso.user.loginCode` data.method = `scrm.api.sso.user.loginCode`
return request(data, RequestMethods.POST) return request(data, RequestMethods.POST)
} }
/**
* 账户中心账号登录
* @param {*} data 参数
*/
export function ssoLogin(data = {}) {
data.method = `ssoCenter.api.cas.api.login`
return request(data, RequestMethods.POST)
}
...@@ -49,7 +49,11 @@ export default { ...@@ -49,7 +49,11 @@ export default {
// labelText: '成功上传0条, 导入失败1条' // labelText: '成功上传0条, 导入失败1条'
// } // }
], ],
updateRefesh: false updateRefesh: false,
scrmInfo: {},
SSOInfo: {
t: "TGT-57-yM93hs2pNJGpm4hloOInTVPRxoSHgwBvkkFdBCQAzP5eJPm7s2-qc36.glsx.com"
}
}, },
mutations: { mutations: {
setDownloadList(state, { list, type }) { setDownloadList(state, { list, type }) {
...@@ -63,6 +67,12 @@ export default { ...@@ -63,6 +67,12 @@ export default {
}, },
setUpdateRefesh(state, data) { setUpdateRefesh(state, data) {
state.updateRefesh = data state.updateRefesh = data
},
setScrmInfo(state, data) {
state.scrmInfo = data
},
setSSOInfo(state, data) {
state.SSOInfo = data
} }
}, },
actions: { actions: {
......
...@@ -145,8 +145,13 @@ ...@@ -145,8 +145,13 @@
<script> <script>
import util from "@/libs/util.js" import util from "@/libs/util.js"
import dayjs from "dayjs" import dayjs from "dayjs"
import { mapActions } from "vuex" import { mapActions, mapState } from "vuex"
import { selectAccount, getUserInfo } from "@api/sys.account" import {
selectAccount,
getUserInfo,
scrmLogin,
ssoLogin
} from "@api/sys.account"
import { baseConfig } from "@/main" import { baseConfig } from "@/main"
export default { export default {
components: { components: {
...@@ -220,6 +225,8 @@ export default { ...@@ -220,6 +225,8 @@ export default {
mounted() { mounted() {
this.timeInterval = setInterval(() => this.refreshTime(), 1000) this.timeInterval = setInterval(() => this.refreshTime(), 1000)
this.$event.$on("e-reg-dialog", (res) => (this.registerDialogVisible = res)) this.$event.$on("e-reg-dialog", (res) => (this.registerDialogVisible = res))
this.scrmLogin()
this.ssoLogin()
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.timeInterval) clearInterval(this.timeInterval)
...@@ -231,6 +238,45 @@ export default { ...@@ -231,6 +238,45 @@ export default {
current: "d2admin/page/currentGet", current: "d2admin/page/currentGet",
initBaseData: "d2admin/base/init" initBaseData: "d2admin/base/init"
}), }),
...mapActions("d2admin/user", ["setScrmInfo"]),
scrmLogin() {
// scrm 登录
scrmLogin({
source: "scrm-base",
loginSource: "SCRM",
productCode: "PC00000",
userName: "glsadmin",
password: "e10adc3949ba59abbe56e057f20f883e",
code: "1",
codeToken: "88af245d-5a3e-4692-9f55-6d7ea3cb9848"
})
.then((res) => {
const { sessionId, merchantId } = res.loginList[0]
this.setScrmInfo({ sessionId, merchantId })
console.log(res)
})
.catch((err) => {
console.log(err)
})
},
ssoLogin() {
// 账户中心 登录
ssoLogin({
username: "admin",
password: "1f0a748dbb065d4f",
code: "8888",
lt: "LT-24330-yMjzGZjMu1tyW29hjqCRU2zcEnsKJq",
j_captcha_response: "8888"
})
.then((res) => {
// const { sessionId, merchantId } = res.loginList[0]
// this.setScrmInfo({ sessionId, merchantId })
console.log(res)
})
.catch((err) => {
console.log(err)
})
},
refreshTime() { refreshTime() {
this.time = dayjs().format("HH:mm:ss") this.time = dayjs().format("HH:mm:ss")
}, },
...@@ -323,6 +369,8 @@ export default { ...@@ -323,6 +369,8 @@ export default {
} }
} }
) )
// 账户中心登录
} }
}) })
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!