点击随机数字验证

class LoginDialog extends Dialog {
  /// 弹窗宽度
  final double width;

  /// 弹窗长度
  final double height;

  /// 是否有圆角
  final bool round;
  final TextEditingController? controller;

  /// 确认回调函数
  final void Function()? fn1;
  final VoidCallback press;

  /// 确认按钮文字

  /// 取消回调函数
  final Function(String)? onChanged;

  /// 取消按钮文字

  LoginDialog(
    this.press, {
    Key? key,
    required this.width,
    required this.height,
    this.controller,
    this.round = true,
    this.onChanged,
    this.fn1,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
        type: MaterialType.transparency,
        child: Center(
            child: Container(
          width: width,
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius:
                round != true ? BorderRadius.zero : BorderRadius.circular(32.w),
          ),
          height: height,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Row(
                children: [
                  SizedBox(
                    width: 30.w,
                  ),
                  GetBuilder<InputPhoneController>(builder: (_) {
                    return Container(
                      alignment: Alignment.center,
                      height: 112.w,
                      width: 260.w,
                      child: Image.file(
                        File(_.path),
                        fit: BoxFit.fitWidth,
                      ),
                    );
                  }).onTap(() {
                    fn1?.call();
                  }),
                  SizedBox(
                    width: 20.w,
                  ),
                  Container(
                    alignment: Alignment.center,
                    height: 56 * 2.w,
                    width: 180 * 2.w,
                    decoration: BoxDecoration(
                      color: Colours.greyF5,
                      borderRadius: BorderRadius.circular(136.w),
                    ),
                    child: TextField(
                        onChanged: onChanged,
                        controller: controller,
                        maxLength: 4,
                        decoration: InputDecoration(
                          border: InputBorder.none,
                          counterText: "",
                          hintText: "请输入校验结果",
                          contentPadding: EdgeInsets.only(left: 50.w),
                          hintStyle: TextStyle(
                              fontSize: 28.f,
                              color: Colours.greyB5,
                              fontWeight: FontWeight.w500),
                        )),
                  ).paddingOnly(right: 20.w)
                ],
              ),
              SizedBox(
                height: 44.w,
              ),
              Container(
                height: 112.w,
                width: 624.w,
                child: TongpinPrimaryButton(
                  color: Colours.app_main_blue,
                  text: "获取验证码",
                  press: press,
                ),
              )
            ],
          ),
        )));
  }
}
  void getCode() {
    DioUtil.getInstance()!.requestNetwork(Apis.URL_VERIFICATIONCODE, "get",
        params: {}, onSuccess: (dynamic data) async {
      String path = await FileUtil.createFileFromString(data['code']);
      print(path);
      this.path = path;
      this.key = data['key'];
      update();
    }, onError: (errno, msg) {});
  }

  void comparison() {
    DioUtil.getInstance()!.requestNetwork(Apis.URL_COMPARISION, "get",
        params: {'inCode': value, 'key': key}, onSuccess: (dynamic data) async {
      Get.back();
      sendCode();
    }, onError: (errno, msg) {
      getCode();
      inputController.clear();
      update();
    });
  }
TongpinPrimaryButton(
                          color: controller.complete == true
                              ? Colours.app_main_blue
                              : Colours.app_main_blue_light,
                          text: "获取验证码",
                          press: () async {
                            RegExp exp = RegExp(
                                r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$');
                            bool matched = exp.hasMatch(controller.phoneController.text);
                            if(matched){
                              Navigator.push(
                                context,
                                MaterialPageRoute(builder: (context) {
                                  return BlockPuzzleCaptchaPage(onSuccess: (s){
                                    _.sendCode();
                                  },);
                                }),
                              );
                              _.getCode();
                              await showDialog(
                                barrierColor: Color(0xb2000000),
                                context: context,
                                builder: (BuildContext context) {
                                  return LoginDialog(
                                        () {
                                      _.comparison();
                                      //  _.sendCode();
                                    },
                                    controller: _.inputController,
                                    height: 388.w,
                                    width: 704.w,
                                    fn1: () {
                                      _.getCode();
                                      _.update();
                                    },
                                    onChanged: (v) {
                                      _.value = v;
                                      _.update();
                                    },
                                  );
                                },
                              );
                            }else{
                              ToastUtil.error("请输入正确的手机号");
                            }


                          },
                        );
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值