更新记录
1.0.0(2026-05-15)
下载此版本
- 首个版本
平台兼容性
uni-app(5.01)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| - |
- |
- |
- |
- |
- |
- |
- |
14 |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(5.01)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
- |
- |
- |
- |
lzk-hwLogin
华为鸿蒙账号登录插件,支持获取用户 OpenID、UnionID 和授权码,不需要申请一键登录权限,使用调试签名即可
使用方式
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<text class="title">{{ title }}</text>
<button type="primary" @click="handleLogin" class="login-btn">
华为账号登录
</button>
<view v-if="userInfo" class="info-card">
<view class="info-item">
<text class="label">昵称:</text>
<text class="value">{{ userInfo.nickName }}</text>
</view>
<view class="info-item">
<text class="label">UnionID:</text>
<text class="value">{{ userInfo.unionID }}</text>
</view>
</view>
<view v-if="extraInfo" class="info-card success">
<text class="card-title">云函数返回</text>
<text class="value">{{ formatData(extraInfo) }}</text>
</view>
</view>
</template>
<script>
import { huaweiLogin } from '@/uni_modules/lzk-hwLogin'
import { callCloudFunction } from '@/uni_modules/lzk-HWcloudFunction'
export default {
data() {
return {
title: 'Hello',
userInfo: null,
extraInfo: null
}
},
methods: {
handleLogin() {
huaweiLogin({
success: (res) => {
this.userInfo = res;
this.title = `欢迎, ${res.nickName}`;
},
fail: (err) => {
uni.showToast({ title: err, icon: 'none' });
}
});
},
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx;
}
.logo {
width: 180rpx;
height: 180rpx;
margin-bottom: 30rpx;
}
.title {
font-size: 32rpx;
color: #333;
margin-bottom: 40rpx;
}
.login-btn {
width: 80%;
margin-bottom: 30rpx;
}
.info-card {
width: 90%;
padding: 20rpx;
margin-top: 20rpx;
background: #f5f5f5;
border-radius: 10rpx;
}
.info-card.success {
background: #e8f5e9;
border: 1px solid #4caf50;
}
.card-title {
font-size: 28rpx;
font-weight: bold;
display: block;
margin-bottom: 10rpx;
}
.info-item {
display: flex;
padding: 8rpx 0;
}
.label {
font-size: 26rpx;
color: #666;
width: 140rpx;
}
.value {
font-size: 26rpx;
color: #333;
flex: 1;
word-break: break-all;
}
</style>
返回数据说明
成功回调 (success)
authorizationCode: 授权码,用于服务端换取 Access Token
openID: 用户的 OpenID,同一应用下唯一
unionID: 用户的 UnionID,同一开发者下唯一
success: true
err: 'ok'
失败回调 (fail)
注意事项
- 修改插件代码后必须重新制作自定义调试基座才能生效
- 基础权限(OpenID、UnionID)无需在华为开发者后台额外申请
- 仅支持 HarmonyOS Next (API 14+)