张延森 hace 4 años
padre
commit
e237b190eb
Se han modificado 1 ficheros con 26 adiciones y 19 borrados
  1. 26
    19
      src/components/MainPage/index.vue

+ 26
- 19
src/components/MainPage/index.vue Ver fichero

@@ -21,7 +21,7 @@
21 21
           <text @tap="ShowUserIconAuthPopup = false; toIndexPage()">拒绝</text>
22 22
           <view class="flex-item"></view>
23 23
           <text>允许</text>
24
-          <button open-type="getUserInfo" @getuserinfo="GetUserIcon">获取授权</button>
24
+          <button @tap="GetUserIcon">获取授权</button>
25 25
         </view>
26 26
       </view>
27 27
     </view>
@@ -129,27 +129,34 @@ export default {
129 129
       }
130 130
     },
131 131
     GetUserIcon (e) {
132
-      if (e.detail.errMsg === 'getUserInfo:ok') {
133
-        const data = {
134
-          signature: e.detail.signature,
135
-          rawData: e.detail.rawData,
136
-          encryptedData: e.detail.encryptedData,
137
-          iv: e.detail.iv,
138
-          sessionKey: this.UserInfo.sessionKey,
139
-        }
132
+      console.log('-----e------->', e)
133
+
134
+      wx.getUserProfile({
135
+        desc: '用于获取个人昵称与头像等',
136
+        success: (res) => {
137
+          if (res.errMsg === 'getUserProfile:ok') {
138
+            const data = {
139
+              signature: res.signature,
140
+              rawData: res.rawData,
141
+              encryptedData: res.encryptedData,
142
+              iv: res.iv,
143
+              sessionKey: this.UserInfo.sessionKey,
144
+            }
140 145
 
141
-        this.WxAuthUserInfo({ data: { data }}).then(res => {
142
-          this.UpdateUserInfo(res.data.data)
143
-          this.ShowUserIconAuthPopup = false
144
-          if (!this.UserInfo.phone) {
145
-            this.ShowPhoneAuthPopup = true
146
+            this.WxAuthUserInfo({ data: { data }}).then(res => {
147
+              this.UpdateUserInfo(res.data.data)
148
+              this.ShowUserIconAuthPopup = false
149
+              if (!this.UserInfo.phone) {
150
+                this.ShowPhoneAuthPopup = true
151
+              }
152
+            })
153
+          } else {
154
+            if (!this.UserInfo.phone) {
155
+              this.ShowPhoneAuthPopup = true
156
+            }
146 157
           }
147
-        })
148
-      } else {
149
-        if (!this.UserInfo.phone) {
150
-          this.ShowPhoneAuthPopup = true
151 158
         }
152
-      }
159
+      })
153 160
     },
154 161
     GetUserPhone (e) {
155 162
       if (e.detail.errMsg !== 'getPhoneNumber:ok') {