Преглед изворни кода

批量创建花店客户--检测数据格式(不能为空,名称不能超过8个汉字,手机号格式要正确)

shizhongqi пре 4 година
родитељ
комит
e70ffe0168
1 измењених фајлова са 18 додато и 0 уклоњено
  1. 18 0
      app-ghs/controllers/CustomController.php

+ 18 - 0
app-ghs/controllers/CustomController.php

@@ -125,6 +125,24 @@ class CustomController extends BaseController
             $mobile = $post['mobile' . $i];
             $confirmMobile = $post['confirmMobile' . $i];
 
+            if (empty($name)) {
+                Yii::info("花店名称不能为空");
+                continue;
+            }
+            if (stringUtil::getWordNum($name) > 8) {
+                Yii::info('名称不能超过8个汉字');
+                continue;
+            }
+
+            if (empty($mobile)) {
+                Yii::info("手机号不能为空");
+                continue;
+            }
+            if (stringUtil::isMobile($mobile) == false) {
+                Yii::info('手机号格式不正确');
+                continue;
+            }
+
             if ($mobile != $confirmMobile) {
                 Yii::info("添加客户失败:mobile " . $mobile . ' != confirmMobile ' . $confirmMobile);
                 continue;