Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
dev
/
zhiliang-light-mp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
844a810d
authored
2019-10-16 15:45:01 +0800
by
simon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
默认提交
1 parent
d96bfccf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
20 deletions
src/component/authorize-comp/authorize-comp.js
src/component/authorize-comp/authorize-comp.wxml
src/component/authorize-comp/authorize-comp.js
View file @
844a810
...
...
@@ -5,6 +5,16 @@ Component({
innerText
:
{
type
:
String
,
value
:
'default value'
,
},
// 用户拒绝授权后是否后退页面
cancelBack
:
{
type
:
Boolean
,
value
:
false
,
},
// 用户拒绝授权后描述
cancelDesc
:
{
type
:
String
,
value
:
"同意授权才能获得更多体验哦~"
,
}
},
data
:
{
...
...
@@ -24,36 +34,71 @@ Component({
name
:
"_evt_hide_mask"
});
},
// 授权成功事件
authComplete
()
{
this
.
triggerEvent
(
'evtcomp'
,
{
name
:
"_evt_auth_complete"
});
},
// 点击暂不授权按钮
cancelAuth
(
e
)
{
this
.
hideMask
();
// this.triggerEvent('evtcomp', {
// name: "_evt_auth_cancel"
// });
// if (this.properties.cancelBack) {
// wx.navigateBack({
// delta: 1
// });
// }
},
// 点击确认授权按钮
bindGetUserInfo
(
e
)
{
wx
.
showLoading
();
this
.
getUserInfo
(
e
.
detail
);
},
// 授权操作
getUserInfo
(
e
)
{
let
_this
=
this
;
// app.globalData.userInfo = e.userInfo;
app
.
post
({
url
:
app
.
api
.
register
,
sid
:
false
,
data
:
{
encryptedData
:
e
.
encryptedData
,
iv
:
e
.
iv
,
code
:
app
.
store
.
getItem
(
"wxcode"
),
tlMemberCode
:
app
.
globalData
.
tlMemberCode
if
(
e
.
encryptedData
&&
e
.
iv
)
{
// 同意授权
app
.
post
({
url
:
app
.
api
.
register
,
sid
:
false
,
data
:
{
encryptedData
:
e
.
encryptedData
,
iv
:
e
.
iv
,
code
:
app
.
store
.
getItem
(
"wxcode"
),
tlMemberCode
:
app
.
globalData
.
tlMemberCode
}
}).
then
((
res2
)
=>
{
wx
.
hideLoading
();
if
(
res2
&&
res2
.
sessionId
)
{
app
.
store
.
setItem
(
'sessionId'
,
res2
.
sessionId
);
}
_this
.
hideMask
();
_this
.
authComplete
();
_this
.
initPage
();
}).
catch
((
err
)
=>
{})
}
else
{
// 取消授权
if
(
_this
.
properties
.
cancelBack
)
{
wx
.
navigateBack
({
delta
:
1
});
}
else
{
if
(
_this
.
properties
.
cancelDesc
)
{
wx
.
showToast
({
title
:
_this
.
properties
.
cancelDesc
,
icon
:
"none"
})
}
}
}).
then
((
res2
)
=>
{
wx
.
hideLoading
();
if
(
res2
&&
res2
.
sessionId
)
{
app
.
store
.
setItem
(
'sessionId'
,
res2
.
sessionId
);
}
_this
.
hideMask
();
_this
.
authComplete
();
_this
.
initPage
();
}).
catch
((
err
)
=>
{})
}
},
/**
...
...
src/component/authorize-comp/authorize-comp.wxml
View file @
844a810
...
...
@@ -10,8 +10,7 @@
</view>
</view>
<view class="btn-wrap">
<!-- <button class="btn gray" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">确认授权</button> -->
<button class="btn btn2" bindtap="hideMask">暂不授权</button>
<button class="btn btn2" bindtap="cancelAuth">暂不授权</button>
<button class="btn" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">确认授权</button>
</view>
</view>
...
...
Please
register
or
sign in
to post a comment