xxxrrrdddd 3 years ago
parent
commit
a98b3a7342
3 changed files with 65 additions and 31 deletions
  1. 19 16
      application/api/controller/Common.php
  2. 3 1
      application/common/model/Feedback.php
  3. 43 14
      public/api.html

+ 19 - 16
application/api/controller/Common.php

@@ -8,6 +8,8 @@ use app\common\exception\UploadException;
 use app\common\library\Upload;
 use app\common\model\Ad;
 use app\common\model\Area;
+use app\common\model\Feedback;
+use app\common\service\SmsSend;
 use think\Cache;
 use think\Config;
 use think\File;
@@ -17,7 +19,7 @@ use think\File;
  */
 class Common extends Api
 {
-    protected $noNeedLogin = ['agreement','ads','area','area_sort','area_tree','config','get_area','upload'];
+    protected $noNeedLogin = ['agreement','ads','area','area_sort','area_tree','config','get_area','upload','feedback'];
     protected $noNeedRight="*";
     /**
      * 获取各种协议
@@ -115,26 +117,27 @@ class Common extends Api
     }
     /**
      * 意见反馈
-     * @ApiParams (name=type,description="类型")
-     * @ApiParams (name=body,description=内容)
-     * @ApiParams (name=contact,description=联系方式)
+     * @ApiParams (name=name,description="称呼")
+     * @ApiParams (name=phone,description=电话)
+     * @ApiParams (name=sms_code,description=验证码)
+     * @ApiParams (name=title,description=标题)
+     * @ApiParams (name=content,description=内容)
+     * @ApiParams (name=images,description=图片数组)
      */
     public function feedback(){
         $data=input();
         $this->validate($data,[
-            'type'=>['require','max:32'],
-            'body'=>['require','max:250'],
-            'contact'=>['require','max:50'],
+            'name'=>['require','max:10'],
+            'phone'=>['require','integer','length:11'],
+            'title'=>['require','max:10'],
+            'content'=>['require','max:120'],
+            'images'=>['require','array','max:3','min:1'],
+            'images.0'=>['require','url'],
         ]);
-        if($this->auth->getUser()->feedback()->whereTime('created_at','today')->count()>=1){
-            $this->error('您今日已反馈过了');
-        }
-        $this->auth->getUser()->feedback()->save([
-            'type'=>$data['type'],
-            'body'=>$data['body'],
-            'contact'=>$data['contact'],
-        ]);
-        $this->success();
+        SmsSend::setMobile($data['phone'])->setCode($data['sms_code']??'')->check();
+        $feedback=new Feedback();
+        $feedback->allowField(true)->save($data);
+        $this->success('',$feedback);
     }
     /**
      * 获取地区信息

+ 3 - 1
application/common/model/Feedback.php

@@ -29,7 +29,9 @@ class Feedback extends Model
     protected $append = [
         'created_at_text'
     ];
-    
+    protected $type=[
+        'images'=>'array',
+    ];
 
     
 

+ 43 - 14
public/api.html

@@ -175,7 +175,6 @@
                                                             </span>
                         </a>
                                                 <a href="#b7ef56c6cafd32b851206aa91ac95c53" md5="b7ef56c6cafd32b851206aa91ac95c53" data-id="5" class="list-group-item api-list">意见反馈                            <span class="tag">
-                                                                    <span class="label label-success pull-right noneedlogin">登</span>
                                                             </span>
                         </a>
                                                 <a href="#97815f0f57b63c7080cf686e9a015db9" md5="97815f0f57b63c7080cf686e9a015db9" data-id="6" class="list-group-item api-list">获取地区信息                            <span class="tag">
@@ -1169,7 +1168,7 @@
                                                 <tbody>
                                                 <tr>
                                                     <td>登录</td>
-                                                    <td></td>
+                                                    <td></td>
                                                 </tr>
                                                 <tr>
                                                     <td>鉴权</td>
@@ -1199,22 +1198,40 @@
                                                 </thead>
                                                 <tbody>
                                                                                                         <tr>
-                                                        <td>type</td>
+                                                        <td>name</td>
                                                         <td>string</td>
                                                         <td>是</td>
-                                                        <td>类型</td>
+                                                        <td>称呼</td>
                                                     </tr>
                                                                                                         <tr>
-                                                        <td>body</td>
+                                                        <td>phone</td>
+                                                        <td>string</td>
+                                                        <td>是</td>
+                                                        <td>电话</td>
+                                                    </tr>
+                                                                                                        <tr>
+                                                        <td>sms_code</td>
+                                                        <td>string</td>
+                                                        <td>是</td>
+                                                        <td>验证码</td>
+                                                    </tr>
+                                                                                                        <tr>
+                                                        <td>title</td>
+                                                        <td>string</td>
+                                                        <td>是</td>
+                                                        <td>标题</td>
+                                                    </tr>
+                                                                                                        <tr>
+                                                        <td>content</td>
                                                         <td>string</td>
                                                         <td>是</td>
                                                         <td>内容</td>
                                                     </tr>
                                                                                                         <tr>
-                                                        <td>contact</td>
+                                                        <td>images</td>
                                                         <td>string</td>
                                                         <td>是</td>
-                                                        <td>联系方式</td>
+                                                        <td>图片数组</td>
                                                     </tr>
                                                                                                     </tbody>
                                             </table>
@@ -1239,16 +1256,28 @@
                                                 <div class="panel-body">
                                                     <form enctype="application/x-www-form-urlencoded" role="form" action="/api/common/feedback" method="get" name="form5" id="form5">
                                                                                                                 <div class="form-group">
-                                                            <label class="control-label" for="type">type</label>
-                                                            <input type="string" class="form-control input-sm" id="type" required placeholder="类型" name="type">
+                                                            <label class="control-label" for="name">name</label>
+                                                            <input type="string" class="form-control input-sm" id="name" required placeholder="称呼" name="name">
                                                         </div>
                                                                                                                 <div class="form-group">
-                                                            <label class="control-label" for="body">body</label>
-                                                            <input type="string" class="form-control input-sm" id="body" required placeholder="内容" name="body">
+                                                            <label class="control-label" for="phone">phone</label>
+                                                            <input type="string" class="form-control input-sm" id="phone" required placeholder="电话" name="phone">
+                                                        </div>
+                                                                                                                <div class="form-group">
+                                                            <label class="control-label" for="sms_code">sms_code</label>
+                                                            <input type="string" class="form-control input-sm" id="sms_code" required placeholder="验证码" name="sms_code">
+                                                        </div>
+                                                                                                                <div class="form-group">
+                                                            <label class="control-label" for="title">title</label>
+                                                            <input type="string" class="form-control input-sm" id="title" required placeholder="标题" name="title">
+                                                        </div>
+                                                                                                                <div class="form-group">
+                                                            <label class="control-label" for="content">content</label>
+                                                            <input type="string" class="form-control input-sm" id="content" required placeholder="内容" name="content">
                                                         </div>
                                                                                                                 <div class="form-group">
-                                                            <label class="control-label" for="contact">contact</label>
-                                                            <input type="string" class="form-control input-sm" id="contact" required placeholder="联系方式" name="contact">
+                                                            <label class="control-label" for="images">images</label>
+                                                            <input type="string" class="form-control input-sm" id="images" required placeholder="图片数组" name="images">
                                                         </div>
                                                                                                                 <div class="form-group form-group-submit">
                                                             <button type="submit" class="btn btn-success send" rel="5">提交</button>
@@ -8856,7 +8885,7 @@
 
                 </div>
                 <div class="col-md-6" align="right">
-                    Generated on 2022-04-13 16:59:19 <a href="./" target="_blank">靓号</a>
+                    Generated on 2022-04-13 17:17:30 <a href="./" target="_blank">靓号</a>
                 </div>
             </div>