Skip to content

Commit 1ba70bb

Browse files
committed
update: get user profile in user page
1 parent b744e5e commit 1ba70bb

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

project.config.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"list": []
3737
},
3838
"miniprogram": {
39-
"current": 3,
39+
"current": 4,
4040
"list": [
4141
{
4242
"id": 0,
@@ -61,6 +61,12 @@
6161
"name": "消息",
6262
"pathName": "pages/message/message",
6363
"query": ""
64+
},
65+
{
66+
"id": -1,
67+
"name": "用户",
68+
"pathName": "pages/user/user",
69+
"query": "name=alsotang"
6470
}
6571
]
6672
}

src/pages/user/user.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
Page({
2-
data: {},
3-
onLoad(options) {}
2+
data: {
3+
sUserName: ''
4+
},
5+
onLoad(options) {
6+
if (options.name) {
7+
this.fnGetUserProfile(options.name);
8+
this.setData({
9+
sUserName: options.name
10+
});
11+
}
12+
},
13+
// 获取用户资料
14+
fnGetUserProfile(sUserName) {
15+
wx.dc.user
16+
.detail({
17+
urlData: {
18+
loginname: sUserName
19+
}
20+
})
21+
.then(res => {
22+
console.log(res);
23+
})
24+
.catch(err => {
25+
console.log(err);
26+
});
27+
}
428
});

src/pages/user/user.wxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
<!-- TODO: 完善页面结构与样式 -->
12
<view class="ta-c">敬请期待</view>

0 commit comments

Comments
 (0)