HarmonyOS 如何实现滑动验证码功能

HarmonyOS 如何实现滑动验证码功能

HarmonyOS
2024-08-11 13:53:30
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

请参考以下代码示例:

import promptAction from '@ohos.promptAction' 
let customDialogId: number = 0; 
let sliderValue = 0; 
@Builder 
function customDialogBuilder() { 
  Column() { 
    Row({space:20}){ 
      Text('安全验证').fontSize(26) 
        .width('80%') 
        .height(60) 
        .textAlign(TextAlign.Center) 
        .lineHeight(60) 
      Image($r('app.media.error')) 
        .width(26) 
        .height(26) 
        .onClick(() => { 
          promptAction.closeCustomDialog(customDialogId) 
        }) 
    } 
    .margin({bottom:16}) 
    Stack() { 
      Text("请滑到最右端") 
        .fontSize(20) 
        .onClick(() => { 
          promptAction.closeCustomDialog(customDialogId) 
        }) 
      Slider({ style: SliderStyle.InSet, value: sliderValue }) 
        .trackColor('rgba(40,40,40,0.5)') 
        .selectedColor('rgba(200,200,200,1)') 
        .trackThickness(66) 
        .blockStyle({ type: SliderBlockType.IMAGE, image: $r('app.media.arrow') }) 
        .onChange((value: number, mode: SliderChangeMode) => { 
          if(value == 100) { 
            promptAction.closeCustomDialog(customDialogId) 
          } 
        }) 
    } 
    .height(90) 
    .width('80%') 
  }.height(220).padding(5) 
} 
@Entry 
@Component 
struct Index { 
  @State message: string = '获取验证码' 
  build() { 
    Row() { 
      Column() { 
        Button(this.message) 
          .fontSize(50) 
          .padding(16) 
          .onClick(() => { 
            promptAction.openCustomDialog({ 
              builder: customDialogBuilder.bind(this) 
            }).then((dialogId: number) => { 
              customDialogId = dialogId 
            }) 
          }) 
      } 
      .width('100%') 
    } 
    .height('100%') 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
分享
微博
QQ
微信
回复
2024-08-11 21:11:04
相关问题
实现验证码登录之前的滑动验证实现
797浏览 • 1回复 待解决
HarmonyOS 申请验证码demo实现
820浏览 • 1回复 待解决
HarmonyOS 验证码输入样式
806浏览 • 1回复 待解决
前端验证码配合后端的实现思路?
4145浏览 • 1回复 待解决
如何实现一个验证码弹窗子窗口
1211浏览 • 1回复 待解决
密码或验证码登录页面完整代码
3536浏览 • 1回复 待解决