wallet_page.dart 67 KB

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