123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:ysairplane2/base/YSBase.dart';
- import 'package:ysairplane2/code/YSInputPayPass.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- class YSSetPayPass extends StatefulWidget {
- @override
- _YSSetPayPassState createState() => _YSSetPayPassState();
- }
- class _YSSetPayPassState extends State<YSSetPayPass> {
- TextEditingController _phoneStr = TextEditingController();
- TextEditingController _codeStr = TextEditingController();
- int _number = 60;
- Timer _timer;
- @override
- void dispose() {
- if(_timer!=null){
- _timer.cancel();
- }
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return YSBase(
- ystitle: '设置支付密码',
- yschild: Column(
- children: [
- Container(
- height: hsp(90),
- padding: EdgeInsets.only(left: wsp(20),right: wsp(20)),
- margin: EdgeInsets.only(top: hsp(138),left: wsp(50),right: wsp(50)),
- color: Color(0xFFF5F5F7),
- child: CupertinoTextField(
- placeholder: '请输入手机号',
- style: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
- placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
- decoration: BoxDecoration(),
- suffix: GestureDetector(child: Text(_number==60?'获取验证码':'$_number秒',style: TextStyle(fontSize: zsp(30),color: Color(0xFF0079FF)),),
- onTap: (){if(_number==60)_getCodeData();},),
- prefix: Container(
- padding: EdgeInsets.only(right: wsp(20)),
- margin: EdgeInsets.only(right: wsp(20)),
- height: hsp(40),
- alignment: Alignment.center,
- child: Text('+86',style: TextStyle(fontSize: zsp(32),color: Color(0xFF1E1721)),),
- decoration: BoxDecoration(
- border: Border(right: BorderSide(color: Color(0xFFCDCDD2)))
- ),
- ),
- keyboardType: TextInputType.phone,
- controller: _phoneStr,
- ),
- ),
- Container(
- height: hsp(90),
- padding: EdgeInsets.only(left: wsp(20),right: wsp(20)),
- margin: EdgeInsets.only(top: hsp(50),left: wsp(50),right: wsp(50)),
- color: Color(0xFFF5F5F7),
- child: CupertinoTextField(
- placeholder: '请输入短信验证码',
- style: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
- placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
- decoration: BoxDecoration(),
- suffix: Icon(Icons.close,color: Color(0xFF75788C),size: hsp(40),),
- suffixMode: OverlayVisibilityMode.editing,
- controller: _codeStr,
- keyboardType: TextInputType.numberWithOptions(),
- ),
- ),
- GestureDetector(
- onTap: (){
- if(_codeStr.text.isEmpty){
- ysFlutterToast(context, '验证码不能为空');
- return;
- }
- FocusScope.of(context).unfocus();
- _timer.cancel();
- Navigator.of(context).push(
- CupertinoPageRoute(
- builder: (context){
- return YSInputPayPass(code: _codeStr.text,);
- }
- )
- );
- },
- child: Container(
- height: hsp(90),
- width: MediaQuery.of(context).size.width-wsp(50)*2,
- alignment: Alignment.center,
- margin: EdgeInsets.only(top: hsp(120)),
- decoration: BoxDecoration(
- color: Color(0xFF3B7EF2),
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- child: Text('下一步',style: TextStyle(fontSize: zsp(34),color: Colors.white),),
- ),
- ),
- ],
- ),
- );
- }
- _getCodeData() async{
- FocusScope.of(context).unfocus();
- if(_phoneStr.text.isEmpty){
- ysFlutterToast(context, '手机号码不能为空');
- return;
- }
- if(isChinaPhoneLegal(_phoneStr.text)==false){
- ysFlutterToast(context, '手机号码格式不正确');
- return;
- }
- _timer = Timer.periodic(Duration(seconds: 1), (timer){
- setState(() {
- if(_number<=1){
- _number = 60;
- _timer.cancel();
- }else{
- _number--;
- }
- });
- });
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/getVerificationCode',parameter: {'phone':_phoneStr.text});
- if(dict!=null){
- }
- }
- }
|