Browse Source

授权头像

1002884655 4 years ago
parent
commit
4de53baa32
2 changed files with 22 additions and 1 deletions
  1. 19
    0
      src/components/GetUserIcon/index.vue
  2. 3
    1
      src/pages/HuiQuanYi/index.vue

+ 19
- 0
src/components/GetUserIcon/index.vue View File

60
         success () {
60
         success () {
61
           wx.getUserInfo({ // 授权成功时,获取用户信息
61
           wx.getUserInfo({ // 授权成功时,获取用户信息
62
             success (res) {
62
             success (res) {
63
+              wx.showToast({
64
+                title: res.userInfo.avatarUrl,
65
+                icon: 'none',
66
+                duration: 2000
67
+              })
63
               _that.EditUserInfo({ name: 'Icon', value: res.userInfo.avatarUrl })
68
               _that.EditUserInfo({ name: 'Icon', value: res.userInfo.avatarUrl })
64
               _that.EditUserInfo({ name: 'Name', value: res.userInfo.nickName })
69
               _that.EditUserInfo({ name: 'Name', value: res.userInfo.nickName })
65
               _that.$emit('UserInfoChange')
70
               _that.$emit('UserInfoChange')
66
               _that.Show = false
71
               _that.Show = false
72
+            },
73
+            fail (res) {
74
+              wx.showToast({
75
+                title: '获取头像授权失败',
76
+                icon: 'none',
77
+                duration: 2000
78
+              })
67
             }
79
             }
68
           })
80
           })
81
+        },
82
+        fail (res) {
83
+          wx.showToast({
84
+            title: '自动获取头像授权失败',
85
+            icon: 'none',
86
+            duration: 2000
87
+          })
69
         }
88
         }
70
       })
89
       })
71
     }
90
     }

+ 3
- 1
src/pages/HuiQuanYi/index.vue View File

34
       </view>
34
       </view>
35
 
35
 
36
       <!-- 授权头像获取弹窗 -->
36
       <!-- 授权头像获取弹窗 -->
37
-      <GetUserIcon></GetUserIcon>
37
+      <GetUserIcon v-if="ShowGetUserIcon"></GetUserIcon>
38
 
38
 
39
     </ScrollY>
39
     </ScrollY>
40
   </view>
40
   </view>
51
   name: 'HuiQuanYi',
51
   name: 'HuiQuanYi',
52
   data () {
52
   data () {
53
     return {
53
     return {
54
+      ShowGetUserIcon: false,
54
       PageList: [],
55
       PageList: [],
55
       RequestNum: 0,
56
       RequestNum: 0,
56
       IsRefreshing: false,
57
       IsRefreshing: false,
71
   created () {
72
   created () {
72
     this.$authed(() => {
73
     this.$authed(() => {
73
       this.Init()
74
       this.Init()
75
+      this.ShowGetUserIcon = true
74
     })
76
     })
75
   },
77
   },
76
   methods: {
78
   methods: {