瀏覽代碼

动态轮播图与举报

lizhen_gitee 1 年之前
父節點
當前提交
ad9a8768ef
共有 3 個文件被更改,包括 58 次插入31 次删除
  1. 7 1
      application/api/controller/Banner.php
  2. 51 0
      application/api/controller/Report.php
  3. 0 30
      application/api/controller/User.php

+ 7 - 1
application/api/controller/Banner.php

@@ -15,7 +15,13 @@ class Banner extends Api
     //轮播图
     public function banner()
     {
-        $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 1])->order('weigh', 'desc')->select();
+        $type = input('type',1);
+
+        $where = [
+            'status' => 1,
+            'type'   => $type,
+        ];
+        $list = Db::name('banner')->field('id, title, image, url')->where($where)->order('weigh', 'desc')->select();
         $list = list_domain_image($list, ['image']);
 
         $this->success(1, $list);

+ 51 - 0
application/api/controller/Report.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 意见反馈
+ */
+class Report extends Api
+{
+    protected $noNeedLogin = ['typelist'];
+    protected $noNeedRight = ['*'];
+
+    //类型列表
+    public function typelist(){
+        $list = Db::name('report_type')->order('id asc')->select();
+        $this->success('success',$list);
+    }
+
+    //新增举报
+    public function addone(){
+        $type = input('type','');
+        $to_user_id = input('to_user_id',0);
+        $content = input('content','');
+        $images  = input('images','');
+
+        if(empty($content)){
+            $this->error('内容不能为空');
+        }
+
+        if(!empty($images) && strpos($images,',')){
+            if(count(explode(',',$images)) > 8){
+                $this->error('一次最多只能上传9张图片');
+            }
+        }
+
+        $data = [
+            'user_id' => $this->auth->id,
+            'to_user_id' => $to_user_id,
+            'type' => $type,
+            'content' => $content,
+            'images' => $images,
+            'createtime' => time(),
+            'updatetime' => time(),
+        ];
+
+        $id = Db::name('report')->insertGetId($data);
+        $this->success();
+    }
+}

+ 0 - 30
application/api/controller/User.php

@@ -732,37 +732,7 @@ class User extends Api
         $this->success("账号注销成功!");
     }
 
-    /**
-     * 用户举报
-     *
-     * @param string $mobile 手机号
-     * @param string $captcha 验证码
-     */
-    public function report()
-    {
-        $type = $this->request->param('type');// 类型描述
-        $content = $this->request->param('content');// 内容
-        $images = $this->request->param('images');// 图片
-        $ruser_id = $this->request->param('ruser_id');// 被举报用户ID
-        if (!$type || !$content || !$images || !$ruser_id) {
-            $this->error("请完成举报内容!");
-        }
-        $user_id = $this->auth->id;
-        $data = [];
-        $data["user_id"] = $user_id;
-        $data["ruser_id"] = $ruser_id;
-        $data["type"] = $type;
-        $data["content"] = $content;
-        $data["images"] = $images;
-        $data["createtime"] = time();
-        $res = \app\common\model\UserReport::insert($data);
-        if ($res) {
-            $this->success("举报内容提交成功!");
-        } else {
-            $this->error("网络错误,请稍后重试!");
-        }
 
-    }
 
     /**
      * 获取昵称