Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-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 4269c4cd
authored
Oct 19, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
合并代码
1 parent
11cbfab2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
300 deletions
pages/authentication/login/login.js
project.private.config.json
pages/authentication/login/login.js
View file @
4269c4c
const
navStyle
=
"background-color: transparent;"
;
const
navStyle
=
'background-color: transparent;'
import
USERAPI
from
'~/api/usersApi/index'
import
WxValidate
from
'~/utils/WxValidate'
import
{
selectAccountLogin
,
setLoginInfo
}
from
'../lib/index'
import
WxValidate
from
'~/utils/wxValidate'
import
{
selectAccountLogin
,
setLoginInfo
}
from
'../lib/index'
Page
({
/**
* 页面的初始数据
*/
data
:
{
navStyle
,
padHeight
:
0
,
padHeight
:
0
,
headerHeight
:
0
,
loginMethod
:
0
,
formData
:{
phone
:
''
,
code
:
''
formData
:
{
phone
:
''
,
code
:
''
},
authorized
:
false
,
phoneReady
:
false
,
disabled
:
true
},
navbarReady
(
e
)
{
let
{
height
}
=
e
.
detail
;
let
{
height
}
=
e
.
detail
this
.
setData
({
headerHeight
:
height
,
})
;
headerHeight
:
height
})
},
/**
...
...
@@ -44,18 +38,12 @@ Page({
async
init
()
{
try
{
const
{
data
,
code
,
message
}
=
await
USERAPI
.
wxCodeLogin
()
const
{
data
,
code
,
message
}
=
await
USERAPI
.
wxCodeLogin
()
if
(
code
==
'0'
)
{
this
.
loginToken
=
data
}
else
this
.
reLogin
(
message
)
wx
.
hideLoading
()
}
catch
({
errMsg
})
{
}
catch
({
errMsg
})
{
console
.
error
(
errMsg
)
this
.
reLogin
()
}
...
...
@@ -66,9 +54,7 @@ Page({
content
:
message
||
'获取loginToken失败'
,
confirmText
:
'重试'
,
confirmColor
:
'#3666FE'
}).
then
(({
confirm
})
=>
{
}).
then
(({
confirm
})
=>
{
if
(
confirm
)
this
.
init
()
})
},
...
...
@@ -85,7 +71,7 @@ Page({
// padHeight: 0
// })
// },
// pageScrollToBottom() {
// pageScrollToBottom() {
// wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) {
// // 使页面滚动到底部
// wx.pageScrollTo({
...
...
@@ -93,197 +79,166 @@ Page({
// })
// }).exec()
// },
handleLogin
(){
const
{
formData
}
=
this
.
data
,
obj
=
{
mobile
:
formData
.
phone
,
code
:
formData
.
code
}
if
(
this
.
data
.
showLoading
)
return
;
this
.
setShowLoading
(
true
)
USERAPI
.
phoneSmsLogin
(
obj
).
then
(({
code
,
data
,
message
,
errId
})
=>
{
this
.
setShowLoading
(
false
)
if
(
code
==
'0'
)
{
this
.
checkLoginUserInfo
(
data
)
}
else
if
(
errId
==
'30990103'
)
{
this
.
setData
({
authorized
:
true
})
}
else
{
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
handleLogin
()
{
const
{
formData
}
=
this
.
data
,
obj
=
{
mobile
:
formData
.
phone
,
code
:
formData
.
code
}
}).
catch
(
err
=>
{
this
.
setShowLoading
(
false
)
wx
.
$api
.
showToast
(
'系统异常'
)
})
if
(
this
.
data
.
showLoading
)
return
this
.
setShowLoading
(
true
)
USERAPI
.
phoneSmsLogin
(
obj
)
.
then
(({
code
,
data
,
message
,
errId
})
=>
{
this
.
setShowLoading
(
false
)
if
(
code
==
'0'
)
{
this
.
checkLoginUserInfo
(
data
)
}
else
if
(
errId
==
'30990103'
)
{
this
.
setData
({
authorized
:
true
})
}
else
{
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
}
})
.
catch
(
err
=>
{
this
.
setShowLoading
(
false
)
wx
.
$api
.
showToast
(
'系统异常'
)
})
},
/**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo
({
loginUserInfoList
,
sessionId
})
{
/**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo
({
loginUserInfoList
,
sessionId
})
{
/**多个账号 */
console
.
log
(
loginUserInfoList
,
'loginUserInfoList'
)
if
(
loginUserInfoList
.
length
>
1
)
wx
.
$router
.
go
(
'/pages/authentication/accountItems/accountItems'
,
{
sessionId
,
...
this
.
options
})
/**只有一个账号 */
else
selectAccountLogin
({
id
:
loginUserInfoList
[
0
].
uuid
,
sessionId
})
console
.
log
(
loginUserInfoList
,
'loginUserInfoList'
)
if
(
loginUserInfoList
.
length
>
1
)
wx
.
$router
.
go
(
'/pages/authentication/accountItems/accountItems'
,
{
sessionId
,
...
this
.
options
})
/**只有一个账号 */
else
selectAccountLogin
({
id
:
loginUserInfoList
[
0
].
uuid
,
sessionId
})
},
switchLoginMethod
(
e
){
const
{
type
}
=
e
.
target
.
dataset
switchLoginMethod
(
e
)
{
const
{
type
}
=
e
.
target
.
dataset
this
.
setData
({
loginMethod
:
type
})
},
input
(
e
){
const
{
value
}
=
e
.
detail
const
{
name
}
=
e
.
target
.
dataset
console
.
log
(
e
,
this
.
data
.
formData
,
'88'
)
input
(
e
)
{
const
{
value
}
=
e
.
detail
const
{
name
}
=
e
.
target
.
dataset
console
.
log
(
e
,
this
.
data
.
formData
,
'88'
)
this
.
setData
({
[
`formData.
${
name
}
`
]
:
value
[
`formData.
${
name
}
`
]:
value
})
this
.
checkInfo
()
},
checkInfo
(){
checkInfo
()
{
this
.
setData
({
phoneReady
:
this
.
validate
.
methods
.
tel
(
this
.
data
.
formData
.
phone
),
disabled
:
!
this
.
validate
.
methods
.
tel
(
this
.
data
.
formData
.
phone
)
||
this
.
data
.
formData
?.
code
?.
length
!=
4
disabled
:
!
this
.
validate
.
methods
.
tel
(
this
.
data
.
formData
.
phone
)
||
this
.
data
.
formData
?.
code
?.
length
!=
4
})
},
/**获取验证码 */
getSmsCode
()
{
const
{
phoneReady
,
formData
,
count
}
=
this
.
data
,
/**获取验证码 */
getSmsCode
()
{
const
{
phoneReady
,
formData
,
count
}
=
this
.
data
,
countDown
=
60
if
(
count
||
!
this
.
data
.
phoneReady
)
return
// this.setData({
// smsLoading: true
// })
USERAPI
.
getSmsCode
(
formData
.
phone
).
then
(({
code
,
message
})
=>
{
// this.setData({
// smsLoading: false
// })
if
(
code
==
'0'
)
this
.
countDown
(
countDown
)
else
wx
.
$api
.
showToast
(
message
||
'发送验证码失败'
)
}).
catch
(
err
=>
{
// this.setData({
// smsLoading: false
// })
wx
.
$api
.
showToast
(
err
||
'发送验证码失败'
)
})
USERAPI
.
getSmsCode
(
formData
.
phone
)
.
then
(({
code
,
message
})
=>
{
// this.setData({
// smsLoading: false
// })
if
(
code
==
'0'
)
this
.
countDown
(
countDown
)
else
wx
.
$api
.
showToast
(
message
||
'发送验证码失败'
)
})
.
catch
(
err
=>
{
// this.setData({
// smsLoading: false
// })
wx
.
$api
.
showToast
(
err
||
'发送验证码失败'
)
})
},
/**验证码倒计时 */
countDown
(
countDown
)
{
if
(
countDown
)
this
.
setData
({
count
:
countDown
})
if
(
countDown
)
this
.
setData
({
count
:
countDown
})
setTimeout
(()
=>
{
let
{
count
}
=
this
.
data
let
{
count
}
=
this
.
data
this
.
setData
({
count
:
--
count
})
if
(
count
>
0
)
this
.
countDown
()
else
this
.
setData
({
count
:
null
})
else
this
.
setData
({
count
:
null
})
},
1
e3
)
},
setShowLoading
(
val
){
setShowLoading
(
val
)
{
this
.
setData
({
showLoading
:
val
})
},
wxLogin
({
detail
})
{
wxLogin
({
detail
})
{
if
(
!
detail
.
code
||
this
.
data
.
showLoading
)
return
this
.
setShowLoading
(
true
)
USERAPI
.
authUserPhone
(
detail
,
this
.
loginToken
).
then
(({
code
,
data
,
message
,
errId
})
=>
{
this
.
setShowLoading
(
false
)
if
(
code
==
'0'
){
this
.
checkLoginUserInfo
(
data
)
}
else
if
(
errId
==
'30990103'
){
this
.
setData
({
authorized
:
true
})
}
else
{
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
}
}).
catch
(({
errMsg
})
=>
{
this
.
setShowLoading
(
false
)
wx
.
$api
.
showToast
(
'系统异常'
)
})
USERAPI
.
authUserPhone
(
detail
,
this
.
loginToken
)
.
then
(({
code
,
data
,
message
,
errId
})
=>
{
this
.
setShowLoading
(
false
)
if
(
code
==
'0'
)
{
this
.
checkLoginUserInfo
(
data
)
}
else
if
(
errId
==
'30990103'
)
{
this
.
setData
({
authorized
:
true
})
}
else
{
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
}
})
.
catch
(({
errMsg
})
=>
{
this
.
setShowLoading
(
false
)
wx
.
$api
.
showToast
(
'系统异常'
)
})
},
goServicePage
(){
goServicePage
()
{
wx
.
$router
.
go
(
'/pages/authentication/customerService/customerService'
)
},
/**
* 生命周期函数--监听页面显示
*/
onShow
()
{
},
onShow
()
{},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
()
{
},
onHide
()
{},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
()
{
},
onUnload
()
{},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
()
{
},
onPullDownRefresh
()
{},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
()
{
},
onReachBottom
()
{},
/**
* 用户点击右上角分享
*/
onShareAppMessage
()
{
}
})
\ No newline at end of file
onShareAppMessage
()
{}
})
project.private.config.json
View file @
4269c4c
{
"setting"
:
{
"compileHotReLoad"
:
false
,
"urlCheck"
:
false
,
"lazyloadPlaceholderEnable"
:
true
},
"condition"
:
{
"miniprogram"
:
{
"list"
:
[
{
"name"
:
"个人中心"
,
"pathName"
:
"pages/tab/mine/mine"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
"编辑"
,
"pathName"
:
"packageMine/pages/editBasicInfo/index"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"pages/authentication/login/login"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"pages/authentication/register/register"
,
"query"
:
"data=%7B%22staffName%22%3A%22%E6%81%92%E6%B2%B3%E7%8C%B4%22%2C%22merchantId%22%3A44184606%2C%22fileUrl%22%3A%22https%3A%2F%2Fimg1.baidu.com%2Fit%2Fu%3D1755961019%2C1690032781%26fm%3D253%26app%3D138%26size%3Dw931%26n%3D0%26f%3DJPEG%26fmt%3Dauto%3Fsec%3D1665766800%26t%3D0b9617eab6fe013e35dc2e491e2e2100%22%7D"
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"pages/authentication/registerSuccess/registerSuccess"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"pages/authentication/registerInfo/registerInfo"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"pages/authentication/customerService/customerService"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/visitor/visitor"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/visitor/visitor"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/visitor/visitor"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/order/order"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/taskDetail/taskDetail"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/taskDetail/taskDetail"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/applyActivity/applyActivity"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/taskDetail/taskDetail"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/taskDetail/taskDetail"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/applySuccess/applySuccess"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/taskDetail/taskDetail"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"packageActivity/pages/order/order"
,
"query"
:
""
,
"launchMode"
:
"default"
,
"scene"
:
null
}
]
}
"urlCheck"
:
true
,
"lazyloadPlaceholderEnable"
:
false
},
"condition"
:
{},
"projectname"
:
"store-assistant"
,
"description"
:
"项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
,
"libVersion"
:
"2.26.1"
...
...
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