bianjunhui hai 1 ano
pai
achega
72a472643e

+ 34 - 1
application/admin/controller/Message.php

@@ -7,8 +7,11 @@ use app\admin\model\Template;
 use app\admin\model\UserGroup;
 use Exception;
 use think\Db;
+use think\exception\DbException;
 use think\exception\PDOException;
 use think\exception\ValidateException;
+use think\response\Json;
+
 /**
  * 
  *
@@ -30,7 +33,37 @@ class Message extends Backend
         $this->view->assign("statusList", $this->model->getStatusList());
     }
 
-
+    /**
+     * 查看
+     *
+     * @return string|Json
+     * @throws \think\Exception
+     * @throws DbException
+     */
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        $list = $this->model
+            ->where($where)
+            ->order($sort, $order)
+            ->paginate($limit);
+        foreach ($list as  $v) {
+            $wheres['message_id']=$v->id;
+            $count = Db('message_read')->where($wheres)->count();
+            $v['counts'] = $count;
+        }
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
     /**
      * 添加
      *

+ 1 - 0
public/assets/js/backend/message.js

@@ -33,6 +33,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'group_id', title: __('Group_id')},
                         {field: 'group_name', title: __('Group_name'), operate: 'LIKE'},
                         {field: 'type', title: __('Type'), searchList: {0: __('url'), 2: __('订单列表'), 3: __('商品详情'), 4: __('购物车'), 5: __('消息列表'), 1: __('商品列表')}, operate: false, formatter: Table.api.formatter.status,},
+                        {field: 'counts', title: __('点击次数')},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'sendtime', title: __('Sendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},