YSInputPayPass.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:ysairplane2/base/YSBase.dart';
  4. import 'package:ysairplane2/tools/YSNetWorking.dart';
  5. import 'package:ysairplane2/tools/YSTools.dart';
  6. class YSInputPayPass extends StatefulWidget {
  7. final String code;
  8. const YSInputPayPass({Key key, this.code}) : super(key: key);
  9. @override
  10. _YSInputPayPassState createState() => _YSInputPayPassState();
  11. }
  12. class _YSInputPayPassState extends State<YSInputPayPass> {
  13. List _passArray = [];
  14. @override
  15. Widget build(BuildContext context) {
  16. return YSBase(
  17. ystitle: '设置支付密码',
  18. yschild: Stack(
  19. children: [
  20. Column(
  21. children: [
  22. Container(
  23. height: hsp(50),
  24. alignment: Alignment.center,
  25. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(150)),
  26. child: Text('设置6位数字支付密码',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333),fontWeight: FontWeight.bold),),
  27. ),
  28. Container(
  29. width: MediaQuery.of(context).size.width-hsp(100),
  30. height: hsp(100),
  31. margin: EdgeInsets.only(top: hsp(200)),
  32. decoration: BoxDecoration(
  33. border: Border.all(color: Color(0xFF108EE9),width: 2),
  34. borderRadius: BorderRadius.all(Radius.circular(5))
  35. ),
  36. child: ListView.separated(
  37. itemBuilder: (context,index){
  38. return Container(
  39. height: hsp(100),
  40. width: (MediaQuery.of(context).size.width-hsp(100)-9)/6,
  41. child: Container(
  42. height: hsp(20),
  43. width: hsp(20),
  44. decoration: BoxDecoration(
  45. color: index<_passArray.length?Colors.black:Colors.transparent,
  46. borderRadius: BorderRadius.all(Radius.circular(50))
  47. ),
  48. ),
  49. alignment: Alignment.center,
  50. );
  51. },
  52. separatorBuilder: (context,index){
  53. return Container(width: 1,color: Color(0xFF9A9A9A),height: hsp(100),);
  54. },
  55. itemCount: 6,
  56. padding: EdgeInsets.all(0),
  57. scrollDirection: Axis.horizontal,
  58. ),
  59. ),
  60. Container(
  61. height: hsp(50),
  62. alignment: Alignment.center,
  63. child: Text('支付密码不能是重复、连续的数字',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  64. ),
  65. ],
  66. ),
  67. Container(
  68. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(432)-MediaQuery.of(context).padding.top-44),
  69. width: MediaQuery.of(context).size.width,
  70. decoration: BoxDecoration(
  71. color: Color(0xFF8C8C8C),
  72. border: Border(top: BorderSide(width: 1,color: Color(0xFF8C8C8C)))
  73. ),
  74. height: hsp(432),
  75. child: GridView.builder(
  76. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  77. crossAxisCount: 3,
  78. mainAxisSpacing: 1,
  79. crossAxisSpacing: 1,
  80. childAspectRatio: ((MediaQuery.of(context).size.width-2)/3)/((hsp(432)-3)/4)
  81. ),
  82. itemBuilder: (context, index) {
  83. return GestureDetector(
  84. onTap: (){
  85. if(index==9){
  86. if(_passArray.length>0){
  87. _passArray.removeAt(_passArray.length-1);
  88. }
  89. setState(() {});
  90. }else if(index==11){
  91. if(_passArray.length==6){
  92. Navigator.of(context).push(
  93. CupertinoPageRoute(
  94. builder: (context){
  95. return YSInputPayPassAgain(code: widget.code,);
  96. }
  97. )
  98. );
  99. }else{
  100. ysFlutterToast(context, '支付密码为6位数字');
  101. }
  102. }else{
  103. if(_passArray.length<6){
  104. _passArray.add(index+1);
  105. setState(() {});
  106. }
  107. }
  108. },
  109. child: Container(
  110. color: index==9||index==11?Color(0xFFD0D5DC):Colors.white,
  111. child: Text(index==9?'删除':index==10?'0':index==11?'确认':'${index+1}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  112. alignment: Alignment.center,
  113. ),
  114. );
  115. },
  116. itemCount: 12,
  117. padding: EdgeInsets.all(0),
  118. physics: NeverScrollableScrollPhysics(),
  119. )
  120. )
  121. ],
  122. ),
  123. );
  124. }
  125. }
  126. class YSInputPayPassAgain extends StatefulWidget {
  127. final String code;
  128. const YSInputPayPassAgain({Key key, this.code}) : super(key: key);
  129. @override
  130. _YSInputPayPassAgainState createState() => _YSInputPayPassAgainState();
  131. }
  132. class _YSInputPayPassAgainState extends State<YSInputPayPassAgain> {
  133. List _passArray = [];
  134. @override
  135. Widget build(BuildContext context) {
  136. return YSBase(
  137. ystitle: '设置支付密码',
  138. yschild: Stack(
  139. children: [
  140. Column(
  141. children: [
  142. Container(
  143. height: hsp(50),
  144. alignment: Alignment.center,
  145. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(150)),
  146. child: Text('请再次填写以确认',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333),fontWeight: FontWeight.bold),),
  147. ),
  148. Container(
  149. width: MediaQuery.of(context).size.width-hsp(100),
  150. height: hsp(100),
  151. margin: EdgeInsets.only(top: hsp(200)),
  152. decoration: BoxDecoration(
  153. border: Border.all(color: Color(0xFF108EE9),width: 2),
  154. borderRadius: BorderRadius.all(Radius.circular(5))
  155. ),
  156. child: ListView.separated(
  157. itemBuilder: (context,index){
  158. return Container(
  159. height: hsp(100),
  160. width: (MediaQuery.of(context).size.width-hsp(100)-9)/6,
  161. child: Container(
  162. height: hsp(20),
  163. width: hsp(20),
  164. decoration: BoxDecoration(
  165. color: index<_passArray.length?Colors.black:Colors.transparent,
  166. borderRadius: BorderRadius.all(Radius.circular(50))
  167. ),
  168. ),
  169. alignment: Alignment.center,
  170. );
  171. },
  172. separatorBuilder: (context,index){
  173. return Container(width: 1,color: Color(0xFF9A9A9A),height: hsp(100),);
  174. },
  175. itemCount: 6,
  176. padding: EdgeInsets.all(0),
  177. scrollDirection: Axis.horizontal,
  178. ),
  179. ),
  180. Container(
  181. height: hsp(50),
  182. alignment: Alignment.center,
  183. child: Text('支付密码不能是重复、连续的数字',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  184. ),
  185. GestureDetector(
  186. onTap: (){
  187. if(_passArray.length==6){
  188. _postPayPassData();
  189. }else{
  190. ysFlutterToast(context, '支付密码为6位数字');
  191. }
  192. },
  193. child: Container(
  194. height: hsp(90),
  195. width: MediaQuery.of(context).size.width-wsp(50)*2,
  196. alignment: Alignment.center,
  197. margin: EdgeInsets.only(top: hsp(80)),
  198. decoration: BoxDecoration(
  199. color: Color(0xFF3B7EF2),
  200. borderRadius: BorderRadius.all(Radius.circular(5))
  201. ),
  202. child: Text('完成',style: TextStyle(fontSize: zsp(34),color: Colors.white),),
  203. ),
  204. ),
  205. ],
  206. ),
  207. Container(
  208. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(432)-MediaQuery.of(context).padding.top-44),
  209. width: MediaQuery.of(context).size.width,
  210. decoration: BoxDecoration(
  211. color: Color(0xFF8C8C8C),
  212. border: Border(top: BorderSide(width: 1,color: Color(0xFF8C8C8C)))
  213. ),
  214. height: hsp(432),
  215. child: GridView.builder(
  216. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  217. crossAxisCount: 3,
  218. mainAxisSpacing: 1,
  219. crossAxisSpacing: 1,
  220. childAspectRatio: ((MediaQuery.of(context).size.width-2)/3)/((hsp(432)-3)/4)
  221. ),
  222. itemBuilder: (context, index) {
  223. return GestureDetector(
  224. onTap: (){
  225. if(index==9){
  226. if(_passArray.length>0){
  227. _passArray.removeAt(_passArray.length-1);
  228. }
  229. setState(() {});
  230. }else if(index==11){
  231. if(_passArray.length==6){
  232. _postPayPassData();
  233. }else{
  234. ysFlutterToast(context, '支付密码为6位数字');
  235. }
  236. }else{
  237. if(_passArray.length<6){
  238. _passArray.add(index+1);
  239. setState(() {});
  240. }
  241. }
  242. },
  243. child: Container(
  244. color: index==9||index==11?Color(0xFFD0D5DC):Colors.white,
  245. child: Text(index==9?'删除':index==10?'0':index==11?'确认':'${index+1}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  246. alignment: Alignment.center,
  247. ),
  248. );
  249. },
  250. itemCount: 12,
  251. padding: EdgeInsets.all(0),
  252. physics: NeverScrollableScrollPhysics(),
  253. )
  254. )
  255. ],
  256. ),
  257. );
  258. }
  259. _postPayPassData() async{
  260. var dict = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/balance/setPayPassword',
  261. parameter: {'verificationCode':widget.code,'password':_passArray.join('')},isLoading: false,isToken: true);
  262. if(dict!=null){
  263. Navigator.pop(context);
  264. Navigator.pop(context);
  265. Navigator.pop(context);
  266. }
  267. }
  268. }