文件
nahaichuan/addons/official/controller/web/OfficialHome.php
2026-10-08 16:23:22 +08:00

91 行
2.6 KiB
PHP

<?php
namespace addons\official\controller\web;
use addons\official\model\OfficialCategory;
use addons\official\model\OfficialListProduct;
use think\Cache;
class OfficialHome extends OfficialBaseController
{
protected $noNeedLogin = ['index', 'single', 'set_language','get_token'];
protected $noNeedRight = '*';
protected $CategoryModel;
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->CategoryModel = new OfficialCategory();
}
/**
* 首页
*/
public function index()
{
//默认栏目数据
$defult_index_url = ADDON_PATH . 'official' . DS . 'config' . DS . 'defult_index.php';
$defult_index = include $defult_index_url;
//产品展示
$new_list = $this->CategoryModel->getFatherIsSon($defult_index['product_father'], 4, $defult_index['product_son'], 8);
//服务范围
$fuwu = $this->CategoryModel->getOneCategoryIsData($defult_index['serve'], 3);
//软件产品
$soft = $this->CategoryModel->getOneCategoryIsData($defult_index['servesoft'], 12);
//新闻资讯
$information = $this->CategoryModel->getFatherIsSon($defult_index['journalism_father'], 2, $defult_index['journalism_son'], 10);
//我们的客户
$kehu = $this->CategoryModel->getOneCategoryIsData($defult_index['our_clients'], 10);
return view("web/official_home/index{$this->Mobile}", compact('new_list', 'fuwu', 'information', 'kehu', 'soft'));
}
/**
* 单页
*/
public function single()
{
$sid = (int)input('param.sid');
//查詢父级
$res = $this->get_cate_pid_in_sid();
//查询子集
$son_data = [];
if (!empty($sid)) {
$son_data = (new OfficialCategory())
->where('id', $sid)
->order('weigh', 'desc')
->find();
}
return view("web/official_home/single{$this->Mobile}", compact('res', 'son_data'));
}
/**
* 设置语言
*/
public function set_language()
{
$url = (string)input('param.url');
$language = (int)input('param.language');
if (!$language) {
$this->error('language 不能为空');
}
cookie('language', $language * 1, 3600);
$this->redirect($url ? base64_decode($url) : $this->rewrite['web.official_home/index']);
}
/**
* 重新刷新表单中的token
*/
public function get_token()
{
$token = request()->token('__token__', 'sha1');
return json_encode(['code' => 1, 'data' => $token]);
}
}