Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
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 b8cea721
authored
Oct 27, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
兼容智能名片登录
1 parent
d0b067e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
34 deletions
login/index/components/Box/Box.js
login/lib/index.js
login/loading/loading.js
login/index/components/Box/Box.js
View file @
b8cea72
// login/index/components/LoginBox.js
// login/index/components/LoginBox.js
import
USERAPI
from
'~/api/usersApi/index'
import
USERAPI
from
'~/api/usersApi/index'
import
{
import
{
selectAccountLogin
,
checkLoginUserInfo
,
setLoginInfo
,
setLoginInfo
,
loginModal
loginModal
}
from
'~/login/lib/index'
}
from
'~/login/lib/index'
...
@@ -176,7 +176,7 @@ Component({
...
@@ -176,7 +176,7 @@ Component({
})
=>
{
})
=>
{
this
.
setBtnLoading
(
false
)
this
.
setBtnLoading
(
false
)
if
(
code
==
'0'
)
{
if
(
code
==
'0'
)
{
if
(
loginType
==
1
)
this
.
checkLoginUserInfo
(
data
)
if
(
loginType
==
1
)
checkLoginUserInfo
(
data
)
else
{
else
{
const
{
const
{
autoLogin
autoLogin
...
@@ -220,7 +220,7 @@ Component({
...
@@ -220,7 +220,7 @@ Component({
data
,
data
,
message
message
})
=>
{
})
=>
{
if
(
code
==
'0'
)
this
.
checkLoginUserInfo
(
data
)
if
(
code
==
'0'
)
checkLoginUserInfo
(
data
)
else
{
else
{
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
this
.
init
()
this
.
init
()
...
@@ -235,24 +235,6 @@ Component({
...
@@ -235,24 +235,6 @@ Component({
this
.
init
()
this
.
init
()
})
})
},
},
/**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo
({
loginUserInfoList
,
sessionId
})
{
/**多个账号 */
if
(
loginUserInfoList
.
length
>
1
)
wx
.
$router
.
go
(
'login.accountItems'
,
{
sessionId
,
...
thisPage
.
options
})
/**只有一个账号 */
else
selectAccountLogin
({
id
:
loginUserInfoList
[
0
].
uuid
,
sessionId
})
},
/**设置登录按钮loading状态 */
/**设置登录按钮loading状态 */
setBtnLoading
(
loading
=
true
)
{
setBtnLoading
(
loading
=
true
)
{
thisPage
.
setData
({
thisPage
.
setData
({
...
...
login/lib/index.js
View file @
b8cea72
import
{
setSessionId
,
setUserInfo
}
from
'~/utils/cache/storageApi'
import
{
setSessionId
,
setUserInfo
}
from
'~/utils/cache/storageApi'
import
USERAPI
from
'~/api/usersApi/index'
import
USERAPI
from
'~/api/usersApi/index'
const
setRouteData
=
targetPath
=>
{
const
setRouteData
=
targetPath
=>
{
let
[
url
,
query
]
=
targetPath
.
split
(
'?'
),
let
[
url
,
query
]
=
targetPath
.
split
(
'?'
),
...
@@ -15,11 +18,18 @@ const setRouteData = targetPath => {
...
@@ -15,11 +18,18 @@ const setRouteData = targetPath => {
}
}
}
}
/**选择账号登录 */
/**选择账号登录 */
const
selectAccountLogin
=
({
id
,
sessionId
})
=>
{
const
selectAccountLogin
=
({
id
,
sessionId
})
=>
{
USERAPI
.
selectAccountLogin
({
USERAPI
.
selectAccountLogin
({
id
,
id
,
sessionId
sessionId
}).
then
(({
code
,
data
,
message
})
=>
{
}).
then
(({
code
,
data
,
message
})
=>
{
if
(
code
==
'0'
)
{
if
(
code
==
'0'
)
{
console
.
log
(
data
)
console
.
log
(
data
)
setLoginInfo
(
data
.
loginUserInfoList
[
0
],
data
.
sessionId
)
setLoginInfo
(
data
.
loginUserInfoList
[
0
],
data
.
sessionId
)
...
@@ -28,7 +38,7 @@ const selectAccountLogin = ({ id, sessionId }) => {
...
@@ -28,7 +38,7 @@ const selectAccountLogin = ({ id, sessionId }) => {
}
}
/**设置登录信息 */
/**设置登录信息 */
const
setLoginInfo
=
(
userInfo
,
sessionId
)
=>
{
const
setLoginInfo
=
(
userInfo
,
sessionId
)
=>
{
if
(
!
userInfo
)
{
if
(
!
userInfo
)
{
wx
.
$api
.
showToast
(
'仅支持服务商类型账户登录'
)
wx
.
$api
.
showToast
(
'仅支持服务商类型账户登录'
)
return
return
}
}
...
@@ -39,14 +49,23 @@ const setLoginInfo = (userInfo, sessionId) => {
...
@@ -39,14 +49,23 @@ const setLoginInfo = (userInfo, sessionId) => {
/**成功跳转 */
/**成功跳转 */
const
loginSuccess
=
()
=>
{
const
loginSuccess
=
()
=>
{
const
{
const
{
options
:
{
targetPath
}
options
:
{
targetPath
}
}
=
wx
.
$router
.
getPageInstance
()
}
=
wx
.
$router
.
getPageInstance
()
if
(
targetPath
)
{
if
(
targetPath
)
{
const
{
url
,
obj
}
=
setRouteData
(
targetPath
)
const
{
url
,
obj
}
=
setRouteData
(
targetPath
)
wx
.
$router
.
reLaunch
(
url
,
obj
)
wx
.
$router
.
reLaunch
(
url
,
obj
)
}
else
wx
.
$router
.
go
(
'pages.index'
)
}
else
wx
.
$router
.
go
(
'pages.index'
)
}
}
const
loginModal
=
async
({
message
,
confirmText
,
cancelText
})
=>
{
const
loginModal
=
async
({
message
,
confirmText
,
cancelText
})
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
showModal
({
wx
.
showModal
({
content
:
message
||
'网络异常'
,
content
:
message
||
'网络异常'
,
...
@@ -60,10 +79,30 @@ const loginModal = async ({ message, confirmText, cancelText }) => {
...
@@ -60,10 +79,30 @@ const loginModal = async ({ message, confirmText, cancelText }) => {
})
})
})
})
}
}
/**手机号&微信登录:是否跳转登录列表页 */
const
checkLoginUserInfo
=
({
loginUserInfoList
,
sessionId
})
=>
{
const
thisPage
=
wx
.
$router
.
getPageInstance
()
/**多个账号 */
if
(
loginUserInfoList
.
length
>
1
)
wx
.
$router
.
go
(
'login.accountItems'
,
{
sessionId
,
...
thisPage
.
options
})
/**只有一个账号 */
else
selectAccountLogin
({
id
:
loginUserInfoList
[
0
].
uuid
,
sessionId
})
}
module
.
exports
=
{
module
.
exports
=
{
checkLoginUserInfo
,
selectAccountLogin
,
selectAccountLogin
,
loginSuccess
,
loginSuccess
,
setRouteData
,
setRouteData
,
setLoginInfo
,
setLoginInfo
,
loginModal
loginModal
}
}
\ No newline at end of file
\ No newline at end of file
login/loading/loading.js
View file @
b8cea72
import
{
import
{
checkLoginUserInfo
,
setRouteData
,
setRouteData
,
setLoginInfo
,
setLoginInfo
,
loginModal
loginModal
...
@@ -35,7 +36,16 @@ Page({
...
@@ -35,7 +36,16 @@ Page({
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
()
{
onShow
()
{
this
.
init
()
const
appEnter
=
wx
.
getEnterOptionsSync
()
if
(
appEnter
.
scene
==
1037
)
{
if
(
Object
.
keys
(
appEnter
.
referrerInfo
).
length
)
{
const
{
extraData
}
=
appEnter
.
referrerInfo
if
(
extraData
&&
Object
.
keys
(
extraData
).
length
)
this
.
phoneSmsLogin
(
extraData
)
else
this
.
init
()
}
else
this
.
init
()
}
else
this
.
init
()
},
},
/**
/**
...
@@ -68,10 +78,10 @@ Page({
...
@@ -68,10 +78,10 @@ Page({
init
()
{
init
()
{
wx
.
nextTick
(()
=>
{
wx
.
nextTick
(()
=>
{
const
sessionId
=
getSessionId
(),
const
sessionId
=
getSessionId
(),
{
{
url
,
url
,
targetPath
=
url
?
decodeURIComponent
(
url
)
:
''
targetPath
=
url
?
decodeURIComponent
(
url
)
:
''
}
=
this
.
options
}
=
this
.
options
let
path
=
'pages.index'
,
let
path
=
'pages.index'
,
obj
=
{}
obj
=
{}
if
(
targetPath
)
obj
.
targetPath
=
targetPath
if
(
targetPath
)
obj
.
targetPath
=
targetPath
...
@@ -128,5 +138,30 @@ Page({
...
@@ -128,5 +138,30 @@ Page({
})
})
}
else
wx
.
$router
.
reLaunch
(
'login.index'
,
obj
)
}
else
wx
.
$router
.
reLaunch
(
'login.index'
,
obj
)
}
else
wx
.
$router
.
reLaunch
(
'login.index'
,
obj
)
}
else
wx
.
$router
.
reLaunch
(
'login.index'
,
obj
)
},
phoneSmsLogin
(
extraData
)
{
console
.
log
(
extraData
)
USERAPI
.
phoneSmsLogin
({
mobile
:
extraData
.
phone
,
code
:
extraData
.
smscode
}).
then
(({
code
,
data
,
message
})
=>
{
if
(
code
==
'0'
)
checkLoginUserInfo
(
data
)
else
{
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
setTimeout
(()
=>
{
wx
.
$router
.
reLaunch
(
'login.index'
)
},
1
e3
)
}
})
.
catch
(
err
=>
{
wx
.
$api
.
showToast
(
'系统异常'
)
setTimeout
(()
=>
{
wx
.
$router
.
reLaunch
(
'login.index'
)
},
1
e3
)
})
}
}
})
})
\ No newline at end of file
\ No newline at end of file
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