鸿蒙harmony 手势密码

embedded/2025/2/10 7:41:15/

1.效果图 

2.设置手势页面代码

/*** 手势密码设置页面*/
@Entry
@Component
struct SettingGesturePage {/*** PatternLock组件控制器*/private patternLockController: PatternLockController = new PatternLockController()/*** 用来保存提示文本信息*/@State message: string = '请绘制解锁图案'/*** 用来保存手势密码*/@State password: Array<number> = []build() {Column({ space: 10 }) {Blank().layoutWeight(1)// 提示Text(this.message).fontSize(16).fontColor(Color.Red)// 手势组件PatternLock(this.patternLockController).sideLength(300).circleRadius(15).pathStrokeWidth(15).autoReset(true).margin({ top: 30, bottom: 30 }).onPatternComplete((input: Array<number>) => {// 根据实际需求修改条件if (input === null || input === undefined || input.length < 5) {this.message = '密码长度需要大于5'return}if (this.password.length > 0) {if (this.password.toString() === input.toString()) {this.password = input// 保存密码this.savePassword()} else {this.message = '密码与上一次不一致,请重新输入'this.patternLockController.reset()}} else {this.password = inputthis.message = '再次输入手势密码'this.patternLockController.reset()}})Blank().layoutWeight(2)}.width('100%').height('100%')}/*** 保存密码,将手势密码发送到后端保存*/savePassword() {// 最终的字符串密码let defaultPassword:string = this.password.toString()/*** 然后根据实际需要是否对字符串密码进行加密,把密码传到后端服务进行保存即可*/// todo 调取后端接口代码。。。。}
}

3.手势登录页面代码

/*** 手势密码登录页面*/
@Entry
@Component
struct GestureLoginPage {private patternLockController: PatternLockController = new PatternLockController()/*** 提示信息*/@State tips: string = ' '/*** 密码数组*/@State passwordArray: Array<number> = []/*** 字符串密码*/@State password: string = ''aboutToAppear() {}build() {Column() {Blank().layoutWeight(1)// 提示Text(this.tips).fontSize(16).fontColor(Color.Red).margin({ top: 20 })// 手势组件PatternLock(this.patternLockController).sideLength(300).circleRadius(15).pathStrokeWidth(15).autoReset(true).margin({ top: 20, bottom: 50 }).onPatternComplete((input: Array<number>) => {if (input === null || input === undefined || input.length < 5) {this.tips = '密码长度需要大于5'return}this.passwordArray = input/*** 根据实际业务调用登录方法/或接口*/this.doGestureLogin()})Blank().layoutWeight(1)}.width('100%').height('100%').justifyContent(FlexAlign.Start)}/*** 手势登录接口*/doGestureLogin() {this.password = this.passwordArray.toString()// todo 登录方法业务逻辑}
}


http://www.ppmy.cn/embedded/161025.html

相关文章

使用deepseek快速创作ppt

目录 1.在DeekSeek生成PPT脚本2.打开Kimi3.最终效果 DeepSeek作为目前最强大模型&#xff0c;其推理能力炸裂&#xff0c;但是DeepSeek官方没有提供生成PPT功能&#xff0c;如果让DeepSeek做PPT呢&#xff1f; 有个途径&#xff1a;在DeepSeek让其深度思考做出PPT脚本&#xf…

【力扣】138.随机链表的复制

AC截图 题目 代码 使用哈希存储<旧节点&#xff0c;新结点> /* // Definition for a Node. class Node { public:int val;Node* next;Node* random;Node(int _val) {val _val;next NULL;random NULL;} }; */class Solution { public:Node* copyRandomList(Node* hea…

DeepSeek-R1技术报告快速解读

相关论文链接如下&#xff1a; DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language ModelsDeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning 文章目录 一、论文脑图二、论文解读2.1 研究背景2.2 研究方法2.3 …

Java基础知识(七) -- 集合

1.概述 集合是 Java 中提供的一种容器&#xff0c;可以用来存储多个数据。集合主要分为两大系列&#xff1a;Collection和Map&#xff0c;Collection 表示一组对象&#xff0c;Map表示一组映射关系或键值对。集合和数组既然都是容器&#xff0c;它们有啥区别呢&#xff1f; 数…

Nginx 日志切割:按日期管理日志文件,提升运维效率

&#x1f3e1;作者主页&#xff1a;点击&#xff01; Nginx-从零开始的服务器之旅专栏&#xff1a;点击&#xff01; &#x1f427;Linux高级管理防护和群集专栏&#xff1a;点击&#xff01; ⏰️创作时间&#xff1a;2025年2月9日11点20分 在日常运维中&#xff0c;Nginx…

idea菜单栏、工具栏、前进后退按钮不显示问题

idea菜单栏、工具栏、前进后退按钮不显示问题 菜单/导航栏不显示 打开 Settings&#xff08;设置&#xff09;&#xff0c;进入 Appearance & Behavior > Appearance > UI Options&#xff0c;勾选 Show main menu in a separate tool bar&#xff08;在单独的工具…

鸿蒙NEXT API使用指导之文件压缩和邮件创建

鸿蒙NEXT API 使用指导 一、前言二、邮件创建1、拉起垂类应用2、 UIAbilityContext.startAbilityByType 原型2.1、wantParam2.2、abilityStartCallback 与 callback 3、拉起邮箱类应用3.1、单纯拉起邮箱应用3.2、传入带附件的邮件 三、压缩文件1、认识 zlib2、压缩处理2.1、单文…

《从入门到精通:蓝桥杯编程大赛知识点全攻略》(八)-摘花生、地宫取宝

前言 在许多算法问题中&#xff0c;动态规划是一种非常有效的技巧&#xff0c;能够在处理最优化问题时提供显著的性能提升。通过将问题拆解成更小的子问题&#xff0c;并利用已解决的子问题来构建最终解&#xff0c;动态规划能够显著减少计算量。在本文中&#xff0c;我们将通…