|
@@ -3,7 +3,7 @@
|
3
|
3
|
<view class="centerLabel">
|
4
|
4
|
<image mode="widthFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/morentouxiang.png"></image>
|
5
|
5
|
<text>授权头像</text>
|
6
|
|
- <button open-type="getUserInfo" @tap="ToGetUserIcon">授权头像</button>
|
|
6
|
+ <button open-type="getUserInfo" @getuserinfo="ToGetUserIcon">授权头像</button>
|
7
|
7
|
</view>
|
8
|
8
|
</view>
|
9
|
9
|
</template>
|
|
@@ -53,40 +53,45 @@ export default {
|
53
|
53
|
}
|
54
|
54
|
})
|
55
|
55
|
},
|
56
|
|
- ToGetUserIcon () { // 获取用户头像
|
57
|
|
- let _that = this
|
58
|
|
- wx.authorize({
|
59
|
|
- scope: 'scope.userInfo',
|
60
|
|
- success () {
|
61
|
|
- wx.getUserInfo({ // 授权成功时,获取用户信息
|
62
|
|
- success (res) {
|
63
|
|
- wx.showToast({
|
64
|
|
- title: res.userInfo.avatarUrl,
|
65
|
|
- icon: 'none',
|
66
|
|
- duration: 2000
|
67
|
|
- })
|
68
|
|
- _that.EditUserInfo({ name: 'Icon', value: res.userInfo.avatarUrl })
|
69
|
|
- _that.EditUserInfo({ name: 'Name', value: res.userInfo.nickName })
|
70
|
|
- _that.$emit('UserInfoChange')
|
71
|
|
- _that.Show = false
|
72
|
|
- },
|
73
|
|
- fail (res) {
|
74
|
|
- wx.showToast({
|
75
|
|
- title: '获取头像授权失败',
|
76
|
|
- icon: 'none',
|
77
|
|
- duration: 2000
|
78
|
|
- })
|
79
|
|
- }
|
80
|
|
- })
|
81
|
|
- },
|
82
|
|
- fail (res) {
|
83
|
|
- wx.showToast({
|
84
|
|
- title: '自动获取头像授权失败',
|
85
|
|
- icon: 'none',
|
86
|
|
- duration: 2000
|
87
|
|
- })
|
88
|
|
- }
|
|
56
|
+ ToGetUserIcon (res) { // 获取用户头像
|
|
57
|
+ wx.showToast({
|
|
58
|
+ title: JSON.stringify(res),
|
|
59
|
+ icon: 'none',
|
|
60
|
+ duration: 200000
|
89
|
61
|
})
|
|
62
|
+ // let _that = this
|
|
63
|
+ // wx.authorize({
|
|
64
|
+ // scope: 'scope.userInfo',
|
|
65
|
+ // success () {
|
|
66
|
+ // wx.getUserInfo({ // 授权成功时,获取用户信息
|
|
67
|
+ // success (res) {
|
|
68
|
+ // wx.showToast({
|
|
69
|
+ // title: res.userInfo.avatarUrl,
|
|
70
|
+ // icon: 'none',
|
|
71
|
+ // duration: 2000
|
|
72
|
+ // })
|
|
73
|
+ // _that.EditUserInfo({ name: 'Icon', value: res.userInfo.avatarUrl })
|
|
74
|
+ // _that.EditUserInfo({ name: 'Name', value: res.userInfo.nickName })
|
|
75
|
+ // _that.$emit('UserInfoChange')
|
|
76
|
+ // _that.Show = false
|
|
77
|
+ // },
|
|
78
|
+ // fail (res) {
|
|
79
|
+ // wx.showToast({
|
|
80
|
+ // title: '获取头像授权失败',
|
|
81
|
+ // icon: 'none',
|
|
82
|
+ // duration: 2000
|
|
83
|
+ // })
|
|
84
|
+ // }
|
|
85
|
+ // })
|
|
86
|
+ // },
|
|
87
|
+ // fail (res) {
|
|
88
|
+ // wx.showToast({
|
|
89
|
+ // title: '自动获取头像授权失败',
|
|
90
|
+ // icon: 'none',
|
|
91
|
+ // duration: 2000
|
|
92
|
+ // })
|
|
93
|
+ // }
|
|
94
|
+ // })
|
90
|
95
|
}
|
91
|
96
|
}
|
92
|
97
|
}
|