diff --git a/app/common.php b/app/common.php
index 75ddedb..d33cee5 100755
--- a/app/common.php
+++ b/app/common.php
@@ -139,6 +139,7 @@ function getstr_random($length = 4) {
}
function getImage($filename, $width = -1, $height = -1, $type = 1, $savedir = 'allimg', $baseurl = '') {
+ // ini_set('memory_limit',-1);
$docDir = request()->server('DOCUMENT_ROOT');
$rootDir = request()->root();
if ($width < 0 && $height < 0) {
diff --git a/app/index/controller/TopsNas.php b/app/index/controller/TopsNas.php
index 1a49d7c..447382c 100755
--- a/app/index/controller/TopsNas.php
+++ b/app/index/controller/TopsNas.php
@@ -194,6 +194,7 @@ class TopsNas extends BaseController
'id',
'pid',
'name',
+ 'picture'
])
->where('isshow', '=', 1)
->where('country_code', '=', $this->country_code)
@@ -310,4 +311,167 @@ 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(126);
+ if (!empty($banners)) {
+ $banners = $banners['typeid_126']['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', $article->cid));
+ }
+
+ return $this->fetch();
+ }
}
diff --git a/app/index/view/index.phtml b/app/index/view/index.phtml
index a77a383..15700aa 100755
--- a/app/index/view/index.phtml
+++ b/app/index/view/index.phtml
@@ -18,12 +18,10 @@