Bladeren bron

发件增加银行卡信息

daxu0403 7 jaren geleden
bovenliggende
commit
cc5ecf2cd5
5 gewijzigde bestanden met toevoegingen van 225 en 14 verwijderingen
  1. BIN
      lib/images/icon_bank.png
  2. 197 10
      lib/pages/send_express_page.dart
  3. 11 2
      lib/util/api.dart
  4. 16 2
      lib/util/models.dart
  5. 1 0
      pubspec.yaml

BIN
lib/images/icon_bank.png


+ 197 - 10
lib/pages/send_express_page.dart

@@ -55,6 +55,10 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   TextEditingController sendCompanyAddressController = TextEditingController();
   TextEditingController receiptCompanyAddressController = TextEditingController();
 
+  TextEditingController bankCardController = TextEditingController();
+  TextEditingController bankNameController = TextEditingController();
+  TextEditingController openBankNameController = TextEditingController();
+  TextEditingController openBankPhoneController = TextEditingController();
 
 
 
@@ -94,6 +98,11 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   double goodsFreight = 0.0; //商品运费 不能为空
   String memo = ''; //备注
 
+  String bankCard = '';//银行卡号
+  String bankName = '';//所属银行
+  String openBankName = '';//开户人
+  String openBankPhone = '';//开户电话
+
   List<CompanyOfLineList>  lineList = [];
 
   String sendPCA = ' '; //Text组件内容必须有空格,否则报null
@@ -103,6 +112,9 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   String showTextGoodsPackage = ' ';
   String showTextPaymentMehod = '到付';
   BluetoothUtils bluetooth = BluetoothUtils();
+  
+  bool checkedCompanyInfo = false;//选择公司信息向sendCompanyPhoneController填充时不去模糊匹配
+
   @override
   void initState() {
     super.initState();
@@ -138,9 +150,12 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
       //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
     });
     sendCompanyPhoneController.addListener(() {
-
+      if(checkedCompanyInfo){
+        return;
+      } 
       setState(() {
         sendCompanyPhone = sendCompanyPhoneController.text;
+       
       });
 
       if (timer != null) {
@@ -151,8 +166,8 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           tipStatus = true;
         });
       }
-      timer = Timer(Duration(milliseconds: 500), () {
-        if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length < 11) {
+      timer = Timer(Duration(milliseconds: 250), () {
+        if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length <= 11) {
           likePhone(sendCompanyPhoneController.text).then((resp) {
             if (isNotError(context, resp) && this.mounted) {
               LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
@@ -179,11 +194,13 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     });
 
     receiptCompanyPhoneController.addListener(() {
-
+      if(checkedCompanyInfo){
+        return;
+      } 
       setState(() {
         receiptCompanyPhone = receiptCompanyPhoneController.text;
       });
-
+              
 
       if (timer != null) {
         timer.cancel();
@@ -193,8 +210,8 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           tipStatus = true;
         });
       }
-      timer = Timer(Duration(milliseconds: 500), () {
-        if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length < 11) {
+      timer = Timer(Duration(milliseconds: 250), () {
+        if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length <= 11) {
           likePhone(receiptCompanyPhoneController.text).then((resp) {
             if (isNotError(context, resp) && this.mounted) {
               LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
@@ -257,6 +274,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                   _sendInfo(context),
                   _getInfo(context),
                   _itemInfoWidget(),
+                  _bankInfo(context),
                   _submitBtn()
                 ],
               ),
@@ -316,7 +334,6 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
           _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
           _underLine(),
           _inputWiget('电话', 'getPhone'),
-          //_contentWiget('企业编码', 'get', true),
           _contentWiget('企业名称', 'get', true),
           _cityWiget('城市/区域', context, 'get'),
           _lastContentWiget('详细地址', 'get')
@@ -329,6 +346,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     return Container(
       child: Container(
         color: Colors.white,
+        margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
         child: Column(
           crossAxisAlignment: CrossAxisAlignment.start,
           children: < Widget > [
@@ -350,6 +368,23 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
+  Widget _bankInfo(BuildContext context) {
+    return Container(
+      color: Colors.white,
+      margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
+      child: Column(
+        children: < Widget > [
+          _titleWidget('lib/images/icon_bank.png', '银行信息'),
+          _underLine(),
+          _contentBankWiget('银行卡号', 'bank'),
+          _contentBankWiget('银行名称', 'bank',true),
+          _contentBankWiget('开户人', 'bank',true),
+          _lastBankContentWiget('开户电话', 'bank'),
+        ],
+      )
+    );
+  }
+
 
   Widget _titleWidget(String iconUrl, String str) {
     return Container(
@@ -416,7 +451,46 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                                 tipStatus = true;
                               });
                             },
+                            onChanged: (value){
+                              checkedCompanyInfo = false;
+                              if(tab=='sendPhone'){
+                                sendCompanyCode = '';
+                                sendCompanyName = '';
+                                sendCompanyId ='0';
+                                sendCompanyCodeController.text = '';
+                                sendCompanyNameController.text = '';
+
+                                sendPCA = '';
+                                sendCompanyProvinceName = '';
+                                sendCompanyProvinceCode = '';
+                                sendCompanyCityName = '';
+                                sendCompanyCityCode = '';
+                                sendCompanyAreaName = '';
+                                sendCompanyAreaCode = '';
+
+                                bankCardController.text = '';
+                                bankNameController.text = '';
+                                openBankNameController.text = '';
+                                openBankPhoneController.text = '';
 
+                                sendCompanyAddressController.text = '';
+                              }else if(tab=='getPhone'){
+                                  receiptCompanyName = '';
+                                  receiptCompanyNameController.text = '';
+                                  receiptCompanyId = null;
+                                 
+                                  getPCA = '';
+                                  receiptCompanyProvinceName = '';
+                                  receiptCompanyProvinceCode = '';
+                                  receiptCompanyCityName = '';
+                                  receiptCompanyCityCode = '';
+                                  receiptCompanyAreaName = '';
+                                  receiptCompanyAreaCode = '';
+
+                                  receiptCompanyAddressController.text = '';
+                              }
+                             
+                            },
                           ),
                         ),
                         Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
@@ -485,7 +559,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                                     receiptCompanyName = value;
                                   });
                                 }
-                              } else {
+                              } else if(type=='goods') {
                                 if (key == '货物名称') {
                                   goods = value;
                                 } else if (key == '数量') {
@@ -507,6 +581,16 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                                   String temp = goodsWeight.toStringAsFixed(1);
                                   goodsWeight = double.parse(temp);
                                 }
+                              }else if(type=='bank'){
+                                if(key == '银行卡号'){
+                                  bankCard = value;
+                                }else if(key=='银行名称'){
+                                  bankName = value;
+                                }else if(key == '开户人'){
+                                  openBankName = value;
+                                }else if(key == '开户电话'){
+                                  openBankPhone = value;
+                                }
                               }
                             },
                           ),
@@ -529,6 +613,55 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
+   Widget _contentBankWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
+    return Padding(
+      padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
+      child: Column(
+        children: < Widget > [
+          SizedBox(
+            height: ScreenUtil.getInstance().setHeight(89),
+            child: Center(
+              child: Row(
+                mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                children: < Widget > [
+                  Expanded(
+                    flex: 0,
+                    child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+                  ),
+                  Expanded(
+                    child: Row(
+                      mainAxisAlignment: MainAxisAlignment.end,
+                      children: < Widget > [
+                        SizedBox(
+                          width: ScreenUtil.getInstance().setWidth(500),
+                          child: TextField(
+                            controller: key == '银行卡号'?bankCardController:key=='银行名称'?bankNameController:openBankNameController,
+                            keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
+                            textAlign: TextAlign.end,
+                            decoration: InputDecoration(
+                              border: InputBorder.none
+                            ),
+                          ),
+                        ),
+
+                        Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
+                      ],
+                    )
+                  )
+                ],
+              ),
+            )
+          ),
+          Expanded(
+            flex: 0,
+            child: _underLine()
+          )
+        ],
+      )
+    );
+  }
+
+
   Widget _cityWiget(String key, BuildContext context, String type) {
     return
     GestureDetector(
@@ -641,6 +774,45 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     );
   }
 
+  Widget _lastBankContentWiget(String key, String type) {
+    return Padding(
+      padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
+      child: SizedBox(
+        height: ScreenUtil.getInstance().setHeight(89),
+        child: Center(
+          child: Row(
+            mainAxisAlignment: MainAxisAlignment.spaceBetween,
+            children: < Widget > [
+              Expanded(
+                flex: 0,
+                child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
+              ),
+              Expanded(
+                child: Row(
+                  mainAxisAlignment: MainAxisAlignment.end,
+                  children: < Widget > [
+                    //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
+                    SizedBox(
+                      width: ScreenUtil.getInstance().setWidth(500),
+                      child: TextField(
+                        controller: openBankPhoneController,
+                        textAlign: TextAlign.end,
+                        decoration: InputDecoration(
+                          border: InputBorder.none
+                        ),
+                      ),
+                    ),
+                    Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
+                  ],
+                )
+              )
+            ],
+          ),
+        )
+      )
+    );
+  }
+
   Widget _descWidget() {
     return
     Container(
@@ -760,9 +932,14 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
         if (goodsFreight == 0.0) {
           errStr = '请填写运费';
         }
-        if (int.tryParse(sendCompanyPhone) == null || int.tryParse(receiptCompanyPhone) == null || sendCompanyPhone.length != 11 || receiptCompanyPhone.length != 11) {
+        if (sendCompanyPhone == '' || receiptCompanyPhone == '' ) {
           errStr = '请输入正确的电话';
         }
+        if (goodsAgencyFund>0 && sendCompanyId=='0') {//如果有代收,接没有拿到公司id
+          if(bankNameController.text=='' || bankCardController.text=='' || openBankNameController.text=='' || openBankPhoneController.text==''){
+            errStr = "请补全银行卡信息";
+          }
+        }
         if (errStr != '') {
           showError(errStr);
           return;
@@ -816,6 +993,10 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
             goodsAgencyFund * 100, //商品代收款,已分为单位
             goodsFreight * 100, //商品运费 不能为空 ,已分为单位
             memo, //备注
+            bankCardController.text,
+            bankNameController.text,
+            openBankNameController.text,
+            openBankPhoneController.text
           ).then((resp) {
             if (isNotError(context, resp) && this.mounted) {
               setState(() {
@@ -977,6 +1158,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
               ),
             ),
             onTap: () {
+              checkedCompanyInfo = true;
               if (sendPhoneOrGetPhoneTab) {
                 sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
                 sendCompanyCode = obj.companyCode;
@@ -995,6 +1177,11 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                 sendCompanyAreaCode = obj.areaCode;
 
                 sendCompanyAddressController.text = obj.address;
+
+                bankCardController.text = obj.bankCard;
+                bankNameController.text = obj.bankName;
+                openBankNameController.text = obj.openBankName;
+                openBankPhoneController.text = obj.openBankPhone;
               } else {
                 receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
                 receiptCompanyName = obj.companyName;

+ 11 - 2
lib/util/api.dart

@@ -89,7 +89,12 @@ Future createOrder(
   double goodsPriceProtection, //商品保价
   double goodsAgencyFund, //商品代收款
   double goodsFreight, //运费 不能为空
-  String memo //备注
+  String memo,
+  String bankCard,
+  String bankName,
+  String openBankName,
+  String openBankPhone,
+   //备注
 ) async {
   var response = await Http().post('app/order/logistics_order_create', data: {
     'lineId':lineId,
@@ -124,7 +129,11 @@ Future createOrder(
     'goodsPriceProtection': goodsPriceProtection,
     'goodsAgencyFund': goodsAgencyFund,
     'goodsFreight': goodsFreight,
-    'memo': memo
+    'memo': memo,
+    'bankCard':bankCard,
+    'bankName':bankName,
+    'openBankName':openBankName,
+    'openBankPhone':openBankPhone,
   });
   return response;
 }

+ 16 - 2
lib/util/models.dart

@@ -284,6 +284,10 @@ class LikePhoneList {
   String provinceCode;
   String provinceName;
   String uzerPhone;
+  String bankCard;
+  String bankName;
+  String openBankName;
+  String openBankPhone;
 
   LikePhoneList(
       {this.address,
@@ -297,7 +301,12 @@ class LikePhoneList {
       this.id,
       this.provinceCode,
       this.provinceName,
-      this.uzerPhone});
+      this.uzerPhone,
+      this.bankCard,
+      this.bankName,
+      this.openBankName,
+      this.openBankPhone,
+      });
 
   factory LikePhoneList.fromJson(Map<String, dynamic> json) {
     return LikePhoneList(
@@ -312,7 +321,12 @@ class LikePhoneList {
         id: json['id'],
         provinceCode: json['provinceCode'],
         provinceName: json['provinceName'],
-        uzerPhone: json['uzerPhone']);
+        uzerPhone: json['uzerPhone'],
+        bankCard:json['bankCard'],
+        bankName:json['bankName'],
+        openBankName:json['openBankName'],
+        openBankPhone:json['openBankPhone'],
+        );
   }
 }
 

+ 1 - 0
pubspec.yaml

@@ -78,6 +78,7 @@ flutter:
     - lib/images/icon_mimas.png
     - lib/images/icon_dayinji.png
     - lib/images/loading.gif
+    - lib/images/icon_bank.png
   # An image asset can refer to one or more resolution-specific "variants", see
   # https://flutter.io/assets-and-images/#resolution-aware.