李志伟 3 år sedan
förälder
incheckning
a95de53006
3 ändrade filer med 155 tillägg och 108 borttagningar
  1. 139
    103
      lib/pages/withdrawal/index.dart
  2. 12
    1
      lib/services/bank.dart
  3. 4
    4
      lib/widgets/layout/BasicPage.dart

+ 139
- 103
lib/pages/withdrawal/index.dart Visa fil

@@ -1,6 +1,8 @@
1 1
 import 'package:flutter/material.dart';
2
+import 'package:flutter_easyloading/flutter_easyloading.dart';
2 3
 import 'package:flutter_picker/Picker.dart';
3 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
+import 'package:fluttertoast/fluttertoast.dart';
4 6
 import 'package:get/get.dart';
5 7
 import 'package:worker_client/models/entities/BankCard.dart';
6 8
 import 'package:worker_client/services/bank.dart';
@@ -20,8 +22,32 @@ class MyWithdrawal extends BasicPage {
20 22
   int index = 0;
21 23
   final bankCardList = Rx<List<BankCardModel>>([]);
22 24
 
23
-  void headleWithdrawal(){
24
-
25
+  void headleWithdrawal() {
26
+    if (withdrawal.value['money'] != null &&
27
+        double.parse(withdrawal.value['money'].toString()) <
28
+            amounts.value / 100) {
29
+      if (withdrawal.value['accountCardNo'] != null) {
30
+        EasyLoading.show(
31
+          status: '申请中...',
32
+          maskType: EasyLoadingMaskType.black,
33
+        );
34
+        var data = {...withdrawal.value};
35
+        data.remove('ownerBank');
36
+        data['money'] = double.parse(data['money'].toString()) * 100;
37
+        addWithdrawal(data).then((value) {
38
+          EasyLoading.dismiss();
39
+          Fluttertoast.showToast(msg: '提交成功,平台审核后1到3个工作日到账!');
40
+          Get.back();
41
+        }).catchError((onError) {
42
+          EasyLoading.dismiss();
43
+          Fluttertoast.showToast(msg: onError.error['message']);
44
+        });
45
+      } else {
46
+        Fluttertoast.showToast(msg: '请选择您的银行卡!');
47
+      }
48
+    } else {
49
+      Fluttertoast.showToast(msg: '请输入正确的金额!');
50
+    }
25 51
   }
26 52
 
27 53
   @override
@@ -50,118 +76,128 @@ class MyWithdrawal extends BasicPage {
50 76
 
51 77
   @override
52 78
   Widget builder(BuildContext context) {
53
-    return Container(
54
-      margin: EdgeInsets.all(15.w),
55
-      child: Column(
56
-        crossAxisAlignment: CrossAxisAlignment.start,
57
-        children: [
58
-          MoneyCard(
59
-            type: true,
60
-            amounts: amounts.value,
61
-            goWithDrawal: () {},
62
-          ),
63
-          const MyTitle(title: '选择银行卡'),
64
-          GestureDetector(
65
-            child: Container(
66
-              height: 54.h,
67
-              padding: EdgeInsets.symmetric(horizontal: 15.w),
68
-              margin: EdgeInsets.only(top: 15.h),
69
-              decoration: BoxDecoration(
70
-                borderRadius: BorderRadius.circular(20.w),
71
-                border: Border.all(
72
-                  color: const Color(0xffF2F2F2),
73
-                  width: 1.w,
79
+    return Column(
80
+      children: [
81
+        Expanded(
82
+            flex: 1,
83
+            child: ListView(
84
+              padding: EdgeInsets.only(top: 15.h, left: 15.w, right: 15.w),
85
+              children: [
86
+                MoneyCard(
87
+                  type: true,
88
+                  amounts: amounts.value,
89
+                  goWithDrawal: () {},
74 90
                 ),
75
-              ),
76
-              child: Row(
77
-                mainAxisAlignment: MainAxisAlignment.spaceBetween,
78
-                children: [
79
-                  Obx(
80
-                    () => Text(
81
-                      withdrawal.value['ownerBank'] == null
82
-                          ? '请选择银行'
83
-                          : withdrawal.value['ownerBank'].toString() +
84
-                              '(' +
85
-                              withdrawal.value['accountCardNo'].toString().substring(
86
-                                  withdrawal.value['accountCardNo'].toString().length -
87
-                                      4,
88
-                                  withdrawal.value['accountCardNo'].toString().length) +
89
-                              ')',
90
-                      style: TextStyle(
91
-                        fontSize: 16.sp,
92
-                        fontWeight: FontWeight.w500,
93
-                        color: const Color(0xff333333),
91
+                const MyTitle(title: '选择银行卡'),
92
+                GestureDetector(
93
+                  child: Container(
94
+                    height: 54.h,
95
+                    padding: EdgeInsets.symmetric(horizontal: 15.w),
96
+                    margin: EdgeInsets.only(top: 15.h),
97
+                    decoration: BoxDecoration(
98
+                      borderRadius: BorderRadius.circular(20.w),
99
+                      border: Border.all(
100
+                        color: const Color(0xffF2F2F2),
101
+                        width: 1.w,
94 102
                       ),
95 103
                     ),
96
-                  ),
97
-                  Image.asset(
98
-                    'images/main/goto.png',
99
-                    height: 18.h,
100
-                    fit: BoxFit.cover,
101
-                  )
102
-                ],
103
-              ),
104
-            ),
105
-            onTap: () {
106
-              showPicker(context);
107
-            },
108
-          ),
109
-          const MyTitle(title: '提取金额'),
110
-          Container(
111
-            height: 54.h,
112
-            padding: EdgeInsets.symmetric(horizontal: 15.w),
113
-            margin: EdgeInsets.only(top: 15.h),
114
-            decoration: BoxDecoration(
115
-              borderRadius: BorderRadius.circular(20.w),
116
-              border: Border.all(
117
-                color: const Color(0xffF2F2F2),
118
-                width: 1.w,
119
-              ),
120
-            ),
121
-            child: Row(
122
-              children: [
123
-                Padding(
124
-                  padding: EdgeInsets.only(right: 10.w),
125
-                  child: Text(
126
-                    '¥',
127
-                    style: TextStyle(
128
-                      fontSize: 24.sp,
129
-                      fontWeight: FontWeight.w500,
130
-                      color: Color(0xff333333),
104
+                    child: Row(
105
+                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
106
+                      children: [
107
+                        Obx(
108
+                          () => Text(
109
+                            withdrawal.value['ownerBank'] == null
110
+                                ? '请选择银行'
111
+                                : withdrawal.value['ownerBank'].toString() +
112
+                                    '(' +
113
+                                    withdrawal.value['accountCardNo']
114
+                                        .toString()
115
+                                        .substring(
116
+                                            withdrawal.value['accountCardNo']
117
+                                                    .toString()
118
+                                                    .length -
119
+                                                4,
120
+                                            withdrawal.value['accountCardNo']
121
+                                                .toString()
122
+                                                .length) +
123
+                                    ')',
124
+                            style: TextStyle(
125
+                              fontSize: 16.sp,
126
+                              fontWeight: FontWeight.w500,
127
+                              color: const Color(0xff333333),
128
+                            ),
129
+                          ),
130
+                        ),
131
+                        Image.asset(
132
+                          'images/main/goto.png',
133
+                          height: 18.h,
134
+                          fit: BoxFit.cover,
135
+                        )
136
+                      ],
131 137
                     ),
132 138
                   ),
139
+                  onTap: () {
140
+                    showPicker(context);
141
+                  },
133 142
                 ),
134
-                Expanded(
135
-                  child: TextField(
136
-                    keyboardType: TextInputType.number,
137
-                    decoration: const InputDecoration(
138
-                      contentPadding: EdgeInsets.symmetric(vertical: 1),
139
-                      hintText: '请输入提现金额',
140
-                      border: OutlineInputBorder(borderSide: BorderSide.none),
143
+                const MyTitle(title: '提取金额'),
144
+                Container(
145
+                  height: 54.h,
146
+                  padding: EdgeInsets.symmetric(horizontal: 15.w),
147
+                  margin: EdgeInsets.only(top: 15.h),
148
+                  decoration: BoxDecoration(
149
+                    borderRadius: BorderRadius.circular(20.w),
150
+                    border: Border.all(
151
+                      color: const Color(0xffF2F2F2),
152
+                      width: 1.w,
141 153
                     ),
142
-                    onChanged: (e) {
143
-                      withdrawal.value['money']=e;
144
-                    },
154
+                  ),
155
+                  child: Row(
156
+                    children: [
157
+                      Padding(
158
+                        padding: EdgeInsets.only(right: 10.w),
159
+                        child: Text(
160
+                          '¥',
161
+                          style: TextStyle(
162
+                            fontSize: 24.sp,
163
+                            fontWeight: FontWeight.w500,
164
+                            color: const Color(0xff333333),
165
+                          ),
166
+                        ),
167
+                      ),
168
+                      Expanded(
169
+                        child: TextField(
170
+                          keyboardType: TextInputType.number,
171
+                          decoration: const InputDecoration(
172
+                            contentPadding: EdgeInsets.symmetric(vertical: 1),
173
+                            hintText: '请输入提现金额',
174
+                            border:
175
+                                OutlineInputBorder(borderSide: BorderSide.none),
176
+                          ),
177
+                          onChanged: (e) {
178
+                            withdrawal.value['money'] = e;
179
+                          },
180
+                        ),
181
+                      ),
182
+                    ],
145 183
                   ),
146 184
                 ),
147 185
               ],
148 186
             ),
187
+        ),
188
+        Padding(
189
+          padding: EdgeInsets.only(bottom: 16.h + 15.w),
190
+          child: MyButton(
191
+            pwith: 30.w,
192
+            text: '提现',
193
+            type: 0,
194
+            disable: false,
195
+            onClick: () {
196
+              headleWithdrawal();
197
+            },
149 198
           ),
150
-          const Spacer(),
151
-          Padding(
152
-            padding: EdgeInsets.only(bottom: 16.h),
153
-            child: MyButton(
154
-              pwith: 30.w,
155
-              text: '提现',
156
-              type: 0,
157
-              disable: false,
158
-              onClick: () {
159
-                headleWithdrawal();
160
-              },
161
-            ),
162
-          ),
163
-        ],
164
-      ),
199
+        ),
200
+      ],
165 201
     );
166 202
   }
167 203
 
@@ -187,7 +223,7 @@ class MyWithdrawal extends BasicPage {
187 223
           withdrawal({
188 224
             ...withdrawal(),
189 225
             'ownerBank': bankCardList.value[index].ownerBank.toString(),
190
-            'accountCardNo': bankCardList.value[index].cardNo.toString()
226
+            'accountCardNo': bankCardList.value[index].cardId.toString()
191 227
           });
192 228
         });
193 229
     picker.showModal(context);

+ 12
- 1
lib/services/bank.dart Visa fil

@@ -52,4 +52,15 @@ Future unbindBankCard(String id) async {
52 52
       .catchError((error) => {
53 53
     Fluttertoast.showToast(msg: error.error['message']),
54 54
   });
55
-}
55
+}
56
+
57
+/// 添加银行卡
58
+/// @param {*} data
59
+/// @returns
60
+Future addWithdrawal(data) async {
61
+  return request(
62
+    '/withdrawal',
63
+    options: Options(method: 'POST'),
64
+    data: data,
65
+  );
66
+}

+ 4
- 4
lib/widgets/layout/BasicPage.dart Visa fil

@@ -21,8 +21,10 @@ abstract class BasicPage extends StatefulWidget {
21 21
   // 允许滚动 - 不是响应式的
22 22
   bool canScroll;
23 23
 
24
+  bool? isPop;
25
+
24 26
   //
25
-  BasicPage({Key? key, this.canScroll = true, this.tabIndex }) : super(key: key);
27
+  BasicPage({Key? key, this.canScroll = true,this.isPop=false, this.tabIndex }) : super(key: key);
26 28
 
27 29
   @protected
28 30
   Widget builder(BuildContext context);
@@ -103,12 +105,10 @@ class _BasicPageState extends State<BasicPage> {
103 105
   Widget build(BuildContext context) {
104 106
 
105 107
     return Scaffold(
106
-      resizeToAvoidBottomInset: true,
108
+      resizeToAvoidBottomInset: false,
107 109
       appBar: _getAppBar(),
108 110
       body: SafeArea(
109
-        // maintainBottomViewPadding:true,
110 111
         child: widget.builder(context),
111
-
112 112
       ),
113 113
       bottomNavigationBar: widget.tabIndex == null ? null : BottomBar(list: BarList, current: widget.tabIndex!),
114 114
     );