一键授权登陆在 微信开放平台 中创建移动应用,其中安卓应用签名为DCloud应用证书详情中的MD5密文(密文需要去除冒号并转小写)
wxLogin() {
let _this = this;
uni.getProvider({
service: 'oauth',
success: function(res) {
if (~res.provider.indexOf('weixin')) {
uni.showLoading({
title: '微信授权中'
});
uni.login({
provider: 'weixin',
success: function(loginRes) {
uni.getUserInfo({
provider: 'weixin',
success: function(infoRes) {
console.log('infoRes', infoRes)
const clientInfo = plus.push.getClientInfo()
_this.$Net.postAction(_this.$api.login, {
account: infoRes.userInfo.openId,
type: 2,
clientId: clientInfo.clientid
}).then((res) => {
uni.hideLoading();
if (res.result.status != 1) {
_this.$Jump.Open(`/pages/login/bind/bind_phone?loginType=2&account=${infoRes.userInfo.openId}`)
} else {
_this.$DataStore.localSet("userinfo", res.result.userInfo);
_this.$DataStore.localSet("loginInfo", res.result.userInfo);
_this.$DataStore.localSet("token", res.result.userInfo.token);
_this.$Jump.reLaunch('/pages/index/index');
this.$Net.get(this.$api.signQueryByUserId).then(res => {
console.log(res);
if (res.result.status == 0) {
this.$Net.post(this.$api.signAdd).then(res => {
this.$Toast.message('签到成功!');
})
}
})
}
}).catch((er) => {
console.log(er)
uni.hideLoading();
_this.$Toast.message(er);
})
}
});
},
fail: function(er) {
uni.hideLoading();
_this.$Toast.message(er);
}
});
}
},
fail: function(er) {
_this.$Toast.message(er);
}
});
},