YSBind.dart 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:ysairplane/code/YSTabbar.dart';
  4. import 'package:ysairplane/tools/YSNetWorking.dart';
  5. import 'package:ysairplane/tools/YSTools.dart';
  6. class YSBind extends StatefulWidget {
  7. @override
  8. _YSBindState createState() => _YSBindState();
  9. }
  10. class _YSBindState extends State<YSBind> {
  11. TextEditingController _userName = TextEditingController();
  12. TextEditingController _password = TextEditingController();
  13. bool _isHave = false;
  14. @override
  15. Widget build(BuildContext context) {
  16. return Scaffold(
  17. backgroundColor: Colors.white,
  18. body: SingleChildScrollView(
  19. padding: EdgeInsets.all(wsp(50)),
  20. child: Container(
  21. width: MediaQuery.of(context).size.width,
  22. child: Column(
  23. children: [
  24. Container(
  25. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(190),bottom: hsp(140)),
  26. alignment: Alignment.centerLeft,
  27. child: Row(
  28. children: [
  29. Container(
  30. child: GestureDetector(
  31. child: Text('新建账号',style: TextStyle(fontSize: zsp(30),color: _isHave==false?Color(0xFF3B7EF2):Color(0xFF999999)),),
  32. onTap: (){
  33. setState(() {
  34. _isHave = false;
  35. });
  36. },
  37. ),
  38. margin: EdgeInsets.only(right: wsp(50)),
  39. ),
  40. GestureDetector(
  41. child: Text('已有账号',style: TextStyle(fontSize: zsp(30),color: _isHave==true?Color(0xFF3B7EF2):Color(0xFF999999)),),
  42. onTap: (){
  43. setState(() {
  44. _isHave = true;
  45. });
  46. },
  47. )
  48. ],
  49. )
  50. ),
  51. Container(
  52. height: hsp(90),
  53. padding: EdgeInsets.only(left: wsp(20),right: wsp(20)),
  54. color: Color(0xFFF5F5F7),
  55. child: CupertinoTextField(
  56. placeholder: '请输入账号',
  57. style: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
  58. placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
  59. decoration: BoxDecoration(),
  60. suffix: Icon(Icons.close,color: Color(0xFF75788C),size: hsp(40),),
  61. suffixMode: OverlayVisibilityMode.editing,
  62. controller: _userName,
  63. ),
  64. ),
  65. Container(
  66. height: hsp(90),
  67. padding: EdgeInsets.only(left: wsp(20),right: wsp(20)),
  68. margin: EdgeInsets.only(top: hsp(50)),
  69. color: Color(0xFFF5F5F7),
  70. child: CupertinoTextField(
  71. placeholder: '请输入密码',
  72. style: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
  73. placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)),
  74. decoration: BoxDecoration(),
  75. suffix: Icon(Icons.remove_red_eye,color: Color(0xFF75788C),size: hsp(40),),
  76. suffixMode: OverlayVisibilityMode.editing,
  77. controller: _password,
  78. ),
  79. ),
  80. GestureDetector(
  81. onTap: (){
  82. showGeneralDialog(
  83. context: context,
  84. barrierDismissible:true,
  85. barrierColor: Colors.black.withOpacity(0.6),
  86. barrierLabel: '',
  87. transitionDuration: Duration(milliseconds: 200),
  88. pageBuilder: (BuildContext context, Animation<double> animation,
  89. Animation<double> secondaryAnimation) {
  90. return Center(
  91. child: Container(
  92. height: MediaQuery.of(context).size.height-(MediaQuery.of(context).padding.top+hsp(100)*2),
  93. width: MediaQuery.of(context).size.width-wsp(100),
  94. decoration: BoxDecoration(
  95. color: Colors.white,
  96. borderRadius: BorderRadius.all(Radius.circular(5))
  97. ),
  98. child: Column(
  99. children: [
  100. Container(
  101. height: hsp(100),
  102. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  103. child: Row(
  104. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  105. children: [
  106. Container(),
  107. Text('隐私声明',style: TextStyle(fontSize: zsp(34),color: Color(0xFF242329),decoration: TextDecoration.none),),
  108. Icon(Icons.close,size: hsp(50),color: Color(0xFF242329))
  109. ],
  110. ),
  111. ),
  112. Container(
  113. height: MediaQuery.of(context).size.height-(MediaQuery.of(context).padding.top+hsp(100)*2)-hsp(200),
  114. width: MediaQuery.of(context).size.width-wsp(100),
  115. padding: EdgeInsets.all(wsp(20)),
  116. color: Color(0xFFF9F9F9),
  117. child: Text('',style: TextStyle(fontSize: zsp(30),color: Color(0xFF242329),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  118. ),
  119. Container(
  120. height: hsp(100),
  121. alignment: Alignment.center,
  122. child: Row(
  123. children: [
  124. Container(
  125. width: (MediaQuery.of(context).size.width-wsp(100))/2-wsp(1),
  126. alignment: Alignment.center,
  127. child: Text('不同意',style: TextStyle(fontSize: zsp(34),color: Color(0xFF999999),decoration: TextDecoration.none),),
  128. ),
  129. Container(
  130. height: hsp(100),
  131. width: wsp(2),
  132. color: Color(0xFFF9F9F9),
  133. ),
  134. Container(
  135. width: (MediaQuery.of(context).size.width-wsp(100))/2-wsp(1),
  136. alignment: Alignment.center,
  137. child: Text('同意',style: TextStyle(fontSize: zsp(34),color: Color(0xFF0079FF),decoration: TextDecoration.none),),
  138. )
  139. ],
  140. )
  141. ),
  142. ],
  143. ),
  144. ),
  145. );
  146. }
  147. );
  148. },
  149. child: GestureDetector(
  150. onTap: (){
  151. FocusScope.of(context).unfocus();
  152. _postCreateAccountData();
  153. },
  154. child: Container(
  155. height: hsp(90),
  156. width: MediaQuery.of(context).size.width-wsp(50)*2,
  157. alignment: Alignment.center,
  158. margin: EdgeInsets.only(top: hsp(116)),
  159. decoration: BoxDecoration(
  160. color: Color(0xFF3B7EF2),
  161. borderRadius: BorderRadius.all(Radius.circular(5))
  162. ),
  163. child: Text('注册绑定',style: TextStyle(fontSize: zsp(34),color: Colors.white),),
  164. ),
  165. ),
  166. ),
  167. ],
  168. ),
  169. ),
  170. ),
  171. );
  172. }
  173. _postCreateAccountData() async{
  174. if(_userName.text.isEmpty){
  175. ysFlutterToast(context, '账号不能为空');
  176. return;
  177. }
  178. if(_password.text.isEmpty){
  179. ysFlutterToast(context, '密码不能为空');
  180. return;
  181. }
  182. var result = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/createAccount',parameter: {'username':_userName.text,'password':_password.text},isLoading: true,isToken: true);
  183. if(result!=null){
  184. Navigator.pushAndRemoveUntil(context,
  185. MaterialPageRoute(
  186. builder: (context){
  187. return YSTabbar();
  188. }
  189. ), (route) => false);
  190. }
  191. }
  192. }