YSChangePayPass.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:ysairplane/base/YSBase.dart';
  4. import 'package:ysairplane/tools/YSNetWorking.dart';
  5. import 'package:ysairplane/tools/YSTools.dart';
  6. import 'YSSetPayPass.dart';
  7. class YSChangeOldPayPass extends StatefulWidget {
  8. @override
  9. _YSChangeOldPayPassState createState() => _YSChangeOldPayPassState();
  10. }
  11. class _YSChangeOldPayPassState extends State<YSChangeOldPayPass> {
  12. List _passArray = [];
  13. @override
  14. Widget build(BuildContext context) {
  15. return YSBase(
  16. ystitle: '修改支付密码',
  17. ysright: GestureDetector(
  18. child: Text('忘记密码',style: TextStyle(fontSize: zsp(32),color: Color(0xFF333333)),),
  19. onTap: (){
  20. Navigator.of(context).push(
  21. CupertinoPageRoute(
  22. builder: (context){
  23. return YSSetPayPass();
  24. }
  25. )
  26. );
  27. }
  28. ),
  29. yschild: Stack(
  30. children: [
  31. Column(
  32. children: [
  33. Container(
  34. height: hsp(50),
  35. alignment: Alignment.center,
  36. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(150)),
  37. child: Text('请输入旧的支付密码',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333),fontWeight: FontWeight.bold),),
  38. ),
  39. Container(
  40. width: MediaQuery.of(context).size.width-hsp(100),
  41. height: hsp(100),
  42. margin: EdgeInsets.only(top: hsp(200)),
  43. decoration: BoxDecoration(
  44. border: Border.all(color: Color(0xFF108EE9),width: 2),
  45. borderRadius: BorderRadius.all(Radius.circular(5))
  46. ),
  47. child: ListView.separated(
  48. itemBuilder: (context,index){
  49. return Container(
  50. height: hsp(100),
  51. width: (MediaQuery.of(context).size.width-hsp(100)-9)/6,
  52. child: Container(
  53. height: hsp(20),
  54. width: hsp(20),
  55. decoration: BoxDecoration(
  56. color: index<_passArray.length?Colors.black:Colors.transparent,
  57. borderRadius: BorderRadius.all(Radius.circular(50))
  58. ),
  59. ),
  60. alignment: Alignment.center,
  61. );
  62. },
  63. separatorBuilder: (context,index){
  64. return Container(width: 1,color: Color(0xFF9A9A9A),height: hsp(100),);
  65. },
  66. itemCount: 6,
  67. padding: EdgeInsets.all(0),
  68. scrollDirection: Axis.horizontal,
  69. ),
  70. ),
  71. Container(
  72. height: hsp(50),
  73. alignment: Alignment.center,
  74. child: Text('支付密码不能是重复、连续的数字',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  75. ),
  76. ],
  77. ),
  78. Container(
  79. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(432)-MediaQuery.of(context).padding.top-44),
  80. width: MediaQuery.of(context).size.width,
  81. decoration: BoxDecoration(
  82. color: Color(0xFF8C8C8C),
  83. border: Border(top: BorderSide(width: 1,color: Color(0xFF8C8C8C)))
  84. ),
  85. height: hsp(432),
  86. child: GridView.builder(
  87. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  88. crossAxisCount: 3,
  89. mainAxisSpacing: 1,
  90. crossAxisSpacing: 1,
  91. childAspectRatio: ((MediaQuery.of(context).size.width-2)/3)/((hsp(432)-3)/4)
  92. ),
  93. itemBuilder: (context, index) {
  94. return GestureDetector(
  95. onTap: (){
  96. if(index==9){
  97. if(_passArray.length>0){
  98. _passArray.removeAt(_passArray.length-1);
  99. }
  100. setState(() {});
  101. }else if(index==11){
  102. if(_passArray.length==6){
  103. Navigator.of(context).push(
  104. CupertinoPageRoute(
  105. builder: (context){
  106. return YSChangePayPass(oldPass: _passArray.join(''),);
  107. }
  108. )
  109. );
  110. }else{
  111. ysFlutterToast(context, '支付密码为6位数字');
  112. }
  113. }else{
  114. if(_passArray.length<6){
  115. _passArray.add(index+1);
  116. setState(() {});
  117. }
  118. }
  119. },
  120. child: Container(
  121. color: index==9||index==11?Color(0xFFD0D5DC):Colors.white,
  122. child: Text(index==9?'删除':index==10?'0':index==11?'确认':'${index+1}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  123. alignment: Alignment.center,
  124. ),
  125. );
  126. },
  127. itemCount: 12,
  128. padding: EdgeInsets.all(0),
  129. physics: NeverScrollableScrollPhysics(),
  130. )
  131. )
  132. ],
  133. ),
  134. );
  135. }
  136. }
  137. class YSChangePayPass extends StatefulWidget {
  138. final String oldPass;
  139. const YSChangePayPass({Key key, this.oldPass}) : super(key: key);
  140. @override
  141. _YSChangePayPassState createState() => _YSChangePayPassState();
  142. }
  143. class _YSChangePayPassState extends State<YSChangePayPass> {
  144. List _passArray = [];
  145. @override
  146. Widget build(BuildContext context) {
  147. return YSBase(
  148. ystitle: '修改支付密码',
  149. yschild: Stack(
  150. children: [
  151. Column(
  152. children: [
  153. Container(
  154. height: hsp(50),
  155. alignment: Alignment.center,
  156. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(150)),
  157. child: Text('请输入新的支付密码',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333),fontWeight: FontWeight.bold),),
  158. ),
  159. Container(
  160. width: MediaQuery.of(context).size.width-hsp(100),
  161. height: hsp(100),
  162. margin: EdgeInsets.only(top: hsp(200)),
  163. decoration: BoxDecoration(
  164. border: Border.all(color: Color(0xFF108EE9),width: 2),
  165. borderRadius: BorderRadius.all(Radius.circular(5))
  166. ),
  167. child: ListView.separated(
  168. itemBuilder: (context,index){
  169. return Container(
  170. height: hsp(100),
  171. width: (MediaQuery.of(context).size.width-hsp(100)-9)/6,
  172. child: Container(
  173. height: hsp(20),
  174. width: hsp(20),
  175. decoration: BoxDecoration(
  176. color: index<_passArray.length?Colors.black:Colors.transparent,
  177. borderRadius: BorderRadius.all(Radius.circular(50))
  178. ),
  179. ),
  180. alignment: Alignment.center,
  181. );
  182. },
  183. separatorBuilder: (context,index){
  184. return Container(width: 1,color: Color(0xFF9A9A9A),height: hsp(100),);
  185. },
  186. itemCount: 6,
  187. padding: EdgeInsets.all(0),
  188. scrollDirection: Axis.horizontal,
  189. ),
  190. ),
  191. Container(
  192. height: hsp(50),
  193. alignment: Alignment.center,
  194. child: Text('支付密码不能是重复、连续的数字',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  195. ),
  196. ],
  197. ),
  198. Container(
  199. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(432)-MediaQuery.of(context).padding.top-44),
  200. width: MediaQuery.of(context).size.width,
  201. decoration: BoxDecoration(
  202. color: Color(0xFF8C8C8C),
  203. border: Border(top: BorderSide(width: 1,color: Color(0xFF8C8C8C)))
  204. ),
  205. height: hsp(432),
  206. child: GridView.builder(
  207. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  208. crossAxisCount: 3,
  209. mainAxisSpacing: 1,
  210. crossAxisSpacing: 1,
  211. childAspectRatio: ((MediaQuery.of(context).size.width-2)/3)/((hsp(432)-3)/4)
  212. ),
  213. itemBuilder: (context, index) {
  214. return GestureDetector(
  215. onTap: (){
  216. if(index==9){
  217. if(_passArray.length>0){
  218. _passArray.removeAt(_passArray.length-1);
  219. }
  220. setState(() {});
  221. }else if(index==11){
  222. if(_passArray.length==6){
  223. Navigator.of(context).push(
  224. CupertinoPageRoute(
  225. builder: (context){
  226. return YSChangePayPassAgain(oldPass: widget.oldPass,pass: _passArray.join(''),);
  227. }
  228. )
  229. );
  230. }else{
  231. ysFlutterToast(context, '支付密码为6位数字');
  232. }
  233. }else{
  234. if(_passArray.length<6){
  235. _passArray.add(index+1);
  236. setState(() {});
  237. }
  238. }
  239. },
  240. child: Container(
  241. color: index==9||index==11?Color(0xFFD0D5DC):Colors.white,
  242. child: Text(index==9?'删除':index==10?'0':index==11?'确认':'${index+1}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  243. alignment: Alignment.center,
  244. ),
  245. );
  246. },
  247. itemCount: 12,
  248. padding: EdgeInsets.all(0),
  249. physics: NeverScrollableScrollPhysics(),
  250. )
  251. )
  252. ],
  253. ),
  254. );
  255. }
  256. }
  257. class YSChangePayPassAgain extends StatefulWidget {
  258. final String oldPass,pass;
  259. const YSChangePayPassAgain({Key key, this.oldPass, this.pass}) : super(key: key);
  260. @override
  261. _YSChangePayPassAgainState createState() => _YSChangePayPassAgainState();
  262. }
  263. class _YSChangePayPassAgainState extends State<YSChangePayPassAgain> {
  264. List _passArray = [];
  265. @override
  266. Widget build(BuildContext context) {
  267. return YSBase(
  268. ystitle: '修改支付密码',
  269. yschild: Stack(
  270. children: [
  271. Column(
  272. children: [
  273. Container(
  274. height: hsp(50),
  275. alignment: Alignment.center,
  276. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(150)),
  277. child: Text('请再次填写以确认',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333),fontWeight: FontWeight.bold),),
  278. ),
  279. Container(
  280. width: MediaQuery.of(context).size.width-hsp(100),
  281. height: hsp(100),
  282. margin: EdgeInsets.only(top: hsp(200)),
  283. decoration: BoxDecoration(
  284. border: Border.all(color: Color(0xFF108EE9),width: 2),
  285. borderRadius: BorderRadius.all(Radius.circular(5))
  286. ),
  287. child: ListView.separated(
  288. itemBuilder: (context,index){
  289. return Container(
  290. height: hsp(100),
  291. width: (MediaQuery.of(context).size.width-hsp(100)-9)/6,
  292. child: Container(
  293. height: hsp(20),
  294. width: hsp(20),
  295. decoration: BoxDecoration(
  296. color: index<_passArray.length?Colors.black:Colors.transparent,
  297. borderRadius: BorderRadius.all(Radius.circular(50))
  298. ),
  299. ),
  300. alignment: Alignment.center,
  301. );
  302. },
  303. separatorBuilder: (context,index){
  304. return Container(width: 1,color: Color(0xFF9A9A9A),height: hsp(100),);
  305. },
  306. itemCount: 6,
  307. padding: EdgeInsets.all(0),
  308. scrollDirection: Axis.horizontal,
  309. ),
  310. ),
  311. Container(
  312. height: hsp(50),
  313. alignment: Alignment.center,
  314. child: Text('支付密码不能是重复、连续的数字',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),),
  315. ),
  316. GestureDetector(
  317. onTap: (){
  318. if(_passArray.length==6){
  319. _postPayPassData();
  320. }else{
  321. ysFlutterToast(context, '支付密码为6位数字');
  322. }
  323. },
  324. child: Container(
  325. height: hsp(90),
  326. width: MediaQuery.of(context).size.width-wsp(50)*2,
  327. alignment: Alignment.center,
  328. margin: EdgeInsets.only(top: hsp(80)),
  329. decoration: BoxDecoration(
  330. color: Color(0xFF3B7EF2),
  331. borderRadius: BorderRadius.all(Radius.circular(5))
  332. ),
  333. child: Text('完成',style: TextStyle(fontSize: zsp(34),color: Colors.white),),
  334. ),
  335. ),
  336. ],
  337. ),
  338. Container(
  339. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-hsp(432)-MediaQuery.of(context).padding.top-44),
  340. width: MediaQuery.of(context).size.width,
  341. decoration: BoxDecoration(
  342. color: Color(0xFF8C8C8C),
  343. border: Border(top: BorderSide(width: 1,color: Color(0xFF8C8C8C)))
  344. ),
  345. height: hsp(432),
  346. child: GridView.builder(
  347. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  348. crossAxisCount: 3,
  349. mainAxisSpacing: 1,
  350. crossAxisSpacing: 1,
  351. childAspectRatio: ((MediaQuery.of(context).size.width-2)/3)/((hsp(432)-3)/4)
  352. ),
  353. itemBuilder: (context, index) {
  354. return GestureDetector(
  355. onTap: (){
  356. if(index==9){
  357. if(_passArray.length>0){
  358. _passArray.removeAt(_passArray.length-1);
  359. }
  360. setState(() {});
  361. }else if(index==11){
  362. if(_passArray.length==6){
  363. _postPayPassData();
  364. }else{
  365. ysFlutterToast(context, '支付密码为6位数字');
  366. }
  367. }else{
  368. if(_passArray.length<6){
  369. _passArray.add(index+1);
  370. setState(() {});
  371. }
  372. }
  373. },
  374. child: Container(
  375. color: index==9||index==11?Color(0xFFD0D5DC):Colors.white,
  376. child: Text(index==9?'删除':index==10?'0':index==11?'确认':'${index+1}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
  377. alignment: Alignment.center,
  378. ),
  379. );
  380. },
  381. itemCount: 12,
  382. padding: EdgeInsets.all(0),
  383. physics: NeverScrollableScrollPhysics(),
  384. )
  385. )
  386. ],
  387. ),
  388. );
  389. }
  390. _postPayPassData() async{
  391. if(widget.pass!=_passArray.join('')){
  392. ysFlutterToast(context, '新密码两次输入不一致');
  393. return;
  394. }
  395. var dict = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/balance/resetPayPassword',
  396. parameter: {'oldPassword':widget.oldPass,'password':_passArray.join('')},isLoading: false,isToken: true);
  397. if(dict!=null){
  398. Navigator.pop(context);
  399. Navigator.pop(context);
  400. Navigator.pop(context);
  401. }
  402. }
  403. }