[更新]修改粉丝标签模块

This commit is contained in:
Anyon 2017-05-03 14:29:03 +08:00
parent 542fddfb0c
commit 0755fbe8d7

View File

@ -15,6 +15,7 @@
namespace app\wechat\controller; namespace app\wechat\controller;
use controller\BasicAdmin; use controller\BasicAdmin;
use service\DataService;
use service\LogService; use service\LogService;
use service\WechatService; use service\WechatService;
use think\Db; use think\Db;
@ -68,23 +69,20 @@ class Tags extends BasicAdmin {
return parent::_form($this->table, 'form', 'id'); return parent::_form($this->table, 'form', 'id');
} }
// 接收提交的数据 // 接收提交的数据
$name = $this->request->post('name', ''); list($name, $id) = [$this->request->post('name', ''), $this->request->post('id', '0')];
$id = $this->request->post('id', '0'); $info = Db::name($this->table)->where('name', $name)->find();
$info = db($this->table)->where('name', $name)->find();
if (!empty($info)) { if (!empty($info)) {
if (intval($info['id']) === intval($id)) { if (intval($info['id']) === intval($id)) {
$this->success('标签没有改变!'); $this->success('粉丝标签没有改变!', '');
} else { }
$this->error('标签已经存在,请使用其它名称再试!'); $this->error('标签已经存在,请使用其它名称再试!');
} }
} $wechat = &load_wechat('User');
$wechat = &load_wechat('User', $this->real_appid);
$data = array('id' => $id, 'name' => $name); $data = array('id' => $id, 'name' => $name);
if (FALSE !== $wechat->updateTag($id, $name) && FALSE !== Data::save($this->table, $data, 'id')) { if (false !== $wechat->updateTag($id, $name) && false !== DataService::save($this->table, $data, 'id')) {
$this->success('编辑标签成功!'); $this->success('编辑标签成功!');
} else {
$this->error('编辑标签失败,请稍后再试!' . $wechat->errMsg);
} }
$this->error('编辑标签失败,请稍后再试!' . $wechat->errMsg);
} }
/** /**