添加:消息插件
This commit is contained in:
parent
432f43178a
commit
fb5c84652d
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
||||
* ==========================================================
|
||||
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
||||
* ----------------------------------------------------------
|
||||
* 官方网址: https://www.zoomtk.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
||||
* ==========================================================
|
||||
*/
|
||||
namespace addon\message\api\controller;
|
||||
|
||||
use addon\message\model\MessageRead;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
class Message extends BaseApi{
|
||||
/**
|
||||
* Common: 消息列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/03/04 16:07
|
||||
* @return false|string
|
||||
*/
|
||||
public function messageList(){
|
||||
// 用户登录
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) return $this->response($token);
|
||||
// 参数获取
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$message_type = input('message_type',0);
|
||||
// 获取内容
|
||||
$field = [
|
||||
'a.id',
|
||||
'a.is_see',
|
||||
'a.order_id',
|
||||
'a.created_time',
|
||||
'mc.type',
|
||||
'mc.message_title',
|
||||
'mc.message_content',
|
||||
];
|
||||
// 条件生成
|
||||
$condition = [
|
||||
['a.site_id','=',$this->site_id],
|
||||
['a.member_id', '=', $this->member_id ],
|
||||
];
|
||||
if($message_type > 0) $condition[] = ['mc.type', '=', $message_type ];
|
||||
// 表关联
|
||||
$join = [
|
||||
['message_center mc', 'mc.id = a.message_center_id', 'left'],
|
||||
];
|
||||
$list = (new MessageRead())->getPageList($condition, $page, $page_size, 'a.created_time desc,a.id desc', $field, 'a', $join);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
/**
|
||||
* Common: 消息查看
|
||||
* Author: wu-hui
|
||||
* Time: 2023/03/04 16:31
|
||||
*/
|
||||
public function see(){
|
||||
$id = input('id',0);
|
||||
model('message_center_read')->update(['is_see'=>1], ['id'=>$id]);
|
||||
|
||||
return $this->response($this->success());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,19 +8,49 @@ use think\facade\Db;
|
|||
|
||||
class Message extends BaseModel{
|
||||
|
||||
private $types = [
|
||||
1 => '交易信息',
|
||||
2 => '系统消息',
|
||||
3 => '通知消息',
|
||||
4 => '留言反馈',
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* Common: 获取消息列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/03/04 15:02
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'a.*', $alias = 'a', $join = []){
|
||||
$list = model('message_center')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
public function getList($siteId){
|
||||
// 参数获取
|
||||
$page = input('page',1);
|
||||
$pageSize = input('page_size',PAGE_LIST_ROWS);
|
||||
$title = input('title','');
|
||||
$type = input('type','');
|
||||
// 条件生成
|
||||
$where = [
|
||||
['a.site_id','=',$siteId],
|
||||
['a.type','in',[2,3]],
|
||||
];
|
||||
if($title) $where[] = ['a.message_title','like',"%{$title}%"];
|
||||
if($type) $where[] = ['a.type','=',$type];
|
||||
// 列表获取
|
||||
$result = Db::name('message_center')
|
||||
->alias('a')
|
||||
->field('a.id,a.type,a.created_time,a.message_title,count(mcr.message_center_id) as total')
|
||||
->join('message_center_read mcr','mcr.message_center_id = a.id', 'left')
|
||||
->where($where)
|
||||
->group('a.id')
|
||||
->order('a.id','DESC')
|
||||
->paginate(['list_rows' => $pageSize,'page' => $page]);
|
||||
if($result) $result = $result->toArray();
|
||||
|
||||
$list = [
|
||||
'count' => $result['total'],
|
||||
'list' => $result['data'],
|
||||
'page_count' => $result['last_page'],
|
||||
];
|
||||
return $this->success($list);
|
||||
}
|
||||
/**
|
||||
|
|
@ -32,9 +62,10 @@ class Message extends BaseModel{
|
|||
* @param int $type
|
||||
* @param string|int $member_id
|
||||
* @param int $orderId
|
||||
* @param string $title
|
||||
* @return array
|
||||
*/
|
||||
public function addMessage(int $siteId,string $content,int $type,$member_id = 'all',int $orderId = 0){
|
||||
public function addMessage(int $siteId,string $content,int $type,$member_id = 'all',int $orderId = 0,$title = ''){
|
||||
if(!$content) return $this->error('','消息不能为空!');
|
||||
// 记录消息信息
|
||||
try{
|
||||
|
|
@ -42,6 +73,7 @@ class Message extends BaseModel{
|
|||
->insertGetId([
|
||||
'site_id' => $siteId,
|
||||
'type' => $type,
|
||||
'message_title' => $title ?? $this->types[$type],
|
||||
'message_content' => $content,
|
||||
'created_time' => time()
|
||||
]);
|
||||
|
|
@ -76,9 +108,19 @@ class Message extends BaseModel{
|
|||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Common: 删除消息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/03/04 15:48
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
public function delInfo($id){
|
||||
// 删除消息信息
|
||||
Model('message_center')->delete(['id'=>$id]);
|
||||
Model('message_center_read')->delete(['message_center_id'=>$id]);
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace addon\message\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
class MessageRead extends BaseModel{
|
||||
/**
|
||||
* 获取列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @return array
|
||||
*/
|
||||
public function getPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'a.*', $alias = 'a', $join = [])
|
||||
{
|
||||
$list = model('message_center_read')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,47 +17,15 @@ use addon\message\model\Message as messageModel;
|
|||
use think\facade\Db;
|
||||
|
||||
class Message extends BaseShop{
|
||||
// 进入消息中心
|
||||
/**
|
||||
* Common: 进入消息中心
|
||||
* Author: wu-hui
|
||||
* Time: 2023/03/04 15:03
|
||||
* @return array|mixed
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function index(){
|
||||
if(request()->isAjax()){
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
debug(table('message_center_read'));
|
||||
// 参数获取
|
||||
$page = input('page',1);
|
||||
$pageSize = input('page_size',PAGE_LIST_ROWS);
|
||||
// 获取内容
|
||||
$field = [
|
||||
'a.id',
|
||||
'a.type',
|
||||
'a.created_time',
|
||||
'count(a.id) as total',
|
||||
'(select count(id) from )',
|
||||
|
||||
];
|
||||
// 表关联
|
||||
$join = [
|
||||
['message_center_read mcr', 'mcr.message_center_id = a.id', 'left'],
|
||||
];
|
||||
// 条件生成
|
||||
$condition = [
|
||||
['a.site_id','=',$this->site_id]
|
||||
];
|
||||
$res = (new messageModel())->getPageList($condition, $page, $pageSize, 'a.created_time desc,a.id desc', $field, 'a', $join);
|
||||
|
||||
debug($res);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(request()->isAjax()) return (new messageModel())->getList($this->site_id);
|
||||
|
||||
$this->forthMenu();
|
||||
return $this->fetch('message/index');
|
||||
|
|
@ -73,11 +41,23 @@ class Message extends BaseShop{
|
|||
// 参数获取
|
||||
$type = input('type',2);
|
||||
$content = input('message_content','');
|
||||
$title = input('title','');
|
||||
|
||||
return (new messageModel())->addMessage($this->site_id,$content,$type);
|
||||
return (new messageModel())->addMessage($this->site_id,$content,$type,'all',0,$title);
|
||||
}
|
||||
|
||||
return $this->fetch('message/send_message');
|
||||
}
|
||||
/**
|
||||
* Common: 删除信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/03/04 15:48
|
||||
* @return array
|
||||
*/
|
||||
public function delMessage(){
|
||||
$id = input('id');
|
||||
|
||||
return (new messageModel())->delInfo($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
||||
* ==========================================================
|
||||
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
||||
* ----------------------------------------------------------
|
||||
* 官方网址: https://www.zoomtk.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
||||
* ==========================================================
|
||||
*/
|
||||
namespace addon\message\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\message\model\Message as messageModel;
|
||||
|
||||
class Remark extends BaseShop{
|
||||
// 进入留言管理
|
||||
public function index(){
|
||||
if(request()->isAjax()) return (new messageModel())->getList($this->site_id);
|
||||
|
||||
$this->forthMenu();
|
||||
return $this->fetch('remark/index');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
background-color: #009688;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
</style>
|
||||
{/block}
|
||||
|
||||
|
|
@ -16,51 +15,22 @@
|
|||
<div class="layui-colla-content layui-form layui-show" lay-filter="search_form">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">用户昵称:</label>
|
||||
<label class="layui-form-label">消息标题:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="nickname" placeholder="用户昵称" autocomplete="off" class="layui-input"/>
|
||||
<input type="text" name="title" placeholder="消息标题" autocomplete="off" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">交易状态:</label>
|
||||
<label class="layui-form-label">消息类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="status" lay-filter="is_settlement">
|
||||
<select name="type">
|
||||
<option value="">全部</option>
|
||||
<option value="1">库存</option>
|
||||
<option value="2">已上架</option>
|
||||
<option value="3">已售出</option>
|
||||
<option value="4">提货中</option>
|
||||
<option value="5">提货完成</option>
|
||||
<option value="6">待支付</option>
|
||||
<option value="7">捡漏</option>
|
||||
<option value="2">系统消息</option>
|
||||
<option value="3">通知消息</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">交易时间:</label>
|
||||
<!--交易时间类型-->
|
||||
<div class="layui-input-inline">
|
||||
<select name="time_type" lay-filter="is_settlement">
|
||||
<option value="created">购买时间</option>
|
||||
<option value="release">上架时间</option>
|
||||
<option value="sell">售卖时间</option>
|
||||
<option value="take">取货时间</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--时间选择-->
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<button class="layui-btn publish-btn" lay-submit lay-filter="publish">发布</button>
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
|
|
@ -74,97 +44,43 @@
|
|||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="seeDetail">查看详情</a>
|
||||
</div>
|
||||
</script>
|
||||
<!--会员信息-->
|
||||
<script type="text/html" id="memberInfo">
|
||||
<div class='table-title'>
|
||||
<div class='title-pic'>
|
||||
<img layer-src src="{{ns.img(d.seller_headimg)}}" onerror="this.src = '{:img(\'public/static/img/default_img/head.png\')}' ">
|
||||
</div>
|
||||
<div class='title-content'>
|
||||
{{# if(d.seller_username){ }}
|
||||
<p class="layui-elip">{{d.seller_username}}</p>
|
||||
{{# } else { }}
|
||||
<p class="layui-elip">{{d.seller_nickname}}</p>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<!--商品信息-->
|
||||
<script type="text/html" id="goodsInfo">
|
||||
<div class='table-title' title="{{d.goods_name}}">
|
||||
<div class='title-pic'>
|
||||
<img layer-src src="{{ns.img(d.goods_image)}}" onerror="this.src = '{:img(\'public/static/img/default_img/head.png\')}' ">
|
||||
</div>
|
||||
<div class='title-content'>
|
||||
<p class="layui-elip">{{d.goods_name}}</p>
|
||||
</div>
|
||||
<a class="layui-btn" lay-event="deleteInfo">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script>
|
||||
var table, form, editIframe,laydate, repeat_flag = false;//防重复标识;
|
||||
layui.use(['form','laydate'], function() {
|
||||
var table, form, editIframe, repeat_flag = false;//防重复标识;
|
||||
layui.use(['form'], function() {
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
form.render();
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
// 内容获取
|
||||
table = new Table({
|
||||
elem: '#listContent',
|
||||
url: ns.url("futures://shop/futures/index"),
|
||||
url: ns.url("message://shop/message/index"),
|
||||
cols: [[
|
||||
{align: 'center', field: 'id', title: 'ID', width: '5%', unresize: 'false'},
|
||||
{align: 'left', title: '买家信息', unresize: 'area',width: '15%', templet: '#memberInfo'},
|
||||
{align: 'left', title: '商品信息', unresize: 'area',width: '15%', templet: '#goodsInfo'},
|
||||
{align: 'center', title: '商品数量', field: 'total',width: '10%', unresize: 'area'},
|
||||
{align: 'center', title: '购买价格', field: 'unit_price',width: '10%', unresize: 'area'},
|
||||
{align: 'center', title: '消息标题', field:'message_title', unresize: 'area'},
|
||||
{align: 'center', title: '接收人数', field: 'total',unresize: 'area'},
|
||||
{
|
||||
align: 'center',width: '10%', templet: function (d) {
|
||||
// 状态(1=库存,2=已上架,3=已售出,4=提货中,5=提货完成,6=待支付,7=捡漏)
|
||||
align: 'center',templet: function (d) {
|
||||
// 消息类型:1=交易信息,2=系统消息,3=通知消息,4=留言反馈
|
||||
let statusText = '';
|
||||
switch (parseInt(d.status)) {
|
||||
case 1: statusText = '<p>库存</p>'; break;
|
||||
case 2: statusText = '<p style="color: #07c160;">已上架</p>'; break;
|
||||
case 3: statusText = '<p style="color: #1989fa;">已售出</p>'; break;
|
||||
case 4: statusText = '<p style="color: #7232dd;">提货中</p>'; break;
|
||||
case 5: statusText = '<p style="color: #ad0000;">提货完成</p>'; break;
|
||||
case 6: statusText = '<p style="color: #ff976a;">待支付</p>'; break;
|
||||
case 7: statusText = '<p style="color: #ee0a24;">捡漏</p>'; break;
|
||||
switch (parseInt(d.type)) {
|
||||
case 1: statusText = '<p style="color: #07c160;">交易信息</p>'; break;
|
||||
case 2: statusText = '<p style="color: #1989fa;">系统消息</p>'; break;
|
||||
case 3: statusText = '<p style="color: #7232dd;">通知消息</p>'; break;
|
||||
case 4: statusText = '<p style="color: #ad0000;">留言反馈</p>'; break;
|
||||
}
|
||||
|
||||
return statusText;
|
||||
}, title: '交易状态', unresize: 'false'
|
||||
},
|
||||
{
|
||||
align: 'center',width: '15%', templet: function (d) {
|
||||
let timeText = '';
|
||||
if(d.release_time > 0) timeText += '<p class="time_p">上架时间:'+ns.time_to_date(d.release_time,'YYYY-MM-DD h:m')+'</p>';
|
||||
if(d.sell_time > 0) timeText += '<p class="time_p">售卖时间:'+ns.time_to_date(d.sell_time,'YYYY-MM-DD h:m')+'</p>';
|
||||
if(d.created_time > 0) timeText += '<p class="time_p">购买时间:'+ns.time_to_date(d.created_time,'YYYY-MM-DD h:m')+'</p>';
|
||||
if(d.take_time > 0) timeText += '<p class="time_p">取货时间:'+ns.time_to_date(d.take_time,'YYYY-MM-DD h:m')+'</p>';
|
||||
|
||||
return timeText;
|
||||
}, title: '交易时间', unresize: 'false'
|
||||
}, title: '消息类型', unresize: 'false'
|
||||
},
|
||||
{align: 'center', title: '发布时间', field: 'created_time',unresize: 'area',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.created_time);
|
||||
}},
|
||||
{title: '操作', toolbar: '#operation', unresize: 'false', align: 'right'}
|
||||
]],
|
||||
});
|
||||
|
|
@ -194,11 +110,8 @@
|
|||
// 重置表单
|
||||
form.on('submit(reset)', function(data) {
|
||||
let field = {
|
||||
"nickname": "",
|
||||
"status": "",
|
||||
"time_type": "created",
|
||||
"start_time": "",
|
||||
"end_time": "",
|
||||
"title": "",
|
||||
"type": "",
|
||||
};
|
||||
form.val("search_form", field);
|
||||
layui.form.render();
|
||||
|
|
@ -216,17 +129,27 @@
|
|||
eval(obj.event)(data)
|
||||
});
|
||||
});
|
||||
// 点击查看详情
|
||||
function seeDetail(data){
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '交易详情',
|
||||
skin: 'layer-tips-class',
|
||||
area: ['80%','90%'],
|
||||
content: ns.url("futures://shop/futures/seeDetail", { id: data.id }),
|
||||
end: function(){
|
||||
//table.reload();
|
||||
// 删除消息
|
||||
function deleteInfo(data){
|
||||
layer.confirm('确认删除当前消息?删除后所有已发送给用户当前消息将同步删除。', {icon: 3, title:'提示'}, function(index){
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("message://shop/message/delMessage"),
|
||||
data: { id: data.id },
|
||||
async: false,
|
||||
success: function(res){
|
||||
if (res.code == 0) {
|
||||
layer.alert('删除成功', function(index){
|
||||
layer.close(index);
|
||||
table.reload();
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -61,6 +61,12 @@
|
|||
|
||||
{block name="body"}
|
||||
<div class="layui-form form-wrap" lay-filter="formInfo">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label img-upload-lable short-label"><span class="required">*</span>消息标题:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="title" autocomplete="off" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label img-upload-lable short-label">消息类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
|
|
@ -101,11 +107,13 @@
|
|||
layer.msg('请输入消息内容!');
|
||||
return false;
|
||||
}
|
||||
if(!field['title']){
|
||||
layer.msg('请输入消息标题!');
|
||||
return false;
|
||||
}
|
||||
// 数据提交
|
||||
layer.confirm('确认发布当前消息给所有用户?', {icon: 3, title:'提示'}, function(index){
|
||||
layer.close(index);
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
|
|
@ -113,7 +121,6 @@
|
|||
data: field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.alert('发布成功', function(index){
|
||||
parent.layer.close(_thisIndex);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,168 @@
|
|||
{extend name="app/shop/view/base.html"/}
|
||||
{block name="resources"}
|
||||
<style>
|
||||
.publish-btn{
|
||||
background-color: #009688;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
{/block}
|
||||
|
||||
{block name="main"}
|
||||
<!-- 筛选面板 -->
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<div class="layui-colla-content layui-form layui-show" lay-filter="search_form">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">消息标题:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="title" placeholder="消息标题" autocomplete="off" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">消息类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="type">
|
||||
<option value="">全部</option>
|
||||
<option value="2">系统消息</option>
|
||||
<option value="3">通知消息</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<button class="layui-btn publish-btn" lay-submit lay-filter="publish">发布</button>
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" lay-submit lay-filter="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 列表 -->
|
||||
<table id="listContent" lay-filter="listContent"></table>
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="deleteInfo">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script>
|
||||
var table, form, editIframe,laydate, repeat_flag = false;//防重复标识;
|
||||
layui.use(['form','laydate'], function() {
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
form.render();
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
// 内容获取
|
||||
table = new Table({
|
||||
elem: '#listContent',
|
||||
url: ns.url("message://shop/message/index"),
|
||||
cols: [[
|
||||
{align: 'center', field: 'id', title: 'ID', width: '5%', unresize: 'false'},
|
||||
{align: 'center', title: '消息标题', field:'message_title', unresize: 'area'},
|
||||
{align: 'center', title: '接收人数', field: 'total',unresize: 'area'},
|
||||
{
|
||||
align: 'center',width: '10%', templet: function (d) {
|
||||
// 消息类型:1=交易信息,2=系统消息,3=通知消息,4=留言反馈
|
||||
let statusText = '';
|
||||
switch (parseInt(d.type)) {
|
||||
case 1: statusText = '<p style="color: #07c160;">交易信息</p>'; break;
|
||||
case 2: statusText = '<p style="color: #1989fa;">系统消息</p>'; break;
|
||||
case 3: statusText = '<p style="color: #7232dd;">通知消息</p>'; break;
|
||||
case 4: statusText = '<p style="color: #ad0000;">留言反馈</p>'; break;
|
||||
}
|
||||
|
||||
return statusText;
|
||||
}, title: '消息类型', unresize: 'false'
|
||||
},
|
||||
{title: '操作', toolbar: '#operation', unresize: 'false', align: 'right'}
|
||||
]],
|
||||
});
|
||||
// 点击发布
|
||||
form.on('submit(publish)', function(data) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '消息发布',
|
||||
skin: 'layer-tips-class',
|
||||
area: ['80%','90%'],
|
||||
content: ns.url("message://shop/message/sendMessage"),
|
||||
end: function(){
|
||||
table.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
// 点击搜索
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
// 重置表单
|
||||
form.on('submit(reset)', function(data) {
|
||||
let field = {
|
||||
"title": "",
|
||||
"type": "",
|
||||
};
|
||||
form.val("search_form", field);
|
||||
layui.form.render();
|
||||
// 刷新表格
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: field
|
||||
});
|
||||
});
|
||||
// 监听工具栏操作
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
eval(obj.event)(data)
|
||||
});
|
||||
});
|
||||
// 删除消息
|
||||
function deleteInfo(data){
|
||||
layer.confirm('确认删除当前消息?删除后所有已发送给用户当前消息将同步删除。', {icon: 3, title:'提示'}, function(index){
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("message://shop/message/delMessage"),
|
||||
data: { id: data.id },
|
||||
async: false,
|
||||
success: function(res){
|
||||
if (res.code == 0) {
|
||||
layer.alert('删除成功', function(index){
|
||||
layer.close(index);
|
||||
table.reload();
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
Loading…
Reference in New Issue