wallet_page.dart 66 KB

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