完善后台消息提示
This commit is contained in:
@@ -1249,4 +1249,18 @@ class Common extends CI_Controller
|
||||
$this->data = $rows;
|
||||
return $this->show_json(SYS_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
public function set_notice()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$this->load->model('sys/sys_notice_model');
|
||||
if ($this->uid) {
|
||||
$where = ['uid' => $this->uid, 'platform' => Sys_notice_model::PLAT_FORM_ADMIN];
|
||||
if ($id) {
|
||||
$where['id'] = $id;
|
||||
}
|
||||
$this->sys_notice_model->update(['read' => Sys_notice_model::STATUS_READ], $where);
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class Welcome extends CI_Controller
|
||||
$where = [
|
||||
'platform' => Sys_notice_model::PLAT_FORM_ADMIN,
|
||||
'uid' => $this->uid,
|
||||
'read' => Sys_notice_model::STATUS_UNREAD
|
||||
];
|
||||
$_noticeCount = $this->sys_notice_model->count($where);
|
||||
if ($_noticeCount) {
|
||||
|
||||
@@ -6,15 +6,48 @@ class Notice extends HD_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('sys/sys_notice_model');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->lists();
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$this->load->view('sys/notice/lists');
|
||||
$params = $this->input->get();
|
||||
|
||||
$page = $this->input->get('page') ?: 1;
|
||||
$pageSize = 20;
|
||||
$where = [
|
||||
'platform' => Sys_notice_model::PLAT_FORM_ADMIN,
|
||||
'uid' => $this->uid
|
||||
];
|
||||
strlen($params['read']) && $where['read'] = intval($params['read']);
|
||||
$count = $this->sys_notice_model->count($where);
|
||||
$list = [];
|
||||
if ($count) {
|
||||
$rows = $this->sys_notice_model->select($where, 'id desc', $page, $pageSize);
|
||||
foreach ($rows as $item) {
|
||||
$list[] = [
|
||||
'id' => $item['id'],
|
||||
'icon' => Sys_notice_model::ICON_TYPE[$item['icon']] ?: Sys_notice_model::ICON_DEFAULT,
|
||||
'content' => $item['content'],
|
||||
'url' => $item['url'],
|
||||
'read' => intval($item['read']),
|
||||
'readCn' => $item['read'] ? '已读' : '未读',
|
||||
'type' => $item['type'],
|
||||
'c_time' => date('Y-m-d H:i:s', $item['c_time'])
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->data['params'] = $params;
|
||||
$this->data['readList'] = Sys_notice_model::READ_STATUS;
|
||||
$this->data['lists'] = $list;
|
||||
$this->data['_title'] = '系统消息';
|
||||
$this->data['pager'] = array('count' => ceil($count / $pageSize), 'curr' => $page, 'totle' => $count);
|
||||
$this->show_view('sys/notice/lists', true);
|
||||
}
|
||||
|
||||
public function add()
|
||||
@@ -44,4 +77,31 @@ class Notice extends HD_Controller
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit_read()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$field = $this->input->post('field');
|
||||
$value = $this->input->post('value');
|
||||
$read = $this->input->post('read');
|
||||
|
||||
if ('read' == $field) {
|
||||
$read = $value;
|
||||
}
|
||||
|
||||
$upd = array('read' => $read);
|
||||
$where = ['uid' => $this->uid, 'platform' => Sys_notice_model::PLAT_FORM_ADMIN];
|
||||
if (is_numeric($id)) {
|
||||
$where['id'] = $id;
|
||||
} else {
|
||||
$where["id in ({$id})"] = null;
|
||||
}
|
||||
|
||||
$ret = $this->sys_notice_model->update($upd, $where);
|
||||
if (!$ret) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class Wss extends HD_Controller
|
||||
'uid' => $info['uid'],
|
||||
'content' => $info['content'],
|
||||
];
|
||||
$params['url'] = $info['url'] ?: '';
|
||||
$endPlatform = Ws_conn_model::PLAT_FORM_SYS_ADMIN;
|
||||
/** @var MyResponse $req */
|
||||
$req = $this->sys_notice_model->addNotice($params, $endPlatform, 8888888, true);
|
||||
|
||||
+48
-5
@@ -75,8 +75,8 @@
|
||||
<a class="tit" href="javascript:;">通知<b><i>{{ countNotice }}</i></b></a>
|
||||
<ul class="dropdown-list" style="width: 180px">
|
||||
<template v-if="notice.length > 0">
|
||||
<li v-for="item in notice">
|
||||
<a href="#"
|
||||
<li v-for="(item,index) in notice">
|
||||
<a @click="setRead(item,index)" href="#"
|
||||
style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
|
||||
{{ item.content}}
|
||||
</a>
|
||||
@@ -84,10 +84,11 @@
|
||||
<!-- 按钮容器:使用Flex实现左右分栏 -->
|
||||
<li style="display: flex; border-top: 1px solid #eee; margin-top: 4px;">
|
||||
<a href="javascript:void(0);"
|
||||
style="color: #ff4d4f; flex: 1; text-align: center; padding: 4px 0; text-decoration: none;">
|
||||
style="color: #ff4d4f; flex: 1; text-align: center; padding: 4px 0; text-decoration: none;"
|
||||
@click="clearNotice">
|
||||
<i class="fa"></i> 清除所有
|
||||
</a>
|
||||
<a href="javascript:void(0);"
|
||||
<a data-open="/sys/notice" href="javascript:void(0);"
|
||||
style="flex: 1; text-align: center; padding: 4px 0; text-decoration: none; color: inherit;">
|
||||
<i class="fa"></i> 查看更多
|
||||
</a>
|
||||
@@ -216,7 +217,49 @@
|
||||
},
|
||||
mounted: function () {
|
||||
},
|
||||
methods: {}
|
||||
methods: {
|
||||
clearNotice() {
|
||||
let that = this;
|
||||
$.post('/common/set_notice', {}, function (data) {
|
||||
if (data.code) {
|
||||
layer.msg(data.msg, {icon: 1});
|
||||
that.countNotice = 0;
|
||||
that.notice = [];
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
})
|
||||
},
|
||||
setRead(item, index) {
|
||||
let that = this;
|
||||
$.post('/common/set_notice', {id: item.id}, function (data) {
|
||||
if (data.code) {
|
||||
that.notice.splice(index, 1);
|
||||
that.countNotice--;
|
||||
let btn = ['关闭'];
|
||||
if (item.url) {
|
||||
btn = ['查看详情', '关闭'];
|
||||
}
|
||||
layer.confirm(item.content, {
|
||||
btn: btn,
|
||||
title: '通知详情'
|
||||
}, function (index) {
|
||||
// 点击查看详情
|
||||
if (item.url) {
|
||||
$.form.href(item.url);
|
||||
}
|
||||
layer.close(index);
|
||||
}, function (index) {
|
||||
// 点击关闭
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
// 初始化 WebSocket 连接
|
||||
initWebSocket();
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/sys/notice" class="form-search" onsubmit="return false">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">状态:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="read" v-model="params.read">
|
||||
<option value="">全部</option>
|
||||
<option :value="i" v-for="(v,i) in readList">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="coms-table-bd">
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">
|
||||
<label><input type="checkbox" data-check-target=".ids"></label>
|
||||
<span>ID</span>
|
||||
</th>
|
||||
<th width="20%"><span>通知内容</span></th>
|
||||
<th width="10%"><span>通知时间</span></th>
|
||||
<th width="8%"><span>状态</span></th>
|
||||
<th width="8%"><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="(v,i) in lists">
|
||||
<tr>
|
||||
<td>
|
||||
<label><input type="checkbox" name="ids[]" class="ids" :value="v.id"/></label>
|
||||
</td>
|
||||
<td>
|
||||
<a v-if="v.url" :data-open="v.url" href="javascript:void(0);">
|
||||
{{v.content}}
|
||||
</a>
|
||||
<span v-else>{{ v.content }}</span>
|
||||
</td>
|
||||
<td>{{v.c_time}}</td>
|
||||
<td>
|
||||
<span v-if="v.read">{{v.readCn}}</span>
|
||||
<span v-else style="color:red">{{v.readCn}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<a></a>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
<label class="fl mr5"><input type="checkbox" data-check-target=".ids">全选</label>
|
||||
<div class="am-para-inline w120">
|
||||
<select data-update-group="" data-list-target=".ids" data-action="/sys/notice/edit_read"
|
||||
data-field="read">
|
||||
<option value="">批量操作</option>
|
||||
<option value="1">设置已读</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var vue_obj;
|
||||
var loading = 0;
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params: <?=json_encode($params)?>,
|
||||
lists: <?=json_encode($lists)?>,
|
||||
readList: <?=json_encode($readList)?>
|
||||
},
|
||||
mounted: function () {
|
||||
},
|
||||
methods: {},
|
||||
watch: {}
|
||||
});
|
||||
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
</script>
|
||||
@@ -23,11 +23,30 @@
|
||||
<input type="text" placeholder="输入推送内容" name="content" v-model="info.content"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">
|
||||
<span class="com-must-star"></span>跳转地址:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="输入跳转地址" name="url" v-model="info.url"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input">
|
||||
<button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-modal am-modal-confirm" id="my-confirm">
|
||||
<div class="am-modal-dialog">
|
||||
<div class="am-modal-hd">Amaze UI</div>
|
||||
<div class="am-modal-bd">
|
||||
你,确定要删除这条记录吗?
|
||||
</div>
|
||||
<div class="am-modal-footer">
|
||||
<span class="am-modal-btn" data-am-modal-cancel>取消</span>
|
||||
<span class="am-modal-btn" data-am-modal-confirm>确定</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
var loading = 0;
|
||||
@@ -40,6 +59,7 @@
|
||||
platform: 1,
|
||||
uid: '',
|
||||
content: '',
|
||||
url: ''
|
||||
},
|
||||
platformList: <?=json_encode($platformList, JSON_UNESCAPED_UNICODE)?>,
|
||||
},
|
||||
|
||||
@@ -54,7 +54,7 @@ class Login extends BaseController
|
||||
}
|
||||
$responseData = $response->getData();
|
||||
$data = [
|
||||
'Authorization' => Authorization::generateToken([$responseData['id'], $responseData['orgId'] ?: 0], 'jwt_key_auto'),
|
||||
'Authorization' => generateToken([$responseData['id'], $responseData['orgId'] ?: 0], 'jwt_key_auto'),
|
||||
];
|
||||
$this->return_response($data, API_CODE_SUCCESS);
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -70,7 +70,7 @@ class Coupon extends BaseController
|
||||
//作废当前用户并返回新token
|
||||
$this->autoUserModel->update(['status' => Auto_user_model::STATUS_DELETE], ['id' => $this->userId]);
|
||||
$resData = [
|
||||
'Authorization' => Authorization::generateToken([$bindUser['id'], $bindUser['orgId'] ?: 0], 'jwt_key_auto'),
|
||||
'Authorization' => generateToken([$bindUser['id'], $bindUser['orgId'] ?: 0], 'jwt_key_auto'),
|
||||
];
|
||||
} else {
|
||||
//绑定手机号
|
||||
|
||||
@@ -39,7 +39,7 @@ class Notice extends BaseController
|
||||
'read' => $item['read'],
|
||||
'readCn' => $item['read'] ? '已读' : '未读',
|
||||
'type' => $item['type'],
|
||||
'c_time' => date('Y-m-d H:i:s')
|
||||
'c_time' => date('Y-m-d H:i:s', $item['c_time'])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ class Sys_notice_model extends HD_Model
|
||||
];
|
||||
const STATUS_UNREAD = 0; //未读
|
||||
const STATUS_READ = 1; //已读
|
||||
const READ_STATUS = [
|
||||
self::STATUS_UNREAD => '未读',
|
||||
self::STATUS_READ => '已读',
|
||||
];
|
||||
const PLATFORM_LIST = [
|
||||
self::PLAT_FORM_ADMIN => '管理后台',
|
||||
self::PLAT_FORM_PINGAN => '平安',
|
||||
|
||||
Reference in New Issue
Block a user