diff --git a/app/mobile/controller/TopsNas.php b/app/mobile/controller/TopsNas.php index 2a9cbe2..e8e15cb 100755 --- a/app/mobile/controller/TopsNas.php +++ b/app/mobile/controller/TopsNas.php @@ -147,6 +147,7 @@ class TopsNas extends BaseController 'id', 'pid', 'name', + 'picture' ]) ->where('isshow', '=', 1) ->where('country_code', '=', $this->country_code) @@ -263,4 +264,171 @@ class TopsNas extends BaseController return $this->fetch(); } + + // 根据分类获取文章 + private function getArticleByCategory($categorys, $limit = null) + { + if (!is_array($categorys)) { + throw new \Exception('请确认分类正确'); + } + if (empty($categorys)) { + return []; + } + + $sub_query = Loader::model('Article') + ->field([ + 'id', + 'cid', + 'name', + 'sort' + ]) + ->where('stat', '=', 0) + ->where('cid', '=', $categorys[0]['id']) + ->where('country_code', '=', $this->country_code) + ->order(['sort' => 'asc', 'id' => 'desc']); + if (!empty($limit)) { + $sub_query = $sub_query->limit($limit); + } + $sub_query = $sub_query->buildSql(); + + $model = \think\Db::table($sub_query . ' a'); + foreach ($categorys as $key => $val) { + if ($key == 0) continue; + $model->union(function($query) use($val, $limit) { + $query->name('article')->field([ + 'id', + 'cid', + 'name', + 'sort' + ]) + ->where('stat', '=', 0) + ->where('cid', '=', $val['id']) + ->where('country_code', '=', $this->country_code) + ->order(['sort' => 'asc', 'id' => 'desc']); + if (!empty($limit)) { + $query->limit($limit); + } + }); + } + + $map = []; + $data = $data = $model->select(); + foreach ($data as $key => $val) { + $map['cid_' . $val['cid']][] = $val; + } + return $map; + } + /** + * 帮助中心 + */ + public function helper() + { + // 获取分类 + $categorys = $this->getCategoryTree(76); + // 获取文章 + $articles = $this->getArticleByCategory($categorys, 3); + // 组装数据 + foreach ($categorys as $key => &$val) { + if (!isset($val['articles'])) { + $val['articles'] = []; + } + if (isset($articles['cid_' . $val['id']])) { + $items = $articles['cid_' . $val['id']]; + foreach ($items as $k => $v) { + $val['articles'][] = [ + 'id' => $v['id'], + 'name' => $v['name'] + ]; + } + } + } + unset($val); + $this->assign('categorys', $categorys); + + $banners = $this->getBanners(127); + if (!empty($banners)) { + $banners = $banners['typeid_127']['banners']; + } + $this->assign('banners', $banners); + $this->assign('banners_size', count($banners)); + + return $this->fetch(); + } + + // 搜索帮助文章 + public function helper_search() + { + $base_category = 76; + $keywords = request()->param('keywords'); + $articles = Loader::model('Article') + ->field([ + 'id', + 'name', + 'sort', + ]) + ->where('stat', '=', 0) + ->where('country_code', '=', $this->country_code) + ->where('cid', 'in', function($query) use($base_category) { + $query->name('article_category') + ->field(['id']) + ->where('id', '=', $base_category) + ->whereOr('pid', '=', $base_category); + }) + ->where(function($query) use($keywords) { + if (!empty($keywords)) { + $query->where('name', 'like', '%' . $keywords . '%'); + } + }) + ->order(['sort' => 'asc', 'id' => 'desc']) + ->select(); + + return json([ + 'code' => 0, + 'message' => '获取成功', + 'data' => $articles + ]); + } + + /** + * 帮助文章详情 + */ + public function helper_detail() + { + $id = request()->param('id'); + $article = Loader::model('Article')->where('id', '=', $id)->find(); + + if (request()->isAjax()) { + return json([ + 'code' => 0, + 'message' => '获取成功', + 'data' => $article + ]); + } else { + // 获取分类 + $categorys = $this->getCategoryTree(76); + // 获取文章 + $articles = $this->getArticleByCategory($categorys, ); + // 组装数据 + foreach ($categorys as $key => &$val) { + if (!isset($val['articles'])) { + $val['articles'] = []; + } + if (isset($articles['cid_' . $val['id']])) { + $items = $articles['cid_' . $val['id']]; + foreach ($items as $k => $v) { + $val['articles'][] = [ + 'id' => $v['id'], + 'name' => $v['name'] + ]; + } + } + } + unset($val); + $this->assign('categorys', $categorys); + $this->assign('article', $article); + $this->assign('cid', request()->param('cid')); + } + + return $this->fetch(); + } } diff --git a/app/mobile/view/tops_nas/guide.phtml b/app/mobile/view/tops_nas/guide.phtml index e1863b5..3897495 100755 --- a/app/mobile/view/tops_nas/guide.phtml +++ b/app/mobile/view/tops_nas/guide.phtml @@ -148,6 +148,7 @@ display: flex; flex-direction: row; align-items: center; + flex-wrap: wrap; } .narsjswdMbPage .narsjswd-mb-list .jswdmb-item .jswdmb-tags .jswdmb-tag { font-size: 0.75rem; @@ -155,6 +156,7 @@ border: 0.0625rem solid #000; border-radius: 0.125rem; margin-right: 0.5rem; + margin-bottom: 0.5rem; } .narsjswdMbPage .narsjswd-mb-list .jswdmb-item .jswdmb-tags .tagmnjswdtype1 { color: #00c5dd; diff --git a/app/mobile/view/tops_nas/helper.phtml b/app/mobile/view/tops_nas/helper.phtml new file mode 100644 index 0000000..85f5aa4 --- /dev/null +++ b/app/mobile/view/tops_nas/helper.phtml @@ -0,0 +1,382 @@ + + +
+ +
+
+
+
+
+ {/volist}
+ {if condition="count($vo.articles) >= 3"}
+
+ 
+ {if condition="!empty($banners[0]['picture']) && $banners[0]['picture'] != '/uploads/nopic.jpg'"}
+
+ {if condition="!empty($banners[1]['picture']) && $banners[1]['picture'] != '/uploads/nopic.jpg'"}
+
+ {if condition="!empty($banners[2]['picture']) && $banners[2]['picture'] != '/uploads/nopic.jpg'"}
+
+ {/if}
+ {$banners[2]['name']}
+ {if condition="!empty($banners[3]['picture']) && $banners[3]['picture'] != '/uploads/nopic.jpg'"}
+
+ {if condition="!empty($banners[4]['picture']) && $banners[4]['picture'] != '/uploads/nopic.jpg'"}
+
+ {if condition="!empty($banners[5]['picture']) && $banners[5]['picture'] != '/uploads/nopic.jpg'"}
+
+ {if condition="!empty($banners[6]['picture']) && $banners[6]['picture'] != '/uploads/nopic.jpg'"}
+
+
+
+
+
+