244 lines
8.2 KiB
Dart
244 lines
8.2 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:talk/tools/shop/shop_model.dart';
|
|
import 'package:talk/tools/shop/transaction_page.dart';
|
|
|
|
import '../../beans/account_bean.dart';
|
|
import '../../beans/transaction_records_bean.dart';
|
|
|
|
///货币
|
|
class AccountPage extends StatefulWidget {
|
|
const AccountPage({super.key});
|
|
|
|
@override
|
|
State<AccountPage> createState() => _AccountPageState();
|
|
}
|
|
|
|
class _AccountPageState extends State<AccountPage> {
|
|
List dataList = [1, 2, 3, 4, 5, 6];
|
|
late StreamSubscription subscription;
|
|
final ShopModel _viewmodel = ShopModel();
|
|
late AccountBean accountBean;
|
|
List<TransactionRecordsBean> recordList = [];
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
|
|
subscription = _viewmodel.streamController.stream.listen((newData) {
|
|
String code = newData['code'];
|
|
if (code.isNotEmpty) {
|
|
switch (code) {
|
|
case "getMyAccount":
|
|
accountBean = newData['data'];
|
|
break;
|
|
case "getTransactionRecords":
|
|
recordList = newData['data'];
|
|
break;
|
|
}
|
|
setState(() {});
|
|
}
|
|
});
|
|
_viewmodel.getMyAccount();
|
|
_viewmodel.getTransactionRecords();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
subscription.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Color(0xFF121213),
|
|
appBar: AppBar(
|
|
backgroundColor: Color(0xFF121213),
|
|
scrolledUnderElevation: 0.0,
|
|
title: Text(
|
|
'我的账户',
|
|
style: TextStyle(fontSize: 16, color: Colors.white),
|
|
),
|
|
centerTitle: true,
|
|
leading: IconButton(
|
|
iconSize: 18,
|
|
icon: Icon(Icons.arrow_back_ios_sharp),
|
|
color: Colors.white,
|
|
onPressed: () {
|
|
// 处理返回操作
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 16),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Image(
|
|
width: 45,
|
|
image: AssetImage('assets/images/ic_pearl.png'),
|
|
),
|
|
Container(
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: 13),
|
|
child: Text(
|
|
'${accountBean.currency}',
|
|
style: TextStyle(fontSize: 24, color: Color(0xFFE1E1E1)),
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(top: 39),
|
|
child: Text(
|
|
'账户充值',
|
|
style: TextStyle(fontSize: 13, color: Color(0xFFACACAC)),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 16),
|
|
child: GridView.count(
|
|
shrinkWrap: true,
|
|
//水平子Widget之间间距
|
|
crossAxisSpacing: 17.0,
|
|
//垂直子Widget之间间距
|
|
mainAxisSpacing: 16.0,
|
|
//GridView内边距
|
|
padding: EdgeInsets.zero,
|
|
//一行的Widget数量
|
|
crossAxisCount: 2,
|
|
//子Widget宽高比例
|
|
childAspectRatio: 2.67,
|
|
//子Widget列表
|
|
children: _item(),
|
|
physics: NeverScrollableScrollPhysics(),
|
|
//类似 cellForRow 函数
|
|
scrollDirection: Axis.vertical),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 14),
|
|
decoration: BoxDecoration(color: Color(0xFF2A2A2A), borderRadius: BorderRadius.all(Radius.circular(17))),
|
|
child: Column(
|
|
children: [
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
// Navigator.pushNamed(context, '/TransactionPage');
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => TransactionPage(
|
|
recordList: recordList,
|
|
)));
|
|
},
|
|
child: const SizedBox(
|
|
height: 35,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: 21,
|
|
child: Text(
|
|
'交易记录',
|
|
style: TextStyle(color: Color(0xFF8E8E8E), fontSize: 12),
|
|
)),
|
|
Positioned(
|
|
right: 21,
|
|
child: Icon(
|
|
size: 10,
|
|
Icons.arrow_forward_ios_sharp,
|
|
color: Color(0xFF6E6E6E),
|
|
))
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
height: 0.33,
|
|
margin: EdgeInsets.symmetric(horizontal: 21),
|
|
color: Color(0xFF3A3A3A),
|
|
),
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, '/ProblemPage');
|
|
},
|
|
child: SizedBox(
|
|
height: 35,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: 21,
|
|
child: Text(
|
|
'常见问题',
|
|
style: TextStyle(color: Color(0xFF8E8E8E), fontSize: 12),
|
|
)),
|
|
Positioned(
|
|
right: 35,
|
|
child: Text(
|
|
'充值须知、充值异常与帮助',
|
|
style: TextStyle(color: Color(0xFF8E8E8E), fontSize: 12),
|
|
)),
|
|
Positioned(
|
|
right: 21,
|
|
child: Icon(
|
|
size: 10,
|
|
Icons.arrow_forward_ios_sharp,
|
|
color: Color(0xFF6E6E6E),
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_item() {
|
|
return accountBean.currencyRechargeList!.map((res) {
|
|
return Container(
|
|
height: 58,
|
|
decoration: BoxDecoration(color: Color(0xFF2A2A2A), borderRadius: BorderRadius.all(Radius.circular(17))),
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
left: 21,
|
|
top: 14,
|
|
child: Text(
|
|
'${res.currencyCount}',
|
|
style: TextStyle(color: Color(0xFFFF9000), fontSize: 13),
|
|
)),
|
|
Positioned(
|
|
left: 48,
|
|
top: 16,
|
|
child: Text(
|
|
'语珠',
|
|
style: TextStyle(color: Color(0xFF6F6F6F), fontSize: 10),
|
|
)),
|
|
Positioned(
|
|
left: 21,
|
|
top: 34,
|
|
child: Text(
|
|
'${res.price}元',
|
|
style: TextStyle(color: Colors.white, fontSize: 10),
|
|
)),
|
|
],
|
|
),
|
|
);
|
|
}).toList();
|
|
}
|
|
}
|