refactor: 英文跳转英文移动端

This commit is contained in:
2025-04-16 17:54:46 +08:00
parent a7d68b57e5
commit 5254a11cde

View File

@@ -8,7 +8,8 @@ use think\Db;
use think\Cache; use think\Cache;
use think\Config; use think\Config;
class BaseController extends Controller { class BaseController extends Controller
{
//当前网站ID //当前网站ID
protected $siteid = 32267; protected $siteid = 32267;
@@ -20,6 +21,7 @@ class BaseController extends Controller {
protected $controller; protected $controller;
protected $action; protected $action;
protected $langid; protected $langid;
protected $country_code;
public function __construct() public function __construct()
{ {
@@ -46,10 +48,10 @@ class BaseController extends Controller {
$this->lang = 'zh-cn'; $this->lang = 'zh-cn';
$this->view->assign('lang', $this->lang); $this->view->assign('lang', $this->lang);
$this->view->assign('langid', $this->langid); $this->view->assign('langid', $this->langid);
$uuid = createGuid(); $uuid = createGuid();
$this->view->assign('uuid', $uuid); $this->view->assign('uuid', $uuid);
// 该服务停用了,导致访问慢,暂时注释 // 该服务停用了,导致访问慢,暂时注释
// setMomitorFeed($this->request->controller(), $uuid); // setMomitorFeed($this->request->controller(), $uuid);
@@ -77,22 +79,22 @@ class BaseController extends Controller {
$url = $this->request->url(true); $url = $this->request->url(true);
if ($url == 'https://www.orico.com.cn/index.php') if ($url == 'https://www.orico.com.cn/index.php')
return $this->redirect('https://www.orico.com.cn'); return $this->redirect('https://www.orico.com.cn');
if ($this->request->isMobile() && strpos($base_url, 'mobile') === false) if ($this->request->isMobile() && strpos($base_url, 'mobile') === false) {
{
$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') {
return $this->redirect(url("@usmobile/$ctrl/$action"));
}
return $this->redirect(url("@mobile/$ctrl/$action")); return $this->redirect(url("@mobile/$ctrl/$action"));
} }
if (strpos($domain, 'orico.cc')) if (strpos($domain, 'orico.cc')) {
{
// 英文 // 英文
if ($base_url == '/') if ($base_url == '/')
return $this->redirect($scheme . '://www.orico.cc/usmobile.html'); // 首页 return $this->redirect($scheme . '://www.orico.cc/usmobile.html'); // 首页
else if ($controller == 'product') else if ($controller == 'product') {
{
// 产品 // 产品
$id = $this->request->param('id'); $id = $this->request->param('id');
if ($action == 'catelists') if ($action == 'catelists')
@@ -103,29 +105,21 @@ class BaseController extends Controller {
return $this->redirect($scheme . '://www.orico.cc/usmobile/product/detail/id/' . $id . '.html'); return $this->redirect($scheme . '://www.orico.cc/usmobile/product/detail/id/' . $id . '.html');
else if ($action == 'new_arrival') else if ($action == 'new_arrival')
return $this->redirect($scheme . '://www.orico.cc/usmobile/product/new_arrival.html'); return $this->redirect($scheme . '://www.orico.cc/usmobile/product/new_arrival.html');
} } else if ($controller == 'article') {
else if ($controller == 'article')
{
// 新闻 // 新闻
$id = $this->request->param('id'); $id = $this->request->param('id');
if ($action == 'catelists') if ($action == 'catelists') {
{
$page = $this->request->param('page'); $page = $this->request->param('page');
$page = isset($page) ? $page : 1; $page = isset($page) ? $page : 1;
} } else if ($action == 'detail')
else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.cc/usmobile/article/detail/id/' . $id . '.html'); return $this->redirect($scheme . '://www.orico.cc/usmobile/article/detail/id/' . $id . '.html');
} } else if ($controller == 'group')
else if ($controller == 'group')
return $this->redirect($scheme . '://www.orico.cc/usmobile/' . $controller . '/' . $action . '.html'); return $this->redirect($scheme . '://www.orico.cc/usmobile/' . $controller . '/' . $action . '.html');
} } else {
else
{
// 中文 // 中文
if ($base_url == '/') if ($base_url == '/')
return $this->redirect($scheme . '://www.orico.com.cn/mobile.html'); // 首页 return $this->redirect($scheme . '://www.orico.com.cn/mobile.html'); // 首页
else if ($controller == 'product') else if ($controller == 'product') {
{
// 产品 // 产品
$id = $this->request->param('id'); $id = $this->request->param('id');
if ($action == 'catelists') if ($action == 'catelists')
@@ -134,42 +128,35 @@ class BaseController extends Controller {
return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/subcatelists/id/' . $id . '.html'); return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/subcatelists/id/' . $id . '.html');
else if ($action == 'detail') else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/detail/id/' . $id . '.html'); return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/detail/id/' . $id . '.html');
} } else if ($controller == 'article') {
else if ($controller == 'article')
{
// 新闻 // 新闻
$id = $this->request->param('id'); $id = $this->request->param('id');
if ($action == 'catelists') if ($action == 'catelists') {
{
$page = $this->request->param('page'); $page = $this->request->param('page');
$page = isset($page) ? $page : 1; $page = isset($page) ? $page : 1;
} } else if ($action == 'detail')
else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.com.cn/mobile/article/detail/id/' . $id . '.html'); return $this->redirect($scheme . '://www.orico.com.cn/mobile/article/detail/id/' . $id . '.html');
} } else if ($controller == 'group') {
else if ($controller == 'group'){
/*if($action == 'oricoindex'){ /*if($action == 'oricoindex'){
return $this->redirect($scheme . '://www.orico.com.cn/mobile'); return $this->redirect($scheme . '://www.orico.com.cn/mobile');
}*/ }*/
return $this->redirect($scheme . '://www.orico.com.cn/mobile/' . $controller . '/' . $action . '.html'); return $this->redirect($scheme . '://www.orico.com.cn/mobile/' . $controller . '/' . $action . '.html');
} }
} }
} }
} }
//空操作 //空操作
public function _empty() { public function _empty()
if ($_SERVER['HTTP_HOST']=="www.orico.com.cn" && $_SERVER['HTTP_HOST']=="orico.com.cn") { {
return $this->redirect("http://orico.com.cn"); if ($_SERVER['HTTP_HOST'] == "www.orico.com.cn" && $_SERVER['HTTP_HOST'] == "orico.com.cn") {
} elseif ($_SERVER['HTTP_HOST']=="www.orico.cc" || $_SERVER['HTTP_HOST']=="orico.cc") { return $this->redirect("http://orico.com.cn");
return $this->redirect("http://orico.cc"); } elseif ($_SERVER['HTTP_HOST'] == "www.orico.cc" || $_SERVER['HTTP_HOST'] == "orico.cc") {
return $this->redirect("http://orico.cc");
} }
return exception(_lang_('This operation not valid')); return exception(_lang_('This operation not valid'));
} }
/** /**
@@ -178,12 +165,14 @@ class BaseController extends Controller {
* @param integer $id id * @param integer $id id
* @return bool 检测结果 * @return bool 检测结果
*/ */
protected function verify_check($code, $id = '') { protected function verify_check($code, $id = '')
{
$verify = new \verify\Verify(); $verify = new \verify\Verify();
return $verify->check($code, $id); return $verify->check($code, $id);
} }
protected function verify_build($id = '', $cfg = []) { protected function verify_build($id = '', $cfg = [])
{
//$verify = new \verify\Verify((array) Config::get('captcha')); //$verify = new \verify\Verify((array) Config::get('captcha'));
$config = [ $config = [
'expire' => 900, // 验证码过期时间s 'expire' => 900, // 验证码过期时间s
@@ -206,7 +195,8 @@ class BaseController extends Controller {
* @param string $name 缓存变量名 * @param string $name 缓存变量名
* @return bool * @return bool
*/ */
public function cacheHas($name) { public function cacheHas($name)
{
return Cache::has($name); return Cache::has($name);
} }
@@ -218,7 +208,8 @@ class BaseController extends Controller {
* @param int|null $expire 有效时间 0为永久 * @param int|null $expire 有效时间 0为永久
* @return boolean * @return boolean
*/ */
public function cacheSet($name, $value, $expire = null) { public function cacheSet($name, $value, $expire = null)
{
return Cache::set($name, $value, $expire); return Cache::set($name, $value, $expire);
} }
@@ -229,7 +220,8 @@ class BaseController extends Controller {
* @param mixed $default 默认值 * @param mixed $default 默认值
* @return mixed * @return mixed
*/ */
public function cacheGet($name, $default = false) { public function cacheGet($name, $default = false)
{
return Cache::get($name, $default); return Cache::get($name, $default);
} }
@@ -240,7 +232,8 @@ class BaseController extends Controller {
* @param string $name 缓存标识 * @param string $name 缓存标识
* @return boolean * @return boolean
*/ */
public function cacheDelete($name) { public function cacheDelete($name)
{
return Cache::rm($name); return Cache::rm($name);
} }
@@ -250,7 +243,8 @@ class BaseController extends Controller {
* @param string $tag 标签名 * @param string $tag 标签名
* @return boolean * @return boolean
*/ */
public function cacheClear($tag = null) { public function cacheClear($tag = null)
{
return Cache::clear($tag); return Cache::clear($tag);
} }
@@ -260,7 +254,8 @@ class BaseController extends Controller {
* @param string $name 缓存变量名 * @param string $name 缓存变量名
* @return mixed * @return mixed
*/ */
public function cachePull($name) { public function cachePull($name)
{
return Cache::pull($name); return Cache::pull($name);
} }
@@ -272,7 +267,8 @@ class BaseController extends Controller {
* @param int $expire 有效时间 0为永久 * @param int $expire 有效时间 0为永久
* @return mixed * @return mixed
*/ */
public function cacheRemember($name, $value, $expire = null) { public function cacheRemember($name, $value, $expire = null)
{
return Cache::remember($name, $value, $expire); return Cache::remember($name, $value, $expire);
} }
@@ -284,7 +280,8 @@ class BaseController extends Controller {
* @param bool $overlay 是否覆盖 * @param bool $overlay 是否覆盖
* @return Driver * @return Driver
*/ */
public function cacheTag($name, $keys = null, $overlay = false) { public function cacheTag($name, $keys = null, $overlay = false)
{
return Cache::tag($name, $keys, $overlay); return Cache::tag($name, $keys, $overlay);
} }
@@ -296,7 +293,8 @@ class BaseController extends Controller {
* @param array $data 返回数据 * @param array $data 返回数据
* @return json * @return json
*/ */
public function json($code, $msg, $data=null) { public function json($code, $msg, $data = null)
{
$result = [ $result = [
'code' => $code, 'code' => $code,
'msg' => $msg, 'msg' => $msg,
@@ -307,5 +305,4 @@ class BaseController extends Controller {
echo json_encode($result); echo json_encode($result);
exit; exit;
} }
} }