[更新]微信关键字管理

This commit is contained in:
邹景立 2017-04-21 14:59:52 +08:00
parent d628e54ef9
commit 64dd473329
4 changed files with 72 additions and 29 deletions

View File

@ -6,13 +6,13 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="shortcut icon" href="{:sysconf('browser_icon')}" />
<title>{block name="title"}{$title|default=''}&nbsp;{if !empty($title)}-{/if}&nbsp;{:sysconf('site_name')}{/block}</title>
<link rel="stylesheet" href="__STATIC__/plugs/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="__STATIC__/plugs/layui/css/layui.css"/>
<link rel="stylesheet" href="__STATIC__/theme/default/css/console.css">
<link rel="stylesheet" href="__STATIC__/theme/default/css/animate.css">{block name="style"}{/block}
<link rel="stylesheet" href="__STATIC__/plugs/bootstrap/css/bootstrap.min.css?v={:date('ymd')}"/>
<link rel="stylesheet" href="__STATIC__/plugs/layui/css/layui.css?v={:date('ymd')}"/>
<link rel="stylesheet" href="__STATIC__/theme/default/css/console.css?v={:date('ymd')}">
<link rel="stylesheet" href="__STATIC__/theme/default/css/animate.css?v={:date('ymd')}">{block name="style"}{/block}
<script>window.ROOT_URL = '__ROOT__';</script>
<script src="__STATIC__/plugs/require/require.js"></script>
<script src="__STATIC__/admin/app.js"></script>
<script src="__STATIC__/plugs/require/require.js?v={:date('ymd')}"></script>
<script src="__STATIC__/admin/app.js?v={:date('ymd')}"></script>
</head>
{block name="bodyTag"}
<body>

View File

@ -26,6 +26,10 @@ use think\Db;
*/
class Keys extends BasicAdmin {
/**
* 指定当前数据表
* @var string
*/
protected $table = 'WechatKeys';
/**
@ -54,7 +58,7 @@ class Keys extends BasicAdmin {
*/
public function add() {
$this->assign('title', '添加关键字规则');
return $this->_form($this->table, 'form', 'id');
return $this->_form($this->table, 'form');
}
/**
@ -63,10 +67,14 @@ class Keys extends BasicAdmin {
*/
public function edit() {
$this->assign('title', '编辑关键字规则');
return $this->_form($this->table, 'form', 'id');
return $this->_form($this->table, 'form');
}
/**
* 表单处理
* @param $data
*/
protected function _form_filter($data) {
if ($this->request->isPost() && isset($data['keys'])) {
$db = Db::name($this->table)->where('keys', $data['keys']);
@ -87,11 +95,43 @@ class Keys extends BasicAdmin {
$this->error("关键字删除失败,请稍候再试!");
}
/**
* 关注默认回复
*/
public function subscribe() {
$this->assign('title', '编辑默认回复');
return $this->_form($this->table, 'form');
}
public function defaults() {
/**
* 关注默认回复表单处理
* @param $data
*/
protected function _subscribe_form_filter(&$data) {
if ($this->request->isGet()) {
$data = Db::name($this->table)->where('keys', 'subscribe')->find();
}
$data['keys'] = 'subscribe';
}
/**
* 无配置默认回复
*/
public function defaults() {
$this->assign('title', '编辑无配置默认回复');
return $this->_form($this->table, 'form');
}
/**
* 无配置默认回复表单处理
* @param $data
*/
protected function _defaults_form_filter(&$data) {
if ($this->request->isGet()) {
$data = Db::name($this->table)->where('keys', 'default')->find();
}
$data['keys'] = 'default';
}
}

View File

@ -4,7 +4,8 @@
<style>
.layui-box .control-label {
margin: 0;
padding: 0;
padding-left: 0;
padding-right: 0;
}
.layui-box textarea {
@ -30,9 +31,9 @@
<fieldset class="layui-elem-field layui-box">
<legend>编辑规则</legend>
<div>
{if !isset($vo.keys) or $vo.keys neq 'default' and $vo.keys neq 'subscribe'}
{if !isset($vo.keys) or ($vo.keys neq 'default' and $vo.keys neq 'subscribe')}
<div class="form-group">
<label class="col-md-2 control-label">关 键 字</label>
<label class="col-md-2 control-label layui-form-label">关 键 字</label>
<div class="col-md-9">
<input required="required" title='请输入关键字' maxlength='20' name='keys'
value='{$vo.keys|default=""}' class="layui-input">
@ -40,7 +41,7 @@
</div>
{else}
<div class="form-group">
<label class="col-md-2 control-label">规则状态</label>
<label class="col-md-2 control-label layui-form-label">规则状态</label>
<div class="col-md-9">
<div class="mt-radio-inline" style='padding-bottom:0'>
{if !isset($vo.status) or $vo.status neq 0}
@ -64,7 +65,7 @@
{/if}
<div class="form-group">
<label class="col-md-2 control-label">规则类型</label>
<label class="col-md-2 control-label layui-form-label label-required">规则类型</label>
<div class="col-md-9">
<select name='type' class='layui-input'>
{if !isset($vo.type) or $vo.type eq 'text'}
@ -107,14 +108,14 @@
</div>
<div class="form-group" data-keys-type='text'>
<label class="col-md-2 control-label label-required">规则内容</label>
<label class="col-md-2 control-label layui-form-label label-required">规则内容</label>
<div class="col-md-9">
<textarea name="content" maxlength="10000" class="form-control" style="height:100px">{$vo.content|default='说点什么吧'}</textarea>
</div>
</div>
<div class="form-group" data-keys-type='news'>
<label class="col-md-2 control-label">选取图文</label>
<label class="col-md-2 control-label layui-form-label">选取图文</label>
<div class="col-md-9">
<a class="btn btn-link"
data-iframe="{:url('wechat/news/select')}?field={:encode('news_id')}">
@ -125,7 +126,7 @@
</div>
<div class="form-group" data-keys-type='image'>
<label class="col-md-2 control-label label-required">图片地址</label>
<label class="col-md-2 control-label layui-form-label label-required">图片地址</label>
<div class="col-md-9">
<input type="text" class="layui-input"
@ -145,7 +146,7 @@
</div>
<div class="form-group" data-keys-type='voice'>
<label class="col-md-2 control-label label-required">上传语音</label>
<label class="col-md-2 control-label layui-form-label label-required">上传语音</label>
<div class="col-md-9">
<div class="input-group">
@ -163,13 +164,14 @@
</div>
<div class="form-group" data-keys-type='music'>
<label class="col-md-2 control-label">音乐标题</label>
<label class="col-md-2 control-label layui-form-label">音乐标题</label>
<div class="col-md-9">
<input class='layui-input' value="{$vo.music_title|default='音乐标题'}" name="music_title"/>
<input class='layui-input' value="{$vo.music_title|default='音乐标题'}"
name="music_title" required="required" title="请输入音乐标题"/>
</div>
</div>
<div class="form-group" data-keys-type='music'>
<label class="col-md-2 control-label label-required">上传音乐</label>
<label class="col-md-2 control-label layui-form-label label-required">上传音乐</label>
<div class="col-md-9">
<div class="input-group">
@ -184,13 +186,13 @@
</div>
</div>
<div class="form-group" data-keys-type='music'>
<label class="col-md-2 control-label">音乐描述</label>
<label class="col-md-2 control-label layui-form-label">音乐描述</label>
<div class="col-md-9">
<textarea name="music_desc" maxlength="50" class="form-control" style="height:100px">{$vo.music_desc|default='音乐描述'}</textarea>
</div>
</div>
<div class="form-group" data-keys-type='music'>
<label class="col-md-2 control-label">音乐图片</label>
<label class="col-md-2 control-label layui-form-label">音乐图片</label>
<div class="col-md-9">
<input onchange="$(this).nextAll('img').attr('src', this.value);"
@ -209,14 +211,15 @@
</div>
<div class="form-group" data-keys-type='video'>
<label class="col-md-2 control-label">视频标题</label>
<label class="col-md-2 control-label layui-form-label">视频标题</label>
<div class="col-md-9">
<input class='layui-input' value="{$vo.video_title|default='视频标题'}" name="video_title"/>
<input class='layui-input' value="{$vo.video_title|default='视频标题'}" name="video_title"
required="required" title="请输入视频标题"/>
</div>
</div>
<div class="form-group" data-keys-type='video'>
<label class="col-md-2 control-label label-required">上传视频</label>
<label class="col-md-2 control-label layui-form-label label-required">上传视频</label>
<div class="col-md-9">
<div class="input-group">
@ -233,7 +236,7 @@
</div>
<div class="form-group" data-keys-type='video'>
<label class="col-md-2 control-label">视频描述</label>
<label class="col-md-2 control-label layui-form-label">视频描述</label>
<div class="col-md-9">
<textarea name="video_desc" maxlength="50" class="form-control" style="height:100px">{$vo.video_desc|default='视频描述'}</textarea>
</div>

View File

@ -121,7 +121,7 @@ input::-ms-clear{display:none}
.layui-btn {border-radius:0!important}
/** checkbox 优化 */
input[type=checkbox],input[type=radio]{-webkit-appearance:none;appearance:none;width:18px;height:18px;margin:0;cursor:pointer;vertical-align:bottom;background:#fff;border:1px solid #dcdcdc;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:relative}
input[type=checkbox],input[type=radio]{-webkit-appearance:none;appearance:none;width:18px;height:18px;margin:0;cursor:pointer;vertical-align:bottom;background:#fff;border:1px solid #dcdcdc;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-sizing:border-box!important;-moz-box-sizing:border-box!important;box-sizing:border-box!important;position:relative}
input[type=checkbox]:active,input[type=radio]:active{border-color:#c6c6c6;background:#ebebeb}
input[type=checkbox]:hover{border-color:#c6c6c6;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.1);box-shadow:inset 0 1px 1px rgba(0,0,0,0.1)}
input[type=radio]{-webkit-border-radius:1em;-moz-border-radius:1em;border-radius:1em;width:18px;height:18px}