123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- class YSWithdrawal extends StatefulWidget {
- const YSWithdrawal({Key key}) : super(key: key);
- @override
- _YSWithdrawalState createState() => _YSWithdrawalState();
- }
- class _YSWithdrawalState extends State<YSWithdrawal> {
- //wexinLogo aliLogo
- List _typeArray = [{'img':'wexinLogo','title':''},{'img':'aliLogo','title':''}];
- int _selectedIndex = 0;
- double _balance = 0.00;
- TextEditingController _amountField = TextEditingController();
- @override
- void dispose() {
- _amountField.dispose();
- super.dispose();
- }
- @override
- void initState() {
- Future.delayed(Duration(seconds: 0)).then((value){
- _getWithdrawalData();
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: CupertinoNavigationBar(
- leading: GestureDetector(
- onTap: (){Navigator.pop(context);},
- child: Icon(Icons.arrow_back_ios,size: 20,color: Color(0xFF000000),),
- ),
- middle: Text('提现',style: TextStyle(color: Color(0xFF000000),fontSize: 16,
- decoration: TextDecoration.none,fontWeight: FontWeight.w600),textAlign: TextAlign.center,),
- backgroundColor: Color(0xFFF5F6F8),
- border: Border.all(color: Colors.transparent,width: hsp(1)),
- ),
- backgroundColor: Color(0xFFF5F6F8),
- body: SingleChildScrollView(
- child: Container(
- width: MediaQuery.of(context).size.width,
- child: Column(
- children: [
- Container(
- height: hsp(150),
- padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
- child: GestureDetector(
- onTap: (){
- FocusScope.of(context).unfocus();
- int selectedIndex = _selectedIndex;
- showModalBottomSheet(
- context: context,
- builder: (context){
- return Container(
- height: hsp(500),
- child: Column(
- children: [
- Container(
- height: hsp(99),
- child: Row(
- children: [
- Container(width: hsp(40),),
- Text('选择提现账号',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
- GestureDetector(
- onTap: (){Navigator.pop(context);},
- child: Icon(Icons.close,size: hsp(40),color: Colors.black,),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
- ),
- Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),),
- StatefulBuilder(
- builder: (context,chooseSet){
- return Container(
- height: hsp(300),
- child: ListView.separated(
- padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
- itemBuilder: (context,index){
- Map item = _typeArray[index];
- return GestureDetector(
- onTap: (){
- chooseSet(() {
- selectedIndex = index;
- });
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- height: hsp(100),
- child: Row(
- children: [
- Image.asset('lib/images/${item['img']}.png',height: hsp(40),width: hsp(40),),
- Container(
- width: MediaQuery.of(context).size.width-hsp(140),
- padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
- child: Text('${item['title']}',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
- ),
- Icon(selectedIndex==index?Icons.check_circle:Icons.radio_button_unchecked,
- size: hsp(40),color: Color(selectedIndex==index?0xFF007AFF:0xFFCCCCCC),),
- ],
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),);
- },
- itemCount: _typeArray.length,
- ),
- );
- },
- ),
- GestureDetector(
- child: Container(
- height: hsp(80),
- margin: EdgeInsets.only(left: hsp(30),right: hsp(30)),
- decoration: BoxDecoration(
- color: Color(0xFF007AFF),
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- alignment: Alignment.center,
- child: Text('确认',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
- ),
- onTap: (){
- Navigator.pop(context);
- _selectedIndex = selectedIndex;
- setState(() {});
- },
- )
- ],
- ),
- );
- }
- );
- },
- child: Row(
- children: [
- Text('到账账号:',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
- Image.asset('lib/images/${_typeArray[_selectedIndex]['img']}.png',height: hsp(40),width: hsp(40),),
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: MediaQuery.of(context).size.width/2
- ),
- child: Text(' ${_typeArray[_selectedIndex]['title']} ',style: TextStyle(fontSize: zsp(30),color: Colors.black),maxLines: 1,),
- ),
- Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFFCCCCCC),)
- ],
- ),
- ),
- ),
- Container(
- width: MediaQuery.of(context).size.width,
- padding: EdgeInsets.all(hsp(30)),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('提现金额',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
- Container(
- margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
- height: hsp(100),
- child: CupertinoTextField(
- placeholder: '',
- decoration: BoxDecoration(),
- style: TextStyle(fontSize: zsp(60),color: Colors.black,fontWeight: FontWeight.bold),
- prefix: Text('¥',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),),
- keyboardType: TextInputType.number,
- inputFormatters: [NumberFormat()],
- controller: _amountField,
- ),
- ),
- RichText(
- text: TextSpan(
- text: '可提现金额:',
- style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),
- children: [
- TextSpan(
- text: '¥$_balance',
- style: TextStyle(color: Colors.black)
- )
- ]
- ),
- ),
- GestureDetector(
- onTap: (){
- _postWithdrawalData();
- },
- child: Container(
- height: hsp(88),
- margin: EdgeInsets.only(left: hsp(40),right: hsp(40),top: hsp(60),bottom: hsp(30)),
- decoration: BoxDecoration(
- color: Color(0xFF007AFF),
- borderRadius: BorderRadius.all(Radius.circular(5))
- ),
- alignment: Alignment.center,
- child: Text('提现',style: TextStyle(fontSize: zsp(32),color: Colors.white),),
- ),
- )
- ],
- ),
- )
- ],
- ),
- ),
- ),
- );
- }
- _getWithdrawalData() async{
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/withDrawInfo',parameter: {},isLoading: false,isToken: true);
- if(dict!=null){
- _typeArray[0]['title'] = dict['data']['paymentAccountWx'];
- _typeArray[1]['title'] = dict['data']['paymentAccountAlipay'];
- _balance = dict['data']['balance']*1.0;
- setState(() {});
- }
- }
- _postWithdrawalData() async{
- if(_amountField.text.isEmpty){
- ysFlutterToast(context, '请输入提现金额');
- return;
- }
- double amount = double.parse(_amountField.text);
- if(amount>_balance){
- ysFlutterToast(context, '提现金额不能大于余额');
- return;
- }
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/commitWithDraw',
- parameter: {'paymentAccountWay':_selectedIndex==0?2:3,'price':amount},isLoading: true,isToken: true);
- if(dict!=null){
- ysFlutterToast(context, '已提交提现申请');
- Navigator.of(context).pop('');
- }
- }
- }
|