Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wx-shopping-mall
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
engine
wx-shopping-mall
Commits
77a29f17
Commit
77a29f17
authored
May 21, 2020
by
Aivs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆要求必须绑定手机号
parent
c7d8800f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
9 deletions
+64
-9
login.js
pages/auth/login/login.js
+60
-8
login.wxml
pages/auth/login/login.wxml
+4
-1
No files found.
pages/auth/login/login.js
View file @
77a29f17
...
@@ -4,6 +4,10 @@ var user = require('../../../utils/user.js');
...
@@ -4,6 +4,10 @@ var user = require('../../../utils/user.js');
var
app
=
getApp
();
var
app
=
getApp
();
Page
({
Page
({
data
:{
hasLogin
:
false
,
phoneshow
:
false
},
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
// 页面渲染完成
...
@@ -20,6 +24,9 @@ Page({
...
@@ -20,6 +24,9 @@ Page({
},
},
onUnload
:
function
()
{
onUnload
:
function
()
{
// 页面关闭
// 页面关闭
if
(
!
this
.
data
.
phoneshow
){
wx
.
clearStorageSync
(
'token'
)
}
},
},
wxLogin
:
function
(
e
)
{
wxLogin
:
function
(
e
)
{
...
@@ -36,7 +43,58 @@ Page({
...
@@ -36,7 +43,58 @@ Page({
})
})
user
.
loginByWeixin
(
e
.
detail
.
userInfo
).
then
(
res
=>
{
user
.
loginByWeixin
(
e
.
detail
.
userInfo
).
then
(
res
=>
{
app
.
globalData
.
hasLogin
=
true
;
app
.
globalData
.
hasLogin
=
true
;
if
(
getCurrentPages
().
length
>
1
)
{
this
.
setData
({
hasLogin
:
true
})
// if (getCurrentPages().length>1) {
// wx.navigateBack({
// delta: 1
// })
// } else {
// wx.reLaunch({
// url: '/pages/ucenter/index/index',
// })
// }
wx
.
hideLoading
();
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'微信登录失败'
);
});
});
},
bindPhoneNumber
:
function
(
e
)
{
let
that
=
this
;
if
(
e
.
detail
.
errMsg
!==
"getPhoneNumber:ok"
)
{
// 拒绝授权
wx
.
clearStorageSync
(
'token'
)
return
;
}
if
(
!
this
.
data
.
hasLogin
)
{
wx
.
showToast
({
title
:
'绑定失败:请先登录'
,
icon
:
'none'
,
duration
:
2000
});
return
;
}
util
.
request
(
api
.
AuthBindPhone
,
{
iv
:
e
.
detail
.
iv
,
encryptedData
:
e
.
detail
.
encryptedData
},
'POST'
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
phoneshow
:
true
})
wx
.
showToast
({
title
:
'绑定手机号成功'
,
icon
:
'success'
,
duration
:
2000
});
if
(
getCurrentPages
().
length
>
1
)
{
wx
.
navigateBack
({
wx
.
navigateBack
({
delta
:
1
delta
:
1
})
})
...
@@ -45,13 +103,7 @@ Page({
...
@@ -45,13 +103,7 @@ Page({
url
:
'/pages/ucenter/index/index'
,
url
:
'/pages/ucenter/index/index'
,
})
})
}
}
wx
.
hideLoading
();
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'微信登录失败'
);
});
});
});
},
},
accountLogin
:
function
()
{
accountLogin
:
function
()
{
...
...
pages/auth/login/login.wxml
View file @
77a29f17
<view class="container">
<view class="container">
<view class="login-box">
<view wx:if='{{hasLogin}}' class="login-box">
<button class="wx-login-btn" open-type="getPhoneNumber" bindgetphonenumber="bindPhoneNumber">绑定手机号</button>
</view>
<view wx:else class="login-box">
<button open-type="getUserInfo" class="wx-login-btn" bindgetuserinfo="wxLogin">微信直接登录</button>
<button open-type="getUserInfo" class="wx-login-btn" bindgetuserinfo="wxLogin">微信直接登录</button>
<button class="account-login-btn" bindtap="accountLogin">账号登录</button>
<button class="account-login-btn" bindtap="accountLogin">账号登录</button>
</view>
</view>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment