Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ee1e35e9
authored
Nov 15, 2023
by
李敏
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v3.21.1' into 'master'
V3.21.1 See merge request
!8
2 parents
c63e6734
e9c53eaf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
67 deletions
src/config/index.js
src/layout/components/SubMenuItem.vue
src/store/modules/app.js
src/views/Login.vue
src/config/index.js
View file @
ee1e35e
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* @Author: limin
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditors: limin
* @LastEditTime: 2023-1
0-07 10:01:47
* @LastEditTime: 2023-1
1-10 13:42:02
*/
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
// 根据环境引入不同配置 process.env.VUE_APP_ENV
let
cfg
=
require
(
'./conf.js'
)
let
cfg
=
require
(
'./conf.js'
)
...
...
src/layout/components/SubMenuItem.vue
View file @
ee1e35e
...
@@ -26,9 +26,6 @@ export default {
...
@@ -26,9 +26,6 @@ export default {
this
.
$router
.
push
(
path
)
this
.
$router
.
push
(
path
)
}
}
}
}
},
mounted
(){
console
.
log
(
this
.
menuItems
);
}
}
}
}
</
script
>
</
script
>
...
...
src/store/modules/app.js
View file @
ee1e35e
...
@@ -126,6 +126,7 @@ function getMenuItem(moduleName, menus) {
...
@@ -126,6 +126,7 @@ function getMenuItem(moduleName, menus) {
const
flattenMenus
=
utils
.
array
.
flattenDeep
(
menus
)
const
flattenMenus
=
utils
.
array
.
flattenDeep
(
menus
)
for
(
let
i
=
0
,
j
=
flattenMenus
.
length
;
i
<
j
;
i
++
)
{
for
(
let
i
=
0
,
j
=
flattenMenus
.
length
;
i
<
j
;
i
++
)
{
const
menu
=
flattenMenus
[
i
]
const
menu
=
flattenMenus
[
i
]
if
(
menu
.
path
===
'^'
)
continue
const
route
=
__gen
(
moduleName
,
menu
)
const
route
=
__gen
(
moduleName
,
menu
)
router
.
addRoute
(
route
)
router
.
addRoute
(
route
)
}
}
...
@@ -134,7 +135,7 @@ function getMenuItem(moduleName, menus) {
...
@@ -134,7 +135,7 @@ function getMenuItem(moduleName, menus) {
/**
/**
* 生成动态路由参数
* 生成动态路由参数
*/
*/
function
__gen
(
moduleName
,
menu
)
{
/*
function __gen(moduleName, menu) {
let { path, meta = {}, id, title, url, children, hidden = false } = menu
let { path, meta = {}, id, title, url, children, hidden = false } = menu
let _path = ''
let _path = ''
let redirect = ''
let redirect = ''
...
@@ -166,6 +167,28 @@ function __gen(moduleName, menu) {
...
@@ -166,6 +167,28 @@ function __gen(moduleName, menu) {
meta: { ...meta, id, title, name, url, path: _path, hidden }
meta: { ...meta, id, title, name, url, path: _path, hidden }
}
}
return route
return route
}*/
function
__gen
(
moduleName
,
menu
)
{
let
{
path
,
meta
=
{},
id
,
title
,
url
,
hidden
=
false
}
=
menu
let
_path
=
_get_path_
(
moduleName
,
path
)
//路由path生成name 如 home/home/index =>HomeHomeIndex
//排除 以:开头 比如 home/home/index/:id 参数:id 不参与生成规则
//name 主要用于 子系统内部 params传参 如 this.$router.push({name:'HomeHomeIndex',params:{id:123}})
const
name
=
_path
.
split
(
'/'
).
reduce
((
t
,
n
)
=>
{
if
(
!
n
.
startsWith
(
':'
))
{
t
+=
n
.
charAt
(
0
).
toUpperCase
()
+
n
.
slice
(
1
)
}
return
t
},
''
)
menu
.
path
=
_path
const
route
=
{
path
:
_path
,
component
:
Layout
,
name
,
meta
:
{
...
meta
,
id
,
title
,
name
,
url
,
path
:
_path
,
hidden
}
}
return
route
}
}
/**
/**
...
@@ -181,8 +204,8 @@ function getDefaultPath(menu) {
...
@@ -181,8 +204,8 @@ function getDefaultPath(menu) {
/**
/**
* 递归获取无实际路径的菜单下的第一个子菜单的路径
* 递归获取无实际路径的菜单下的第一个子菜单的路径
* @param {*} menus
* @param {*} menus
* @returns
* @returns
*/
*/
function
_loop
(
menus
)
{
function
_loop
(
menus
)
{
const
{
path
}
=
menus
.
noHidden
()[
0
]
const
{
path
}
=
menus
.
noHidden
()[
0
]
...
...
src/views/Login.vue
View file @
ee1e35e
...
@@ -4,13 +4,14 @@
...
@@ -4,13 +4,14 @@
<el-image
:src=
"`$
{$config.cdn}/assets/${$config.customized.assets}/logo_login.png`">
</el-image>
<el-image
:src=
"`$
{$config.cdn}/assets/${$config.customized.assets}/logo_login.png`">
</el-image>
<h2>
专注汽车行业数字化+智能营销解决方案——帮您的流量变销量
</h2>
<h2>
专注汽车行业数字化+智能营销解决方案——帮您的流量变销量
</h2>
</div>
</div>
<div
class=
"login-wrap animate__animated"
:class=
"
{ animate__fadeInUp: isDoAnimate }">
<div
class=
"login-wrap animate__animated"
:class=
"
{ animate__fadeInUp: isDoAnimate }" v-loading="isMutilMerchantLogin">
<div
class=
"merchants"
v-if=
"isHasMutilMerchants"
@
click=
"forback"
>
<div
class=
"merchants"
v-if=
"isHasMutilMerchants"
>
<i
class=
"icon el-icon-arrow-left forback"
@
click=
"forback"
></i>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<span
class=
"title"
>
请选择登录商户号
</span>
<span
class=
"title"
>
请选择登录商户号
</span>
<GLScroll
class=
"login-merchants-scroll"
>
<GLScroll
class=
"login-merchants-scroll"
>
<div
class=
"item-wrap"
>
<div
class=
"item-wrap"
>
<div
class=
"merchant-item"
v-for=
"merchant in merchants"
:key=
"merchant.
merchantId"
@
click
.
stop=
"loginChoose(merchant.merchantId
)"
>
<div
class=
"merchant-item"
v-for=
"merchant in merchants"
:key=
"merchant.
uuid || merchant.id"
@
click
.
stop=
"loginChoose(merchant
)"
>
<i
class=
"i i-dot"
></i>
<i
class=
"i i-dot"
></i>
<div
class=
"merchant-info"
>
<div
class=
"merchant-info"
>
<div
class=
"merchant-item-name"
>
{{
merchant
.
merchantName
}}
</div>
<div
class=
"merchant-item-name"
>
{{
merchant
.
merchantName
}}
</div>
...
@@ -73,7 +74,7 @@
...
@@ -73,7 +74,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
<LoginSMSCodeCheck
:visible
.
sync=
"smsCodeDialogVisible"
:checkProps=
"smsCheckProps"
@
onSuccess=
"afterVerify"
></LoginSMSCodeCheck>
<LoginSMSCodeCheck
:visible
.
sync=
"smsCodeDialogVisible"
:checkProps=
"smsCheckProps"
@
onSuccess=
"afterVerify
Phone
"
></LoginSMSCodeCheck>
</div>
</div>
</
template
>
</
template
>
...
@@ -124,19 +125,19 @@ export default {
...
@@ -124,19 +125,19 @@ export default {
rules
:
RULES
,
rules
:
RULES
,
//手机号验证组件所需参数
//手机号验证组件所需参数
smsCheckProps
:
{
smsCheckProps
:
{
sessionId
:
''
,
mobile
:
'13800138000'
mobile
:
'13800138000'
},
},
//登录成功后,短信验证前保存的登录数据
isPrivacyChecked
:
true
,
loginSuccessData
:
{}
,
chooseMerchant
:
null
,
is
PrivacyChecked
:
tru
e
is
MutilMerchantLogin
:
fals
e
}
}
},
},
watch
:
{
watch
:
{
smsCodeDialogVisible
:
function
(
val
)
{
smsCodeDialogVisible
:
function
(
val
)
{
if
(
!
val
)
{
if
(
!
val
)
{
this
.
isLogin
=
false
this
.
isLogin
=
false
this
.
getCode
()
this
.
isMutilMerchantLogin
=
false
!
this
.
isHasMutilMerchants
&&
this
.
getCode
()
}
}
}
}
},
},
...
@@ -178,10 +179,8 @@ export default {
...
@@ -178,10 +179,8 @@ export default {
const loginData = Object.assign({ loginSource, productCode }, this.loginForm, { password: md5(this.loginForm.password).toLowerCase() })
const loginData = Object.assign({ loginSource, productCode }, this.loginForm, { password: md5(this.loginForm.password).toLowerCase() })
let { code, data, message } = await api.app.login(loginData)
let { code, data, message } = await api.app.login(loginData)
if (code === response.code_success_value) {
if (code === response.code_success_value) {
//将登录成功信息存起来。当短信验证完后,需要用来走后面的流程
//判断是否绑定多个商户。
this.loginSuccessData = data
this.checkMutilMerchants(data)
//调接口判断是否要验证短信验证码
this.verifyPhone(data)
} else {
} else {
this.error(message)
this.error(message)
}
}
...
@@ -189,36 +188,33 @@ export default {
...
@@ -189,36 +188,33 @@ export default {
})
})
}, 500),
}, 500),
/**
/**
*
验证完短信,
判断是否绑定多个商户。如果有多个,则打开选择界面
* 判断是否绑定多个商户。如果有多个,则打开选择界面
* 如果只有一个,
则直接获取权限信息
* 如果只有一个,
直接判断是否要验证短信验证码
*/
*/
afterVerify(
) {
checkMutilMerchants(data
) {
const { loginList: merchants, loginToken } =
this.loginSuccessD
ata
const { loginList: merchants, loginToken } =
d
ata
if (merchants.length > 1) {
if (merchants.length > 1) {
this.loginForm.loginToken = loginToken
this.loginForm.loginToken = loginToken
this.merchants =
merchants
this.merchants =
Object.freeze(merchants)
this.doAnimate()
this.doAnimate()
this.isHasMutilMerchants = true
this.isHasMutilMerchants = true
} else {
} else {
this.
_permission
(merchants[0])
this.
verifyPhone
(merchants[0])
}
}
},
},
/**
/**
* 获取商户下的菜单信息
* 获取商户下的菜单信息
*/
*/
async _permission(merchant) {
async _permission(merchant) {
let { response, track } = this.$config
if (!merchant) throw new Error('商户信息不能为空')
try {
try {
merchant.pw = md5(this.loginForm.password)
let { response, track } = this.$config
const { code, message, menus, sessionData } = await this.permission(
merchant
)
const { code, message, menus, sessionData } = await this.permission(
Object.assign({ pw: md5(this.loginForm.password) }, merchant)
)
if (code == response.code_success_value) {
if (code == response.code_success_value) {
const { defaultPath } = await this.login(menus)
const { defaultPath } = await this.login(menus)
this.isLogin = false
Object.assign(sessionData, { defaultPath, loginpath: location.pathname, track })
sessionData.defaultPath = defaultPath
sessionData.loginpath = location.pathname
sessionData.track = track
this.setSession(sessionData)
this.setSession(sessionData)
this.setTracker(sessionData)
t
rack && t
his.setTracker(sessionData)
this.storeConfig()
this.storeConfig()
const path = helper.locationPath()
const path = helper.locationPath()
const redirect = path?.get('redirect')
const redirect = path?.get('redirect')
...
@@ -230,6 +226,9 @@ export default {
...
@@ -230,6 +226,9 @@ export default {
}
}
} catch (error) {
} catch (error) {
this.error(error.message, ERROR_TYPE.MESSAGE)
this.error(error.message, ERROR_TYPE.MESSAGE)
} finally {
this.isLogin = false
this.isMutilMerchantLogin = false
}
}
},
},
/**
/**
...
@@ -237,12 +236,72 @@ export default {
...
@@ -237,12 +236,72 @@ export default {
* 1.获取选择的商户信息
* 1.获取选择的商户信息
* 2.获取菜单信息并登录
* 2.获取菜单信息并登录
*/
*/
loginChoose: utils.debounce(async function (merchantId) {
loginChoose(merchant) {
if (this.isMutilMerchantLogin) return
this.isMutilMerchantLogin = true
this.verifyPhone(merchant)
},
/**
* 登录成功,验证本账号是否需要短信验证登录
* 如果不需要验证,直接调取是否选择门店方法
* 如果需要验证,弹出验证窗口
*/
async verifyPhone(merchant) {
try {
let { response } = this.$config
const loginAccount = this.loginForm.userName
const { merchantId, userType } = merchant
const { code, message, data: mobile } = await api.app.verifyPhone({ loginAccount, merchantId, userType })
if (code == response.code_success_value) {
this.chooseMerchant = Object.freeze(merchant)
if (mobile) {
//如果返回手机号,则弹出验证窗口
this.smsCodeDialogVisible = true
Object.assign(this.smsCheckProps, { mobile })
} else {
//如果没有手机号,跳过手机号验证
this.afterVerifyPhone()
}
} else {
this.error(message)
}
} catch (error) {
this.error(error.message, ERROR_TYPE.MESSAGE)
}
},
/**
* 验证短信验证码后,判断是否多商户
* 1.如果是多商户,需要重新登录 并获取菜单信息
* 2.如果不是多商户,直接获取菜单信息
*/
afterVerifyPhone() {
let merchant = this.chooseMerchant
this.$nextTick(async () => {
//如果是多商户,需要重新登录 并获取菜单信息
if (this.isHasMutilMerchants) {
this.isMutilMerchantLogin = true
merchant = await this.reLoginAfterChooseMerchantSuccess(merchant.merchantId)
}
this._permission(merchant)
})
},
/**
* 选择商户成功后重新登录
*/
async reLoginAfterChooseMerchantSuccess(merchantId) {
const { response, loginSource } = this.$config
const { response, loginSource } = this.$config
const { userName: loginAccount, loginToken } = this.loginForm
const { userName: loginAccount, loginToken } = this.loginForm
const { code, message, data } = await api.app.choose({ merchantId, loginAccount, loginToken, loginSource })
const { code, message, data: merchant } = await api.app.choose({ merchantId, loginAccount, loginToken, loginSource })
~[() => this.error(message), () => this._permission(data)][+(code === response.code_success_value)].call()
if (code === response.code_success_value) {
}, 2000),
return merchant
}
this.error(message)
return null
},
storeConfig() {
utils.storage.setSession(constants.SCRM_BASE_CONFIG, this.$config)
},
async getCode() {
async getCode() {
this.loginForm.code = ''
this.loginForm.code = ''
sessionStorage.clear()
sessionStorage.clear()
...
@@ -257,6 +316,7 @@ export default {
...
@@ -257,6 +316,7 @@ export default {
*/
*/
error(message, type = this.isHasMutilMerchants) {
error(message, type = this.isHasMutilMerchants) {
this.isLogin = false
this.isLogin = false
this.isMutilMerchantLogin = false
~[() => (this.errMsg = message), () => Message.error(message)][+type].call()
~[() => (this.errMsg = message), () => Message.error(message)][+type].call()
this.getCode()
this.getCode()
},
},
...
@@ -275,35 +335,8 @@ export default {
...
@@ -275,35 +335,8 @@ export default {
this.doAnimate()
this.doAnimate()
this.getCode()
this.getCode()
this.isHasMutilMerchants = false
this.isHasMutilMerchants = false
},
this.chooseMerchant = null
/**
this.isMutilMerchantLogin = false
* 登录成功,验证本账号是否需要短信验证登录
* 如果不需要验证,直接调取是否选择门店方法
* 如果需要验证,弹出验证窗口
*/
async verifyPhone() {
const loginData = this.loginSuccessData
let { response } = this.$config
try {
const loginAccount = this.loginForm.userName
const sessionId = loginData.loginList[0]?.sessionId
const { code, message, data: mobile } = await api.app.verifyPhone({ loginAccount, sessionId })
if (code == response.code_success_value) {
if (mobile) {
this.smsCodeDialogVisible = true
Object.assign(this.smsCheckProps, { sessionId, mobile })
} else {
this.afterVerify()
}
} else {
this.error(message)
}
} catch (error) {
this.error(error.message, ERROR_TYPE.MESSAGE)
}
},
storeConfig() {
utils.storage.setSession(constants.SCRM_BASE_CONFIG, this.$config)
},
},
...mapActions('app', ['login']),
...mapActions('app', ['login']),
...mapActions('auth', ['permission', 'setSession']),
...mapActions('auth', ['permission', 'setSession']),
...
@@ -341,6 +374,19 @@ $border-radius: 20px;
...
@@ -341,6 +374,19 @@ $border-radius: 20px;
box-shadow
:
15px
18px
64px
0px
rgba
(
210
,
210
,
210
,
0.13
);
box-shadow
:
15px
18px
64px
0px
rgba
(
210
,
210
,
210
,
0.13
);
border-radius
:
$
border-radius
;
border-radius
:
$
border-radius
;
overflow
:
hidden
;
overflow
:
hidden
;
.forback
{
position
:
absolute
;
top
:
20px
;
left
:
20px
;
font-size
:
16px
;
z-index
:
1234
;
padding
:
10px
;
cursor
:
pointer
;
&:hover
{
background-color
:
#f1f1f1
;
border-radius
:
50%
;
}
}
.merchants
{
.merchants
{
position
:
absolute
;
position
:
absolute
;
width
:
100%
;
width
:
100%
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment