wx.getUserInfo deprecated
Showing
1 changed file
with
0 additions
and
96 deletions
@@ -121,44 +121,7 @@ function wechatUserIsBind(unionID, nickName) { | @@ -121,44 +121,7 @@ function wechatUserIsBind(unionID, nickName) { | ||
121 | } | 121 | } |
122 | 122 | ||
123 | /** | 123 | /** |
124 | - * 获取unionID、如果用户拒绝授权则无法获得unionID | ||
125 | - * @param srd_session | ||
126 | - * @param showMsg | ||
127 | - * @returns {Promise.<T>} | ||
128 | - */ | ||
129 | -function getUnionID(srd_session, showMsg) { | ||
130 | - let nickName; | ||
131 | - let app = getApp(); | ||
132 | - | ||
133 | - return wx.getUserInfo() | ||
134 | - .then(res => { | ||
135 | - let userInfo = res.userInfo; | ||
136 | - | ||
137 | - nickName = userInfo.nickName; | ||
138 | - return accountModel.decodeUserInfo(srd_session, res.encryptedData, res.iv); | ||
139 | - }) | ||
140 | - .then(data => { | ||
141 | - if (data.data.union_id) { | ||
142 | - app.setUnionID(data.data.union_id); | ||
143 | - return wechatUserIsBind(data.data.union_id, nickName); | ||
144 | - } | ||
145 | - }) | ||
146 | - .catch(() => { | ||
147 | - let msg = { | ||
148 | - succeed: false, | ||
149 | - message: '使用微信小程序登录需要微信授权,您已经拒绝了该请求,请删除小程序重新进入。' | ||
150 | - }; | ||
151 | - | ||
152 | - if (showMsg) { | ||
153 | - msg.code = 10001; | ||
154 | - } | ||
155 | - return Promise.reject(msg); | ||
156 | - }); | ||
157 | -} | ||
158 | - | ||
159 | -/** | ||
160 | * 微信授权登录 | 124 | * 微信授权登录 |
161 | - * @param showMsg | ||
162 | * @returns {Promise.<T>} | 125 | * @returns {Promise.<T>} |
163 | */ | 126 | */ |
164 | function wechatAuthLogin() { // showMsg: 是否显示拒绝授权提示 | 127 | function wechatAuthLogin() { // showMsg: 是否显示拒绝授权提示 |
@@ -188,7 +151,6 @@ function wechatAuthLogin() { // showMsg: 是否显示拒绝授权提示 | @@ -188,7 +151,6 @@ function wechatAuthLogin() { // showMsg: 是否显示拒绝授权提示 | ||
188 | // change: 微信不再支持直接调用wx.getUserInfo | 151 | // change: 微信不再支持直接调用wx.getUserInfo |
189 | // return getUnionID(data.srd_session, showMsg); | 152 | // return getUnionID(data.srd_session, showMsg); |
190 | } else { | 153 | } else { |
191 | - wx.getUserInfo(); | ||
192 | app.setUnionID(data.unionid); | 154 | app.setUnionID(data.unionid); |
193 | return wechatUserIsBind(data.unionid, ''); | 155 | return wechatUserIsBind(data.unionid, ''); |
194 | } | 156 | } |
@@ -200,63 +162,6 @@ function wechatAuthLogin() { // showMsg: 是否显示拒绝授权提示 | @@ -200,63 +162,6 @@ function wechatAuthLogin() { // showMsg: 是否显示拒绝授权提示 | ||
200 | } | 162 | } |
201 | 163 | ||
202 | /** | 164 | /** |
203 | - * 用户手动点击登录 | ||
204 | - * @returns {Promise.<T>} | ||
205 | - */ | ||
206 | -function tapToLogin() { | ||
207 | - let app = getApp(); | ||
208 | - let router = global.router; | ||
209 | - | ||
210 | - if (wx.getSetting) { | ||
211 | - return wx.getSetting() | ||
212 | - .then(res => { | ||
213 | - if (res.authSetting['scope.userInfo']) { | ||
214 | - return router.go('bindMobile'); | ||
215 | - } else { | ||
216 | - return wx.showModal({ | ||
217 | - title: '', | ||
218 | - content: '检测到您未打开微信用户信息授权,开启后即可进行登录', | ||
219 | - confirmText: '去开启', | ||
220 | - confirmColor: '#000000' | ||
221 | - }); | ||
222 | - } | ||
223 | - }) | ||
224 | - .then(res => { | ||
225 | - if (res.confirm) { | ||
226 | - return wx.openSetting(); | ||
227 | - } | ||
228 | - | ||
229 | - if (res.cancel) { | ||
230 | - return router.go('bindMobile'); | ||
231 | - } | ||
232 | - }) | ||
233 | - .then(res => { | ||
234 | - if (res.authSetting['scope.userInfo'] && res.authSetting['scope.userInfo'] === true) { | ||
235 | - return getUnionID(app.getWechatThirdSession()); | ||
236 | - } | ||
237 | - }) | ||
238 | - .then(res => { | ||
239 | - if (res.code === 10003) { // 已经绑定手机号 | ||
240 | - app.setUserInfo(res.data); | ||
241 | - app.setSessionKey(res.data.sessionKey); | ||
242 | - event.emit('user-login-success'); | ||
243 | - event.emit('login-type-report', {LOGIN_TYPE: 4}); | ||
244 | - } | ||
245 | - | ||
246 | - if (res.code === 10004) { // 手动授权登录未绑定强制绑定 | ||
247 | - return router.go('bindMobile'); | ||
248 | - } | ||
249 | - }) | ||
250 | - .catch(() => {}); | ||
251 | - } else { | ||
252 | - return wx.showModal({ | ||
253 | - title: '提示', | ||
254 | - content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' | ||
255 | - }); | ||
256 | - } | ||
257 | -} | ||
258 | - | ||
259 | -/** | ||
260 | * open-type获取用户信息登录绑定 | 165 | * open-type获取用户信息登录绑定 |
261 | */ | 166 | */ |
262 | function getUserInfoLogin(e) { | 167 | function getUserInfoLogin(e) { |
@@ -392,7 +297,6 @@ export { | @@ -392,7 +297,6 @@ export { | ||
392 | isNeedImgCheck, | 297 | isNeedImgCheck, |
393 | getVerifyCode, | 298 | getVerifyCode, |
394 | bindMobileAction, | 299 | bindMobileAction, |
395 | - tapToLogin, | ||
396 | verifySessionKey, | 300 | verifySessionKey, |
397 | getPhoneNumber, | 301 | getPhoneNumber, |
398 | getUserInfoLogin | 302 | getUserInfoLogin |
-
Please register or login to post a comment