123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:ysairplane2/code/YSTabbar.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- class YSBind extends StatefulWidget {
- final String phoneStr;
- const YSBind({Key key, this.phoneStr}) : super(key: key);
- @override
- _YSBindState createState() => _YSBindState();
- }
- class _YSBindState extends State<YSBind> {
- TextEditingController _userName = TextEditingController();
- TextEditingController _password = TextEditingController();
- bool _isHave = false;
- @override
- void initState() {
- if(widget.phoneStr!=null){
- _userName.text = widget.phoneStr;
- }
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.white,
- body: SingleChildScrollView(
- padding: EdgeInsets.all(wsp(50)),
- child: Container(
- width: MediaQuery.of(context).size.width,
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(190),bottom: hsp(140)),
- alignment: Alignment.centerLeft,
- child: Row(
- children: [
- Container(
- child: GestureDetector(
- child: Text('新建账号',style: TextStyle(fontSize: zsp(30),color: _isHave==false?Color(0xFF3B7EF2):Color(0xFF999999)),),
- onTap: (){
- setState(() {
- _isHave = false;
- });
- },
- ),
- margin: EdgeInsets.only(right: wsp(50)),
- ),
- GestureDetector(
- child: Text('已有账号',style: TextStyle(fontSize: zsp(30),color: _isHave==true?Color(0xFF3B7EF2):Color(0xFF999999)),),
- onTap: (){
- setState(() {
- _isHave = true;
- });
- },
- )
- ],
- )
- ),
- Container(
- height: hsp(90),
- padding: EdgeInsets.only(left: wsp(20),right: wsp(20)),
- 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: _userName,
- ),
- ),
- Container(
- height: hsp(90),
- padding: EdgeInsets.only(left: wsp(20),right: wsp(20)),
- margin: EdgeInsets.only(top: hsp(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.remove_red_eye,color: Color(0xFF75788C),size: hsp(40),),
- suffixMode: OverlayVisibilityMode.editing,
- controller: _password,
- ),
- ),
- GestureDetector(
- onTap: (){
- showGeneralDialog(
- context: context,
- barrierDismissible:true,
- barrierColor: Colors.black.withOpacity(0.6),
- barrierLabel: '',
- transitionDuration: Duration(milliseconds: 200),
- pageBuilder: (BuildContext context, Animation<double> animation,
- Animation<double> secondaryAnimation) {
- return Center(
- child: Container(
- height: MediaQuery.of(context).size.height-(MediaQuery.of(context).padding.top+hsp(100)*2),
- width: MediaQuery.of(context).size.width-wsp(100),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(100),
- padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(),
- Text('隐私声明',style: TextStyle(fontSize: zsp(34),color: Color(0xFF242329),decoration: TextDecoration.none),),
- Icon(Icons.close,size: hsp(50),color: Color(0xFF242329))
- ],
- ),
- ),
- Container(
- height: MediaQuery.of(context).size.height-(MediaQuery.of(context).padding.top+hsp(100)*2)-hsp(200),
- width: MediaQuery.of(context).size.width-wsp(100),
- padding: EdgeInsets.all(wsp(20)),
- color: Color(0xFFF9F9F9),
- child: Text('',style: TextStyle(fontSize: zsp(30),color: Color(0xFF242329),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
- ),
- Container(
- height: hsp(100),
- alignment: Alignment.center,
- child: Row(
- children: [
- Container(
- width: (MediaQuery.of(context).size.width-wsp(100))/2-wsp(1),
- alignment: Alignment.center,
- child: Text('不同意',style: TextStyle(fontSize: zsp(34),color: Color(0xFF999999),decoration: TextDecoration.none),),
- ),
- Container(
- height: hsp(100),
- width: wsp(2),
- color: Color(0xFFF9F9F9),
- ),
- Container(
- width: (MediaQuery.of(context).size.width-wsp(100))/2-wsp(1),
- alignment: Alignment.center,
- child: Text('同意',style: TextStyle(fontSize: zsp(34),color: Color(0xFF0079FF),decoration: TextDecoration.none),),
- )
- ],
- )
- ),
- ],
- ),
- ),
- );
- }
- );
- },
- child: GestureDetector(
- onTap: (){
- FocusScope.of(context).unfocus();
- _postCreateAccountData();
- },
- child: Container(
- height: hsp(90),
- width: MediaQuery.of(context).size.width-wsp(50)*2,
- alignment: Alignment.center,
- margin: EdgeInsets.only(top: hsp(116)),
- decoration: BoxDecoration(
- color: Color(0xFF3B7EF2),
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- child: Text('注册绑定',style: TextStyle(fontSize: zsp(34),color: Colors.white),),
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
- _postCreateAccountData() async{
- if(_userName.text.isEmpty){
- ysFlutterToast(context, '账号不能为空');
- return;
- }
- if(_password.text.isEmpty){
- ysFlutterToast(context, '密码不能为空');
- return;
- }
- var result = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/createAccount',
- parameter: {'username':_userName.text,'password':_password.text},isLoading: true,isToken: true);
- if(result!=null){
- Navigator.pushAndRemoveUntil(context,
- MaterialPageRoute(
- builder: (context){
- return YSTabbar();
- }
- ), (route) => false);
- }
- }
- }
|