فهرست منبع

发件增加格式验证

daxu0403 7 سال پیش
والد
کامیت
b7036e9709

BIN
android/.gradle/4.10.2/fileHashes/fileHashes.bin


BIN
android/.gradle/4.10.2/fileHashes/fileHashes.lock


BIN
android/.gradle/4.10.2/taskHistory/taskHistory.bin


BIN
android/.gradle/4.10.2/taskHistory/taskHistory.lock


BIN
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock


+ 24 - 21
lib/pages/send_express_page.dart

@@ -1,4 +1,5 @@
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:city_pickers/city_pickers.dart';
 import 'package:flutter_picker/flutter_picker.dart';
@@ -64,7 +65,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
   String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
   String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
   String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
-  String receiptCompanyId='0'; //收件公司id
+  String receiptCompanyId = '0'; //收件公司id
   String receiptCompanyPhone = ''; //收件公司电话 不能为空
   String receiptCompanyName = ''; //收件公司名称 不能为空
   String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
@@ -128,21 +129,15 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
       //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
     });
     sendCompanyPhoneController.addListener(() {
-      if(int.tryParse(sendCompanyPhoneController.text)==null){
-          sendCompanyPhoneController.text = sendCompanyPhone;
-      }
-      if(sendCompanyPhoneController.text.length>11){
-        sendCompanyPhoneController.text = sendCompanyPhone;
-      }
-      print(sendCompanyAddreddController);
-      print(sendCompanyPhoneController.text);
-      setState(() {
-        sendCompanyPhone = sendCompanyPhoneController.text;
-      });
+     
+        setState(() {
+          sendCompanyPhone = sendCompanyPhoneController.text;
+        });
+      
       if (timer != null) {
         timer.cancel();
       }
-      if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length >= 11) {
+      if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
         setState(() {
           tipStatus = true;
         });
@@ -175,13 +170,16 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
     });
 
     receiptCompanyPhoneController.addListener(() {
-      setState(() {
-        receiptCompanyPhone = receiptCompanyPhoneController.text;
-      });
+      
+        setState(() {
+          receiptCompanyPhone = receiptCompanyPhoneController.text;
+        });
+      
+
       if (timer != null) {
         timer.cancel();
       }
-      if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length >= 11) {
+      if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
         setState(() {
           tipStatus = true;
         });
@@ -394,7 +392,6 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
                     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(
@@ -429,8 +426,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
       )
     );
   }
-
-
+  
   Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
     return Padding(
       padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
@@ -741,16 +737,23 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
         if (goods == '') {
           errStr = '请填写货物名称';
         }
-        if (goodsQuantity == 0.0) {
+        if (goodsQuantity == 0) {
           errStr = '请填写货物数量';
+        } 
+        if(int.tryParse(goodsQuantity.toString())==null){
+          errStr='货物数量格式错误';
         }
         if (goodsFreight == 0.0) {
           errStr = '请填写运费';
         }
+        if(int.tryParse(sendCompanyPhone)==null || int.tryParse(receiptCompanyPhone)==null || sendCompanyPhone.length!=11 ||  receiptCompanyPhone.length!=11){
+          errStr='请输入正确的电话';
+        }
         if (errStr != '') {
           showError(errStr);
           return;
         }
+        return;
         setState(() {
           submitStatus = false;
         });