wallet_page.dart 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/internal/wode/wode_router.dart';
  3. import 'package:liftmanager/res/gaps.dart';
  4. import 'package:liftmanager/net/api_service.dart';
  5. import 'package:liftmanager/utils/toast.dart';
  6. import 'package:liftmanager/widgets/app_bar.dart';
  7. import 'package:liftmanager/internal/search/search_router.dart';
  8. import 'package:liftmanager/widgets/app_search_bar.dart';
  9. import 'package:liftmanager/res/resources.dart';
  10. import 'package:liftmanager/routers/fluro_navigator.dart';
  11. import 'package:liftmanager/widgets/load_image.dart';
  12. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  13. import 'package:liftmanager/widgets/bbs_content.dart';
  14. import 'package:liftmanager/internal/wode/page/wallet/small_money.dart';
  15. import 'package:flutter_screenutil/flutter_screenutil.dart';
  16. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  17. import 'package:liftmanager/mvp/base_page_state.dart';
  18. import 'package:liftmanager/internal/wode/model/wallet_model.dart';
  19. import 'package:liftmanager/internal/wode/presenter/wallet_list_presenter.dart';
  20. import 'package:liftmanager/widgets/my_refresh_list.dart';
  21. import 'package:liftmanager/widgets/state_layout.dart';
  22. import 'package:provider/provider.dart';
  23. import 'package:liftmanager/utils/time_format.dart';
  24. import 'package:liftmanager/utils/log_util.dart';
  25. import 'package:flutter_alipay/flutter_alipay.dart';
  26. import 'package:liftmanager/utils/fast_notification.dart';
  27. import 'dart:math';
  28. import 'package:fluwx/fluwx.dart' as fluwx;
  29. import 'package:liftmanager/utils/theme_utils.dart';
  30. class WalletPage extends StatefulWidget {
  31. @override
  32. WalletPageState createState() => WalletPageState();
  33. }
  34. class WalletPageState extends BasePageState<WalletPage, WalletListPresenter>
  35. with AutomaticKeepAliveClientMixin {
  36. BaseListProvider<Records> provider = BaseListProvider<Records>();
  37. int _page = 1;
  38. @override
  39. void initState() {
  40. provider.setStateTypeNotNotify(StateType.loading);
  41. super.initState();
  42. setSchema();
  43. getCoupon();
  44. _onRefresh();
  45. }
  46. void setSchema() async{
  47. // await FlutterAlipay.setIosUrlSchema("tytylift");
  48. await FlutterAlipay.setIosUrlSchema("com.tyty.lift.managers");
  49. }
  50. getBusinessType(int type) {
  51. String str;
  52. if (type == 1) {
  53. str = "充值会员";
  54. } else if (type == 2) {
  55. str = "打赏";
  56. } else if (type == 3) {
  57. str = "充值";
  58. } else if (type == 4) {
  59. str = "诊单业务";
  60. } else if (type == 5) {
  61. str = "提现";
  62. } else if (type == 6) {
  63. str = "提现失败退款";
  64. } else if (type == 7) {
  65. str = "余额消费";
  66. } else if (type == 8) {
  67. str = "拒绝接单退款";
  68. } else if (type == 9) {
  69. str = "专家惩罚";
  70. } else if (type == 10) {
  71. str = "申诉退款";
  72. } else if (type == 11) {
  73. str = "粉丝充值返利";
  74. }else if (type == 12) {
  75. str = "现金支付";
  76. }else if (type == 13) {
  77. str = "差旅费";
  78. }
  79. return str;
  80. }
  81. Map<String, dynamic> detailOj = {
  82. "couponNum": 0,
  83. "balance": 0.0,
  84. "freezeBalance": 0.0,
  85. "hongBaoNum": 0
  86. };
  87. Future getCoupon() async {
  88. await NewApiService().getUserCoupons(onSuccess: (res) {
  89. if (res != null) {
  90. detailOj["couponNum"] = res["couponNum"];
  91. detailOj["balance"] = res["balance"];
  92. detailOj["freezeBalance"] = res["freezeBalance"];
  93. detailOj["hongBaoNum"] = res["hongBaoNum"];
  94. setState(() {});
  95. print(6666544);
  96. }
  97. }, onError: (code, msg) {
  98. toasts(msg);
  99. });
  100. }
  101. @override
  102. void dispose() {
  103. provider.dispose();
  104. super.dispose();
  105. }
  106. // 确认充值
  107. void recharge(provider, money) async {
  108. int payType;
  109. if (provider == 'alipay') {
  110. payType = 1;
  111. await NewApiService().createRecharge(
  112. payType: payType,
  113. productPrice: money,
  114. productName: "用户充值",
  115. memo: "用户充值",
  116. onSuccess: (res) {
  117. getAlipayOrderInfo(res);
  118. },
  119. onError: (code, msg) {
  120. toasts(msg);
  121. });
  122. }else if (provider == 'weixin'){
  123. payType = 2;
  124. await NewApiService().createRecharge(
  125. payType: payType,
  126. productPrice: money,
  127. productName: "用户充值",
  128. memo: "用户充值",
  129. onSuccess: (res) {
  130. getAlipayOrderInfowx(res);
  131. },
  132. onError: (code, msg) {
  133. toasts(msg);
  134. });
  135. }
  136. }
  137. // 确认提现
  138. void ticharge(provider, money) async {
  139. int payType;
  140. if (provider == 'alipay') {
  141. payType = 1;
  142. await NewApiService().getInsetWithdrwa(
  143. type: payType,
  144. amount: money,
  145. onSuccess: (res) {
  146. toasts(res);
  147. getCoupon();
  148. _onRefresh();
  149. String initThisUserMoney = randomInt(1111, 9999).toString() +
  150. DateTime.now().millisecondsSinceEpoch.toString();
  151. FastNotification.push("initUserMoney", initThisUserMoney);
  152. Navigator.pop(context);
  153. },
  154. onError: (code, msg) {
  155. toasts(msg);
  156. if (code == 400) {
  157. NavigatorUtils.push(context, WodeRouter.bandAccount);
  158. }
  159. });
  160. }else if (provider == 'weixin'){
  161. payType = 2;
  162. toasts("暂未开通");
  163. }else {
  164. toasts("暂未开通");
  165. return;
  166. }
  167. }
  168. // 根据orderNo获取支付宝订单信息
  169. Future getAlipayOrderInfo(ordersNo) async {
  170. await NewApiService().alipayRecharge(
  171. orders: ordersNo,
  172. onSuccess: (res) {
  173. callAlipay(res);
  174. },
  175. onError: (code, msg) {
  176. toasts(msg);
  177. });
  178. }
  179. // 根据orderNo获取wx订单信息
  180. Future getAlipayOrderInfowx(ordersNo) async {
  181. await NewApiService().alipayRechargewx(
  182. orders: ordersNo,
  183. onSuccess: (res) {
  184. wxMethod(res);
  185. },
  186. onError: (code, msg) {
  187. toasts(msg);
  188. });
  189. }
  190. dynamic _wxPay;
  191. wxMethod(_payInfo) {
  192. print(_payInfo["appid"]);
  193. fluwx.payWithWeChat(
  194. appId: _payInfo["appid"],
  195. partnerId: _payInfo["partnerid"],
  196. prepayId: _payInfo["prepayid"],
  197. packageValue: _payInfo["package"],
  198. nonceStr: _payInfo["noncestr"],
  199. timeStamp: int.parse(_payInfo["timestamp"]),
  200. sign: _payInfo["sign"]
  201. ).then((data) {
  202. print(data);
  203. });
  204. _wxPay?.cancel();
  205. _wxPay = fluwx.responseFromPayment.listen((fluwx.WeChatPaymentResponse response) async {
  206. print("WeChatPaymentResponse"+response.errCode.toString());
  207. if (response.errCode == -2) {
  208. //支付取消
  209. toasts("支付取消");
  210. } else if (response.errCode == -1) {
  211. //支付失败
  212. toasts("支付失败");
  213. } else if (response.errCode == 0) {
  214. //支付成功
  215. toasts("充值成功");
  216. getCoupon();
  217. _onRefresh();
  218. String initThisUserMoney = randomInt(1111, 9999).toString() +
  219. DateTime.now().millisecondsSinceEpoch.toString();
  220. FastNotification.push("initUserMoney", initThisUserMoney);
  221. setState(() {});
  222. Navigator.pop(context);
  223. }
  224. });
  225. }
  226. // 调用支付宝
  227. void callAlipay(String _payInfo) async {
  228. AlipayResult payResult;
  229. try {
  230. print("The pay info is : " + _payInfo);
  231. payResult = await FlutterAlipay.pay(_payInfo);
  232. } on Exception catch (e) {
  233. payResult = null;
  234. }
  235. print(payResult);
  236. if (payResult != null) {
  237. if (payResult.resultStatus == "9000") {
  238. toasts("充值成功");
  239. getCoupon();
  240. _onRefresh();
  241. String initThisUserMoney = randomInt(1111, 9999).toString() +
  242. DateTime.now().millisecondsSinceEpoch.toString();
  243. FastNotification.push("initUserMoney", initThisUserMoney);
  244. setState(() {});
  245. Navigator.pop(context);
  246. } else {
  247. toasts(payResult.memo);
  248. }
  249. } else {
  250. toasts("支付异常");
  251. }
  252. }
  253. randomInt(int min, int max) {
  254. return new Random().nextInt(max) % (max - min + 1) + min;
  255. }
  256. FocusNode blankNode = FocusNode();
  257. @override
  258. Widget build(BuildContext context) {
  259. double width = MediaQuery.of(context).size.width;
  260. return ChangeNotifierProvider<BaseListProvider<Records>>(
  261. create: (_) => provider,
  262. child: Scaffold(
  263. resizeToAvoidBottomPadding: true,
  264. appBar: MyAppBar(
  265. centerTitle: "我的钱包",
  266. actions: <Widget>[
  267. FlatButton(
  268. child: Text("绑定账号"),
  269. textColor: Colours.dark_text,
  270. highlightColor: Colors.transparent,
  271. onPressed: () {
  272. NavigatorUtils.push(context, WodeRouter.bandAccount);
  273. },
  274. )
  275. ],
  276. ),
  277. body: GestureDetector(
  278. onTap: () {
  279. // 点击空白页面关闭键盘
  280. FocusScope.of(context).requestFocus(blankNode);
  281. },
  282. child: Container(
  283. // color: Color(0xFFF1F4FC),
  284. child: Column(
  285. crossAxisAlignment: CrossAxisAlignment.start,
  286. children: <Widget>[
  287. Container(
  288. child: Column(
  289. children: <Widget>[
  290. Container(
  291. decoration: BoxDecoration(
  292. gradient: const LinearGradient(
  293. colors: [Color(0xFF00D9FF), Color(0xFF0287FF)],
  294. ),
  295. ),
  296. height: ScreenUtil().setWidth(140),
  297. child: Column(
  298. children: <Widget>[
  299. GestureDetector(
  300. onTap: () {
  301. // NavigatorUtils.push(context, WodeRouter.personalPage);
  302. },
  303. child: Container(
  304. padding: EdgeInsets.only(
  305. bottom: ScreenUtil().setWidth(25),
  306. top: ScreenUtil().setWidth(15)),
  307. child: Row(
  308. mainAxisAlignment: MainAxisAlignment.spaceAround,
  309. children: <Widget>[
  310. Column(
  311. mainAxisAlignment: MainAxisAlignment.center,
  312. crossAxisAlignment: CrossAxisAlignment.center,
  313. children: <Widget>[
  314. Text(
  315. '可用余额',
  316. textAlign: TextAlign.center,
  317. style: TextStyle(
  318. fontSize: ScreenUtil().setSp(16),
  319. color: Color(0xffffffff),
  320. ),
  321. ),
  322. SizedBox(height: 5),
  323. Row(
  324. mainAxisAlignment:
  325. MainAxisAlignment.center,
  326. crossAxisAlignment:
  327. CrossAxisAlignment.center,
  328. children: <Widget>[
  329. Text(
  330. '¥',
  331. textAlign: TextAlign.center,
  332. style: TextStyle(
  333. fontSize: ScreenUtil().setSp(14),
  334. color: Color(0xffffffff),
  335. ),
  336. ),
  337. Text(
  338. detailOj["balance"] != null
  339. ? detailOj["balance"].toStringAsFixed(2).toString()
  340. : "",
  341. textAlign: TextAlign.center,
  342. style: TextStyle(
  343. fontSize: ScreenUtil().setSp(22),
  344. color: Color(0xffffffff),
  345. ),
  346. ),
  347. ],
  348. )
  349. ],
  350. ),
  351. Column(
  352. mainAxisAlignment: MainAxisAlignment.center,
  353. crossAxisAlignment: CrossAxisAlignment.center,
  354. children: <Widget>[
  355. Text(
  356. '冻结余额',
  357. textAlign: TextAlign.center,
  358. style: TextStyle(
  359. fontSize: ScreenUtil().setSp(16),
  360. color: Color(0xffffffff),
  361. ),
  362. ),
  363. SizedBox(height: 5),
  364. Row(
  365. mainAxisAlignment:
  366. MainAxisAlignment.center,
  367. crossAxisAlignment:
  368. CrossAxisAlignment.center,
  369. children: <Widget>[
  370. Text(
  371. '¥',
  372. textAlign: TextAlign.center,
  373. style: TextStyle(
  374. fontSize: ScreenUtil().setSp(14),
  375. color: Color(0xffffffff),
  376. ),
  377. ),
  378. Text(
  379. detailOj["freezeBalance"] != null
  380. ? detailOj["freezeBalance"].toStringAsFixed(2).toString()
  381. : "",
  382. textAlign: TextAlign.center,
  383. style: TextStyle(
  384. fontSize: ScreenUtil().setSp(22),
  385. color: Color(0xffffffff),
  386. ),
  387. ),
  388. ],
  389. )
  390. ],
  391. ),
  392. ],
  393. )
  394. ),
  395. ),
  396. Container(
  397. padding: EdgeInsets.only(
  398. left: ScreenUtil().setWidth(25),
  399. right: ScreenUtil().setWidth(25),
  400. top: ScreenUtil().setWidth(10)),
  401. decoration: BoxDecoration(
  402. border: Border(
  403. top: BorderSide(
  404. width: 0.5, color: Colours.line),
  405. ),
  406. ),
  407. child: Row(
  408. mainAxisAlignment:
  409. MainAxisAlignment.spaceAround,
  410. children: <Widget>[
  411. GestureDetector(
  412. child: Container(
  413. child: Row(
  414. crossAxisAlignment:
  415. CrossAxisAlignment.center,
  416. children: <Widget>[
  417. Icon(
  418. IconData(0xe627,
  419. fontFamily: "myfont"),
  420. size: 20.0,
  421. color: Color.fromRGBO(
  422. 255, 255, 255, 1),
  423. ),
  424. SizedBox(width: 8),
  425. Text(
  426. '提现',
  427. textAlign: TextAlign.left,
  428. style: TextStyle(
  429. fontSize: ScreenUtil().setSp(15),
  430. color: Color(0xffffffff),
  431. ),
  432. ),
  433. ],
  434. ),
  435. ),
  436. onTap: () {
  437. showModalBottomSheet(
  438. isScrollControlled: true,
  439. shape: RoundedRectangleBorder(
  440. borderRadius: BorderRadius.all(
  441. Radius.circular(5.0)),
  442. ),
  443. context: context,
  444. builder: (BuildContext context) {
  445. return StatefulBuilder(
  446. builder: (context1,
  447. setBottomSheetState) {
  448. return MoneyDalog(
  449. title: "提现",
  450. confirm: (provider, money) {
  451. ticharge(provider, money);
  452. },
  453. );
  454. },
  455. );
  456. },
  457. );
  458. },
  459. ),
  460. Container(
  461. width: 0.5,
  462. height: ScreenUtil().setWidth(20),
  463. color: Colors.white,
  464. ),
  465. GestureDetector(
  466. child: Container(
  467. child: Row(
  468. crossAxisAlignment:
  469. CrossAxisAlignment.center,
  470. children: <Widget>[
  471. Icon(
  472. IconData(0xe666,
  473. fontFamily: "myfont"),
  474. size: 20.0,
  475. color: Color.fromRGBO(
  476. 255, 255, 255, 1),
  477. ),
  478. SizedBox(width: 8),
  479. Text(
  480. '充值',
  481. textAlign: TextAlign.left,
  482. style: TextStyle(
  483. fontSize: ScreenUtil().setSp(15),
  484. color: Color(0xffffffff),
  485. ),
  486. ),
  487. ],
  488. ),
  489. ),
  490. onTap: () {
  491. showModalBottomSheet(
  492. isScrollControlled: true,
  493. shape: RoundedRectangleBorder(
  494. borderRadius: BorderRadius.all(
  495. Radius.circular(5.0)),
  496. ),
  497. context: context,
  498. builder: (BuildContext context) {
  499. return StatefulBuilder(
  500. builder: (context1,
  501. setBottomSheetState) {
  502. return MoneyDalog(
  503. title: "充值",
  504. confirm: (provider, money) {
  505. recharge(provider, money);
  506. },
  507. );
  508. },
  509. );
  510. },
  511. );
  512. },
  513. ),
  514. ],
  515. ),
  516. ),
  517. ],
  518. ),
  519. ),
  520. LableTitle(
  521. title: "零钱明细",
  522. hasArrow: true,
  523. isMore: false,
  524. userTap: () {
  525. NavigatorUtils.push(context, WodeRouter.smallMoney);
  526. },
  527. ),
  528. ],
  529. ),
  530. ),
  531. Expanded(
  532. flex: 1,
  533. child: Consumer<BaseListProvider<Records>>(
  534. builder: (_, provider, __) {
  535. return MyListView(
  536. key: Key('wallet_list'),
  537. itemCount: provider.list.length,
  538. stateType: provider.stateType,
  539. onRefresh: _onRefresh,
  540. loadMore: _loadMore,
  541. pageSize: 6,
  542. hasMore: provider.hasMore,
  543. itemBuilder: (_, index) {
  544. return Container(
  545. child: Column(
  546. children: <Widget>[
  547. // index == 0
  548. // ? Container(
  549. // child: Column(
  550. // children: <Widget>[
  551. // Container(
  552. // decoration: BoxDecoration(
  553. // gradient: const LinearGradient(
  554. // colors: [
  555. // Color(0xFF00D9FF),
  556. // Color(0xFF0287FF)
  557. // ],
  558. // ),
  559. // ),
  560. // height: ScreenUtil().setWidth(140),
  561. // child: Column(
  562. // children: <Widget>[
  563. // GestureDetector(
  564. // onTap: () {
  565. // // NavigatorUtils.push(context, WodeRouter.personalPage);
  566. // },
  567. // child: Container(
  568. // padding: EdgeInsets.only(
  569. // bottom: ScreenUtil()
  570. // .setWidth(25),
  571. // top: ScreenUtil()
  572. // .setWidth(15)),
  573. // child: Column(
  574. // mainAxisAlignment:
  575. // MainAxisAlignment
  576. // .center,
  577. // crossAxisAlignment:
  578. // CrossAxisAlignment
  579. // .center,
  580. // children: <Widget>[
  581. // Text(
  582. // '余额',
  583. // textAlign:
  584. // TextAlign.center,
  585. // style: TextStyle(
  586. // fontSize:
  587. // ScreenUtil()
  588. // .setSp(16),
  589. // color: Color(
  590. // 0xffffffff),
  591. // ),
  592. // ),
  593. // SizedBox(height: 5),
  594. // Row(
  595. // mainAxisAlignment:
  596. // MainAxisAlignment
  597. // .center,
  598. // crossAxisAlignment:
  599. // CrossAxisAlignment
  600. // .center,
  601. // children: <Widget>[
  602. // Text(
  603. // '¥',
  604. // textAlign:
  605. // TextAlign
  606. // .center,
  607. // style: TextStyle(
  608. // fontSize:
  609. // ScreenUtil()
  610. // .setSp(
  611. // 14),
  612. // color: Color(
  613. // 0xffffffff),
  614. // ),
  615. // ),
  616. // Text(
  617. // detailOj[
  618. // "balance"]
  619. // .toString(),
  620. // textAlign:
  621. // TextAlign
  622. // .center,
  623. // style: TextStyle(
  624. // fontSize:
  625. // ScreenUtil()
  626. // .setSp(
  627. // 22),
  628. // color: Color(
  629. // 0xffffffff),
  630. // ),
  631. // ),
  632. // ],
  633. // )
  634. // ],
  635. // ),
  636. // ),
  637. // ),
  638. // Container(
  639. // padding: EdgeInsets.only(
  640. // left: ScreenUtil()
  641. // .setWidth(25),
  642. // right: ScreenUtil()
  643. // .setWidth(25),
  644. // top: ScreenUtil()
  645. // .setWidth(10)),
  646. // decoration: BoxDecoration(
  647. // border: Border(
  648. // top: BorderSide(
  649. // width: 0.5,
  650. // color: Colours.line),
  651. // ),
  652. // ),
  653. // child: Row(
  654. // mainAxisAlignment:
  655. // MainAxisAlignment
  656. // .spaceAround,
  657. // children: <Widget>[
  658. // GestureDetector(
  659. // child: Container(
  660. // child: Row(
  661. // crossAxisAlignment:
  662. // CrossAxisAlignment
  663. // .center,
  664. // children: <Widget>[
  665. // Icon(
  666. // IconData(0xe627,
  667. // fontFamily:
  668. // "myfont"),
  669. // size: 20.0,
  670. // color: Color
  671. // .fromRGBO(
  672. // 255,
  673. // 255,
  674. // 255,
  675. // 1),
  676. // ),
  677. // SizedBox(
  678. // width: 8),
  679. // Text(
  680. // '提现',
  681. // textAlign:
  682. // TextAlign
  683. // .left,
  684. // style:
  685. // TextStyle(
  686. // fontSize:
  687. // ScreenUtil()
  688. // .setSp(
  689. // 15),
  690. // color: Color(
  691. // 0xffffffff),
  692. // ),
  693. // ),
  694. // ],
  695. // ),
  696. // ),
  697. // onTap: () {
  698. // showModalBottomSheet(
  699. // isScrollControlled:
  700. // true,
  701. // shape:
  702. // RoundedRectangleBorder(
  703. // borderRadius: BorderRadius
  704. // .all(Radius
  705. // .circular(
  706. // 5.0)),
  707. // ),
  708. // context: context,
  709. // builder:
  710. // (BuildContext
  711. // context) {
  712. // return StatefulBuilder(
  713. // builder: (context1,
  714. // setBottomSheetState) {
  715. // return MoneyDalog(
  716. // title: "提现",
  717. // confirm:
  718. // (provider,
  719. // money) {
  720. // ticharge(
  721. // provider,
  722. // money);
  723. // },
  724. // );
  725. // },
  726. // );
  727. // },
  728. // );
  729. // },
  730. // ),
  731. // Container(
  732. // width: 0.5,
  733. // height: ScreenUtil()
  734. // .setWidth(20),
  735. // color: Colors.white,
  736. // ),
  737. // GestureDetector(
  738. // child: Container(
  739. // child: Row(
  740. // crossAxisAlignment:
  741. // CrossAxisAlignment
  742. // .center,
  743. // children: <Widget>[
  744. // Icon(
  745. // IconData(0xe666,
  746. // fontFamily:
  747. // "myfont"),
  748. // size: 20.0,
  749. // color: Color
  750. // .fromRGBO(
  751. // 255,
  752. // 255,
  753. // 255,
  754. // 1),
  755. // ),
  756. // SizedBox(
  757. // width: 8),
  758. // Text(
  759. // '充值',
  760. // textAlign:
  761. // TextAlign
  762. // .left,
  763. // style:
  764. // TextStyle(
  765. // fontSize:
  766. // ScreenUtil()
  767. // .setSp(
  768. // 15),
  769. // color: Color(
  770. // 0xffffffff),
  771. // ),
  772. // ),
  773. // ],
  774. // ),
  775. // ),
  776. // onTap: () {
  777. // showModalBottomSheet(
  778. // isScrollControlled:
  779. // true,
  780. // shape:
  781. // RoundedRectangleBorder(
  782. // borderRadius: BorderRadius
  783. // .all(Radius
  784. // .circular(
  785. // 5.0)),
  786. // ),
  787. // context: context,
  788. // builder:
  789. // (BuildContext
  790. // context) {
  791. // return StatefulBuilder(
  792. // builder: (context1,
  793. // setBottomSheetState) {
  794. // return MoneyDalog(
  795. // title: "充值",
  796. // confirm:
  797. // (provider,
  798. // money) {
  799. // recharge(
  800. // provider,
  801. // money);
  802. // },
  803. // );
  804. // },
  805. // );
  806. // },
  807. // );
  808. // },
  809. // ),
  810. // ],
  811. // ),
  812. // ),
  813. // ],
  814. // ),
  815. // ),
  816. // LableTitle(
  817. // title: "零钱明细",
  818. // hasArrow: true,
  819. // isMore: false,
  820. // userTap: () {
  821. // NavigatorUtils.push(context,
  822. // WodeRouter.smallMoney);
  823. // },
  824. // ),
  825. // ],
  826. // ),
  827. // )
  828. // : Container(child: null),
  829. InkWell(
  830. child: Container(
  831. padding: EdgeInsets.only(
  832. left: ScreenUtil().setWidth(15),
  833. right: ScreenUtil().setWidth(15),
  834. top: ScreenUtil().setWidth(15),
  835. bottom: ScreenUtil().setWidth(15)),
  836. decoration: BoxDecoration(
  837. border: Border(
  838. bottom: BorderSide(
  839. width: 0.5, color: Colours.line),
  840. ),
  841. color: ThemeUtils.getTabsBg(context),
  842. ),
  843. child: Column(
  844. children: <Widget>[
  845. Container(
  846. padding: EdgeInsets.only(bottom: 5),
  847. child: Row(
  848. mainAxisAlignment:
  849. MainAxisAlignment.spaceBetween,
  850. children: <Widget>[
  851. Text(
  852. getBusinessType(provider
  853. .list[index].businessType),
  854. textAlign: TextAlign.left,
  855. style: TextStyle(
  856. fontSize:
  857. ScreenUtil().setSp(16),
  858. ),
  859. ),
  860. Text(
  861. (provider.list[index].type == 1
  862. ? "-"
  863. : "+") +
  864. (provider.list[index]
  865. .amount !=
  866. null
  867. ? provider
  868. .list[index].amount
  869. .toString()
  870. : ""),
  871. textAlign: TextAlign.left,
  872. style: TextStyle(
  873. fontSize:
  874. ScreenUtil().setSp(16),
  875. color: Colors.red,
  876. ),
  877. ),
  878. ],
  879. ),
  880. ),
  881. Row(
  882. mainAxisAlignment:
  883. MainAxisAlignment.spaceBetween,
  884. children: <Widget>[
  885. Text(
  886. provider.list[index].descr ?? "",
  887. textAlign: TextAlign.left,
  888. style: TextStyle(
  889. fontSize:
  890. ScreenUtil().setSp(13),
  891. color: Color(0xff999999),
  892. ),
  893. ),
  894. Text(
  895. provider.list[index].createTime !=
  896. null
  897. ? DateUtils.instance
  898. .getFormartData(
  899. timeSamp: provider
  900. .list[index]
  901. .createTime,
  902. format: "yyyy-MM-dd")
  903. : "",
  904. textAlign: TextAlign.left,
  905. style: TextStyle(
  906. fontSize:
  907. ScreenUtil().setSp(13),
  908. color: Color(0xff999999),
  909. ),
  910. ),
  911. ],
  912. ),
  913. ],
  914. ),
  915. ),
  916. onTap: () {
  917. // print(i);
  918. // NavigatorUtils.push(context, BbsRouter.positionDetail);
  919. },
  920. )
  921. ],
  922. ),
  923. );
  924. },
  925. );
  926. },
  927. ),
  928. )
  929. ],
  930. ),
  931. ),
  932. ),
  933. ),
  934. );
  935. }
  936. Future _onRefresh() async {
  937. _page = 1;
  938. await presenter.getWalletList(_page);
  939. }
  940. Future _loadMore() async {
  941. _page++;
  942. await presenter.getWalletList(_page);
  943. }
  944. @override
  945. WalletListPresenter createPresenter() {
  946. return WalletListPresenter();
  947. }
  948. bool get wantKeepAlive => true;
  949. }
  950. class MoneyDalog extends StatefulWidget {
  951. MoneyDalog({Key key, this.title, this.confirm}) : super(key: key);
  952. final String title;
  953. final Function(String, String) confirm;
  954. @override
  955. _MoneyDalogState createState() => _MoneyDalogState();
  956. }
  957. class _MoneyDalogState extends State<MoneyDalog> {
  958. @override
  959. initState() {
  960. super.initState();
  961. }
  962. TextEditingController moneyController = new TextEditingController();
  963. static const payType = [
  964. {"icon": "tab_first/pay_winxin", "title": "微信", "value": "weixin"},
  965. {"icon": "tab_first/pay_zhifubao", "title": "支付宝", "value": "alipay"},
  966. // {"icon": "tab_first/pay_yue", "title": "账户余额支付", "value": "balance"},
  967. ];
  968. String checkFalse = "tab_first/check_false";
  969. String checkTrue = "tab_first/check_true";
  970. int selectIndex = -1;
  971. void changeType(index) {
  972. setState(() {
  973. selectIndex = index;
  974. });
  975. }
  976. FocusNode blankNode = FocusNode();
  977. @override
  978. Widget build(BuildContext context) {
  979. double width = MediaQuery.of(context).size.width;
  980. return GestureDetector(
  981. onTap: () {
  982. // 点击空白页面关闭键盘
  983. FocusScope.of(context).requestFocus(blankNode);
  984. },
  985. child: Container(
  986. child: Container(
  987. height: ScreenUtil().setWidth(330),
  988. child: Column(
  989. children: <Widget>[
  990. Container(
  991. // color: Colors.red,
  992. padding: EdgeInsets.only(bottom: 10),
  993. width: width,
  994. child: Stack(
  995. children: <Widget>[
  996. Container(
  997. width: width,
  998. padding: EdgeInsets.only(top: 10),
  999. child: Text(
  1000. widget.title,
  1001. textAlign: TextAlign.center,
  1002. style: TextStyle(
  1003. fontSize: ScreenUtil().setSp(17),
  1004. ),
  1005. ),
  1006. ),
  1007. Positioned(
  1008. right: 5,
  1009. top: 5,
  1010. child: GestureDetector(
  1011. onTap: () async {
  1012. Navigator.pop(context);
  1013. },
  1014. child: Icon(
  1015. IconData(0xe62a, fontFamily: "myfont"),
  1016. size: 22.0,
  1017. color: Color.fromRGBO(200, 200, 200, 1),
  1018. ),
  1019. ),
  1020. )
  1021. ],
  1022. ),
  1023. ),
  1024. Container(
  1025. height: ScreenUtil().setWidth(200),
  1026. child: ListView(
  1027. children: <Widget>[
  1028. Container(
  1029. // height:260,
  1030. child: Column(
  1031. children: <Widget>[
  1032. Container(
  1033. padding: EdgeInsets.only(
  1034. left: ScreenUtil().setWidth(15)),
  1035. width: width,
  1036. child: Text(
  1037. widget.title + "金额",
  1038. textAlign: TextAlign.left,
  1039. style: TextStyle(
  1040. fontSize: ScreenUtil().setSp(16),
  1041. ),
  1042. ),
  1043. ),
  1044. SizedBox(height: 10),
  1045. Container(
  1046. // height: 30,
  1047. padding: EdgeInsets.only(
  1048. left: ScreenUtil().setWidth(15),
  1049. right: ScreenUtil().setWidth(15),
  1050. ),
  1051. // color: Colors.yellow,
  1052. child: TextField(
  1053. keyboardType: TextInputType.number,
  1054. controller: moneyController,
  1055. // textInputAction: TextInputAction.go, // 输入框的确定按钮
  1056. // focusNode: focusNode1,
  1057. decoration: InputDecoration(
  1058. contentPadding: EdgeInsets.only(
  1059. left: 10,
  1060. right: 5,
  1061. ),
  1062. border: UnderlineInputBorder(
  1063. borderSide: BorderSide(
  1064. color: Colours.text_gray_c, width: 0.8),
  1065. ),
  1066. focusedBorder: UnderlineInputBorder(
  1067. borderSide: BorderSide(
  1068. color: Colours.text_gray_c, width: 0.8),
  1069. ),
  1070. labelText: '¥',
  1071. labelStyle: TextStyle(
  1072. fontSize: ScreenUtil().setSp(24),
  1073. ), // 上标
  1074. hintText: '请输入', // hint 暗示
  1075. hasFloatingPlaceholder: false, // labelText是否漂浮
  1076. // errorText: '错误文本',
  1077. errorBorder: InputBorder.none, // 当error时的border
  1078. prefix: Text('¥'),
  1079. prefixStyle: TextStyle(
  1080. fontSize: ScreenUtil().setSp(24),
  1081. color: Colors.black,
  1082. ),
  1083. filled: false, // 背景色
  1084. ),
  1085. cursorColor: Color(0xFF999999),
  1086. obscureText: false, // 输入变成**
  1087. onChanged: (val) {
  1088. // xxx
  1089. },
  1090. ),
  1091. ),
  1092. Container(
  1093. padding: EdgeInsets.only(
  1094. left: ScreenUtil().setWidth(15),
  1095. top: ScreenUtil().setWidth(10),
  1096. ),
  1097. width: width,
  1098. child: Text(
  1099. widget.title+'方式',
  1100. textAlign: TextAlign.left,
  1101. style: TextStyle(
  1102. fontSize: ScreenUtil().setSp(16),
  1103. ),
  1104. ),
  1105. ),
  1106. Container(
  1107. padding: EdgeInsets.only(
  1108. left: ScreenUtil().setWidth(15),
  1109. right: ScreenUtil().setWidth(15),
  1110. ),
  1111. child: Column(
  1112. children: payType.asMap().keys.map((i) {
  1113. return Container(
  1114. decoration: BoxDecoration(),
  1115. height: 40,
  1116. child: Row(
  1117. mainAxisAlignment: MainAxisAlignment.start,
  1118. children: <Widget>[
  1119. InkWell(
  1120. child: Container(
  1121. child: LoadAssetImage(
  1122. selectIndex == i
  1123. ? checkTrue
  1124. : checkFalse,
  1125. width: ScreenUtil().setWidth(20),
  1126. height: ScreenUtil().setWidth(20),
  1127. ),
  1128. ),
  1129. onTap: () {
  1130. changeType(i);
  1131. },
  1132. ),
  1133. SizedBox(
  1134. width: ScreenUtil().setWidth(20)),
  1135. Row(
  1136. children: <Widget>[
  1137. LoadAssetImage(
  1138. payType[i]["icon"],
  1139. width: ScreenUtil().setWidth(20),
  1140. height: ScreenUtil().setWidth(20),
  1141. ),
  1142. Container(width: 5, child: null),
  1143. Text(
  1144. widget.title=="充值"? payType[i]["title"] + "支付":"提现到"+payType[i]["title"],
  1145. style: TextStyle(
  1146. fontSize: ScreenUtil().setSp(14),
  1147. ),
  1148. textAlign: TextAlign.start,
  1149. ),
  1150. ],
  1151. ),
  1152. ],
  1153. ),
  1154. );
  1155. }).toList(),
  1156. ),
  1157. )
  1158. ],
  1159. ),
  1160. )
  1161. ],
  1162. ),
  1163. ),
  1164. Container(
  1165. width: width,
  1166. padding: EdgeInsets.only(
  1167. top: ScreenUtil().setWidth(15),
  1168. bottom: ScreenUtil().setWidth(10),
  1169. left: ScreenUtil().setWidth(25),
  1170. right: ScreenUtil().setWidth(25),
  1171. ),
  1172. color: ThemeUtils.getTabsBg(context),
  1173. child: Container(
  1174. height: ScreenUtil().setWidth(40),
  1175. decoration: BoxDecoration(
  1176. borderRadius:
  1177. BorderRadius.circular(ScreenUtil().setWidth(22)),
  1178. gradient: const LinearGradient(
  1179. colors: [Color(0xFF00D9FF), Color(0xFF0287FF)],
  1180. ),
  1181. ),
  1182. child: FlatButton(
  1183. // padding: EdgeInsets.all(15.0),
  1184. child: Text("确认"),
  1185. textColor: Colors.white,
  1186. onPressed: () async {
  1187. RegExp exp = RegExp("[0-9]");
  1188. if (selectIndex == -1) {
  1189. toasts("请选择");
  1190. } else {
  1191. if (!exp.hasMatch(moneyController.text) ||
  1192. double.parse(moneyController.text) < 0) {
  1193. toasts("请输入正确的金额");
  1194. } else {
  1195. widget.confirm(payType[selectIndex]['value'],
  1196. moneyController.text);
  1197. }
  1198. }
  1199. },
  1200. ),
  1201. ),
  1202. )
  1203. ],
  1204. ),
  1205. ),
  1206. ),
  1207. );
  1208. }
  1209. }