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 542b5bdf
authored
Oct 12, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'develop' of 192.168.3.233:saas_plus/business-assistant into develop
2 parents
8c92d3d8
f9dfabb8
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
231 additions
and
206 deletions
api/usersApi/UsersApi.js
components/NavigationBar/NavigationBar.js
login/accountItems/accountItems.js
login/accountItems/accountItems.json
login/accountItems/accountItems.scss
login/accountItems/accountItems.wxml
login/index/components/Box/Box.js
login/index/components/Box/Box.scss
login/index/components/Box/Box.wxml
login/index/index.js
login/index/index.scss
login/lib/index.js
project.private.config.json
api/usersApi/UsersApi.js
View file @
542b5bd
...
...
@@ -84,10 +84,11 @@ class UsersApi {
)
}
/** 获取登录账号列表 */
getAccountList
()
{
getAccountList
(
sessionId
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.listSelectAccount'
,
platformEntrance
:
'BUSINESS_ASSISTANT'
platformEntrance
:
'BUSINESS_ASSISTANT'
,
sessionId
},
true
)
...
...
components/NavigationBar/NavigationBar.js
View file @
542b5bd
...
...
@@ -46,7 +46,9 @@ Component({
right
,
width
,
top
}
=
wx
.
getMenuButtonBoundingClientRect
()
}
=
wx
.
getMenuButtonBoundingClientRect
(),
currentPages
=
getCurrentPages
()
let
navigationBarHeight
=
height
+
((
top
-
statusBarHeight
)
*
2
)
+
4
// 4
let
navigationBarPadding
=
screenWidth
-
right
let
navigationBarWidth
=
screenWidth
-
(
navigationBarPadding
*
2
+
width
)
-
width
...
...
@@ -68,7 +70,6 @@ Component({
})
{
let
navHeight
=
navigationBarHeight
+
statusBarHeight
const
thisPage
=
wx
.
$router
.
getPageInstance
()
const
currentPages
=
getCurrentPages
()
this
.
triggerEvent
(
'navbarReady'
,
{
height
:
navHeight
,
statusBarHeight
...
...
@@ -80,9 +81,6 @@ Component({
navHeight
,
statusBarHeight
})
if
(
currentPages
.
length
==
1
&&
!
thisPage
.
rootName
)
thisPage
.
setData
({
showHomeBtn
:
true
})
}
},
lifetimes
:
{
...
...
login/accountItems/accountItems.js
View file @
542b5bd
// pages/accountItems/accountItems.js
import
USERAPI
from
'~/api/usersApi/index'
import
{
selectAccountLogin
}
from
'~/login/lib/index'
Page
({
/**
* 页面的初始数据
*/
data
:
{
/**accountLevel 1工厂。2省 ,3市。4门店 */
data
:
{},
onRoute
({
sessionId
})
{
this
.
getListSelectAccount
(
sessionId
)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
this
.
getListSelectAccount
()
},
getListSelectAccount
()
{
wx
.
$util
.
showLoading
(
'加载中...'
)
api
.
getListSelectAccount
().
then
(
res
=>
{
getListSelectAccount
(
sessionId
)
{
wx
.
$api
.
showLoading
(
'加载中...'
)
USERAPI
.
getAccountList
(
sessionId
).
then
(({
code
,
data
,
message
})
=>
{
wx
.
hideLoading
()
console
.
log
(
res
)
let
{
code
,
data
,
message
}
=
res
if
(
code
==
0
)
{
let
{
loginUserInfoList
,
sessionId
}
=
data
wx
.
$util
.
setSessionId
(
sessionId
)
this
.
setData
({
loginUserInfoList
})
}
else
{
wx
.
$util
.
showToast
(
message
)
}
this
.
sessionId
=
sessionId
}
else
wx
.
$api
.
showToast
(
message
)
this
.
setData
({
flag
:
true
})
...
...
@@ -59,48 +59,23 @@ Page({
choiceAccountLogin
()
{
let
{
loginUserInfoList
}
=
this
.
data
let
id
=
null
}
=
this
.
data
,
id
=
null
,
{
sessionId
}
=
this
loginUserInfoList
.
map
(
e
=>
{
if
(
e
.
active
)
id
=
e
.
uuid
})
if
(
!
id
)
{
wx
.
$
util
.
showToast
(
'请选择账号'
)
wx
.
$
api
.
showToast
(
'请选择账号'
)
return
}
wx
.
$util
.
showLoading
()
api
.
selectAccountLogin
({
id
}).
then
(
res
=>
{
let
{
data
,
message
}
=
res
if
(
data
)
{
wx
.
$util
.
setUserInfo
(
data
.
loginUserInfoList
[
0
])
const
SCENE
=
wx
.
$SCENE
if
(
SCENE
)
{
let
{
path
,
query
:
{
scene
}
}
=
SCENE
let
{
target
,
name
}
=
wx
.
$util
.
getSceneId
(
path
)
wx
.
$router
.
reLaunch
(
`
${
target
}
.
${
name
}
`
,
{
scene
})
wx
.
$SCENE
=
null
}
else
{
wx
.
$router
.
reLaunch
(
'tabIndex.index'
)
}
}
else
{
wx
.
$util
.
showToast
(
message
)
}
})
console
.
log
(
sessionId
)
wx
.
$api
.
showLoading
()
selectAccountLogin
({
id
,
sessionId
})
},
/**
* 生命周期函数--监听页面初次渲染完成
...
...
@@ -110,9 +85,7 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
wx
.
hideHomeButton
()
},
onShow
:
function
()
{},
/**
* 生命周期函数--监听页面隐藏
...
...
login/accountItems/accountItems.json
View file @
542b5bd
{
"navigationBarTitleText"
:
"选择账号"
"usingComponents"
:
{
"navigation-bar"
:
"/components/NavigationBar/NavigationBar"
},
"navigationStyle"
:
"custom"
}
\ No newline at end of file
login/accountItems/accountItems.scss
View file @
542b5bd
/* login/accountItems/accountItems.wxss */
@import
'../index/index.scss'
;
page
{
background-color
:
#fff
;
}
.layout
{
margin
:
40rpx
40rpx
0
;
font-size
:
28rpx
;
color
:
#3
33
;
color
:
#3
23436
;
letter-spacing
:
0
;
padding
:
196rpx
32rpx
224rpx
;
position
:
relative
;
&
:
:
after
{
content
:
''
;
width
:
100%
;
height
:
486rpx
;
background
:
url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg.png')
no-repeat
;
background-size
:
100%
486rpx
;
position
:
absolute
;
left
:
0
;
top
:
0
;
z-index
:
-1
;
}
}
.title
{
margin-bottom
:
32rpx
;
font-weight
:
500
;
font-size
:
36rpx
;
color
:
#323436
;
margin-bottom
:
20rpx
;
}
.items
{
width
:
100%
;
min-height
:
10
4
rpx
;
box-shadow
:
0
0
8rpx
0
rgba
(
0
,
0
,
0
,
0
.15
);
min-height
:
10
8
rpx
;
box-shadow
:
0
4rpx
16rpx
0
rgba
(
180
,
186
,
204
,
0
.32
);
padding
:
32rpx
;
margin-bottom
:
40
rpx
;
margin-bottom
:
32
rpx
;
background-color
:
#fff
;
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
box-sizing
:
border-box
;
}
.items
.name
{
.items
.name
{
width
:
calc
(
100%
-
70rpx
);
}
.items
:last-of-type
{
margin-bottom
:
0
;
}
.radio
{
width
:
32
rpx
;
height
:
32
rpx
;
border
:
2rpx
solid
#
cccccc
;
width
:
28
rpx
;
height
:
28
rpx
;
border
:
2rpx
solid
#
DDE3F0
;
border-radius
:
100%
;
transition
:
all
.2s
;
box-sizing
:
border-box
;
}
.icon
{
width
:
36
rpx
;
height
:
36
rpx
;
width
:
28
rpx
;
height
:
28
rpx
;
transition
:
all
.2s
;
display
:
none
;
}
...
...
@@ -48,9 +73,11 @@
.active
.icon
{
display
:
block
;
}
.active
.radio
{
.active
.radio
{
display
:
none
;
}
.btn-box
{
position
:
fixed
;
left
:
0
;
...
...
@@ -62,24 +89,12 @@
align-items
:
center
;
z-index
:
20
;
background-color
:
#fff
;
border-radius
:
40rpx
;
font-size
:
32rpx
;
color
:
#fff
;
letter-spacing
:
13rpx
;
}
.isFullSucreen-btn
{
padding-bottom
:
34px
!
important
;
padding
:
0
32rpx
;
box-sizing
:
border-box
;
}
.btn
{
width
:
calc
(
100%
-
80rpx
);
height
:
80rpx
;
line-height
:
80rpx
;
text-align
:
center
;
background-color
:
#3582EE
;
border-radius
:
16rpx
;
}
.list-not
{
.list-not
{
height
:
calc
(
100vh
-
159px
);
font-size
:
40rpx
;
}
\ No newline at end of file
login/accountItems/accountItems.wxml
View file @
542b5bd
<view class="layout"
style="padding-bottom:{{isFullSucreen?'224rpx':'160rpx'}}"
>
<view class="title">请选择登录的账号</view
>
<view class="list"
>
<block wx:if="{{flag}}
">
<block wx:if="{{loginUserInfoList
}}">
<block wx:for="{{loginUserInfoList}}" wx:key="index
">
<view class="items {{item.active?'active':''}}" bindtap="chooseAccount" data-index="{{index}}
">
<view class="name
">
{{item.merchantName}}{{item.isSuper==true?'(超管)':item.userType==1?'(商户号)':'(员工号)'}}
</view>
<view class="icon"
>
<image src="/images/active-arc.png" /
>
</view
>
<view class='radio' /
>
</view
>
</block
>
</block>
<block wx:else
>
<view class="list-not" style="height: calc(100vh - {{isFullSucreen ? '159' :'125'}}px)" bindtap="getListSelectAccount"
>
点击刷新
</view>
</block
>
</block>
</view
>
<view class="btn-box {{isFullSucreen?'isFullSucreen-btn':''}}"
>
<view class='btn' bindtap="choiceAccountLogin">确定</view
>
</view
>
</view>
<view class="layout">
<navigation-bar navStyle="background-color: rgba(0,0,0,0)">选择账号</navigation-bar
>
<view class="title">请选择登录的账号</view
>
<view class="list
">
<block wx:if="{{flag
}}">
<block wx:if="{{loginUserInfoList.length}}
">
<block wx:for="{{loginUserInfoList}}" wx:key="index
">
<view class="items {{item.active?'active':''}}" bindtap="chooseAccount" data-index="{{index}}
">
<view class="name">
{{item.merchantName}}{{item.isSuper?'(超管)':item.userType==1?'(商户号)':'(员工号)'}}
</view
>
<view class="icon"
>
<image src="https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/radio.png" /
>
</view
>
<view class='radio' /
>
</view
>
</block>
</block
>
<block wx:else
>
<view class="list-not" bindtap="getListSelectAccount">
点击刷新
</view
>
</block>
</block
>
</view
>
<view class="btn-box isFullSucreen"
>
<button class="button" bindtap="choiceAccountLogin">确定</button
>
</view>
</view>
\ No newline at end of file
login/index/components/Box/Box.js
View file @
542b5bd
// login/index/components/LoginBox.js
import
USERAPI
from
'~/api/usersApi/index'
import
{
setSessionId
,
setUserInfo
}
from
'~/utils/cache/storageApi'
import
{
setRouteData
selectAccountLogin
,
setLoginInfo
}
from
'~/login/lib/index'
let
thisPage
Component
({
...
...
@@ -38,11 +35,13 @@ Component({
* 组件的方法列表
*/
methods
:
{
/**隐藏验证码错误 */
hideError
(
name
)
{
if
(
name
==
'code'
)
this
.
setData
({
smsError
:
false
})
},
/**输入回调 */
input
(
e
)
{
const
{
value
...
...
@@ -58,6 +57,7 @@ Component({
this
.
hideError
(
name
)
this
.
checkFormData
()
},
/**清除input value */
clear
(
e
)
{
const
{
name
...
...
@@ -68,6 +68,7 @@ Component({
this
.
hideError
(
name
)
this
.
checkFormData
()
},
/**获取验证码 */
getSmsCode
()
{
const
{
phoneReady
,
...
...
@@ -95,6 +96,7 @@ Component({
wx
.
$api
.
showToast
(
err
||
'发送验证码失败'
)
})
},
/**验证码倒计时 */
countDown
(
countDown
)
{
if
(
countDown
)
this
.
setData
({
count
:
countDown
...
...
@@ -112,6 +114,7 @@ Component({
})
},
1
e3
)
},
/**检查输入框内容 */
checkFormData
()
{
const
{
loginType
,
...
...
@@ -127,11 +130,13 @@ Component({
}
else
thisPage
.
checkLoginBtn
()
}
},
/**显示隐藏密码 */
pwdSwitch
()
{
this
.
setData
({
showPwd
:
!
this
.
data
.
showPwd
})
},
/**手机号&帐号密码登录 */
login
()
{
const
{
formData
,
...
...
@@ -157,12 +162,12 @@ Component({
})
=>
{
this
.
setBtnLoading
(
false
)
if
(
code
==
'0'
)
{
if
(
loginType
==
1
)
this
.
selectAccountLogin
({
id
:
data
.
loginUserInfoList
[
0
].
uuid
,
sessionId
:
data
.
sessionId
})
if
(
loginType
==
1
)
this
.
checkLoginUserInfo
(
data
)
else
{
console
.
log
(
data
)
const
{
sessionId
}
=
data
setLoginInfo
(
data
,
sessionId
)
}
}
else
{
if
(
loginType
==
1
)
this
.
setData
({
...
...
@@ -175,6 +180,7 @@ Component({
this
.
setBtnLoading
(
false
)
})
},
/**微信登录 */
wxLogin
({
detail
})
{
...
...
@@ -185,18 +191,8 @@ Component({
data
,
message
})
=>
{
if
(
code
==
'0'
)
{
const
{
loginUserInfoList
,
sessionId
}
=
data
if
(
loginUserInfoList
.
length
>
1
)
{
wx
.
$router
.
go
(
'login.accountItems'
)
}
else
this
.
selectAccountLogin
({
id
:
loginUserInfoList
[
0
].
uuid
,
sessionId
})
}
else
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
if
(
code
==
'0'
)
this
.
checkLoginUserInfo
(
data
)
else
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
this
.
setBtnLoading
(
false
)
}).
catch
(({
errMsg
...
...
@@ -205,6 +201,23 @@ Component({
this
.
setBtnLoading
(
false
)
})
},
/**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo
({
loginUserInfoList
,
sessionId
})
{
/**多个账号 */
if
(
loginUserInfoList
.
length
>
1
)
wx
.
$router
.
go
(
'login.accountItems'
,
{
sessionId
,
...
thisPage
.
options
})
/**只有一个账号 */
else
selectAccountLogin
({
id
:
loginUserInfoList
[
0
].
uuid
,
sessionId
})
},
/**设置登录按钮loading状态 */
setBtnLoading
(
loading
=
true
)
{
thisPage
.
setData
({
loading
...
...
@@ -213,6 +226,7 @@ Component({
loading
})
},
/**页面初始化 */
async
init
()
{
thisPage
=
wx
.
$router
.
getPageInstance
()
wx
.
$api
.
showLoading
()
...
...
@@ -236,6 +250,7 @@ Component({
this
.
reLogin
()
}
},
/**获取loginToken */
reLogin
(
message
)
{
wx
.
showModal
({
content
:
message
||
'获取loginToken失败'
,
...
...
@@ -246,40 +261,6 @@ Component({
})
=>
{
if
(
confirm
)
this
.
init
()
})
},
selectAccountLogin
({
id
,
sessionId
})
{
const
{
options
:
{
targetPath
}
}
=
thisPage
USERAPI
.
selectAccountLogin
({
id
,
sessionId
}).
then
(({
code
,
data
,
message
})
=>
{
if
(
code
==
'0'
)
{
setUserInfo
(
data
.
loginUserInfoList
[
0
])
setSessionId
(
data
.
sessionId
)
if
(
targetPath
)
{
const
{
url
,
obj
}
=
setRouteData
(
targetPath
)
wx
.
$router
.
reLaunch
(
url
,
obj
)
}
else
wx
.
$router
.
go
(
'pages.index'
)
}
else
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
}).
catch
(({
errMsg
})
=>
{
wx
.
$api
.
showToast
(
errMsg
||
'系统异常'
)
})
}
},
lifetimes
:
{
...
...
login/index/components/Box/Box.scss
View file @
542b5bd
...
...
@@ -68,22 +68,3 @@
}
}
}
.button
{
width
:
100%
!
important
;
height
:
88rpx
;
background
:
#3666FE
;
border-radius
:
8rpx
;
font-weight
:
500
;
font-size
:
28rpx
;
color
:
#FFFFFF
;
line-height
:
88rpx
;
padding
:
0
;
&
[
disabled
]
:not
([
type
])
{
background
:
#CCCED1
!
important
;
color
:
#fff
!
important
;
}
}
.btn-hover
{
opacity
:
.75
;
}
\ No newline at end of file
login/index/components/Box/Box.wxml
View file @
542b5bd
...
...
@@ -23,7 +23,7 @@
</block>
<block wx:else>
<view class="input">
<input type="text" placeholder="填写账号" placeholder-class="placeholder" bindinput="input" data-name="account" value="{{formData.account}}" maxlength="
20
" />
<input type="text" placeholder="填写账号" placeholder-class="placeholder" bindinput="input" data-name="account" value="{{formData.account}}" maxlength="
15
" />
<input-icon show="{{formData.account}}" bindtap="clear" data-name="account" />
</view>
<view class="input">
...
...
login/index/index.js
View file @
542b5bd
...
...
@@ -8,8 +8,7 @@ Page({
loginType
:
0
,
disabled
:
true
},
onRoute
(
options
){
},
onRoute
(
options
)
{},
/**
* 生命周期函数--监听页面加载
*/
...
...
@@ -65,15 +64,14 @@ Page({
loginType
}
=
this
.
data
,
{
data
:
{
formData
,
phoneReady
formData
},
loginToken
}
=
this
.
selectComponent
(
'#box'
)
if
(
loginType
==
0
)
{
disabled
=
loginToken
}
else
disabled
=
loginType
==
1
?
phoneReady
&&
formData
.
code
:
formData
.
phone
&&
this
.
validate
.
methods
.
tel
(
formData
.
phone
)
&&
formData
.
code
:
formData
.
account
&&
formData
.
password
this
.
setData
({
disabled
:
!
disabled
...
...
login/index/index.scss
View file @
542b5bd
...
...
@@ -26,4 +26,22 @@
opacity
:
1
;
transform
:
scale
(
1
);
}
}
.button
{
width
:
100%
!
important
;
height
:
88rpx
;
background
:
var
(
--
btnColor
);
border-radius
:
8rpx
;
font-weight
:
500
;
font-size
:
28rpx
;
color
:
#FFFFFF
;
line-height
:
88rpx
;
padding
:
0
;
&
[
disabled
]
:not
([
type
])
{
background
:
#CCCED1
!
important
;
color
:
#fff
!
important
;
}
}
.btn-hover
{
opacity
:
.75
;
}
\ No newline at end of file
login/lib/index.js
View file @
542b5bd
export
const
setRouteData
=
targetPath
=>
{
import
{
setSessionId
,
setUserInfo
}
from
'~/utils/cache/storageApi'
import
USERAPI
from
'~/api/usersApi/index'
const
setRouteData
=
targetPath
=>
{
let
[
url
,
query
]
=
targetPath
.
split
(
'?'
),
obj
=
{}
if
(
query
)
{
...
...
@@ -11,4 +16,49 @@ export const setRouteData = targetPath => {
url
,
obj
}
}
/**选择账号登录 */
const
selectAccountLogin
=
({
id
,
sessionId
})
=>
{
USERAPI
.
selectAccountLogin
({
id
,
sessionId
}).
then
(({
code
,
data
,
message
})
=>
{
if
(
code
==
'0'
)
{
setLoginInfo
(
data
.
loginUserInfoList
[
0
],
data
.
sessionId
)
}
else
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
})
}
/**设置登录信息 */
const
setLoginInfo
=
(
userInfo
,
sessionId
)
=>
{
setUserInfo
(
userInfo
)
setSessionId
(
sessionId
)
loginSuccess
()
}
/**成功跳转 */
const
loginSuccess
=
()
=>
{
const
{
options
:
{
targetPath
}
}
=
wx
.
$router
.
getPageInstance
()
if
(
targetPath
)
{
const
{
url
,
obj
}
=
setRouteData
(
targetPath
)
wx
.
$router
.
reLaunch
(
url
,
obj
)
}
else
wx
.
$router
.
go
(
'pages.index'
)
}
module
.
exports
=
{
selectAccountLogin
,
loginSuccess
,
setRouteData
,
setLoginInfo
}
\ No newline at end of file
project.private.config.json
View file @
542b5bd
...
...
@@ -17,7 +17,14 @@
{
"name"
:
"携带目标页面"
,
"pathName"
:
"login/loading/loading"
,
"query"
:
"url=%2Fpages%2Ftab%2Foutput%2Foutput%3Fid%3D123"
,
"query"
:
"url=%2Fpages%2Ftab%2Fmine%2Fmine%3Fid%3D123"
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
"选择账号"
,
"pathName"
:
"login/accountItems/accountItems"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
}
...
...
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