|
|
|
@ -210,6 +210,7 @@ export default function userMixin() { |
|
|
|
|
|
|
|
// 微信登录
|
|
|
|
function handleWxLogin() { |
|
|
|
// #ifdef H5
|
|
|
|
const origin = `${Config.baseUrl}/pt-mui`; // 测试
|
|
|
|
const appid = 'wxd1842e073e0e6d91'; |
|
|
|
const state = 'wx_web'; |
|
|
|
@ -217,6 +218,44 @@ export default function userMixin() { |
|
|
|
// eslint-disable-next-line
|
|
|
|
window.location.href = |
|
|
|
`${href}?appid=${appid}&redirect_uri=${origin}&response_type=code&scope=snsapi_login&state=${state}#wechat_redirect`; |
|
|
|
// #endif
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
uni.getProvider({ |
|
|
|
service: 'oauth', |
|
|
|
success: function(res) { |
|
|
|
console.log(res.provider); |
|
|
|
//支持微信、qq和微博等
|
|
|
|
if (~res.provider.indexOf('weixin')) { |
|
|
|
uni.login({ |
|
|
|
provider: 'weixin', |
|
|
|
success: function(loginRes) { |
|
|
|
uni.$ui.showToast("App微信获取用户信息成功", loginRes); |
|
|
|
console.log("App微信获取用户信息成功", loginRes); |
|
|
|
// 获取用户信息
|
|
|
|
uni.getUserInfo({ |
|
|
|
provider: 'weixin', |
|
|
|
success: function(infoRes) { |
|
|
|
uni.$ui.showToast('-------获取微信用户所有-----'); |
|
|
|
uni.$ui.showToast(infoRes.userInfo.openId); |
|
|
|
uni.$ui.showToast(JSON.stringify(infoRes.userInfo)); |
|
|
|
console.log('-------获取微信用户所有-----'); |
|
|
|
console.log(infoRes.userInfo.openId); |
|
|
|
console.log(JSON.stringify(infoRes.userInfo)); |
|
|
|
// 提交信息
|
|
|
|
// that.wxSubmit(infoRes.userInfo.openId)
|
|
|
|
} |
|
|
|
}); |
|
|
|
// that.getApploginData(loginRes) //请求登录接口方法
|
|
|
|
}, |
|
|
|
fail: function(res) { |
|
|
|
console.log("App微信获取用户信息失败", res); |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
// #endif
|
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
|