YSMoney.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_alipay/flutter_alipay.dart';
  4. import 'package:ysairplane/base/YSBase.dart';
  5. import 'package:ysairplane/code/YSBill.dart';
  6. import 'package:ysairplane/tools/YSTools.dart';
  7. import 'package:fluwx/fluwx.dart';
  8. class YSMoney extends StatefulWidget {
  9. @override
  10. _YSMoneyState createState() => _YSMoneyState();
  11. }
  12. class _YSMoneyState extends State<YSMoney> {
  13. List array = ['支付宝','微信'];
  14. int _selected = 0;
  15. bool _isSucceed = false;
  16. @override
  17. Widget build(BuildContext context) {
  18. return YSBase(
  19. ystitle: '钱包',
  20. ysright: GestureDetector(
  21. child: Text('账单',style: TextStyle(fontSize: zsp(34),color: Color(0xFF131318)),),
  22. onTap: (){
  23. Navigator.of(context).push(
  24. CupertinoPageRoute(
  25. builder: (context){
  26. return YSBill();
  27. }
  28. )
  29. );
  30. },
  31. ),
  32. yschild: Container(
  33. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  34. width: MediaQuery.of(context).size.width,
  35. color: Color(0xFFF5F6F8),
  36. child: SingleChildScrollView(
  37. child: _isSucceed==true?Column(
  38. children: [
  39. Container(
  40. color: Colors.white,
  41. width: MediaQuery.of(context).size.width,
  42. padding: EdgeInsets.only(left: wsp(30),right: wsp(30),top: hsp(60),bottom: hsp(60)),
  43. child: Column(
  44. children: [
  45. Image(
  46. image: AssetImage('lib/images/succeed.png'),
  47. height: hsp(130),
  48. width: wsp(130)
  49. ),
  50. Container(
  51. child: Text('充值成功',style: TextStyle(fontSize: zsp(40),color: Color(0xFF333333)),),
  52. margin: EdgeInsets.only(top: hsp(40),bottom: hsp(33)),
  53. ),
  54. Text('本次充值可用金额1100元',style: TextStyle(fontSize: zsp(28),color: Color(0xFF878787)),),
  55. ],
  56. ),
  57. ),
  58. GestureDetector(
  59. onTap: (){
  60. setState(() {
  61. _isSucceed = false;
  62. });
  63. },
  64. child: Container(
  65. height: hsp(94),
  66. width: MediaQuery.of(context).size.width-wsp(24)*2,
  67. alignment: Alignment.center,
  68. margin: EdgeInsets.only(top: hsp(58)),
  69. decoration: BoxDecoration(
  70. color: Color(0xFF0079FF),
  71. borderRadius: BorderRadius.all(Radius.circular(5))
  72. ),
  73. child: Text('完成',style: TextStyle(color: Colors.white,fontSize: zsp(34)),),
  74. ),
  75. )
  76. ],
  77. ):Column(
  78. children: [
  79. Container(
  80. margin: EdgeInsets.only(left: wsp(24),right: wsp(24),bottom: hsp(24),top: hsp(18)),
  81. height: hsp(240),
  82. decoration: BoxDecoration(
  83. image: DecorationImage(
  84. image: AssetImage('lib/images/top.png'),
  85. fit: BoxFit.fill
  86. ),
  87. ),
  88. child: Stack(
  89. children: [
  90. Container(
  91. margin: EdgeInsets.only(left: wsp(46),top: hsp(65)),
  92. child: Row(
  93. children: [
  94. Text('可用余额(RMB) ',style: TextStyle(fontSize: zsp(24),color: Colors.white),),
  95. Image(image: AssetImage('lib/images/eyes2.png'),color: Colors.white,height: hsp(21),width: wsp(28),)
  96. ],
  97. ),
  98. ),
  99. Container(
  100. margin: EdgeInsets.only(left: wsp(48),top: hsp(120)),
  101. child: Text('99.69',style: TextStyle(fontSize: zsp(68),color: Colors.white,fontWeight: FontWeight.bold),),
  102. )
  103. ],
  104. ),
  105. ),
  106. Container(
  107. margin: EdgeInsets.only(left: wsp(24),right: wsp(24),bottom: hsp(14)),
  108. width: MediaQuery.of(context).size.width-wsp(48),
  109. decoration: BoxDecoration(
  110. color: Colors.white,
  111. borderRadius: BorderRadius.all(Radius.circular(5))
  112. ),
  113. child: Column(
  114. crossAxisAlignment: CrossAxisAlignment.start,
  115. children: [
  116. Container(
  117. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),top: hsp(26),bottom: hsp(26)),
  118. decoration: BoxDecoration(
  119. border: Border(bottom: BorderSide(color: Color(0xFFF5F5F7),width: hsp (1)))
  120. ),
  121. child: Text('优惠活动',style: TextStyle(fontSize: zsp(30)),),
  122. ),
  123. Container(
  124. height: hsp(370),
  125. margin: EdgeInsets.only(left: wsp(34),right: wsp(34),top: hsp(40),bottom: hsp(40)),
  126. child: GridView.builder(
  127. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  128. crossAxisCount: 3,
  129. crossAxisSpacing: wsp(20),
  130. mainAxisSpacing: hsp(20),
  131. childAspectRatio: wsp(198)/hsp(110)
  132. ),
  133. itemBuilder: (context,index){
  134. return GestureDetector(
  135. onTap: (){
  136. setState(() {
  137. _selected = index;
  138. });
  139. },
  140. child: index==8?Container(
  141. height: hsp(110),
  142. decoration: BoxDecoration(
  143. color: Color(0xFFF5F7F7),
  144. border: Border.all(color: index==_selected?Color(0xFF0079FF):Colors.transparent,width: 0.5),
  145. borderRadius: BorderRadius.all(Radius.circular(5))
  146. ),
  147. child: Center(child: Text('其他金额',style: TextStyle(fontSize: zsp(26),color: Color(0xFF999999)),)),
  148. ):Container(
  149. padding: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  150. height: hsp(110),
  151. decoration: BoxDecoration(
  152. color: Color(0xFFF5F7F7),
  153. border: Border.all(color: index==_selected?Color(0xFF0079FF):Colors.transparent,width: 0.5),
  154. borderRadius: BorderRadius.all(Radius.circular(5))
  155. ),
  156. child: Column(
  157. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  158. children: [
  159. Row(
  160. children: [
  161. Image(height: hsp(26),width: wsp(26),image: AssetImage('lib/images/money2.png')),
  162. Text(' ${(index+1)*100}',style: TextStyle(fontSize: zsp(30),fontWeight: FontWeight.bold,color: Color(0xFF181818)),)
  163. ],
  164. mainAxisSize: MainAxisSize.min,
  165. ),
  166. Text('充值1000送100',style: TextStyle(fontSize: zsp(20),color: Color(0xFF999999)),)
  167. ],
  168. ),
  169. ),
  170. );
  171. },
  172. itemCount: 9,
  173. physics: NeverScrollableScrollPhysics(),
  174. ),
  175. ),
  176. if(_selected==8)Container(
  177. width: MediaQuery.of(context).size.width,
  178. margin: EdgeInsets.only(left: wsp(34),right: wsp(34),bottom: hsp(22)),
  179. child: Column(
  180. crossAxisAlignment: CrossAxisAlignment.start,
  181. children: [
  182. Text('转入金额',style: TextStyle(fontSize: zsp(28),color: Color(0xFF333333)),),
  183. Container(
  184. height: hsp(100),
  185. decoration: BoxDecoration(
  186. border: Border(bottom: BorderSide(color: Color(0xFFEEEEEE),width: 0.5))
  187. ),
  188. child: CupertinoTextField(
  189. decoration: BoxDecoration(),
  190. prefix: Text('\n¥',style: TextStyle(fontSize: zsp(36),color: Color(0xFF333333)),),
  191. style: TextStyle(fontSize: zsp(60),color: Color(0xFF333333),fontWeight: FontWeight.bold),
  192. keyboardType: TextInputType.number,
  193. suffix: Image(image: AssetImage('lib/images/off2.png'),height: 20,width: 20,),
  194. ),
  195. )
  196. ],
  197. ),
  198. ),
  199. Container(
  200. margin: EdgeInsets.only(left: wsp(34),right: wsp(34),bottom: hsp(49)),
  201. child: Row(
  202. children: [
  203. Text('充值即代表同意',style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),),
  204. Text('《某某充值协议》',style: TextStyle(fontSize: zsp(22),color: Color(0xFF0079FF),fontWeight: FontWeight.bold),)
  205. ],
  206. ),
  207. )
  208. ],
  209. ),
  210. ),
  211. Container(
  212. height: hsp(92),
  213. width: MediaQuery.of(context).size.width-wsp(48),
  214. decoration: BoxDecoration(
  215. color: Colors.white,
  216. borderRadius: BorderRadius.all(Radius.circular(5))
  217. ),
  218. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  219. child: Row(
  220. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  221. children: [
  222. Text('支付方式',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000)),),
  223. DropdownButton(
  224. value: '${array[0]}',
  225. items: [
  226. for(int i=0;i<array.length;i++)DropdownMenuItem(child: Text('${array[i]}'),value: '${array[i]}',),
  227. ],
  228. onChanged: (value){
  229. },
  230. underline: Container(),
  231. icon: Icon(Icons.keyboard_arrow_down,size: zsp(30),color: Color(0xFF999999),),
  232. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  233. )
  234. ],
  235. ),
  236. ),
  237. GestureDetector(
  238. onTap: (){
  239. setState(() {
  240. _isSucceed = true;
  241. });
  242. },
  243. child: GestureDetector(
  244. onTap: (){
  245. _payClick(false);
  246. },
  247. child: Container(
  248. height: hsp(90),
  249. width: MediaQuery.of(context).size.width-wsp(24)*2,
  250. alignment: Alignment.center,
  251. margin: EdgeInsets.only(top: hsp(65)),
  252. decoration: BoxDecoration(
  253. color: Color(0xFF0079FF),
  254. borderRadius: BorderRadius.all(Radius.circular(5))
  255. ),
  256. child: Text('充值',style: TextStyle(color: Colors.white,fontSize: zsp(34)),),
  257. ),
  258. ),
  259. )
  260. ],
  261. ),
  262. ),
  263. ),
  264. );
  265. }
  266. _payClick(bool isWechat) async{
  267. if(isWechat==true){
  268. payWithWeChat(
  269. appId: null,
  270. partnerId: null,
  271. prepayId: null,
  272. packageValue: null,
  273. nonceStr: null,
  274. timeStamp: null,
  275. sign: null
  276. ).then((value){
  277. print('value == $value');
  278. });
  279. }else{
  280. var payResult = await FlutterAlipay.pay('payUrl');
  281. print('$payResult');
  282. }
  283. }
  284. }