Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
肖康
/
photoStore
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a08bab95
authored
Sep 03, 2020
by
肖康
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
获取用户信息JSapi鉴权
parent
e41fa984
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
11 deletions
app.js
pages/detail/detail.js
pages/index/index.js
pages/list/list.js
app.js
View file @
a08bab95
...
...
@@ -3,11 +3,53 @@ App({
// 第一次打开
// options.query == {number:1}
console
.
info
(
'App onLaunch'
);
this
.
getUserInfos
()
},
onShow
(
options
)
{
// 从后台被 scheme 重新打开
// options.query == {number:1}
},
personName
:
"仓库管理员"
personName
:
""
,
getUserInfos
()
{
var
self
=
this
;
dd
.
getAuthCode
({
success
:
(
res
)
=>
{
var
code
=
res
.
authCode
;
dd
.
httpRequest
({
url
:
"https://oapi.dingtalk.com/gettoken?appkey=dingmwxikbdltarcjlb8&appsecret=GUS0_HylYmPcoPYCshqUI3U2ik3r1eu7SyydOCWzUny7SZwDUQb1E1jnW7vpZCvM"
,
success
:
function
(
res
)
{
var
access_token
=
res
.
data
.
access_token
;
dd
.
httpRequest
({
url
:
'https://oapi.dingtalk.com/user/getuserinfo?access_token='
+
access_token
+
'&code='
+
code
,
success
:
function
(
res
)
{
dd
.
httpRequest
({
url
:
'https://oapi.dingtalk.com/user/get?access_token='
+
access_token
+
'&userid='
+
res
.
data
.
userid
,
success
:
function
(
res
)
{
self
.
personName
=
res
.
data
.
name
}
});
},
});
}
})
},
fail
:
(
err
)
=>
{
dd
.
alert
({
content
:
JSON
.
stringify
(
err
)
})
}
})
},
setName
(
self
)
{
// 页面加载完成
let
name_
=
setInterval
(()
=>
{
self
.
setData
({
personName
:
getApp
().
personName
})
if
(
this
.
personName
)
{
clearInterval
(
name_
)
}
},
1000
)
}
});
pages/detail/detail.js
View file @
a08bab95
...
...
@@ -18,9 +18,7 @@ Page({
},
onReady
()
{
// 页面加载完成
this
.
setData
({
personName
:
getApp
().
personName
})
getApp
().
setName
(
this
)
},
getDateList
()
{
axios
({
...
...
@@ -170,6 +168,8 @@ Page({
duration
:
3000
});
}
})
},
onShareAppMessage
()
{
...
...
pages/index/index.js
View file @
a08bab95
...
...
@@ -9,9 +9,7 @@ Page({
},
onReady
()
{
// 页面加载完成
this
.
setData
({
personName
:
getApp
().
personName
})
getApp
().
setName
(
this
)
},
gotoList
(){
dd
.
navigateTo
({
...
...
pages/list/list.js
View file @
a08bab95
...
...
@@ -11,9 +11,7 @@ Page({
onReady
()
{
// 页面加载完成
this
.
setData
({
personName
:
getApp
().
personName
})
getApp
().
setName
(
this
)
},
saoma
()
{
...
...
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