From ec7ee48be88639fdde65ec89abb2526ac3c2096b Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 18 Feb 2025 09:20:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86master=E4=B8=8Edev=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/view/tops_nas/beta.phtml | 4 +- app/index/view/tops_nas/helper.phtml | 26 +- app/mobile/controller/TopsNas.php | 168 +++++++++ app/mobile/view/tops_nas/beta.phtml | 4 +- app/mobile/view/tops_nas/helper.phtml | 371 +++++++++++++++++++ app/mobile/view/tops_nas/helper_detail.phtml | 306 +++++++++++++++ 6 files changed, 862 insertions(+), 17 deletions(-) create mode 100755 app/mobile/view/tops_nas/helper.phtml create mode 100755 app/mobile/view/tops_nas/helper_detail.phtml diff --git a/app/index/view/tops_nas/beta.phtml b/app/index/view/tops_nas/beta.phtml index c46c3cb..d7499c8 100755 --- a/app/index/view/tops_nas/beta.phtml +++ b/app/index/view/tops_nas/beta.phtml @@ -225,8 +225,8 @@ 3.请遵守国家相关法律、法规,勿上传、下载和分享非法数据
- 意见反馈 - 帮助中心 + 意见反馈 + 帮助中心
diff --git a/app/index/view/tops_nas/helper.phtml b/app/index/view/tops_nas/helper.phtml index 6874f10..5c8ce91 100644 --- a/app/index/view/tops_nas/helper.phtml +++ b/app/index/view/tops_nas/helper.phtml @@ -365,7 +365,7 @@

联系我们

{if condition="$banners_size > 0"} - + {if condition="!empty($banners[0]['picture']) && $banners[0]['picture'] != '/uploads/nopic.jpg'"} @@ -375,64 +375,64 @@ {/if} {if condition="$banners_size > 1"} - + {if condition="!empty($banners[1]['picture']) && $banners[1]['picture'] != '/uploads/nopic.jpg'"} {/if} {$banners[1]['name']} {$banners[1]['desc']} - + {/if} {if condition="$banners_size > 2"} - + {if condition="!empty($banners[2]['picture']) && $banners[2]['picture'] != '/uploads/nopic.jpg'"} {/if} {$banners[2]['name']} {$banners[2]['desc']} - + {/if} {if condition="$banners_size > 3"} - + {if condition="!empty($banners[3]['picture']) && $banners[3]['picture'] != '/uploads/nopic.jpg'"} {/if} {$banners[3]['name']} {$banners[3]['desc']} - + {/if} {if condition="$banners_size > 4"} - + {if condition="!empty($banners[4]['picture']) && $banners[4]['picture'] != '/uploads/nopic.jpg'"} {/if} {$banners[4]['name']} {$banners[4]['desc']} - + {/if} {if condition="$banners_size > 5"} - + {if condition="!empty($banners[5]['picture']) && $banners[5]['picture'] != '/uploads/nopic.jpg'"} {/if} {$banners[5]['name']} {$banners[5]['desc']} - + {/if} {if condition="$banners_size > 6"} - + {if condition="!empty($banners[6]['picture']) && $banners[6]['picture'] != '/uploads/nopic.jpg'"} {/if} {$banners[6]['name']} {$banners[6]['desc']} - + {/if}
diff --git a/app/mobile/controller/TopsNas.php b/app/mobile/controller/TopsNas.php index 2a9cbe2..fce39aa 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/beta.phtml b/app/mobile/view/tops_nas/beta.phtml index b6bc5a1..33266e6 100755 --- a/app/mobile/view/tops_nas/beta.phtml +++ b/app/mobile/view/tops_nas/beta.phtml @@ -230,8 +230,8 @@ 3.请遵守国家相关法律、法规,勿上传、下载和分享非法数据
- 意见反馈 - 帮助中心 + 意见反馈 + 帮助中心
diff --git a/app/mobile/view/tops_nas/helper.phtml b/app/mobile/view/tops_nas/helper.phtml new file mode 100755 index 0000000..cfd89a5 --- /dev/null +++ b/app/mobile/view/tops_nas/helper.phtml @@ -0,0 +1,371 @@ + + + + + 帮助中心 + + {include file='include/head-nas' /} + + + +
+
+ + +
+ +

使用教程

+ {volist name="categorys" id="vo"} +
+
+ {$vo.name} +
+
+ {volist name="vo.articles" id="va"} + +
+ {$va.name} + +
+ {/volist} + {if condition="count($vo.articles) >= 3"} + +
查看更多
+
+ {/if} +
+
+ {/volist} +

联系我们

+
+ {if condition="$banners_size > 0"} + + + + {$banners[0]['name']} + {$banners[0]['desc']} + + {/if} + {if condition="$banners_size > 1"} + + + {$banners[1]['name']} + {$banners[1]['desc']} + + {/if} + {if condition="$banners_size > 2"} + + + {$banners[2]['name']}
{$banners[2]['desc']}
+
+ {/if} + {if condition="$banners_size > 3"} + + + {$banners[3]['name']}
{$banners[3]['desc']}
+
+ {/if} + {if condition="$banners_size > 4"} + + + {$banners[4]['name']}
{$banners[4]['desc']}
+
+ {/if} + {if condition="$banners_size > 5"} + + + {$banners[5]['name']}
{$banners[5]['desc']}
+
+ {/if} + {if condition="$banners_size > 6"} + + + {$banners[6]['name']}
{$banners[6]['desc']}
+
+ {/if} +
+ + + {include file="include/bottom1" /} +
+ + + \ No newline at end of file diff --git a/app/mobile/view/tops_nas/helper_detail.phtml b/app/mobile/view/tops_nas/helper_detail.phtml new file mode 100755 index 0000000..9b3d04b --- /dev/null +++ b/app/mobile/view/tops_nas/helper_detail.phtml @@ -0,0 +1,306 @@ + + + + + 帮助中心 + + {include file='include/head-nas' /} + + + +
+
+ +
+ + +
+
+
{$article.content|default=''}
+ + + +
+
+ +
+
+ {include file="include/bottom1" /} +
+ + + \ No newline at end of file