withdraw_page.dart 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. import 'dart:convert';
  2. import 'package:bbyyy/beans/pay_way_bean_entity.dart';
  3. import 'package:bbyyy/beans/user_balance_entity.dart';
  4. import 'package:bbyyy/beans/user_bean_entity.dart';
  5. import 'package:bbyyy/beans/withdraw_pricing_bean_entity.dart';
  6. import 'package:bbyyy/https/MyDio.dart';
  7. import 'package:bbyyy/my_tools/dims.dart';
  8. import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
  9. import 'package:bbyyy/my_tools/event_bus.dart';
  10. import 'package:bbyyy/my_tools/my_apis.dart';
  11. import 'package:bbyyy/my_tools/my_colors.dart';
  12. import 'package:bbyyy/my_tools/my_cookie.dart';
  13. import 'package:bbyyy/my_tools/my_tools.dart';
  14. import 'package:bbyyy/my_tools/my_views.dart';
  15. import 'package:bbyyy/paegs/mine_page/bind_alipay_page/bind_alipay_page.dart';
  16. import 'package:bbyyy/pay/pay_tools.dart';
  17. import 'package:flustars/flustars.dart';
  18. import 'package:flutter/cupertino.dart';
  19. import 'package:flutter/gestures.dart';
  20. import 'package:flutter/material.dart';
  21. import 'package:flutter/services.dart';
  22. import 'package:flutter_svg/flutter_svg.dart';
  23. import 'package:pinput/pin_put/pin_put.dart';
  24. class WithdrawPage extends StatefulWidget {
  25. @override
  26. _WithdrawPageState createState() => _WithdrawPageState();
  27. }
  28. class _WithdrawPageState extends State<WithdrawPage> {
  29. TextEditingController _controller = TextEditingController();
  30. int withdrawalStatus = 1; //0--未提现 1--提现中 2--提现完成
  31. double percentFee = 0.0;
  32. double extraFee = 0.0;
  33. double threshold = 0.0;
  34. double maxPerHand = 0.0;
  35. double minPerHand = 0.0;
  36. int withdrawalPath = -1; // 1---支付宝 2---微信
  37. List<PayWayBeanData> payWays;
  38. bool showAlipay = false;
  39. bool showWeChat = false;
  40. bool showHandlingFee = false;
  41. double handlingFee = 0.0;
  42. double balance = 0.0;
  43. String withdrawPassword = '';
  44. @override
  45. void initState() {
  46. // TODO: implement initState
  47. super.initState();
  48. queryPersonalInformation();
  49. queryWithdrawalInstructions();
  50. Future.delayed(Duration.zero, () {
  51. checkPaymentMethod((response, hasError) {
  52. if (!hasError) {
  53. PayWayBeanEntity entity =
  54. PayWayBeanEntity.fromJson(json.decode(response.toString()));
  55. payWays = entity.data;
  56. showWeChat =
  57. payWays[payWays.indexWhere((element) => element.way == 2)]
  58. .withdraw;
  59. showAlipay =
  60. payWays[payWays.indexWhere((element) => element.way == 1)]
  61. .withdraw;
  62. if (MyCookie().userBean.aliPayAccount.isNotEmpty &&
  63. payWays[payWays.indexWhere((element) => element.way == 1)]
  64. .withdraw) {
  65. withdrawalPath = 1;
  66. } else if (MyCookie().userBean.wxOpenid.isNotEmpty &&
  67. payWays[payWays.indexWhere((element) => element.way == 2)]
  68. .withdraw) {
  69. withdrawalPath = 2;
  70. }
  71. setState(() {});
  72. }
  73. }, (e) {});
  74. EasyLoading.show();
  75. getUserWalletBalance((re, hE) {
  76. if (!hE) {
  77. UserBalanceEntity balance =
  78. UserBalanceEntity.fromJson(json.decode(re.data.toString()));
  79. MyCookie().balance = balance.data;
  80. setState(() {
  81. EasyLoading.dismiss();
  82. });
  83. }
  84. }, (e) {
  85. EasyLoading.dismiss();
  86. }, context);
  87. });
  88. }
  89. @override
  90. Widget build(BuildContext context) {
  91. return GestureDetector(
  92. onTap: () {
  93. MyTools().hideKeyboard(context);
  94. },
  95. behavior: HitTestBehavior.translucent,
  96. child: Scaffold(
  97. backgroundColor: MyColors.cF7F7F7,
  98. body: Column(
  99. children: [
  100. MyViews().myAppBar('申请提现', context, [
  101. GestureDetector(
  102. onTap: () {
  103. MyTools().toPage(context, BindAlipayPage(), (then) {
  104. setState(() {});
  105. });
  106. },
  107. behavior: HitTestBehavior.translucent,
  108. child: Container(
  109. padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
  110. child: Text(
  111. '修改绑定',
  112. style: TextStyle(color: MyColors.c333333, fontSize: 16),
  113. ),
  114. ),
  115. ),
  116. ]),
  117. Expanded(
  118. child: SingleChildScrollView(
  119. child: Column(
  120. children: [
  121. if (showAlipay)
  122. GestureDetector(
  123. onTap: () {
  124. if (!payWays[payWays
  125. .indexWhere((element) => element.way == 1)]
  126. .withdraw) {
  127. showToast('支付宝提现暂时维护中');
  128. return;
  129. }
  130. if (MyCookie().userBean.aliPayAccount.isEmpty) {
  131. showToast('未绑定支付宝');
  132. } else {
  133. setState(() {
  134. withdrawalPath = 1;
  135. });
  136. }
  137. },
  138. behavior: HitTestBehavior.translucent,
  139. child: Container(
  140. margin: EdgeInsets.fromLTRB(17, 24, 17, 0),
  141. child: Row(
  142. children: [
  143. Container(
  144. decoration: BoxDecoration(
  145. color: withdrawalPath == 1
  146. ? MyColors.cFF4233
  147. : MyColors.cD0D0D0,
  148. borderRadius: BorderRadius.circular(9)),
  149. height: 18,
  150. width: 18,
  151. child: Icon(
  152. Icons.check,
  153. color: Colors.white,
  154. size: 14,
  155. ),
  156. alignment: Alignment.center,
  157. margin: EdgeInsets.only(right: 10),
  158. ),
  159. MyViews().myText(
  160. '提现到支付宝:${MyCookie().userBean.aliPayAccount.isEmpty ? '未绑定支付宝' : MyCookie().userBean.aliPayAccount}',
  161. MyColors.c666666,
  162. 15),
  163. ],
  164. ),
  165. ),
  166. ),
  167. if (showWeChat)
  168. GestureDetector(
  169. onTap: () {
  170. // if (!payWays[payWays
  171. // .indexWhere((element) => element.way == 2)]
  172. // .withdraw) {
  173. // showToast('微信提现暂时维护中');
  174. // return;
  175. // }
  176. if (MyCookie().userBean.wxOpenid.isEmpty) {
  177. showToast('未绑定微信');
  178. } else {
  179. setState(() {
  180. withdrawalPath = 2;
  181. });
  182. }
  183. },
  184. behavior: HitTestBehavior.translucent,
  185. child: Container(
  186. margin: EdgeInsets.fromLTRB(17, 24, 17, 0),
  187. child: Row(
  188. children: [
  189. Container(
  190. decoration: BoxDecoration(
  191. color: withdrawalPath == 2
  192. ? MyColors.cFF4233
  193. : MyColors.cD0D0D0,
  194. borderRadius: BorderRadius.circular(9)),
  195. height: 18,
  196. width: 18,
  197. child: Icon(
  198. Icons.check,
  199. color: Colors.white,
  200. size: 14,
  201. ),
  202. alignment: Alignment.center,
  203. margin: EdgeInsets.only(right: 10),
  204. ),
  205. MyViews().myText('提现到微信:', MyColors.c666666, 15),
  206. MyCookie().userBean.wxOpenid.isEmpty
  207. ? MyViews()
  208. .myText('未绑定微信', MyColors.c666666, 15)
  209. : Row(
  210. children: [
  211. Container(
  212. margin: EdgeInsets.only(right: 10),
  213. child: ClipRRect(
  214. borderRadius:
  215. BorderRadius.circular(12),
  216. child: MyViews().netImg(
  217. MyCookie().userBean.wxPicture,
  218. 24,
  219. 24),
  220. ),
  221. ),
  222. MyViews().myText(
  223. MyCookie().userBean.wxName,
  224. MyColors.c666666,
  225. 15)
  226. ],
  227. )
  228. ],
  229. ),
  230. ),
  231. ),
  232. Container(
  233. decoration: BoxDecoration(
  234. color: Colors.white,
  235. borderRadius: BorderRadius.circular(4),
  236. ),
  237. margin:
  238. EdgeInsets.symmetric(horizontal: 17, vertical: 14),
  239. padding:
  240. EdgeInsets.symmetric(horizontal: 20, vertical: 15),
  241. child: Column(
  242. children: [
  243. MyViews().myText('提现金额', MyColors.c333333, 16),
  244. Container(
  245. margin: EdgeInsets.only(top: 15),
  246. child: Row(
  247. children: [
  248. Text(
  249. '¥',
  250. style: TextStyle(
  251. color: MyColors.c333333, fontSize: 30),
  252. ),
  253. Expanded(
  254. child: TextField(
  255. inputFormatters: [
  256. FilteringTextInputFormatter.allow(
  257. RegExp("[0-9.]")),
  258. MoneyTextInputFormatter()
  259. ],
  260. controller: _controller,
  261. cursorColor: MyColors.cFF4233,
  262. cursorWidth: 1.0,
  263. decoration: InputDecoration(
  264. border: InputBorder.none,
  265. disabledBorder: InputBorder.none,
  266. enabledBorder: InputBorder.none,
  267. focusedBorder: InputBorder.none,
  268. hintText: '请输入金额',
  269. hintStyle: TextStyle(
  270. color: MyColors.c999999,
  271. fontSize: 16),
  272. isDense: true,
  273. contentPadding:
  274. const EdgeInsets.fromLTRB(
  275. 14, 4.5, 8, 4.5)),
  276. maxLines: 1,
  277. style: TextStyle(
  278. color: MyColors.c333333,
  279. fontSize: 30,
  280. fontWeight: FontWeight.bold,
  281. height: 1.3,
  282. letterSpacing: 0.2),
  283. keyboardType: TextInputType.number,
  284. onChanged: (t) {
  285. try {
  286. showH();
  287. double amount = double.parse(t);
  288. if (amount > 0) {
  289. withdrawalStatus = 0;
  290. setState(() {});
  291. }
  292. } catch (e) {
  293. withdrawalStatus = 1;
  294. }
  295. setState(() {});
  296. },
  297. ),
  298. )
  299. ],
  300. ),
  301. ),
  302. Container(
  303. margin: EdgeInsets.only(top: 4, bottom: 15),
  304. color: MyColors.cE7E7E7,
  305. height: 0.5,
  306. ),
  307. RichText(
  308. text: TextSpan(
  309. text: '当前零钱余额',
  310. style: TextStyle(
  311. color: MyColors.c999999, fontSize: 15),
  312. children: [
  313. TextSpan(
  314. text:
  315. '${balanceDisplay(balance).toStringAsFixed(2)}',
  316. style: TextStyle(
  317. color: MyColors.cFF4233, fontSize: 15),
  318. ),
  319. TextSpan(
  320. text: '元,',
  321. style: TextStyle(
  322. color: MyColors.c999999, fontSize: 15),
  323. ),
  324. TextSpan(
  325. text: '全部提现',
  326. style: TextStyle(
  327. color: MyColors.cFF4233,
  328. fontSize: 15),
  329. recognizer: TapGestureRecognizer()
  330. ..onTap = () {
  331. _controller.text =
  332. balance.toStringAsFixed(2);
  333. showH();
  334. setState(() {
  335. withdrawalStatus = 0;
  336. });
  337. }),
  338. ]),
  339. ),
  340. if (showHandlingFee)
  341. RichText(
  342. text: TextSpan(
  343. text: '手续费',
  344. style: TextStyle(
  345. color: MyColors.c999999, fontSize: 15),
  346. children: [
  347. TextSpan(
  348. text: '${handlingFee.toStringAsFixed(2)}',
  349. style: TextStyle(
  350. color: MyColors.cFF4233,
  351. fontSize: 15),
  352. ),
  353. ]),
  354. ),
  355. if (showHandlingFee)
  356. RichText(
  357. text: TextSpan(
  358. text: '实际到账',
  359. style: TextStyle(
  360. color: MyColors.c999999, fontSize: 15),
  361. children: [
  362. TextSpan(
  363. text:
  364. '${(double.parse(_controller.text.toString()) - handlingFee).toStringAsFixed(2)}',
  365. style: TextStyle(
  366. color: MyColors.cFF4233,
  367. fontSize: 15),
  368. ),
  369. ]),
  370. ),
  371. GestureDetector(
  372. onTap: () {
  373. MyTools().hideKeyboard(context);
  374. if (withdrawalPath == -1) {
  375. showToast('请选择提现方式');
  376. return;
  377. }
  378. if (MyCookie().userBean.forbidWithdraw) {
  379. showSimpleDialog('你已经被冻结提现,请联系群主或客服。', context,
  380. () {
  381. Navigator.pop(context);
  382. });
  383. return;
  384. }
  385. if (withdrawalStatus == 0) {
  386. enterTheWithdrawalPassword();
  387. } else {}
  388. },
  389. behavior: HitTestBehavior.translucent,
  390. child: Container(
  391. decoration: BoxDecoration(
  392. color: withdrawalStatus == 0
  393. ? MyColors.cFF4233
  394. : MyColors.cEFEFEF,
  395. borderRadius: BorderRadius.circular(20)),
  396. child: MyViews().myText('提现', Colors.white, 14),
  397. alignment: Alignment.center,
  398. height: 40,
  399. margin: EdgeInsets.only(top: 20, bottom: 15),
  400. ),
  401. ),
  402. Container(
  403. margin: EdgeInsets.only(bottom: 8),
  404. child: RichText(
  405. text: TextSpan(
  406. text: '您的提现手续费为:',
  407. style: TextStyle(
  408. color: MyColors.c999999, fontSize: 14),
  409. children: [
  410. TextSpan(
  411. text:
  412. '${NumUtil.multiply(percentFee, 100)}%${extraFee == 0 ? '' : '+$extraFee'}',
  413. style: TextStyle(
  414. color: MyColors.cE2A62D,
  415. fontSize: 14),
  416. ),
  417. // TextSpan(
  418. // text: '元',
  419. // style: TextStyle(
  420. // color: MyColors.c999999,
  421. // fontSize: 14),
  422. // ),
  423. ]),
  424. ),
  425. ),
  426. Visibility(
  427. visible: maxPerHand != 0,
  428. child: Container(
  429. margin: EdgeInsets.only(bottom: 8),
  430. child: RichText(
  431. text: TextSpan(
  432. text: '单笔最高限额:',
  433. style: TextStyle(
  434. color: MyColors.c999999, fontSize: 14),
  435. children: [
  436. TextSpan(
  437. text: '$maxPerHand',
  438. style: TextStyle(
  439. color: MyColors.cE2A62D,
  440. fontSize: 14),
  441. ),
  442. TextSpan(
  443. text: '元',
  444. style: TextStyle(
  445. color: MyColors.c999999,
  446. fontSize: 14),
  447. ),
  448. ]),
  449. ),
  450. ),
  451. ),
  452. Visibility(
  453. visible: minPerHand != 0,
  454. child: Container(
  455. margin: EdgeInsets.only(bottom: 8),
  456. child: RichText(
  457. text: TextSpan(
  458. text: '单笔最低限额:',
  459. style: TextStyle(
  460. color: MyColors.c999999, fontSize: 14),
  461. children: [
  462. TextSpan(
  463. text: '$minPerHand',
  464. style: TextStyle(
  465. color: MyColors.cE2A62D,
  466. fontSize: 14),
  467. ),
  468. TextSpan(
  469. text: '元',
  470. style: TextStyle(
  471. color: MyColors.c999999,
  472. fontSize: 14),
  473. ),
  474. ]),
  475. ),
  476. ),
  477. ),
  478. Visibility(
  479. visible: threshold != 0,
  480. child: RichText(
  481. text: TextSpan(
  482. text: '当日免手续费提现额度:',
  483. style: TextStyle(
  484. color: MyColors.c999999, fontSize: 14),
  485. children: [
  486. TextSpan(
  487. text: '$threshold',
  488. style: TextStyle(
  489. color: MyColors.cE2A62D,
  490. fontSize: 14),
  491. ),
  492. TextSpan(
  493. text: '元',
  494. style: TextStyle(
  495. color: MyColors.c999999,
  496. fontSize: 14),
  497. ),
  498. ]),
  499. ),
  500. ),
  501. ],
  502. crossAxisAlignment: CrossAxisAlignment.start,
  503. ),
  504. )
  505. ],
  506. ),
  507. ),
  508. ),
  509. ],
  510. ),
  511. ),
  512. );
  513. }
  514. void withdraw() {
  515. EasyLoading.show();
  516. try {
  517. double amount = double.parse(_controller.text.toString());
  518. if (amount <= balance && amount >= minPerHand) {
  519. var j = {
  520. 'user_uid': MyCookie().getUID(),
  521. 'way': withdrawalPath,
  522. 'amount': amount,
  523. 'password': MyTools.base64Encode(withdrawPassword)
  524. };
  525. if (withdrawalPath == 2) {
  526. j['wx_openid'] = MyCookie().userBean.wxOpenid;
  527. }
  528. print(j.toString());
  529. MyDio().post(MyApis.getApi('withdraw'), j, (response, hasError) {
  530. if (!hasError) {
  531. showToast('提现成功');
  532. withdrawalStatus = 2;
  533. queryPersonalInformation();
  534. } else {
  535. setState(() {
  536. withdrawalStatus = 0;
  537. });
  538. }
  539. }, (error) {
  540. setState(() {
  541. withdrawalStatus = 0;
  542. });
  543. });
  544. } else if (amount > balance) {
  545. setState(() {
  546. withdrawalStatus = 0;
  547. });
  548. EasyLoading.dismiss();
  549. showSimpleDialog('您的余额不足。', context, () {
  550. Navigator.pop(context);
  551. });
  552. } else {
  553. setState(() {
  554. withdrawalStatus = 0;
  555. });
  556. EasyLoading.dismiss();
  557. showSimpleDialog('提现失败:提现金额不能低于$minPerHand元。', context, () {
  558. Navigator.pop(context);
  559. });
  560. }
  561. } catch (e) {
  562. EasyLoading.dismiss();
  563. setState(() {
  564. withdrawalStatus = 0;
  565. EasyLoading.dismiss();
  566. });
  567. EasyLoading.dismiss();
  568. showSimpleDialog('输入内容有误,请重新输入', context, () {
  569. Navigator.pop(context);
  570. });
  571. }
  572. }
  573. void queryPersonalInformation() {
  574. MyDio().query({
  575. "key": "user",
  576. "filters": {
  577. "conditions": ["uid == ${MyCookie().getUID()}"]
  578. },
  579. "dims": userDims,
  580. "paging": [1, 20]
  581. }, (response, hasError) {
  582. if (!hasError) {
  583. UserBeanEntity entity =
  584. UserBeanEntity.fromJson(json.decode(response.data.toString()));
  585. MyCookie().userBean = entity.data.data[0];
  586. balance = balanceDisplay(MyCookie().balance);
  587. EventBus().emit('userChange');
  588. setState(() {});
  589. if (withdrawalStatus == 2) {
  590. Navigator.pop(context);
  591. }
  592. }
  593. }, (error) {});
  594. }
  595. void queryWithdrawalInstructions() {
  596. MyDio().query({
  597. "key": "withdraw_pricing",
  598. "filters": {},
  599. "dims": withdrawPricingDims,
  600. "paging": [1, 20]
  601. }, (response, hasError) {
  602. if (!hasError) {
  603. WithdrawPricingBeanEntity entity = WithdrawPricingBeanEntity.fromJson(
  604. json.decode(response.data.toString()));
  605. if (entity.data.data.isNotEmpty) {
  606. percentFee = entity.data.data[0].percentFee;
  607. extraFee = entity.data.data[0].extraFee;
  608. threshold = entity.data.data[0].threshold;
  609. maxPerHand = entity.data.data[0].maxPerHand;
  610. minPerHand = entity.data.data[0].minPerHand;
  611. }
  612. }
  613. setState(() {});
  614. }, (error) {});
  615. }
  616. showH() {
  617. try {
  618. double amount = double.parse(_controller.text.toString());
  619. if (amount >= minPerHand) {
  620. handlingFee = double.parse((double.parse(_controller.text.toString()) *
  621. percentFee *
  622. 100)
  623. .toStringAsFixed(0)) /
  624. 100 +
  625. extraFee;
  626. setState(() {
  627. showHandlingFee = true;
  628. });
  629. } else {
  630. setState(() {
  631. showHandlingFee = false;
  632. });
  633. }
  634. } catch (e) {
  635. setState(() {
  636. showHandlingFee = false;
  637. });
  638. }
  639. }
  640. void enterTheWithdrawalPassword() {
  641. StateSetter ss;
  642. showDialog(
  643. context: context,
  644. builder: (BuildContext context) {
  645. return Material(
  646. color: Colors.black12,
  647. child: Center(
  648. child: Container(
  649. decoration: BoxDecoration(
  650. borderRadius: BorderRadius.circular(16),
  651. color: Colors.white,
  652. ),
  653. height: 300,
  654. margin: EdgeInsets.symmetric(horizontal: 18),
  655. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  656. child: Column(
  657. children: [
  658. Expanded(
  659. child: Column(
  660. children: [
  661. Stack(
  662. children: [
  663. Positioned(
  664. child: Container(
  665. child: MyViews()
  666. .myText('提现密码', MyColors.c333333, 14),
  667. margin: EdgeInsets.symmetric(horizontal: 20),
  668. width: double.infinity,
  669. alignment: Alignment.center,
  670. height: 30,
  671. ),
  672. ),
  673. Positioned(
  674. right: 0,
  675. child: GestureDetector(
  676. onTap: () {
  677. _pinPutController.clear();
  678. MyTools().hideKeyboard(context);
  679. Navigator.pop(context);
  680. },
  681. behavior: HitTestBehavior.translucent,
  682. child: Icon(
  683. Icons.cancel,
  684. color: MyColors.cB6B6B6,
  685. ),
  686. ),
  687. )
  688. ],
  689. ),
  690. Container(
  691. height: 0.5,
  692. width: double.infinity,
  693. color: MyColors.cE7E7E7,
  694. margin: EdgeInsets.only(
  695. left: 8, right: 8, top: 8, bottom: 20),
  696. ),
  697. Text(
  698. '提现金额',
  699. style:
  700. TextStyle(color: MyColors.c333333, fontSize: 13),
  701. ),
  702. Text(
  703. '¥${(double.parse(_controller.text.toString()) - handlingFee).toStringAsFixed(2)}',
  704. style:
  705. TextStyle(color: MyColors.c333333, fontSize: 32),
  706. ),
  707. // Container(
  708. // margin: EdgeInsets.only(top: 10),
  709. // child: PasswordInputTextField(
  710. // decoration: BoxLooseDecoration(
  711. // strokeColor: MyColors.cEDEDED,
  712. // solidColor:MyColors.cEDEDED ,
  713. // radius: Radius.circular(2),
  714. // obscureStyle:
  715. // ObscureStyle(isTextObscure: true,obscureText: '*'),),
  716. // passwordLength: 6,
  717. // keyboardType: TextInputType.number,
  718. // autoFocus: true,
  719. // inputFormatter: [
  720. // FilteringTextInputFormatter.allow(RegExp(r'[0-9]'
  721. // r''))
  722. // ],
  723. // textInputAction: TextInputAction.done,
  724. // onChanged: (password) {
  725. // withdrawPassword = password;
  726. // },
  727. // ),
  728. // ),
  729. Container(
  730. margin: EdgeInsets.fromLTRB(20, 10, 20, 10),
  731. child: PinPut(
  732. fieldsCount: 6,
  733. eachFieldConstraints:
  734. BoxConstraints(minHeight: 34.0, minWidth: 34.0),
  735. focusNode: _pinPutFocusNode,
  736. autofocus: true,
  737. controller: _pinPutController,
  738. submittedFieldDecoration:
  739. _pinPutDecoration.copyWith(
  740. borderRadius: BorderRadius.circular(2.0),
  741. ),
  742. onChanged: (t) {
  743. withdrawPassword = t;
  744. if (t.length == 6) {
  745. MyTools().hideKeyboard(context);
  746. }
  747. },
  748. inputFormatters: [
  749. FilteringTextInputFormatter.allow(RegExp(r'[0-9]'
  750. r''))
  751. ],
  752. obscureText: '*',
  753. selectedFieldDecoration: _pinPutDecoration,
  754. followingFieldDecoration:
  755. _pinPutDecoration.copyWith(
  756. borderRadius: BorderRadius.circular(2.0),
  757. border: Border.all(
  758. color: MyColors.cEDEDED,
  759. ),
  760. ),
  761. ),
  762. ),
  763. Container(
  764. child: Row(
  765. children: [
  766. Text(
  767. '提现路径',
  768. style: TextStyle(
  769. color: MyColors.c666666, fontSize: 12),
  770. ),
  771. GestureDetector(
  772. onTap: () {
  773. showCupertinoModalPopup(
  774. context: context,
  775. builder: (BuildContext context) {
  776. return CupertinoActionSheet(
  777. title: MyViews().myText(
  778. '提现路径', MyColors.c333333, 20),
  779. actions: [
  780. if (MyCookie()
  781. .userBean
  782. .aliPayAccount
  783. .isNotEmpty)
  784. CupertinoActionSheetAction(
  785. child: Row(
  786. children: [
  787. SvgPicture.asset(
  788. 'images/svg/支付宝.svg',
  789. width: 24,
  790. height: 24,
  791. ),
  792. Container(
  793. child: MyViews().myText(
  794. '支付宝提现',
  795. MyColors.c333333,
  796. 16),
  797. margin: EdgeInsets.only(
  798. left: 6, right: 6),
  799. ),
  800. ],
  801. mainAxisAlignment:
  802. MainAxisAlignment.center,
  803. ),
  804. onPressed: (() {
  805. ss(() {
  806. withdrawalPath = 1;
  807. Navigator.pop(context);
  808. });
  809. }),
  810. ),
  811. if (MyCookie()
  812. .userBean
  813. .wxOpenid
  814. .isNotEmpty)
  815. CupertinoActionSheetAction(
  816. child: Row(
  817. children: [
  818. SvgPicture.asset(
  819. 'images/svg/微信.svg',
  820. width: 24,
  821. height: 24,
  822. ),
  823. Container(
  824. child: MyViews().myText(
  825. '微信提现',
  826. MyColors.c333333,
  827. 16),
  828. margin: EdgeInsets.only(
  829. left: 6, right: 6),
  830. ),
  831. ],
  832. mainAxisAlignment:
  833. MainAxisAlignment.center,
  834. ),
  835. onPressed: (() {
  836. ss(() {
  837. withdrawalPath = 2;
  838. Navigator.pop(context);
  839. });
  840. }),
  841. ),
  842. ],
  843. cancelButton:
  844. CupertinoActionSheetAction(
  845. child: Text("取消"),
  846. isDefaultAction: true,
  847. onPressed: (() {
  848. Navigator.pop(context, 'Cancel');
  849. }),
  850. ),
  851. );
  852. });
  853. },
  854. behavior: HitTestBehavior.translucent,
  855. child: StatefulBuilder(
  856. builder: (BuildContext context,
  857. void Function(void Function()) setState) {
  858. ss = setState;
  859. return Row(
  860. children: [
  861. SvgPicture.asset(
  862. withdrawalPath == 1
  863. ? 'images/svg/支付宝.svg'
  864. : 'images/svg/微信.svg',
  865. height: 18,
  866. width: 18,
  867. ),
  868. Container(
  869. child: Text(
  870. withdrawalPath == 1 ? '支付宝' : '微信',
  871. style: TextStyle(
  872. color: MyColors.c333333,
  873. fontSize: 14),
  874. ),
  875. margin: EdgeInsets.symmetric(
  876. horizontal: 8),
  877. ),
  878. Icon(
  879. Icons.arrow_forward_ios,
  880. size: 11,
  881. color: MyColors.cB6B6B6,
  882. )
  883. ],
  884. );
  885. },
  886. ),
  887. )
  888. ],
  889. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  890. ),
  891. margin: EdgeInsets.symmetric(horizontal: 20),
  892. )
  893. ],
  894. ),
  895. ),
  896. Container(
  897. height: 0.5,
  898. color: MyColors.cE7E7E7,
  899. margin: EdgeInsets.only(bottom: 12),
  900. ),
  901. Container(
  902. margin: EdgeInsets.symmetric(horizontal: 10),
  903. child: GestureDetector(
  904. behavior: HitTestBehavior.translucent,
  905. onTap: () {
  906. if (withdrawPassword.length != 6) {
  907. return;
  908. }
  909. _pinPutController.clear();
  910. MyTools().hideKeyboard(context);
  911. Navigator.pop(context);
  912. withdrawalStatus = 1;
  913. withdraw();
  914. },
  915. child: Container(
  916. decoration: BoxDecoration(
  917. borderRadius: BorderRadius.circular(20),
  918. color: MyColors.cFF4233),
  919. height: 40,
  920. width: 150,
  921. child: MyViews().myText('提现', Colors.white, 14),
  922. alignment: Alignment.center,
  923. ),
  924. ),
  925. )
  926. ],
  927. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  928. ),
  929. ),
  930. ),
  931. );
  932. },
  933. );
  934. }
  935. final TextEditingController _pinPutController = TextEditingController();
  936. final FocusNode _pinPutFocusNode = FocusNode();
  937. BoxDecoration get _pinPutDecoration {
  938. return BoxDecoration(
  939. border: Border.all(color: MyColors.cEDEDED),
  940. color: MyColors.cEDEDED,
  941. borderRadius: BorderRadius.circular(2.0),
  942. );
  943. }
  944. }
  945. class MoneyTextInputFormatter extends TextInputFormatter {
  946. @override
  947. TextEditingValue formatEditUpdate(
  948. TextEditingValue oldValue, TextEditingValue newValue) {
  949. // TODO: implement formatEditUpdate
  950. String newvalueText = newValue.text;
  951. if (newvalueText == ".") {
  952. //第一个数为.
  953. newvalueText = "0.";
  954. } else if (newvalueText.contains(".")) {
  955. if (newvalueText.lastIndexOf(".") != newvalueText.indexOf(".")) {
  956. //输入了2个小数点
  957. newvalueText = newvalueText.substring(0, newvalueText.lastIndexOf('.'));
  958. } else if (newvalueText.length - 1 - newvalueText.indexOf(".") > 2) {
  959. //输入了1个小数点 小数点后两位
  960. newvalueText = newvalueText.substring(0, newvalueText.indexOf(".") + 3);
  961. }
  962. }
  963. return TextEditingValue(
  964. text: newvalueText,
  965. selection: new TextSelection.collapsed(offset: newvalueText.length),
  966. );
  967. }
  968. }