|
|
@@ -1,9 +1,11 @@ |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/withdraw_page/bloc/withdraw_bloc.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/withdraw_page/models/withdraw_model.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page_sk.dart'; |
|
|
|
import 'package:zhiying_base_widget/utils/contants.dart'; |
|
|
|
import 'package:zhiying_comm/util/base_bloc.dart'; |
|
|
|
import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
|
|
|
@@ -24,51 +26,12 @@ class _WithdrawPageState extends State<WithdrawPage> { |
|
|
|
onTap: () { |
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
}, |
|
|
|
child: Scaffold( |
|
|
|
appBar: _createNav(), |
|
|
|
backgroundColor: Colors.white, |
|
|
|
body: SafeArea( |
|
|
|
child: BlocProvider<WithdrawBloc>( |
|
|
|
bloc: WithdrawBloc(), |
|
|
|
child: _WithdrawContainer(widget.data), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 导航栏 |
|
|
|
Widget _createNav() { |
|
|
|
return CupertinoNavigationBar( |
|
|
|
leading: Navigator.canPop(context) |
|
|
|
? GestureDetector( |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
child: Icon( |
|
|
|
Icons.arrow_back_ios, |
|
|
|
size: 20, |
|
|
|
), |
|
|
|
), |
|
|
|
onTap: () { |
|
|
|
if (Navigator.canPop(context)) { |
|
|
|
Navigator.pop(context); |
|
|
|
} |
|
|
|
}, |
|
|
|
) |
|
|
|
: Container(), |
|
|
|
middle: Text( |
|
|
|
'提现', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 15, |
|
|
|
color: Color(0xff333333), |
|
|
|
), |
|
|
|
), |
|
|
|
trailing: GestureDetector( |
|
|
|
child: Text( |
|
|
|
'明细', |
|
|
|
style: TextStyle(fontSize: 13, color: Color(0xff333333)), |
|
|
|
child: Container( |
|
|
|
color: Colors.white, |
|
|
|
child: BlocProvider<WithdrawBloc>( |
|
|
|
bloc: WithdrawBloc(), |
|
|
|
child: _WithdrawContainer(widget.data), |
|
|
|
), |
|
|
|
onTap: () {}, |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
@@ -88,7 +51,7 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
|
|
|
|
int _currentIndex = 0; |
|
|
|
TextEditingController _controller = TextEditingController(); |
|
|
|
bool _submitable = false; |
|
|
|
bool _submitable = true; |
|
|
|
bool _inputable = false; |
|
|
|
|
|
|
|
@override |
|
|
@@ -96,42 +59,92 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
_bloc = BlocProvider.of<WithdrawBloc>(context); |
|
|
|
if (widget.data.containsKey('skip_identifier')) { |
|
|
|
_bloc.loadData(widget.data['skip_identifier']); |
|
|
|
_bloc.loadWithdrawData(); |
|
|
|
_bloc.getAlipayStatus(); |
|
|
|
} |
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
|
reload() { |
|
|
|
_bloc.loadData(widget.data['skip_identifier']); |
|
|
|
_bloc.loadWithdrawData(); |
|
|
|
_bloc.getAlipayStatus(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return SingleChildScrollView( |
|
|
|
child: StreamBuilder<WithdrawModel>( |
|
|
|
stream: _bloc.outData, |
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) { |
|
|
|
WithdrawModel model = snapshot.data; |
|
|
|
if (model == null) { |
|
|
|
return WithdrawPageSketelon(); |
|
|
|
} |
|
|
|
return StreamBuilder( |
|
|
|
stream: _bloc.outData, |
|
|
|
builder: (context, asny) { |
|
|
|
WithdrawModel model = asny.data; |
|
|
|
if (model == null) { |
|
|
|
return WithdrawPageSketelon(); |
|
|
|
} |
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
backgroundColor: HexColor.fromHex('#FFFFFFFF'), |
|
|
|
appBar: _createNav(model), |
|
|
|
body: SafeArea( |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: Container( |
|
|
|
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 8), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
_createHeader(model), |
|
|
|
_createVerify(model), |
|
|
|
_createPrice(model), |
|
|
|
_createInput(model), |
|
|
|
_createSubmit(model), |
|
|
|
_createDesc(model), |
|
|
|
], |
|
|
|
), |
|
|
|
)), |
|
|
|
), |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return Container( |
|
|
|
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 8), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
_createHeader(model), |
|
|
|
_createVerify(model), |
|
|
|
_createPrice(model), |
|
|
|
_createInput(model), |
|
|
|
_createSubmit(model), |
|
|
|
_createDesc(model), |
|
|
|
], |
|
|
|
// 导航栏 |
|
|
|
Widget _createNav(WithdrawModel model) { |
|
|
|
return CupertinoNavigationBar( |
|
|
|
leading: Navigator.canPop(context) |
|
|
|
? GestureDetector( |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
child: Icon( |
|
|
|
Icons.arrow_back_ios, |
|
|
|
size: 20, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
// child: Column( |
|
|
|
// children: <Widget>[], |
|
|
|
// ), |
|
|
|
onTap: () { |
|
|
|
if (Navigator.canPop(context)) { |
|
|
|
Navigator.pop(context); |
|
|
|
} |
|
|
|
}, |
|
|
|
) |
|
|
|
: Container(), |
|
|
|
middle: Text( |
|
|
|
model.appBarName, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 15, |
|
|
|
color: HexColor.fromHex(model.appBarNameColor), |
|
|
|
), |
|
|
|
), |
|
|
|
trailing: GestureDetector( |
|
|
|
child: Text( |
|
|
|
model.appBarRightText, |
|
|
|
style: TextStyle(fontSize: 13, color: Color(0xff333333)), |
|
|
|
), |
|
|
|
onTap: () { |
|
|
|
RouterUtil.route( |
|
|
|
model.detailSkipModel, model.detailSkipModel.toJson(), context); |
|
|
|
}, |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _createHeader(WithdrawModel model) { |
|
|
|
var data = _bloc.withdrawDataModel; |
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
height: 97, |
|
|
@@ -152,16 +165,16 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: <Widget>[ |
|
|
|
Text( |
|
|
|
'¥0.03', |
|
|
|
data?.finValue ?? "", |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.white, |
|
|
|
fontSize: 30, |
|
|
|
), |
|
|
|
), |
|
|
|
Text( |
|
|
|
'可提现总余额', |
|
|
|
model?.availableCashOutText ?? "", |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.white, |
|
|
|
color: HexColor.fromHex(model.availableCashOutTextColor), |
|
|
|
fontSize: 14, |
|
|
|
), |
|
|
|
), |
|
|
@@ -174,28 +187,57 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _createVerify(WithdrawModel model) { |
|
|
|
var data = _bloc.withdrawDataModel; |
|
|
|
var param = { |
|
|
|
'status': _bloc.aliPayModel, |
|
|
|
Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, |
|
|
|
'data': _bloc.aliPayModel |
|
|
|
}; |
|
|
|
return GestureDetector( |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
onTap: () { |
|
|
|
Logger.debug('绑定支付宝'); |
|
|
|
RouterUtil.route( |
|
|
|
model.gotoAliPay, |
|
|
|
{ |
|
|
|
'status': _bloc.aliPayModel, |
|
|
|
Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, |
|
|
|
'data': param |
|
|
|
}, |
|
|
|
context) |
|
|
|
.then((value) { |
|
|
|
reload(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
margin: EdgeInsets.only(top: 8, bottom: 8), |
|
|
|
child: Row( |
|
|
|
children: <Widget>[ |
|
|
|
CachedNetworkImage( |
|
|
|
imageUrl: model.unbindAlipayImg, |
|
|
|
imageUrl: (data?.alipayUserName == null || |
|
|
|
data?.alipayUserName.length == 0) |
|
|
|
? model.unbindAlipayImg |
|
|
|
: model.bindAlipayImg, |
|
|
|
height: 23, |
|
|
|
), |
|
|
|
Expanded( |
|
|
|
child: Padding( |
|
|
|
padding: const EdgeInsets.only(left: 8, right: 8), |
|
|
|
child: Text( |
|
|
|
model.unbindAlipayText, |
|
|
|
(data?.alipayUserName == null || |
|
|
|
data?.alipayUserName.length == 0) |
|
|
|
? model.unbindAlipayText |
|
|
|
: data.alipayUserName, |
|
|
|
style: TextStyle(fontSize: 11, color: Color(0xff999999)), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Text( |
|
|
|
(data?.alipayUserName == null || data?.alipayUserName.length == 0) |
|
|
|
? model.unbindAlipayGotoText |
|
|
|
: model.bindAlipayGotoText, |
|
|
|
style: TextStyle(fontSize: 11, color: Color(0xff999999)), |
|
|
|
), |
|
|
|
Icon( |
|
|
|
Icons.arrow_forward_ios, |
|
|
|
size: 12, |
|
|
@@ -208,6 +250,10 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _createPrice(WithdrawModel model) { |
|
|
|
if (_controller.text.length == 0 && |
|
|
|
model.cashOutDashbordItems[_currentIndex].name != "自定义") { |
|
|
|
_controller.text = model.cashOutDashbordItems[0].value; |
|
|
|
} |
|
|
|
return GridView.builder( |
|
|
|
shrinkWrap: true, |
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
@@ -301,6 +347,8 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
onChanged: (value) { |
|
|
|
_checkSubmit(value); |
|
|
|
}, |
|
|
|
placeholderStyle: |
|
|
|
TextStyle(fontSize: 26, color: Colors.grey[400]), |
|
|
|
), |
|
|
|
), |
|
|
|
Container( |
|
|
@@ -315,22 +363,31 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _createSubmit(WithdrawModel model) { |
|
|
|
return Container( |
|
|
|
height: 50, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: _submitable |
|
|
|
? HexColor.fromHex(model.cashOutBtnTextAvailableBgColor ?? '') |
|
|
|
: HexColor.fromHex(model.cashOutBtnTextUnavailableBgColor ?? ''), |
|
|
|
borderRadius: BorderRadius.circular(7.5), |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
model.cashOutBtnText ?? '', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 15, |
|
|
|
color: _submitable |
|
|
|
? HexColor.fromHex(model.cashOutBtnTextAvailableColor ?? '') |
|
|
|
: HexColor.fromHex(model.cashOutBtnTextUnavailableColor ?? ''), |
|
|
|
return GestureDetector( |
|
|
|
onTap: () { |
|
|
|
///提现 |
|
|
|
if (_submitable) { |
|
|
|
_bloc.submitApply(context, _controller.text); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
height: 50, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: _submitable |
|
|
|
? HexColor.fromHex(model.cashOutBtnTextAvailableBgColor ?? '') |
|
|
|
: HexColor.fromHex(model.cashOutBtnTextUnavailableBgColor ?? ''), |
|
|
|
borderRadius: BorderRadius.circular(7.5), |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
model.cashOutBtnText ?? '', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 15, |
|
|
|
color: _submitable |
|
|
|
? HexColor.fromHex(model.cashOutBtnTextAvailableColor ?? '') |
|
|
|
: HexColor.fromHex( |
|
|
|
model.cashOutBtnTextUnavailableColor ?? ''), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
@@ -365,7 +422,18 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { |
|
|
|
} |
|
|
|
|
|
|
|
void _checkSubmit(String value) { |
|
|
|
_submitable = value.length > 0; |
|
|
|
try { |
|
|
|
if (num.tryParse(value) != null && |
|
|
|
num.tryParse(value) < |
|
|
|
num.tryParse(_bloc.withdrawDataModel.finValue)) { |
|
|
|
_submitable = true; |
|
|
|
} else { |
|
|
|
_submitable = false; |
|
|
|
} |
|
|
|
} catch (e, s) { |
|
|
|
print(e); |
|
|
|
print(s); |
|
|
|
} |
|
|
|
setState(() {}); |
|
|
|
} |
|
|
|
} |