diff --git a/application/wechat/controller/Tags.php b/application/wechat/controller/Tags.php index 0d0ca3a7a..f25133520 100644 --- a/application/wechat/controller/Tags.php +++ b/application/wechat/controller/Tags.php @@ -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); + } } /** diff --git a/application/wechat/view/tags.form.html b/application/wechat/view/tags.form.html new file mode 100644 index 000000000..c616fc1dd --- /dev/null +++ b/application/wechat/view/tags.form.html @@ -0,0 +1,22 @@ +
+ +
+ +
+ +
+
+ +
+ +
+ + {if isset($vo['id'])}{/if} + + + + + +
+ +
diff --git a/application/wechat/view/tags.index.html b/application/wechat/view/tags.index.html index c042d12f8..1a5bf1486 100644 --- a/application/wechat/view/tags.index.html +++ b/application/wechat/view/tags.index.html @@ -2,8 +2,8 @@ {block name="button"}
- - + +
{/block} @@ -59,7 +59,7 @@ {if auth("$classuri/edit")} | - 编辑 + 编辑 {/if} {if auth("$classuri/del")} |