diff --git a/application/wechat/controller/Fans.php b/application/wechat/controller/Fans.php index 72efe9dd7..3ad6eff7c 100644 --- a/application/wechat/controller/Fans.php +++ b/application/wechat/controller/Fans.php @@ -15,6 +15,7 @@ namespace app\wechat\controller; use controller\BasicAdmin; +use service\LogService; use service\WechatService; use think\Db; diff --git a/application/wechat/controller/News.php b/application/wechat/controller/News.php index 84de693e2..3de6c681f 100644 --- a/application/wechat/controller/News.php +++ b/application/wechat/controller/News.php @@ -14,6 +14,8 @@ namespace app\wechat\controller; use controller\BasicAdmin; +use service\DataService; +use think\Db; /** * 微信图文管理 @@ -24,7 +26,54 @@ use controller\BasicAdmin; */ class News extends BasicAdmin { - public function index() { + /** + * 设置默认操作表 + * @var string + */ + protected $table = 'WechatNews'; + public function add() { + if ($this->request->isGet()) { + $this->assign('title', '新建图文'); + return view('form'); + } + if ($this->request->isPost()) { + $data = $this->request->post(); + if (($ids = $this->_apply_news_article($data['data'])) && !empty($ids)) { + $post = ['article_id' => $ids, 'create_by' => session('user.id')]; + if (DataService::save($this->table, $post, 'id') !== FALSE) { + $this->success('图文添加成功!', url('@wechat/news')); + } + } + $this->error('图文添加失败,请稍候再试!'); + } + } + + /** + * 图文更新操作 + * @param array $data + * @param array $ids + * @return string + */ + protected function _apply_news_article($data, $ids = []) { + foreach ($data as &$vo) { + $vo['create_by'] = session('user.id'); + $vo['create_at'] = date('Y-m-d H:i:s'); + $vo['digest'] = empty($vo['digest']) ? mb_substr(strip_tags($vo['content']), 0, 120) : $vo['digest']; + if (empty($vo['id'])) { + $result = $id = Db::name('WechatNewsArticle')->insertGetId($vo); + } else { + $id = intval($vo['id']); + $result = Db::name('WechatNewsArticle')->where('id', $id)->update($vo); + } + if ($result !== FALSE) { + $ids[] = $id; + } + } + return join(',', $ids); + } + + public function select() { + return '开发中'; } } diff --git a/application/wechat/view/news.form.html b/application/wechat/view/news.form.html new file mode 100644 index 000000000..ff896686c --- /dev/null +++ b/application/wechat/view/news.form.html @@ -0,0 +1,362 @@ +{extend name='extra@admin/content' /} + +{block name="style"} + +{/block} + +{block name='content'} +
+
+
+
+
+
图文列表
+
+
+
+
+ {if empty($vo['articles']) eq FALSE} + {foreach $vo.articles as $key=>$value} +
+ +
+ image +
+ {$value.title} +
+
+ {/foreach} + {else} +
+
+ image +
+ +
+
+ {/if} +
+ +
+
+
+
+
+ +
+
+
+
+
图文内容编辑
+
+
+
+
+
+ +
+
+
+ 标题 + + +
+
+
+
+
+
+ 作者 + +
+
+
+
+
+
+ +
+
+
+ + +
+
+
+
+ 上传图片 + 从图库中选择图片 +
+
+ +
+
+

封面大图片建议尺寸:900像素 * 500像素

+
+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+{/block} + + +{block name='script'} + +{/block} \ No newline at end of file diff --git a/public/static/admin/app.js b/public/static/admin/app.js index fc0f55f65..6c06588c4 100644 --- a/public/static/admin/app.js +++ b/public/static/admin/app.js @@ -66,7 +66,7 @@ require.config({ }); window.WEB_SOCKET_SWF_LOCATION = "//cdn.bootcss.com/web-socket-js/1.0.0/WebSocketMain.swf"; -window.UEDITOR_HOME_URL = (window.ROOT_URL ? window.ROOT_URL + '/static/' : baseUrl) + '../plugs/ueditor/'; +window.UEDITOR_HOME_URL = (window.ROOT_URL ? window.ROOT_URL + '/static/' : baseUrl) + 'plugs/ueditor/'; window.LAYDATE_PATH = baseUrl + '../plugs/layui/laydate/'; // UI框架初始化