From d4f48eea8f403f406d4f2cf9da018ba3784306a4 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 25 Apr 2017 17:21:08 +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=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/News.php | 34 +++++++++++++++++++++++++ application/wechat/view/news.index.html | 17 +++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/application/wechat/controller/News.php b/application/wechat/controller/News.php index 7bc382b29..047e2086b 100644 --- a/application/wechat/controller/News.php +++ b/application/wechat/controller/News.php @@ -118,6 +118,40 @@ class News extends BasicAdmin { return join(',', $ids); } + /** + * 图文推送 + */ + public function push() { + + } + + /** + * 删除图文 + */ + 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('图文删除成功!'); + } + $this->error('图文删除失败,请重新再试!'); + } + + /** + * 图文选择器 + * @return string + */ public function select() { return '开发中'; } diff --git a/application/wechat/view/news.index.html b/application/wechat/view/news.index.html index e4e3aeb2e..2689d4e98 100644 --- a/application/wechat/view/news.index.html +++ b/application/wechat/view/news.index.html @@ -14,7 +14,7 @@
推送 编辑 - 删除 + 删除
{foreach $vo.articles as $k => $v} {if $k < 1} @@ -47,10 +47,23 @@ $(this).find('.news_tools').addClass('hide'); }); - require(['jquery.masonry'], function (Masonry, tpl) { + require(['jquery.masonry'], function (Masonry) { var container = document.querySelector('#news_box'); var msnry = new Masonry(container, {itemSelector: '.news_item', columnWidth: 0}); msnry.layout(); + $('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) { + if (ret.code) { + $(self).parents('.news_item').remove(); + msnry.layout(); + return $.msg.success(ret.msg), false; + } + return $.msg.error(ret.msg), false; + }); + }); + }); });