- 发布:2020-09-19 15:49
- 更新:2020-09-28 09:22
- 阅读:662
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 10.15.6
HBuilderX类型: 正式
HBuilderX版本号: 2.8.11
手机系统: 全部
手机厂商: 华为
页面类型: nvue
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
uni.login({
provider: 'weixin',
success: (res) => {
uni.hideLoading();
const accessToken = this.$util.tryGet(res, 'authResult.access_token', '');
const openId = this.$util.tryGet(res, 'authResult.openid', '');
const unionId = this.$util.tryGet(res, 'authResult.unionid', '');
const data = {
accessToken, // 授权token
openId, // 公众号唯一标识
invatorCode: '', // 邀请码
cid: plus.push.getClientInfo().clientid, // 个推标识
appVersion: this.version.split('.').join(''), // app 版本
phoneOs: plus.os.name, // 手机操作系统
phoneOsVersion: plus.os.version, // 操作系统版本
phoneBrand: plus.device.vendor, // 手机厂商
phoneDevice:plus.device.model, // 手机型号
uid:plus.device.uuid, // 唯一识别号
imei:plus.push.getClientInfo().clientid, // 设备标识
idfa:uni.getStorageSync(storage_key.idfa), // ios设备标识
oaid: uni.getStorageSync(storage_key.oaid).oaid, // 安卓10+设备标识
utdid:uni.getStorageSync(storage_key.utdid), // 安卓10+设备标识
loginIp:'' // 登录IP
};
uni.setStorageSync('accessToken', data.accessToken);
uni.setStorageSync('openId', data.openId);
uni.setStorageSync('unionId', data.unionId);
this.$Request.post('/app/login/loginByWxAuth', data)
.then(res => {
// 进入首页 代码就不帖了
})
.catch((error) => {
console.log(error)
uni.hideLoading();
uni.showToast({
icon:'none',
title: '登录异常',
});
})
},
fail: (error) => {
uni.hideLoading();
console.info({
type: 'behavior',
msg: 'login.vue oauth fail [SYSTEM_ERROR]' + JSON.stringify(error)
})
uni.showToast({
icon:'none',
title: '微信授权失败',
});
},
complete: (result) => {
console.log(result)
}
});
uni.login({
provider: 'weixin',
success: (res) => {
uni.hideLoading();
const accessToken = this.$util.tryGet(res, 'authResult.access_token', '');
const openId = this.$util.tryGet(res, 'authResult.openid', '');
const unionId = this.$util.tryGet(res, 'authResult.unionid', '');
const data = {
accessToken, // 授权token
openId, // 公众号唯一标识
invatorCode: '', // 邀请码
cid: plus.push.getClientInfo().clientid, // 个推标识
appVersion: this.version.split('.').join(''), // app 版本
phoneOs: plus.os.name, // 手机操作系统
phoneOsVersion: plus.os.version, // 操作系统版本
phoneBrand: plus.device.vendor, // 手机厂商
phoneDevice:plus.device.model, // 手机型号
uid:plus.device.uuid, // 唯一识别号
imei:plus.push.getClientInfo().clientid, // 设备标识
idfa:uni.getStorageSync(storage_key.idfa), // ios设备标识
oaid: uni.getStorageSync(storage_key.oaid).oaid, // 安卓10+设备标识
utdid:uni.getStorageSync(storage_key.utdid), // 安卓10+设备标识
loginIp:'' // 登录IP
};
uni.setStorageSync('accessToken', data.accessToken);
uni.setStorageSync('openId', data.openId);
uni.setStorageSync('unionId', data.unionId);
this.$Request.post('/app/login/loginByWxAuth', data)
.then(res => {
// 进入首页 代码就不帖了
})
.catch((error) => {
console.log(error)
uni.hideLoading();
uni.showToast({
icon:'none',
title: '登录异常',
});
})
},
fail: (error) => {
uni.hideLoading();
console.info({
type: 'behavior',
msg: 'login.vue oauth fail [SYSTEM_ERROR]' + JSON.stringify(error)
})
uni.showToast({
icon:'none',
title: '微信授权失败',
});
},
complete: (result) => {
console.log(result)
}
});
操作步骤:
可以实现微信登录
可以实现微信登录
预期结果:
可以实现微信登录
可以实现微信登录
实际结果:
可以实现微信登录
可以实现微信登录
bug描述:
微信登录无法使用,每次打基座,一次能用,好几次基座无法使用。 uni.login({
provider: 'weixin',
success:
fail:
complete:
完全没有返回结果。
2 个回复
全盘崩坏 - 此颜差矣!
你是不是微信后台配置和app配置不一样??我用了微信登录,微信分享都没有问题
h***@163.com (作者)
开发工具更新完了,重新打基座包,在安装就好了。每次打包跟抽风似的。