Compare commits

..

3 Commits

8 changed files with 693 additions and 690 deletions

View File

@@ -85,9 +85,9 @@ class BaseController extends Controller
$ctrl = \think\helper\Str::snake($this->controller); $ctrl = \think\helper\Str::snake($this->controller);
if ($ctrl == 'tops_nas') { if ($ctrl == 'tops_nas') {
if ($this->country_code == 'US') { if ($this->country_code == 'US') {
return $this->redirect(url("@usmobile/$ctrl/$action")); return $this->redirect(url("@usmobile/$ctrl/$action", $this->request->param()));
} }
return $this->redirect(url("@mobile/$ctrl/$action")); return $this->redirect(url("@mobile/$ctrl/$action", $this->request->param()));
} }
if (strpos($domain, 'orico.cc')) { if (strpos($domain, 'orico.cc')) {

View File

@@ -341,7 +341,7 @@ class TopsNas extends BaseController
$model = \think\Db::table($sub_query . ' a'); $model = \think\Db::table($sub_query . ' a');
foreach ($categorys as $key => $val) { foreach ($categorys as $key => $val) {
if ($key == 0) continue; if ($key == 0) continue;
$model->union(function($query) use($val, $limit) { $model->union(function($query) use($key, $val, $limit) {
$query->name('article')->field([ $query->name('article')->field([
'id', 'id',
'cid', 'cid',
@@ -355,6 +355,8 @@ class TopsNas extends BaseController
if (!empty($limit)) { if (!empty($limit)) {
$query->limit($limit); $query->limit($limit);
} }
// 嵌套子查询解决union没有limit时排序问题
$query->table($query->buildSql() . 'a' . $key);
}); });
} }

View File

@@ -264,6 +264,7 @@ class TopsNas extends BaseController
return $this->fetch(); return $this->fetch();
} }
// 根据分类获取文章 // 根据分类获取文章
private function getArticleByCategory($categorys, $limit = null) private function getArticleByCategory($categorys, $limit = null)
{ {
@@ -293,7 +294,7 @@ class TopsNas extends BaseController
$model = \think\Db::table($sub_query . ' a'); $model = \think\Db::table($sub_query . ' a');
foreach ($categorys as $key => $val) { foreach ($categorys as $key => $val) {
if ($key == 0) continue; if ($key == 0) continue;
$model->union(function($query) use($val, $limit) { $model->union(function($query) use($key, $val, $limit) {
$query->name('article')->field([ $query->name('article')->field([
'id', 'id',
'cid', 'cid',
@@ -307,6 +308,8 @@ class TopsNas extends BaseController
if (!empty($limit)) { if (!empty($limit)) {
$query->limit($limit); $query->limit($limit);
} }
// 嵌套子查询解决union没有limit时排序问题
$query->table($query->buildSql() . 'a' . $key);
}); });
} }

0
app/mobile/view/tops_nas/helper.phtml Executable file → Normal file
View File

0
app/mobile/view/tops_nas/helper_detail.phtml Executable file → Normal file
View File

View File

@@ -123,7 +123,7 @@ class TopsNas extends BaseController
$model = \think\Db::table($sub_query . ' a'); $model = \think\Db::table($sub_query . ' a');
foreach ($categorys as $key => $val) { foreach ($categorys as $key => $val) {
if ($key == 0) continue; if ($key == 0) continue;
$model->union(function ($query) use ($val, $limit) { $model->union(function ($query) use ($key, $val, $limit) {
$query->name('article')->field([ $query->name('article')->field([
'id', 'id',
'cid', 'cid',
@@ -137,6 +137,8 @@ class TopsNas extends BaseController
if (!empty($limit)) { if (!empty($limit)) {
$query->limit($limit); $query->limit($limit);
} }
// 嵌套子查询解决union没有limit时排序问题
$query->table($query->buildSql() . 'a' . $key);
}); });
} }
@@ -262,15 +264,12 @@ class TopsNas extends BaseController
// 下载 // 下载
public function download() public function download()
{ {
$focus_image = [];
$downloads = []; $downloads = [];
// 获取banner // 获取banner
$banners = $this->getBanners([129, 130]); $banners = $this->getBanners([129]);
if (!empty($banners)) { if (!empty($banners)) {
$focus_image = $banners['typeid_130']['banners'];
$downloads = $banners['typeid_129']['banners']; $downloads = $banners['typeid_129']['banners'];
} }
$this->assign('focus_image', $focus_image);
$this->assign('downloads', $downloads); $this->assign('downloads', $downloads);
return $this->fetch(); return $this->fetch();

View File

@@ -184,7 +184,7 @@ class TopsNas extends BaseController
$model = \think\Db::table($sub_query . ' a'); $model = \think\Db::table($sub_query . ' a');
foreach ($categorys as $key => $val) { foreach ($categorys as $key => $val) {
if ($key == 0) continue; if ($key == 0) continue;
$model->union(function ($query) use ($val, $limit) { $model->union(function ($query) use ($key, $val, $limit) {
$query->name('article')->field([ $query->name('article')->field([
'id', 'id',
'cid', 'cid',
@@ -198,6 +198,8 @@ class TopsNas extends BaseController
if (!empty($limit)) { if (!empty($limit)) {
$query->limit($limit); $query->limit($limit);
} }
// 嵌套子查询解决union没有limit时排序问题
$query->table($query->buildSql() . 'a' . $key);
}); });
} }
@@ -251,15 +253,12 @@ class TopsNas extends BaseController
public function download() public function download()
{ {
$focus_image = [];
$downloads = []; $downloads = [];
// 获取banner // 获取banner
$banners = $this->getBanners([129, 130]); $banners = $this->getBanners([129]);
if (!empty($banners)) { if (!empty($banners)) {
$focus_image = $banners['typeid_130']['banners'];
$downloads = $banners['typeid_129']['banners']; $downloads = $banners['typeid_129']['banners'];
} }
$this->assign('focus_image', $focus_image);
$this->assign('downloads', $downloads); $this->assign('downloads', $downloads);
return $this->fetch(); return $this->fetch();