import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterappfuyou/code/base/YSTools.dart';
import 'package:flutterappfuyou/code/version3/YSPerfectChapterInfo.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../YSPage.dart';
import 'YSMeans.dart';
import 'base/YSNetWorking.dart';

class YSLoginRelation extends StatefulWidget {
  final String token;
  const YSLoginRelation({Key key, this.token}) : super(key: key);

  @override
  _YSLoginRelationState createState() => _YSLoginRelationState();
}

class _YSLoginRelationState extends State<YSLoginRelation> {
  TextEditingController _userName = TextEditingController();
  TextEditingController _password = TextEditingController();
  TextEditingController _code = TextEditingController();
  bool _isObscure = true;
  bool _isCode = false;
  bool _isAgree = false;
  @override
  void dispose() {
    _userName.dispose();
    _password.dispose();
    _code.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async{
        return false;
      },
      child: Scaffold(
        backgroundColor: Colors.white,
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+50,left: 50),
                // child: GestureDetector(
                //   child: Icon(Icons.arrow_back_ios,size: 25,color: Colors.pinkAccent,),
                //   onTap: (){
                //     Navigator.pop(context);
                //   },
                // )
              ),
              Container(
                padding: EdgeInsets.only(left: 60,top: 40,right: 60),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('关联账号',style: TextStyle(fontSize: 20,color: Color(0xFF282828)),),
                    Container(
                      margin: EdgeInsets.only(top: 20,bottom: 100),
                      child: Text('如果您还未有平台账号，请返回注册账号,请登录关联账号后，可以使用微信一键登录，快速进入应用。',
                        style: TextStyle(fontSize: 10,color: Color(0xFF707070)),),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(bottom: 10),
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入手机号码',
                        decoration: BoxDecoration(),
                        controller: _userName,
                        keyboardType: TextInputType.phone,
                        prefix: Icon(Icons.edit,size: 20,color: Colors.pinkAccent,),
                        suffix: GestureDetector(
                          onTap: (){
                            _userName.text = '';
                          },
                          child: Container(
                            width: 15,
                            height: 15,
                            decoration: BoxDecoration(
                                color: Colors.pinkAccent,
                                borderRadius: BorderRadius.all(Radius.circular(50))
                            ),
                            child: Icon(Icons.close,size: 10,color: Colors.white,),
                          ),
                        ),
                      ),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      height: 50,
                      decoration: BoxDecoration(
                        border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: _isCode==true?CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入验证码',
                        decoration: BoxDecoration(),
                        controller: _code,
                        prefix: Icon(Icons.security,size: 20,color: Colors.pinkAccent,),
                        suffix: GestureDetector(
                          onTap: (){

                          },
                          child: Container(
                            padding: EdgeInsets.only(top: 5,bottom: 5,left: 10,right: 10),
                            child: Text('获取验证码',style: TextStyle(fontSize: 10,color: Color(0xFFDE577D)),),
                            decoration: BoxDecoration(
                              border: Border.all(color: Color(0xFFDE577D),width: 0.5),
                              borderRadius: BorderRadius.all(Radius.circular(50))
                            ),
                          )
                        ),
                      ):CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入密码',
                        decoration: BoxDecoration(),
                        controller: _password,
                        obscureText: _isObscure,
                        prefix: Icon(Icons.lock_outline,size: 20,color: Colors.pinkAccent,),
                        suffix: GestureDetector(
                          onTap: (){
                            _isObscure = !_isObscure;
                            setState(() {});
                          },
                          child: Icon(Icons.remove_red_eye_outlined,size: 20,color: Colors.pinkAccent,),
                        ),
                      ),
                    ),
                    Container(
                      height: 20,
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(top: 10,bottom: 60),
                      alignment: Alignment.centerRight,
                      // child: GestureDetector(
                      //   onTap: (){
                      //     FocusScope.of(context).unfocus();
                      //     _isCode = !_isCode;
                      //     setState(() {});
                      //   },
                      //   child: Text(_isCode==false?'验证码登录':'账号密码登陆',style: TextStyle(fontSize: 12,color: Colors.pinkAccent,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
                      // )
                    ),
                    CupertinoButton(
                      padding: EdgeInsets.all(0),
                      child: Container(
                        width: MediaQuery.of(context).size.width-100,
                        height: 40,
                        decoration: BoxDecoration(
                          color: Color(0xFFEA6C8F),
                          borderRadius: BorderRadius.all(Radius.circular(20))
                        ),
                        alignment: Alignment.center,
                        child: Text(_isCode?'登陆':'绑定',style: TextStyle(fontSize: 16,color: Colors.white,decoration: TextDecoration.none),),
                      ),
                      onPressed: (){
                        FocusScope.of(context).unfocus();
                        loginToPage();
                        // loginToPage();
                      },
                    ),
                    // Container(
                    //   margin: EdgeInsets.only(top: 200),
                    //   child: RichText(
                    //     text: TextSpan(
                    //         style: TextStyle(fontSize: 12,color: Color(0xFF292929),
                    //             decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                    //         children: [
                    //           WidgetSpan(
                    //             alignment: PlaceholderAlignment.middle,
                    //             child: GestureDetector(
                    //               onTap: (){
                    //                 _isAgree = !_isAgree;
                    //                 setState(() {});
                    //               },
                    //               child: Icon(_isAgree==true?Icons.check_circle:Icons.radio_button_unchecked,
                    //                 size: 20,color: _isAgree==true?Colors.pinkAccent:Colors.grey,),
                    //             )
                    //           ),
                    //           TextSpan(
                    //             text: ' 我已阅读并同意'
                    //           ),
                    //           TextSpan(
                    //             text: '《用户协议》',
                    //             style: TextStyle(color: Colors.pinkAccent)
                    //           ),
                    //           TextSpan(
                    //             text: '及'
                    //           ),
                    //           TextSpan(
                    //             text: '《隐私协议》',
                    //             style: TextStyle(color: Colors.pinkAccent)
                    //           )
                    //         ]
                    //     ),
                    //   ),
                    // )
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  loginToPage() async{
    if(_userName.text.isEmpty){
      ysFlutterToast(context,'用户名不能为空');
      return;
    }
    if(_password.text.isEmpty){
      ysFlutterToast(context,'密码不能为空');
      return;
    }
    if(_password.text.length<6){
      ysFlutterToast(context,'密码长度不能小于6位');
      return;
    }
    Map dict = await ysRequestHttp(context,requestType.post, 'sign/in', {
      'username':_userName.text,
      'password':_password.text,
      'token':widget.token
    });
    if(dict!=null){
      SharedPreferences  _perfer = await SharedPreferences.getInstance();
      _perfer.setString('token', dict['data'].toString());
      toPage(context);
    }
  }
}

class YSLoginRelation2 extends StatefulWidget {
  final String bindCode;
  const YSLoginRelation2({Key key, this.bindCode}) : super(key: key);

  @override
  _YSLoginRelation2State createState() => _YSLoginRelation2State();
}

class _YSLoginRelation2State extends State<YSLoginRelation2> {
  TextEditingController _userName = TextEditingController();
  TextEditingController _code = TextEditingController();
  int _count = 60;
  Timer _timer;
  @override
  void dispose() {
    if(_timer!=null){
      _timer.cancel();
    }
    _userName.dispose();
    _code.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async{
        return true;
      },
      child: Scaffold(
        backgroundColor: Colors.white,
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+50,left: 50),
              ),
              Container(
                padding: EdgeInsets.only(left: 60,top: 40,right: 60),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('关联账号',style: TextStyle(fontSize: 20,color: Color(0xFF282828)),),
                    Container(
                      margin: EdgeInsets.only(top: 20,bottom: 50),
                      child: Text('为了保障您的账号安全，请完成手机号绑定操',
                        style: TextStyle(fontSize: 10,color: Color(0xFF707070)),),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(bottom: 10),
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入手机号码',
                        decoration: BoxDecoration(),
                        controller: _userName,
                        keyboardType: TextInputType.phone,
                        prefix: Image.asset('lib/images/phone_fy.png',height: 20,width: 20,),
                        suffix: GestureDetector(
                          onTap: (){
                            _userName.text = '';
                          },
                          child: Container(
                            width: 15,
                            height: 15,
                            decoration: BoxDecoration(
                                color: Colors.pinkAccent,
                                borderRadius: BorderRadius.all(Radius.circular(50))
                            ),
                            child: Icon(Icons.close,size: 10,color: Colors.white,),
                          ),
                        ),
                      ),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入验证码',
                        decoration: BoxDecoration(),
                        controller: _code,
                        prefix: Image.asset('lib/images/lock_fy.png',height: 20,width: 20,),
                        suffix: GestureDetector(
                            onTap: () async{
                              getCode();
                            },
                            child: Text('｜   ${_count==60?'获取验证码':'     $_count秒'}',style: TextStyle(fontSize: 10,color: Color(0xFFDE577D)),)
                        ),
                      ),
                    ),
                    Container(
                      height: 20,
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(top: 10,bottom: 60),
                      alignment: Alignment.centerRight,
                    ),
                    CupertinoButton(
                      padding: EdgeInsets.all(0),
                      child: Container(
                        width: MediaQuery.of(context).size.width-100,
                        height: 40,
                        decoration: BoxDecoration(
                            color: Color(0xFFEA6C8F),
                            borderRadius: BorderRadius.all(Radius.circular(20))
                        ),
                        alignment: Alignment.center,
                        child: Text('下一步',style: TextStyle(fontSize: 16,color: Colors.white,decoration: TextDecoration.none),),
                      ),
                      onPressed: (){
                        FocusScope.of(context).unfocus();
                        loginToPage();
                        // loginToPage();
                      },
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  getCode() {
    if(_count!=60)return;
    FocusScope.of(context).unfocus();
    if(_userName.text.isEmpty){
      ysFlutterToast(context,'手机号码不能为空');
      return;
    }
    _timer =Timer.periodic(Duration(milliseconds: 1000), (timer) {
      _count--;
      if(_count<=0){
        _count = 60;
        timer.cancel();
      }
      setState(() {});
    });
    ysRequestHttp(context,requestType.post, 'sign/sendSms', {'phone':_userName.text,'type':'login'});
  }

  loginToPage() async{
    if(_userName.text.isEmpty){
      ysFlutterToast(context,'用户名不能为空');
      return;
    }
    if(_code.text.isEmpty){
      ysFlutterToast(context,'验证码不能为空');
      return;
    }
    Map dict = await ysRequestHttp(context,requestType.post, 'sign/bindPhoneByCode', {
      'phone':_userName.text,
      'code':_code.text,
      'bind_code':widget.bindCode
    });
    if(dict!=null){
      Map data = dict['data'];
      SharedPreferences  _perfer = await SharedPreferences.getInstance();
      _perfer.setString('token', data['token'].toString());
      if(data['is_need_password']==false){
        Navigator.pushAndRemoveUntil(context, MaterialPageRoute(
            builder: (context){
              return YSPage();
            }
        ), (route) => false);
        return;
        toPage(context);
      }else{
        Navigator.pushAndRemoveUntil(context, MaterialPageRoute(
            builder: (context){
              return YSLoginRelation3(phone: _userName.text,);
            }
        ), (route) => false);
      }
    }
  }
}

class YSLoginRelation3 extends StatefulWidget {
  final String phone;
  const YSLoginRelation3({Key key, this.phone}) : super(key: key);

  @override
  _YSLoginRelation3State createState() => _YSLoginRelation3State();
}

class _YSLoginRelation3State extends State<YSLoginRelation3> {
  TextEditingController _phone = TextEditingController();
  TextEditingController _name = TextEditingController();
  TextEditingController _pass = TextEditingController();
  TextEditingController _word = TextEditingController();
  bool _isObscure1 = true;
  bool _isObscure2 = true;
  @override
  void initState() {
    _phone.text = widget.phone??'';
    super.initState();
  }
  @override
  void dispose() {
    _phone.dispose();
    _name.dispose();
    _pass.dispose();
    _word.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async{
        return false;
      },
      child: Scaffold(
        backgroundColor: Colors.white,
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+50,left: 50),
              ),
              Container(
                padding: EdgeInsets.only(left: 60,top: 40,right: 60),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('关联账号',style: TextStyle(fontSize: 20,color: Color(0xFF282828)),),
                    Container(
                      margin: EdgeInsets.only(top: 20,bottom: 50),
                      child: Text('请使用您的手机号码绑定微信，以便下次使用微信一键登陆,您也可以使用设置的手机号码和密码进行登陆。',
                        style: TextStyle(fontSize: 10,color: Color(0xFF707070)),),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(bottom: 10),
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入手机号码',
                        decoration: BoxDecoration(),
                        controller: _phone,
                        keyboardType: TextInputType.phone,
                        prefix: Image.asset('lib/images/phone_fy.png',height: 20,width: 20,),
                        onChanged: (value){setState(() {});},
                        suffix: _phone.text.isEmpty?Container(width: 15,):GestureDetector(
                          onTap: (){
                            _phone.text = '';
                            setState(() {});
                          },
                          child: Container(
                            width: 15,
                            height: 15,
                            decoration: BoxDecoration(
                                color: Colors.pinkAccent,
                                borderRadius: BorderRadius.all(Radius.circular(50))
                            ),
                            child: Icon(Icons.close,size: 10,color: Colors.white,),
                          ),
                        ),
                      ),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(bottom: 10),
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入昵称',
                        decoration: BoxDecoration(),
                        controller: _name,
                        prefix: Image.asset('lib/images/name_fy.png',height: 20,width: 20,),
                        onChanged: (value){setState(() {});},
                        suffix: _name.text.isEmpty?Container(width: 15,):GestureDetector(
                          onTap: (){
                            _name.text = '';
                            setState(() {});
                          },
                          child: Container(
                            width: 15,
                            height: 15,
                            decoration: BoxDecoration(
                                color: Colors.pinkAccent,
                                borderRadius: BorderRadius.all(Radius.circular(50))
                            ),
                            child: Icon(Icons.close,size: 10,color: Colors.white,),
                          ),
                        ),
                      ),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(bottom: 10),
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请输入密码',
                        decoration: BoxDecoration(),
                        controller: _pass,
                        prefix: Image.asset('lib/images/lock_fy.png',height: 20,width: 20,),
                        onChanged: (value){setState(() {});},
                        obscureText: _isObscure1,
                        suffix: _pass.text.isEmpty?Container(width: 15,):Row(
                          children: [
                            GestureDetector(
                              onTap: (){
                                _isObscure1 = !_isObscure1;
                                setState(() {});
                              },
                              child: Image.asset('lib/images/${_isObscure1?'eye-slash':'eye'}.png',height: 20,width: 20,),
                            ),
                            GestureDetector(
                              onTap: (){
                                _pass.text = '';
                                setState(() {});
                              },
                              child: Container(
                                margin: EdgeInsets.only(left: 5),
                                width: 15,
                                height: 15,
                                decoration: BoxDecoration(
                                    color: Colors.pinkAccent,
                                    borderRadius: BorderRadius.all(Radius.circular(50))
                                ),
                                child: Icon(Icons.close,size: 10,color: Colors.white,),
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(bottom: 10),
                      height: 50,
                      decoration: BoxDecoration(
                          border: Border(bottom: BorderSide(color: Color(0xFFD7D7D7),width: 0.5))
                      ),
                      child: CupertinoTextField(
                        style: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholderStyle: TextStyle(fontSize: 12,color: Color(0xFF808080),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
                        placeholder: '请确认密码',
                        decoration: BoxDecoration(),
                        controller: _word,
                        prefix: Image.asset('lib/images/phone_fy.png',height: 20,width: 20,),
                        onChanged: (value){setState(() {});},
                        obscureText: _isObscure2,
                        suffix: _word.text.isEmpty?Container(width: 30,):Row(
                          children: [
                            GestureDetector(
                              onTap: (){
                                _isObscure2 = !_isObscure2;
                                setState(() {});
                              },
                              child: Image.asset('lib/images/${_isObscure2?'eye-slash':'eye'}.png',height: 20,width: 20,),
                            ),
                            GestureDetector(
                              onTap: (){
                                _word.text = '';
                                setState(() {});
                              },
                              child: Container(
                                margin: EdgeInsets.only(left: 5),
                                width: 15,
                                height: 15,
                                decoration: BoxDecoration(
                                    color: Colors.pinkAccent,
                                    borderRadius: BorderRadius.all(Radius.circular(50))
                                ),
                                child: Icon(Icons.close,size: 10,color: Colors.white,),
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                    Container(
                      height: 20,
                      width: MediaQuery.of(context).size.width-100,
                      margin: EdgeInsets.only(top: 10,bottom: 40),
                      alignment: Alignment.centerRight,
                    ),
                    CupertinoButton(
                      padding: EdgeInsets.all(0),
                      child: Container(
                        width: MediaQuery.of(context).size.width-100,
                        height: 40,
                        decoration: BoxDecoration(
                            color: Color(0xFFEA6C8F),
                            borderRadius: BorderRadius.all(Radius.circular(20))
                        ),
                        alignment: Alignment.center,
                        child: Text('绑定',style: TextStyle(fontSize: 16,color: Colors.white,decoration: TextDecoration.none),),
                      ),
                      onPressed: (){
                        FocusScope.of(context).unfocus();
                        loginToPage();
                        // loginToPage();
                      },
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  loginToPage() async{
    // return;
    if(_phone.text.isEmpty){
      ysFlutterToast(context,'手机号码不能为空');
      return;
    }
    if(_name.text.isEmpty){
      ysFlutterToast(context,'昵称不能为空');
      return;
    }
    if(_pass.text.isEmpty){
      ysFlutterToast(context,'密码不能为空');
      return;
    }
    if(_word.text.isEmpty){
      ysFlutterToast(context,'确认密码不能为空');
      return;
    }
    if(_pass.text!=_word.text){
      ysFlutterToast(context,'两次密码输入不一致');
      return;
    }
    Map dict = await ysRequestHttp(context,requestType.post, 'user/info', {
      'username':_phone.text,
      'name':_name.text,
      'password':_pass.text,
    });
    if(dict!=null){
      // SharedPreferences  _perfer = await SharedPreferences.getInstance();
      // _perfer.setInt('chapters', 0);
      Navigator.pushAndRemoveUntil(context, MaterialPageRoute(
          builder: (context){
            return YSPerfectChapterInfo(isFirst: true,);
          }
      ), (route) => false);
    }
  }
}