Compare commits

..

2 Commits

8 changed files with 691 additions and 682 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

@@ -435,7 +435,7 @@
{/if} {/if}
<span class="t1">{$banners[6]['name']}</span> <span class="t1">{$banners[6]['name']}</span>
<span class="t2">{$banners[6]['desc']}</span> <span class="t2">{$banners[6]['desc']}</span>
</a> </a>
{/if} {/if}
</div> </div>
</div> </div>

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);
}); });
} }

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);
}); });
} }