notice message

This commit is contained in:
toogee 2020-04-01 12:18:43 +08:00
parent 642404359a
commit ce856b2502
8 changed files with 49 additions and 39 deletions

View File

@ -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']; //个人通知

View File

@ -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;
}
}

View File

@ -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]);
}
}

View File

@ -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();
//用户回答

View File

@ -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 '更新时间',

View File

@ -70,8 +70,7 @@
,layedit = layui.layedit
,table = layui.table
,form = layui.form;
/*
//发站内通知信息
/*
form.on('select(type)', function(data){
var tpl = '<div class="layui-col-md12">\
<label for="L_title" class="layui-form-label">收件人</label>\

View File

@ -10,7 +10,7 @@
{$u.nickname ?: $u.name}
{if($u.sex==0)}<i class="iconfont icon-nan"></i>
{else}<i class="iconfont icon-nv"></i> {/if}
<i class="layui-badge fly-badge-vip">VIP3</i>
<i class="layui-badge fly-badge-vip">VIP{$u.vip}</i>
<!--
<span style="color:#c00;">(管理员)</span>
<span style="color:#5FB878;">(社区之光)</span>

View File

@ -27,45 +27,40 @@
var id = $(this).attr('id-data');
var othis = $(this);
$.ajax({
type:"post",
url:"{:url('message/read')}",
data:{"id":id},
daType:"json",
success:function (res){
if(res.status == 0){
type:"post",
url:"{:url('message/read')}",
data:{"id":id},
daType:"json",
success:function (res){
if(res.status == 0){
location.reload();
//othis.append('<span class="float:right">已读</span>');
}
}
});
}
});
});
//点开标题写入系统信已读
$('#LAY_minemsg').on('click','.sys-title', function(){
var id = $(this).attr('id-data');
//var othis = $(this);
console.log(id);
var othis = $(this);
$.ajax({
type:"post",
url:"{:url('message/read')}",
data:{"id":id},
daType:"json",
success:function (res){
type:"post",
url:"{:url('message/read')}",
data:{"id":id},
daType:"json",
success:function (res){
if(res.status == 0){
layer.open({
type: 1,
skin: 'layui-layer-rim', //加上边框
area: ['420px', '240px'], //宽高
content: '<div class="layui-form" tyle="padding: 20px 30px 0 0;"> '+ res.content +'</div>'
area: ['500px', '350px'], //宽高
content: '<div class="layui-form" style="padding: 10px 20px 0 20px;"> '+ res.content +'</div>'
});
//location.reload();
//othis.append('<span class="float:right">已读</span>');
//location.reload(); //数据刷新
}
}
});
}
});
});
</script>