[更新]添加粉丝标签模块

This commit is contained in:
Anyon 2017-05-03 13:31:08 +08:00
parent 1d6d24eb9d
commit 542fddfb0c
3 changed files with 50 additions and 5 deletions

View File

@ -54,14 +54,37 @@ class Tags extends BasicAdmin {
* 添加粉丝标签
*/
public function add() {
if ($this->request->isGet()) {
return parent::_form($this->table, 'form', 'id');
}
}
/**
* 编辑粉丝标签
*/
public function edit() {
// 显示编辑界面
if ($this->request->isGet()) {
return parent::_form($this->table, 'form', 'id');
}
// 接收提交的数据
$name = $this->request->post('name', '');
$id = $this->request->post('id', '0');
$info = db($this->table)->where('name', $name)->find();
if (!empty($info)) {
if (intval($info['id']) === intval($id)) {
$this->success('标签没有改变!');
} else {
$this->error('标签已经存在,请使用其它名称再试!');
}
}
$wechat = &load_wechat('User', $this->real_appid);
$data = array('id' => $id, 'name' => $name);
if (FALSE !== $wechat->updateTag($id, $name) && FALSE !== Data::save($this->table, $data, 'id')) {
$this->success('编辑标签成功!');
} else {
$this->error('编辑标签失败,请稍后再试!' . $wechat->errMsg);
}
}
/**

View File

@ -0,0 +1,22 @@
<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="{:url()}" data-auto="true" method="post">
<div class="layui-form-item">
<label class="layui-form-label">标签名称</label>
<div class="layui-input-block">
<input type="text" name="name" value='{$vo.name|default=""}' required="required" title="请输入标签名称" placeholder="请输入标签名称" class="layui-input">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
{if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
</form>

View File

@ -2,8 +2,8 @@
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
<button data-load="{:url('add')}" class='layui-btn layui-btn-small'><i class='fa fa-referer'></i> 添加标签</button>
<button data-load="{:url('sync')}" class='layui-btn layui-btn-small'><i class='fa fa-plus-square-o'></i> 同步标签</button>
<button data-modal="{:url('add')}" data-title="添加标签" class='layui-btn layui-btn-small'> 添加标签 </button>
<button data-load="{:url('sync')}" class='layui-btn layui-btn-small'> 同步标签 </button>
</div>
{/block}
@ -59,7 +59,7 @@
<td class='text-center nowrap'>
{if auth("$classuri/edit")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/edit")}?id={$vo.id}' href="javascript:void(0)">编辑</a>
<a data-modal='{:url("$classuri/edit")}?id={$vo.id}' data-title="编辑标签" href="javascript:void(0)">编辑</a>
{/if}
{if auth("$classuri/del")}
<span class="text-explode">|</span>