diff --git a/application/wechat/controller/Article.php b/application/wechat/controller/Article.php deleted file mode 100644 index 48cbd0a95..000000000 --- a/application/wechat/controller/Article.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @date 2017/03/27 14:43 - */ -class Article extends BasicAdmin { - - public function index($p1Str, $p2Str, $p3Str, $dStr) { - list($x1, $y1) = explode(',', $p1Str); - list($x2, $y2) = explode(',', $p2Str); - list($x3, $y3) = explode(',', $p3Str); - list($d1, $d2, $d3) = explode(',', $dStr); - $va = (($d2 * $d2 - $d3 * $d3) - ($x2 * $x2 - $x3 * $x3) - ($y2 * $y2 - $y3 * $y3)) / 2; - $vb = (($d2 * $d2 - $d1 * $d1) - ($x2 * $x2 - $x1 * $x1) - ($y2 * $y2 - $y1 * $y1)) / 2; - $y_point = ($vb * ($x3 - $x2) - $va * ($x1 - $x2)) / (($y1 - $y2) * ($x3 - $x2) - ($y3 - $y2) * ($x1 - $x2)); - $x_point = ($va - $y_point * ($y3 - $y2)) / ($x3 - $x2); - return ['x' => $x_point, 'y' => $y_point]; - } -} diff --git a/application/wechat/controller/News.php b/application/wechat/controller/News.php index 3de6c681f..03b960204 100644 --- a/application/wechat/controller/News.php +++ b/application/wechat/controller/News.php @@ -15,6 +15,7 @@ namespace app\wechat\controller; use controller\BasicAdmin; use service\DataService; +use service\WechatService; use think\Db; /** @@ -32,23 +33,47 @@ class News extends BasicAdmin { */ protected $table = 'WechatNews'; + /** + * 添加图文 + * @return \think\response\View + */ public function add() { if ($this->request->isGet()) { - $this->assign('title', '新建图文'); - return view('form'); + return view('form', ['title' => '新建图文']); } 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')); + if (DataService::save($this->table, $post, 'id') !== false) { + $this->success('图文添加成功!', ''); } } $this->error('图文添加失败,请稍候再试!'); } } + /** + * 编辑图文 + * @return \think\response\View + */ + public function edit() { + $id = $this->request->get('id', ''); + if ($this->request->isGet()) { + empty($id) && $this->error('参数错误,请稍候再试!'); + return view('form', ['title' => '编辑图文', 'vo' => WechatService::getNewsById($id)]); + } + $data = $this->request->post(); + $ids = $this->_apply_news_article($data['data']); + if (!empty($ids)) { + $post = ['id' => $id, 'article_id' => $ids, 'create_by' => session('user.id')]; + if (false !== DataService::save('wechat_news', $post, 'id')) { + $this->success('图文更新成功!', ''); + } + } + $this->error('图文更新失败,请稍候再试!'); + } + /** * 图文更新操作 * @param array $data diff --git a/application/wechat/view/news.form.html b/application/wechat/view/news.form.html index ff896686c..166b33c81 100644 --- a/application/wechat/view/news.form.html +++ b/application/wechat/view/news.form.html @@ -1,245 +1,117 @@ {extend name='extra@admin/content' /} -{block name="style"} - -{/block} - {block name='content'} -