李志伟 3 vuotta sitten
vanhempi
commit
27a1659707

+ 37
- 0
lib/models/entities/Log.dart Näytä tiedosto

@@ -0,0 +1,37 @@
1
+class LogModel {
2
+  int? logId;
3
+  String? payId;
4
+  String? accountId;
5
+  int? feeType;
6
+  String? chargeType;
7
+  int? money;
8
+  String? orderId;
9
+  String? remarks;
10
+  String? createDate;
11
+
12
+  LogModel();
13
+
14
+  LogModel.fromJson(Map<String, dynamic> json):
15
+  logId=json['logId'],
16
+  payId=json['payId'],
17
+  accountId=json['accountId'],
18
+  feeType=json['feeType'],
19
+  chargeType=json['chargeType'],
20
+  money=json['money'],
21
+  orderId=json['orderId'],
22
+  remarks=json['remarks'],
23
+  createDate=json['createDate'];
24
+
25
+  Map<String, dynamic> toJson() => {
26
+    'logId':logId,
27
+    'payId':payId,
28
+    'accountId':accountId,
29
+    'feeType':feeType,
30
+    'chargeType':chargeType,
31
+    'money':money,
32
+    'orderId':orderId,
33
+    'remarks':remarks,
34
+    'createDate':createDate,
35
+  };
36
+
37
+}

+ 1
- 1
lib/pages/bankList/index.dart Näytä tiedosto

@@ -85,7 +85,7 @@ class BankListPages extends BasicPage {
85 85
                         },
86 86
                       );
87 87
                     }).toList())
88
-                  : const NullCard(text: '暂未绑定银行卡'),
88
+                  : const NullCard(text: '暂未添加银行卡'),
89 89
             ),
90 90
           ),
91 91
           Container(

+ 45
- 56
lib/pages/wallet/index.dart Näytä tiedosto

@@ -1,75 +1,64 @@
1 1
 import 'package:flutter/material.dart';
2 2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 3
 import 'package:get/get.dart';
4
-import 'package:worker_client/pages/wallet/widget/money.dart';
4
+import 'package:worker_client/models/entities/Log.dart';
5 5
 import 'package:worker_client/pages/wallet/widget/moneyInfo.dart';
6
-
7
-import '../../widgets/layout/BasicPage.dart';
6
+import 'package:worker_client/services/account.dart';
7
+import 'package:worker_client/widgets/MoneyCard/index.dart';
8
+import 'package:worker_client/widgets/MyTitle/index.dart';
9
+import 'package:worker_client/widgets/NullCard.dart';
10
+import 'package:worker_client/widgets/layout/BasicPage.dart';
8 11
 
9 12
 class MyWallet extends BasicPage {
10 13
   MyWallet({Key? key}) : super(key: key) {
11 14
     naviTitle = '我的钱包';
12 15
   }
16
+  final amounts = Rx<double>(0);
17
+  final logList = Rx<List<LogModel>>([]);
18
+  @override
19
+  void beforeShow() {
20
+    // TODO: implement beforeShow
21
+    super.beforeShow();
22
+
23
+    getAccount().then((res) {
24
+      amounts(double.parse(res['amounts'].toString()));
25
+    });
26
+    getLogList({'pageNum': 1}).then((value) {
27
+      var list = <LogModel>[];
28
+      value['records'].forEach((item) {
29
+        list.add(LogModel.fromJson(item));
30
+      });
31
+      logList(list);
32
+    });
33
+  }
34
+
35
+  void goWithDrawal() {
36
+    Get.toNamed('/withdrawal');
37
+  }
13 38
 
14 39
   @override
15 40
   Widget builder(BuildContext context) {
16 41
     return ListView(
42
+      padding: EdgeInsets.all(15.w),
17 43
       children: [
18
-        Container(
19
-          alignment: Alignment.center,
20
-          child: Column(
21
-            children: [
22
-              MoneyCard(),
23
-              Container(
24
-                  alignment: Alignment.center,
25
-                  width: 345.w,
26
-                  margin: EdgeInsets.fromLTRB(0, 15.w, 0, 15.w),
27
-                  decoration: BoxDecoration(
28
-                    borderRadius: BorderRadius.circular(10),
29
-                    color: Colors.white,
30
-                  ),
31
-                  child: Column(
32
-                    children: [
33
-                      Container(
34
-                          margin: EdgeInsets.fromLTRB(0, 30.w, 0, 20.w),
35
-                          alignment: Alignment.topLeft,
36
-                          decoration: const BoxDecoration(
37
-                              border: Border(
38
-                                  left: BorderSide(
39
-                                      width: 5, color: Color(0xff000000)
40
-                                      // 0x17000000
41
-                                      ))),
42
-                          child: Padding(
43
-                            padding: EdgeInsets.fromLTRB(13.w, 0, 0, 0),
44
-                            child: Text(
45
-                              '零钱明细',
46
-                              style: TextStyle(
47
-                                color: Color(0xff333333),
48
-                                fontWeight: FontWeight.bold,
49
-                                fontSize: 17,
50
-                              ),
51
-                            ),
52
-                          )),
53
-                      MoneyInfoCard(),
54
-                      MoneyInfoCard(),
55
-                      MoneyInfoCard(),
56
-                      MoneyInfoCard(),
57
-                      MoneyInfoCard(),
58
-                      MoneyInfoCard(),
59
-                      MoneyInfoCard(),
60
-                      MoneyInfoCard(),
61
-                      MoneyInfoCard(),
62
-                      MoneyInfoCard(),
63
-                      MoneyInfoCard(),
64
-                      MoneyInfoCard(),
65
-                      MoneyInfoCard(),
66
-                      MoneyInfoCard(),
67
-                      MoneyInfoCard(),
68
-                    ],
69
-                  )),
70
-            ],
44
+        Obx(
45
+          () => MoneyCard(
46
+            amounts: amounts.value,
47
+            goWithDrawal: () {
48
+              goWithDrawal();
49
+            },
71 50
           ),
72 51
         ),
52
+        const MyTitle(title: '零钱明细'),
53
+        Obx(() => logList.value != []
54
+            ? Column(
55
+                children: logList.value
56
+                    .map((e) => MoneyInfoCard(
57
+                          logData: e,
58
+                        ))
59
+                    .toList(),
60
+              )
61
+            : const NullCard(text: '暂无明细')),
73 62
       ],
74 63
     );
75 64
   }

+ 0
- 132
lib/pages/wallet/widget/money.dart Näytä tiedosto

@@ -1,132 +0,0 @@
1
-import 'package:flutter/material.dart';
2
-import 'package:flutter_screenutil/flutter_screenutil.dart';
3
-import 'package:get/get.dart';
4
-import 'package:get/get_core/src/get_main.dart';
5
-
6
-class MoneyCard extends StatefulWidget {
7
-  final bool type;
8
-  const MoneyCard({Key? key, this.type = false}) : super(key: key);
9
-
10
-  @override
11
-  State<MoneyCard> createState() => _MoneyCardState();
12
-}
13
-
14
-class _MoneyCardState extends State<MoneyCard> {
15
-  void _goWithdrawPage() {
16
-    print('asdasdsad');
17
-    Get.toNamed('/withdrawal');
18
-  }
19
-
20
-  @override
21
-  Widget build(BuildContext context) {
22
-    if (!widget.type) {
23
-      return Container(
24
-        width: 345.w,
25
-        height: 173.w,
26
-        padding: EdgeInsets.fromLTRB(40, 33, 0, 0),
27
-        alignment: Alignment.centerLeft,
28
-        decoration: BoxDecoration(
29
-          borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
30
-          image: const DecorationImage(
31
-            image: AssetImage(
32
-              'images/main/walletBgi.png',
33
-            ),
34
-          ),
35
-        ),
36
-        child: Column(
37
-          children: [
38
-            Text(
39
-              '钱包余额(元)',
40
-              style: TextStyle(fontSize: 20.sp, color: Colors.white),
41
-            ),
42
-            Container(
43
-              margin: EdgeInsets.fromLTRB(0, 20, 0, 10),
44
-              child: Text(
45
-                (5 / 100).toString(),
46
-                style: TextStyle(
47
-                  fontSize: 35.sp,
48
-                  color: Colors.white,
49
-                  fontWeight: FontWeight.bold,
50
-                ),
51
-              ),
52
-            ),
53
-            GestureDetector(
54
-              onTap: () {
55
-                _goWithdrawPage();
56
-              },
57
-              child: Container(
58
-                alignment: Alignment.center,
59
-                width: 70.w,
60
-                height: 34.w,
61
-                decoration: BoxDecoration(
62
-                  borderRadius: BorderRadius.circular(20),
63
-                  gradient: LinearGradient(
64
-
65
-
66
-                    begin: Alignment.topCenter,
67
-                    end: Alignment.bottomCenter,
68
-                    colors: [
69
-                      Color(0xff37BC6A),
70
-                      Color(0xff127B39),
71
-                    ],
72
-                  ),
73
-                ),
74
-                child: Text(
75
-                  '提现',
76
-                  style: TextStyle(
77
-                    fontSize: 24.sp,
78
-                    color: Colors.white,
79
-                    fontWeight: FontWeight.bold,
80
-                  ),
81
-                ),
82
-              ),
83
-            )
84
-          ],
85
-        ),
86
-      );
87
-    } else {
88
-      return _initWidget();
89
-    }
90
-  }
91
-}
92
-
93
-class _initWidget extends StatelessWidget {
94
-  const _initWidget({Key? key}) : super(key: key);
95
-
96
-  @override
97
-  Widget build(BuildContext context) {
98
-    return Container(
99
-      width: 345.w,
100
-      height: 173.w,
101
-      padding: EdgeInsets.fromLTRB(40, 33, 0, 0),
102
-      alignment: Alignment.centerLeft,
103
-      decoration: BoxDecoration(
104
-        borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
105
-        image: const DecorationImage(
106
-          image: AssetImage(
107
-            'images/main/walletBgi.png',
108
-          ),
109
-        ),
110
-      ),
111
-      child: Column(
112
-        children: [
113
-          Text(
114
-            '钱包余额(元)',
115
-            style: TextStyle(fontSize: 20.sp, color: Colors.white),
116
-          ),
117
-          Container(
118
-            margin: EdgeInsets.fromLTRB(0, 20, 0, 10),
119
-            child: Text(
120
-              (5 / 100).toString(),
121
-              style: TextStyle(
122
-                fontSize: 35.sp,
123
-                color: Colors.white,
124
-                fontWeight: FontWeight.bold,
125
-              ),
126
-            ),
127
-          ),
128
-        ],
129
-      ),
130
-    );
131
-  }
132
-}

+ 55
- 58
lib/pages/wallet/widget/moneyInfo.dart Näytä tiedosto

@@ -1,77 +1,74 @@
1
-import 'package:flutter/cupertino.dart';
2 1
 import 'package:flutter/material.dart';
3 2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+import 'package:worker_client/models/entities/Log.dart';
4 4
 
5 5
 class MoneyInfoCard extends StatelessWidget {
6
-  const MoneyInfoCard({Key? key}) : super(key: key);
6
+  final LogModel logData;
7
+  const MoneyInfoCard({Key? key, required this.logData}) : super(key: key);
7 8
 
8 9
   @override
9 10
   Widget build(BuildContext context) {
10 11
     return Container(
11
-      alignment: Alignment.topLeft,
12
-      padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
13
-      decoration: const BoxDecoration(
14
-          border: Border(
15
-              bottom: BorderSide(width: 1, color: Color(0x20000000)
16
-                  // 0x17000000
17
-                  ))),
18
-      child: Row(
19
-        mainAxisAlignment: MainAxisAlignment.spaceBetween,
12
+      margin: EdgeInsets.only(bottom: 1.h),
13
+      padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 10.w),
14
+      decoration: BoxDecoration(
15
+        color: Colors.white,
16
+        boxShadow: [
17
+          BoxShadow(color: const Color(0x20000000), offset: Offset(0, 0.5.h))
18
+        ],
19
+      ),
20
+      child: Column(
21
+        crossAxisAlignment: CrossAxisAlignment.start,
20 22
         children: [
21
-          Column(
22
-            mainAxisAlignment: MainAxisAlignment.center,
23
-            //交叉轴方向从起点开始,默认为center
24
-            crossAxisAlignment: CrossAxisAlignment.start,
23
+          Row(
24
+            mainAxisAlignment: MainAxisAlignment.spaceBetween,
25 25
             children: [
26
-              Container(
27
-                alignment: Alignment.topLeft,
28
-                child: Text(
29
-                  '订单收入',
30
-                  textAlign: TextAlign.left,
31
-                  style: TextStyle(
32
-                    fontWeight: FontWeight.w500,
33
-                    fontSize: 17,
34
-                  ),
26
+              Text(
27
+                logData.chargeType == 'order_pay'
28
+                    ? '订单收入'
29
+                    : logData.chargeType == 'order_refund'
30
+                        ? '用户退款'
31
+                        : logData.chargeType == 'withdraw'
32
+                            ? '提现'
33
+                            : '',
34
+                style: TextStyle(
35
+                  fontWeight: FontWeight.bold,
36
+                  color: const Color(0xff333333),
37
+                  fontSize: 16.sp,
35 38
                 ),
36 39
               ),
37
-              Padding(
38
-                padding: EdgeInsets.fromLTRB(0, 8, 0, 5),
39
-                child: Text('2022-05-01 16:66',
40
-                    style: TextStyle(fontSize: 15, color: Color(0xff666666))),
40
+              Container(
41
+                margin: EdgeInsets.only(right: 5.w),
42
+                child: logData.chargeType == 'order_pay'
43
+                    ? Text(
44
+                        '+${(logData.money ?? 0) / 100}',
45
+                        style: TextStyle(
46
+                          color: const Color(0xffff3f3f),
47
+                          fontSize: 20.sp,
48
+                          fontWeight: FontWeight.bold,
49
+                        ),
50
+                      )
51
+                    : Text(
52
+                        '-${(logData.money ?? 0) / 100}',
53
+                        style: TextStyle(
54
+                          color: const Color(0xff00ae3a),
55
+                          fontSize: 15.sp,
56
+                          fontWeight: FontWeight.bold,
57
+                        ),
58
+                      ),
41 59
               ),
42 60
             ],
43 61
           ),
44
-          RichText(
45
-            text: TextSpan(children: <InlineSpan>[
46
-              const TextSpan(
47
-                  text: '+',
48
-                  style: TextStyle(
49
-                      color: Color(
50
-                        0xffFF3F3F,
51
-                      ),
52
-                      fontSize: 22,
53
-                      fontWeight: FontWeight.bold)),
54
-              TextSpan(
55
-                  text: (2559 / 100).toString(),
56
-                  style: TextStyle(
57
-                      color: Color(
58
-                        0xffFF3F3F,
59
-                      ),
60
-                      fontSize: 22,
61
-                      fontWeight: FontWeight.bold)),
62
-            ]),
62
+          Padding(
63
+            padding: EdgeInsets.only(top: 13.h),
64
+            child: Text(
65
+              logData.createDate.toString().substring(0, 16),
66
+              style: TextStyle(
67
+                fontSize: 15.sp,
68
+                color: const Color(0xff666666),
69
+              ),
70
+            ),
63 71
           ),
64
-
65
-          // RichText(
66
-          //   text: TextSpan(children: <InlineSpan>[
67
-          //     const TextSpan(
68
-          //         text: '-',
69
-          //         style: TextStyle(color: Color(0xff00AE3A,),fontSize: 15,fontWeight: FontWeight.bold)),
70
-          //     TextSpan(
71
-          //         text: (5500/100).toString(),
72
-          //         style: TextStyle(color: Color(0xff00AE3A,),fontSize: 15,fontWeight: FontWeight.bold)),
73
-          //   ]),
74
-          // ),
75 72
         ],
76 73
       ),
77 74
     );

+ 2
- 3
lib/pages/withdrawal/index.dart Näytä tiedosto

@@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
3 3
 import 'package:flutter_picker/Picker.dart';
4 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5 5
 import 'package:get/get.dart';
6
-import 'package:worker_client/pages/wallet/widget/money.dart';
7
-import 'package:worker_client/pages/wallet/widget/moneyInfo.dart';
6
+import 'package:worker_client/widgets/MoneyCard/index.dart';
8 7
 
9 8
 import '../../widgets/MyButton/index.dart';
10 9
 import '../../widgets/layout/BasicPage.dart';
@@ -24,7 +23,7 @@ class MyWithdrawal extends BasicPage {
24 23
           alignment: Alignment.center,
25 24
           child: Column(
26 25
             children: [
27
-              MoneyCard(type: true,),
26
+              MoneyCard(type: true, amounts: 6, goWithDrawal: () {  },),
28 27
               Container(
29 28
                   margin: EdgeInsets.fromLTRB(20, 30.w, 0, 20.w),
30 29
                   alignment: Alignment.topLeft,

+ 23
- 0
lib/services/account.dart Näytä tiedosto

@@ -0,0 +1,23 @@
1
+import 'package:dio/dio.dart';
2
+import '../utils/Request.dart';
3
+import 'package:fluttertoast/fluttertoast.dart';
4
+
5
+/// 账户余额
6
+/// @param {*} data
7
+/// @returns
8
+Future getAccount() async {
9
+  return request('/account/mine',
10
+      options: Options(method: 'GET'))
11
+      .catchError((error) =>
12
+  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
13
+}
14
+
15
+/// 我的流水
16
+/// @param {*} data
17
+/// @returns
18
+Future getLogList(params) async {
19
+  return request('/account-log',
20
+      options: Options(method: 'GET'), queryParameters: params)
21
+      .catchError((error) =>
22
+  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
23
+}

+ 87
- 0
lib/widgets/MoneyCard/index.dart Näytä tiedosto

@@ -0,0 +1,87 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:flutter_screenutil/flutter_screenutil.dart';
3
+
4
+class MoneyCard extends StatefulWidget {
5
+  final bool type;
6
+  final double amounts;
7
+  final GestureTapCallback goWithDrawal;
8
+  const MoneyCard({Key? key, this.type = false, required this.amounts, required this.goWithDrawal}) : super(key: key);
9
+
10
+  @override
11
+  State<MoneyCard> createState() => _MoneyCardState();
12
+}
13
+
14
+class _MoneyCardState extends State<MoneyCard> {
15
+
16
+  @override
17
+  Widget build(BuildContext context) {
18
+    return Container(
19
+      width: 345.w,
20
+      height: 172.5.w,
21
+      padding: EdgeInsets.fromLTRB(40.w, 33.5.w, 0, 22.5.w),
22
+      decoration: BoxDecoration(
23
+        borderRadius: BorderRadius.all(Radius.circular(20.w)),
24
+        image: const DecorationImage(
25
+          image: AssetImage(
26
+            'images/main/walletBgi.png',
27
+          ),
28
+        ),
29
+      ),
30
+      child: Column(
31
+        mainAxisAlignment: MainAxisAlignment.start,
32
+        crossAxisAlignment: CrossAxisAlignment.start,
33
+        children: [
34
+          Text(
35
+            '钱包余额(元)',
36
+            style: TextStyle(
37
+              fontSize: 16.sp,
38
+              color: Colors.white,
39
+            ),
40
+          ),
41
+          Container(
42
+            margin: EdgeInsets.only(top: 20.w),
43
+            child: Text(
44
+              (widget.amounts / 100).toString(),
45
+              style: TextStyle(
46
+                fontSize: 33.sp,
47
+                color: Colors.white,
48
+                fontWeight: FontWeight.bold,
49
+              ),
50
+            ),
51
+          ),
52
+          Visibility(
53
+            visible: !widget.type,
54
+            child: GestureDetector(
55
+              onTap: widget.goWithDrawal,
56
+              child: Container(
57
+                alignment: Alignment.center,
58
+                width: 80.w,
59
+                height: 34.w,
60
+                margin: EdgeInsets.only(top: 12.w),
61
+                decoration: BoxDecoration(
62
+                  borderRadius: BorderRadius.circular(16.w),
63
+                  gradient: const LinearGradient(
64
+                    begin: Alignment.topCenter,
65
+                    end: Alignment.bottomCenter,
66
+                    colors: [
67
+                      Color(0xff37BC6A),
68
+                      Color(0xff127B39),
69
+                    ],
70
+                  ),
71
+                ),
72
+                child: Text(
73
+                  '提现',
74
+                  style: TextStyle(
75
+                    fontSize: 19.sp,
76
+                    color: Colors.white,
77
+                    fontWeight: FontWeight.bold,
78
+                  ),
79
+                ),
80
+              ),
81
+            ),
82
+          ),
83
+        ],
84
+      ),
85
+    );
86
+  }
87
+}

+ 32
- 0
lib/widgets/MyTitle/index.dart Näytä tiedosto

@@ -0,0 +1,32 @@
1
+
2
+import 'package:flutter/material.dart';
3
+import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+
5
+class MyTitle extends StatelessWidget{
6
+  final String title;
7
+
8
+  const MyTitle({Key? key, required this.title}) : super(key: key);
9
+
10
+  @override
11
+  Widget build(BuildContext context) {
12
+    return Container(
13
+      margin: EdgeInsets.fromLTRB(0, 30.w, 0, 5.w),
14
+      decoration: BoxDecoration(
15
+        border: Border(
16
+          left: BorderSide(width: 4.w, color: const Color(0xff000000)),
17
+        ),
18
+      ),
19
+      child: Padding(
20
+        padding: EdgeInsets.only(left: 11.5.w),
21
+        child: Text(
22
+          title,
23
+          style: TextStyle(
24
+            color: const Color(0xff333333),
25
+            fontWeight: FontWeight.bold,
26
+            fontSize: 17.sp,
27
+          ),
28
+        ),
29
+      ),
30
+    );
31
+  }
32
+}