From 86a48de9e248f024344742d959b68d9073fd4277 Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 12 May 2017 17:53:39 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=9B=BE=E6=96=87=E4=B8=BA=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/News.php | 23 +++++------------------ application/wechat/view/news.index.html | 5 ++--- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/application/wechat/controller/News.php b/application/wechat/controller/News.php index bad07bb39..fe2c97b29 100644 --- a/application/wechat/controller/News.php +++ b/application/wechat/controller/News.php @@ -44,7 +44,7 @@ class News extends BasicAdmin { */ public function index() { $this->assign('title', '图文列表'); - $db = Db::name($this->table)->order('id desc'); + $db = Db::name($this->table)->where('is_deleted', '0')->order('id desc'); parent::_list($db); } @@ -124,26 +124,13 @@ class News extends BasicAdmin { } /** - * 删除图文 + * 删除用户 */ public function del() { - $id = $this->request->post('id', ''); - empty($id) && $this->error('参数错误,请重新操作删除!'); - $info = Db::name('WechatNews')->where('id', $id)->find(); - empty($info) && $this->error('删除的记录不存在,请重新操作删除!'); - if (isset($info['article_id'])) { - Db::startTrans(); - try { - Db::name('WechatNewsArticle')->where('id', 'in', explode(',', $info['article_id']))->delete(); - Db::name('WechatNews')->where('id', $id)->delete(); - Db::commit(); - $isSuccess = true; - } catch (Exception $e) { - Db::rollback(); - } - (isset($isSuccess) && $isSuccess) && $this->success('图文删除成功!'); + if (DataService::update($this->table)) { + $this->success("图文删除成功!", ''); } - $this->error('图文删除失败,请重新再试!'); + $this->error("图文删除失败, 请稍候再试!"); } /** diff --git a/application/wechat/view/news.index.html b/application/wechat/view/news.index.html index db660256d..0a8c7f761 100644 --- a/application/wechat/view/news.index.html +++ b/application/wechat/view/news.index.html @@ -54,11 +54,10 @@ $('body').on('click', '[data-news-del]', function () { var self = this; $.msg.confirm('确定要删除图文吗?', function () { - $.form.load('{:url("del")}', {id: self.getAttribute('data-news-del')}, 'post', function (ret) { + $.form.load('{:url("del")}', {field: 'delete', value: 0, id: self.getAttribute('data-news-del')}, 'post', function (ret) { if (ret.code) { $(self).parents('.news_item').remove(); - msnry.layout(); - return $.msg.success(ret.msg), false; + return $.msg.success(ret.msg), msnry.layout(), false; } return $.msg.error(ret.msg), false; });