diff --git a/app/admin/controller/Notice.php b/app/admin/controller/Notice.php index a2032ec..75e11d0 100644 --- a/app/admin/controller/Notice.php +++ b/app/admin/controller/Notice.php @@ -36,7 +36,8 @@ class Notice extends AdminController //添加消息 public function add() { - $sendId = Session::get('user_id'); + $sendId = Session::get('admin_id'); + var_dump($sendId); $data = Request::only(['type','title','receve_id','content']); if($data['type'] == 1){ $receveId = $data['receve_id']; //个人通知 diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index ac26567..bc17e99 100644 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -27,7 +27,7 @@ class User extends AdminController { if(Request::isAjax()){ $datas = Request::only(['id','name','email','sex']); - $map = array_filter($datas); + $map = array_filter($datas,[$this,'filtrArr']); $user = Db::name('user')->where(['delete_time'=>0])->where($map)->order('id desc')->select(); $count = $user->count(); $res = []; @@ -167,4 +167,13 @@ class User extends AdminController return json($res); } + //过滤数组中为空和null的值 + public function filtrArr($arr) + { + if($arr === '' || $arr === null){ + return false; + } + return true; + } + } diff --git a/app/index/controller/Message.php b/app/index/controller/Message.php index b0468a0..23abce0 100644 --- a/app/index/controller/Message.php +++ b/app/index/controller/Message.php @@ -50,16 +50,22 @@ class Message extends BaseController { $id =input('id'); //$msg = Db::name('message_to')->where('id',$id)->save(['is_read'=>1]); - - $msg = MessageTo::field('id,message_id')->with(['messages' => function($query){ + if($id){ + $msg = MessageTo::field('id,message_id')->with(['messages' => function($query){ $query->where('delete_time',0)->field('id,content'); }])->where('id',$id)->find(); - //改变读状态 - $result = $msg->update(['id'=>$id,'is_read'=>1]); - if($result){ - $res=['status' =>0,'content'=>$msg['messages']['content']]; - return json($res); - } + //改变读状态 + $result = $msg->update(['id'=>$id,'is_read'=>1]); + if($result){ + $res=['status' =>0,'content'=>$msg['messages']['content']]; + return json($res); + } + + } else { + return json(['status' =>0]); + } + + } diff --git a/app/index/controller/User.php b/app/index/controller/User.php index 3525a69..aff645b 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -139,7 +139,7 @@ class User extends BaseController public function home($id) { //用户 - $u = Db::name('user')->field('name,nickname,city,sex,sign,user_img,point,create_time')->cache(3600)->find($id); + $u = Db::name('user')->field('name,nickname,city,sex,sign,user_img,point,vip,create_time')->cache(3600)->find($id); //用户发贴 $arts = Db::name('user')->alias('u')->join('article a','u.id = a.user_id')->field('u.id,a.id,a.title,a.pv,a.is_hot,a.create_time,a.delete_time')->where('a.delete_time',0)->where('a.user_id',$id)->order(['a.create_time'=>'desc'])->cache(3600)->select(); //用户回答 diff --git a/app/install/data/taoler.sql b/app/install/data/taoler.sql index eb7f79c..b337636 100644 --- a/app/install/data/taoler.sql +++ b/app/install/data/taoler.sql @@ -249,7 +249,7 @@ CREATE TABLE `tao_message` ( `title` varchar(255) NOT NULL COMMENT '消息标题', `content` text COMMENT '消息内容', `user_id` int(11) NOT NULL COMMENT '发送人ID', - `link` varchar(255) NOT NULL COMMENT '链接', + `link` varchar(255) COMMENT '链接', `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '消息类型0系统消息1普通消息', `create_time` int(11) NOT NULL COMMENT '创建时间', `update_time` int(11) NOT NULL COMMENT '更新时间', diff --git a/view/admin/notice/index.html b/view/admin/notice/index.html index accf798..c5a6bfc 100644 --- a/view/admin/notice/index.html +++ b/view/admin/notice/index.html @@ -70,8 +70,7 @@ ,layedit = layui.layedit ,table = layui.table ,form = layui.form; -/* - //发站内通知信息 +/* form.on('select(type)', function(data){ var tpl = '
\ \ diff --git a/view/index/user/home.html b/view/index/user/home.html index a0f5898..83edf70 100644 --- a/view/index/user/home.html +++ b/view/index/user/home.html @@ -10,7 +10,7 @@ {$u.nickname ?: $u.name} {if($u.sex==0)} {else} {/if} - VIP3 + VIP{$u.vip}