linwu hai 9 meses
pai
achega
ed29c5506a

+ 29 - 0
app/common/validate/AppealValidate.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace app\common\validate;
+
+use think\Validate;
+
+class AppealValidate extends Validate
+{
+    protected $rule = [
+        'company_name'    => 'require',
+        'company_contact' => 'require',
+        'street'          => 'require',
+        'cate'            => 'require',
+        'content'         => 'require',
+        'filled_by'       => 'require',
+        'mobile'          => 'require|mobile',
+    ];
+
+    protected $message = [
+        'company_name'    => '企业名称不能为空',
+        'company_contact' => '联系人及职务不能为空',
+        'street'          => '先选择镇街',
+        'cate'            => '需求类别不能为空',
+        'content'         => '具体内容不能为空',
+        'filled_by'       => '填表人不能为空',
+        'mobile'          => '联系电话格式错误',
+    ];
+
+}

+ 17 - 0
app/mobile/controller/Jfm.php

@@ -2,12 +2,15 @@
 
 namespace app\mobile\controller;
 
+use app\common\model\AppealModel;
 use app\common\model\ArticleModel;
 use app\common\model\NavigationModel;
 use app\common\model\PolicyModel;
 use app\common\model\SlideModel;
 use app\common\model\StreetModel;
+use app\common\validate\AppealValidate;
 use app\mobile\MobileBaseController;
+use think\exception\ValidateException;
 
 class Jfm extends MobileBaseController
 {
@@ -36,6 +39,20 @@ class Jfm extends MobileBaseController
         ]);
     }
 
+    public function appealPost()
+    {
+        $data = input('post.');
+        try {
+            validate(AppealValidate::class)->check($data);
+        } catch (ValidateException $e) {
+            ajax_return(1, $e->getError());
+        }
+
+        AppealModel::create($data);
+
+        ajax_return(0, '提交成功');
+    }
+
     public function policy()
     {
         $list = PolicyModel::where('status', PolicyModel::STATUS_PUBLISH)->select();

+ 0 - 7
app/mobile/view/jfm/appeal.html

@@ -137,13 +137,6 @@
 
         //表单提交
         base.onSubmit = () => {
-            if (base.form.avatar === '') {
-                vant.showToast('请上传头像');
-            }
-            if (base.form.gender === 0) {
-                vant.showToast('请选择性别');
-            }
-
             postJson('/jfm/appealPost',base.form).then(({code,msg}) => {
                 vant.showDialog({
                     title: '提示',