diff --git a/app/us/view/tops_nas/helper.phtml b/app/us/view/tops_nas/helper.phtml index aeb5a51..a2a1da4 100644 --- a/app/us/view/tops_nas/helper.phtml +++ b/app/us/view/tops_nas/helper.phtml @@ -406,7 +406,7 @@ {/volist} {if condition="count($vo.articles) >= 3"} - 查看更多 + Click to view more diff --git a/app/usmobile/controller/BaseController.php b/app/usmobile/controller/BaseController.php index 308ca2c..31a3d59 100755 --- a/app/usmobile/controller/BaseController.php +++ b/app/usmobile/controller/BaseController.php @@ -15,6 +15,9 @@ class BaseController extends Controller { //当前用户 protected $customer_id = 0; + // 当前国家编码 + protected $country_code = 'US'; + public function __construct() { parent::__construct(); } @@ -71,6 +74,47 @@ class BaseController extends Controller { $this->view->assign('allCategoryList', $this->categoryList); } + protected function buildTree($data, $pid = 0) + { + $tree = []; + foreach ($data as $val) { + if ($val['pid'] == $pid) { + $children = $this->buildTree($data, $val['id']); + if (!empty($children)) { + $val['items'] = $children; + } + $tree[] = $val; + } + } + + return $tree; + } + + /** + * nasNavigation 获取并组装nas专题页的top导航和footer + */ + protected function nasNavigation() + { + $navs = Loader::model('Navigation')->field([ + 'id', + 'pid', + 'name', + 'url', + 'value', + 'data_type', + 'is_new_window_open', + ]) + ->where('stat', '=', 0) + ->where('nav_type', '=', 'tops_nas_header') + ->where('country_code', '=', $this->country_code) + ->order('sort') + ->select(); + + $navs_array = collection($navs)->toArray(); + $header = $this->NavDataDealWith($navs_array); + $this->assign('nav_header', $this->buildTree($header)); + } + //导航初始化 private function navInit(){ // 读取缓存数据 diff --git a/app/usmobile/controller/TopsNas.php b/app/usmobile/controller/TopsNas.php index af87026..1f8a78d 100755 --- a/app/usmobile/controller/TopsNas.php +++ b/app/usmobile/controller/TopsNas.php @@ -1,12 +1,252 @@ alias('b')->field([ + 'b.id', + 'b.typeid', + 'bt.name' => 'typename', + 'bt.description' => 'typedesc', + 'b.name', + 'b.categoryid', + 'b.url', + 'b.picture', + 'b.alt', + 'b.style', + 'b.description' => 'desc', + 'b.descolor', + 'b.btncolor', + 'b.videourl', + ]) + ->join('banner_type bt', 'bt.stat= 0 and bt.id=b.typeid') + ->where('b.stat', '=', 0) + ->where('b.typeid', 'in', $typeids) + ->order(['sort' => 'asc', 'id' => 'asc']) + ->select(); + + $chucks = []; + foreach ($banners as $val) { + if (empty($chucks['typeid_' . $val['typeid']])) { + $chucks['typeid_' . $val['typeid']]['id'] = $val['typeid']; + $chucks['typeid_' . $val['typeid']]['name'] = $val['typename']; + $chucks['typeid_' . $val['typeid']]['desc'] = $val['typedesc']; + $chucks['typeid_' . $val['typeid']]['banners'] = []; + } + + $link = $val['url']; + if (empty($val['url']) && !empty($val['categoryid'])) { + $link = url_rewrite('productsub', ['id' => $val['categoryid']]); + } + $chucks['typeid_' . $val['typeid']]['banners'][] = [ + 'id' => $val['id'], + 'name' => $val['name'], + 'link' => $link, + 'picture' => $val['picture'], + 'alt' => $val['alt'], + 'style' => $val['style'], + 'desc' => $val['desc'], + 'desc_color' => $val['descolor'], + 'btn_color' => $val['btncolor'], + 'video_url' => $val['videourl'], + ]; + } + + return $chucks; + } + + public function helper() + { + // 获取分类 + $categorys = $this->getCategoryTree(77); + // 获取文章 + $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(128); + if (!empty($banners)) { + $banners = $banners['typeid_128']['banners']; + } + $this->assign('banners', $banners); + $this->assign('banners_size', count($banners)); + + return $this->fetch(); + } + + public function helper_search() + { + $base_category = 77; + $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 + ]); + } + + /** + * getCategoryTree 获取特定文章分类树 + */ + private function getCategoryTree($cid = 36) + { + // 设备 + $category = Loader::model('ArticleCategory') + ->field([ + 'id', + 'pid', + 'name', + 'picture' + ]) + ->where('isshow', '=', 1) + ->where('country_code', '=', $this->country_code) + ->order(['sort' => 'asc']) + ->select(); + $category_array = collection($category)->toArray(); + $category_tree = $this->buildTree($category_array, $cid); + return $category_tree; + } + + // 根据分类获取文章 + 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_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(77); + // 获取文章 + $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(); } public function download() diff --git a/app/usmobile/view/include/top_nas.phtml b/app/usmobile/view/include/top_nas.phtml new file mode 100755 index 0000000..87bad8b --- /dev/null +++ b/app/usmobile/view/include/top_nas.phtml @@ -0,0 +1,174 @@ +
+
+ +
+ + + + + + + + + +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/app/usmobile/view/tops_nas/download.phtml b/app/usmobile/view/tops_nas/download.phtml index eabb554..7fa7e38 100755 --- a/app/usmobile/view/tops_nas/download.phtml +++ b/app/usmobile/view/tops_nas/download.phtml @@ -1,270 +1,201 @@ - - - - 元创官网 - - {include file='include/head-nas'/} - + - .narsmb-wlj .narsmbwltitem { - margin: 0 0.4375rem; - height: 9.0625rem; - background: #131b28; - display: flex; - flex-direction: row; - justify-content: space-between; - margin-bottom: 0.5rem; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcp { - display: flex; - flex-direction: row; - align-items: center; - justify-content: center; - height: inherit; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcp .narsmbtt { - font-size: 1.0625rem; - font-weight: bold; - color: #fff; - width: 35.5rem; - text-align: center; - margin-left: 35%; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcp .narsmbwljimg { - height: inherit; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcpinfo { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - color: #fff; - flex: 1; - margin: 0 1.25rem; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcpinfo .narsmbif-title { - font-weight: bold; - font-size: 1.0625rem; - padding-bottom: 1rem; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcpinfo .narsmbif-info { - font-size: 0.625rem; - line-height: 1rem; - text-align: center; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcpinfo .narsmbwlj-xzbt { - width: 7.25rem; - height: 2.1875rem; - border-radius: 3.25rem; - line-height: 2.1875rem; - border: 1px solid #ffffff; - font-size: 0.875rem; - text-align: center; - cursor: pointer; - margin: 0 1.25rem; - } - - .narsmb-wlj .narsmbwltitem .narsmbwljcpinfo .narsmbtt { - font-size: 1.0625rem; - font-weight: bold; - color: #fff; - text-align: center; - } - - .narsMBbannerSwiper { - padding-top: 0px; - } - - - - - - - -
- -
-
-
- -
- -
- -
-
+ + {include file='include/top_nas'/} +
+
+ +
+
+
- - - {include file='include/bottom'/} + +
- + +
+
+ +
+ +
+ {include file='include/bottom'/} +
+ + - + \ No newline at end of file diff --git a/app/usmobile/view/tops_nas/helper.phtml b/app/usmobile/view/tops_nas/helper.phtml new file mode 100644 index 0000000..8492cde --- /dev/null +++ b/app/usmobile/view/tops_nas/helper.phtml @@ -0,0 +1,408 @@ + + + + + + 帮助中心 + + {include file='include/head-nas' /} + + + + +
+
+ + +
+ +

User's Guide

+ {volist name="categorys" id="vo"} +
+
+ {$vo.name} +
+
+ {volist name="vo.articles" id="va"} + +
+ {$va.name} + +
+ {/volist} + {if condition="count($vo.articles) >= 3"} + +
Click to view more
+
+ {/if} +
+
+ {/volist} +

Contact US

+
+ {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} +
+ + + {include file="include/bottom" /} +
+ + + \ No newline at end of file diff --git a/app/usmobile/view/tops_nas/helper_detail.phtml b/app/usmobile/view/tops_nas/helper_detail.phtml new file mode 100644 index 0000000..431c279 --- /dev/null +++ b/app/usmobile/view/tops_nas/helper_detail.phtml @@ -0,0 +1,344 @@ + + + + + + 帮助中心 + + {include file='include/head-nas' /} + + + + +
+
+ +
+ + +
+
+
{$article.content|default=''}
+ + + +
+
+ +
+
+ {include file="include/bottom" /} +
+ + + \ No newline at end of file