YSBind.dart 9.2 KB

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