| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:twong/api/index.dart';
- import 'package:twong/pages/tabs.dart';
- import 'package:twong/router/base.dart';
- import 'package:twong/utils/index.dart';
- import 'package:twong/utils/sentry.dart';
- import 'package:twong/config/style.dart';
- import 'package:twong/models/balance.dart';
- class WalletPage extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return _WalletPageState();
- }
- }
- class _WalletPageState extends State<WalletPage> {
- Balance _balance;
- @override
- void initState() {
- super.initState();
- SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
- statusBarBrightness: Brightness.light,
- statusBarIconBrightness: Brightness.light,
- ));
- loadData();
- }
- loadData () async {
- _balance = Cache.get(SaveKey.balance);
- Network.inst.getBalance().then((balance) {
- if(!mounted) return;
- setState(() {
- _balance = balance;
- });
- Cache.set(SaveKey.balance, _balance);
- }).catchError((err) {
- Log.e(err);
- });
- }
- Widget _buildWallet () {
- return Container(
- height: 168.px,
- margin: EdgeInsets.only(right: 12.px, left: 12.px),
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius: BorderRadius.circular(8.px),
- ),
- child: Container(
- padding: EdgeInsets.all(12.px),
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Expanded(child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text('总资产(元)', style: TextStyle(color: Colors.white,
- fontSize: 12.px,
- fontWeight: FontWeight.w100)),
- RichText(text: TextSpan(
- text: "¥",
- style: TextStyle(color: Colors.white,
- fontSize: 18),
- children: [ TextSpan(
- style: TextStyle(
- color: Colors.white, fontSize: 30),
- text: _balance?.now_money == null
- ? '--'
- : _balance.now_money),
- ])
- ),
- ])
- ),
- FlatButton(
- onPressed: () {
- Navigator.pushNamed(context, RouteNames.recharge);
- },
- color: Colors.white,
- highlightColor: Colors.transparent,
- shape: RoundedRectangleBorder(side: BorderSide.none,
- borderRadius: BorderRadius.all(
- Radius.circular(16.px))),
- child: Text('充值', style: TextStyle(color: Colors.red)),
- )
- ]),
- Container(
- padding: EdgeInsets.only(top: 40.px),
- child: Row(
- children: <Widget>[
- Expanded(child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text('累计充值(元)', style: TextStyle(color: Colors
- .white,
- fontSize: 12.px,
- fontWeight: FontWeight.w100)),
- RichText(text: TextSpan(
- text: "¥",
- style: TextStyle(
- color: Colors.white, fontSize: 12),
- children: [ TextSpan(
- style: TextStyle(
- color: Colors.white, fontSize: 20),
- text: _balance?.recharge == null
- ? '--'
- : _balance.recharge.toString(),
- ),
- ])
- ),
- ])
- ),
- Expanded(child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text('累计消费(元)', style: TextStyle(color: Colors
- .white,
- fontSize: 12.px,
- fontWeight: FontWeight.w100)),
- RichText(text: TextSpan(
- text: "¥",
- style: TextStyle(
- color: Colors.white, fontSize: 12),
- children: [ TextSpan(
- style: TextStyle(
- color: Colors.white, fontSize: 20),
- text: _balance?.orderStatusSum == null
- ? '--'
- : _balance.orderStatusSum.toString(),),
- ])),
- ])),
- ]),
- ),
- ]),
- )
- );
- }
- Widget _buildMenu () {
- return Container(
- padding: EdgeInsets.all(6.px),
- margin: EdgeInsets.only(top: 12.px, left: 12.px, right: 12.px),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(6.px)
- ),
- child: Flex(
- direction: Axis.horizontal,
- children: <Widget>[
- Expanded(child: Container(
- child: GestureDetector(
- onTap: () {
- Navigator.pushNamed(context,
- RouteNames.billRecord, arguments: 0);
- },
- child: Column(
- children: <Widget>[
- Icon(Icons.library_books, color: Colors.red),
- Container(height: 6),
- Text('账单记录', style: TextStyle(
- fontWeight: FontWeight.w200, fontSize: 12.px)),
- ],
- ),
- ),
- ),),
- Expanded(child: Container(
- child: GestureDetector(
- onTap: () {
- Navigator.pushNamed(context,
- RouteNames.billRecord, arguments: 1);
- },
- child: Column(
- children: <Widget>[
- Icon(Icons.attach_money, color: Colors.red),
- Container(height: 6.px),
- Text('消费记录', style: TextStyle(
- fontWeight: FontWeight.w200, fontSize: 12.px)),
- ],
- ),
- ),
- ),),
- Expanded(child: Container(
- child: GestureDetector(
- onTap: () {
- Navigator.pushNamed(context,
- RouteNames.billRecord, arguments: 2);
- },
- child: Column(
- children: <Widget>[
- Icon(Icons.monetization_on, color: Colors.red),
- Container(height: 6.px),
- Text('充值记录', style: TextStyle(
- fontWeight: FontWeight.w200, fontSize: 12.px)),
- ],
- ),
- ),
- ),),
- Expanded(child: Container(
- child: GestureDetector(
- onTap: () {
- Navigator.pushNamed(context, RouteNames.integralRecord);
- },
- child: Column(
- children: <Widget>[
- Icon(Icons.receipt, color: Colors.red),
- Container(height: 6.px),
- Text('积分记录', style: TextStyle(
- fontWeight: FontWeight.w200, fontSize: 12.px)),
- ]),
- ),
- ))
- ]),
- );
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: DColors.back,
- body: SafeArea(
- child: ListView(
- physics: ClampingScrollPhysics(),
- children: <Widget>[
- _buildWallet(),
- _buildMenu(),
- Divider()
- ]),
- )
- );
- }
- }
|