<template>
<view class="content">
<view @click="wxLogin">
<u-image width="76rpx" height="76rpx" src="@/static/images/bindPhone/wxlogo.png" class="logoImg">
</u-image>
</view>
</view>
</template>
<script>
export default ({
data() {
return {}
},
methods: {
wxLogin() {
var that = this;
uni.getProvider({
service: 'oauth',
success: function(res) {
//支持微信、qq和微博等
if (~res.provider.indexOf('weixin')) {
uni.login({
provider: 'weixin',
onlyAuthorize: true,
success: function(loginRes) {
that.$u.get(that.$api.app.wxLogin +
`${uni.getStorageSync('appId')}?code=${loginRes.code}`
)
.then(res => {
if (res.code == 0) {
//授权成功,处理业务
} else {
that.$msg(res.msg)
}
})
},
fail: function(res) {
console.log("App微信获取用户信息失败", res);
}
});
}
}
});
}
}
})
</script>
<style lang="scss">
</style>
版权声明:本文为weixin_42998230原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。