手机好授权
This commit is contained in:
parent
a36ff7e890
commit
a3ad5139b3
@ -129,37 +129,47 @@ Page({
|
||||
let THIS=this;
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let next_url = wx.getStorageSync('next_url');
|
||||
wx.login({
|
||||
success (res) {
|
||||
if (res.code) {
|
||||
console.log('登录成功!' + res.errMsg)
|
||||
var params = {
|
||||
phone_code: e.detail.code,
|
||||
user_type: usertype,
|
||||
wx_code: res.code
|
||||
}
|
||||
api.wechatMobileLogin(params).then(response => {
|
||||
console.log(response);
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
wx.setStorageSync('user_id_'+usertype, response.data.user_id);
|
||||
wx.setStorageSync('client_user_id_'+usertype, response.data.client_user_id);
|
||||
app.globalData.config.userID = response.data.user_id;
|
||||
app.globalData.isLogin=true;
|
||||
let handleGo=function(){
|
||||
wx.switchTab({
|
||||
url: next_url
|
||||
})
|
||||
if(e.detail.errMsg == 'getPhoneNumber:ok'){
|
||||
wx.login({
|
||||
success (res) {
|
||||
if (res.code) {
|
||||
console.log('登录成功!' + res.errMsg)
|
||||
var params = {
|
||||
phone_code: e.detail.code,
|
||||
user_type: usertype,
|
||||
wx_code: res.code
|
||||
}
|
||||
app.imInit({path:'Pages/login/index'},1,handleGo);
|
||||
//跳转页面
|
||||
|
||||
}).catch(errors => {
|
||||
console.error(errors);
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
api.wechatMobileLogin(params).then(response => {
|
||||
console.log(response);
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
wx.setStorageSync('user_id_'+usertype, response.data.user_id);
|
||||
wx.setStorageSync('client_user_id_'+usertype, response.data.client_user_id);
|
||||
app.globalData.config.userID = response.data.user_id;
|
||||
app.globalData.isLogin=true;
|
||||
let handleGo=function(){
|
||||
wx.switchTab({
|
||||
url: next_url
|
||||
})
|
||||
}
|
||||
app.imInit({path:'Pages/login/index'},1,handleGo);
|
||||
//跳转页面
|
||||
|
||||
}).catch(errors => {
|
||||
console.error(errors);
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}else if(e.detail.errMsg == 'getPhoneNumber:fail user deny'){
|
||||
console.log('您拒绝手机号授权')
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: '手机号授权失败',
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
@ -18,11 +18,11 @@
|
||||
wx:if="{{ checked }}"
|
||||
open-type="getPhoneNumber"
|
||||
bindgetphonenumber="getPhoneNumber"
|
||||
color="#09BB07" custom-style="font-size: 36rpx;" type="primary" round block>微信授权手机号登录</van-button>
|
||||
color="#09BB07" custom-style="font-size: 36rpx;" type="primary" round block>手机号快捷登录</van-button>
|
||||
<van-button
|
||||
wx:else
|
||||
bindtap="getPhoneNumber"
|
||||
color="#09BB07" custom-style="font-size: 36rpx;" type="primary" round block>微信授权手机号登录</van-button>
|
||||
color="#09BB07" custom-style="font-size: 36rpx;" type="primary" round block>手机号快捷登录</van-button>
|
||||
|
||||
<view style="display: flex;margin-top: 30rpx;line-height: 50rpx;">
|
||||
<van-checkbox value="{{ checked }}" bind:change="onChange"></van-checkbox>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user