feat: 初始化纳海川官网代码仓
这个提交包含在:
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
use addons\official\model\OfficialBanners;
|
||||
use addons\official\model\OfficialCategory;
|
||||
use think\addons\Controller;
|
||||
use think\Cache;
|
||||
|
||||
class OfficialBaseController extends Controller
|
||||
{
|
||||
|
||||
public $basic = [];
|
||||
public $language_z = '';
|
||||
protected $language = 2;
|
||||
protected $basic_title;
|
||||
protected $keywords;
|
||||
protected $description;
|
||||
protected $Mobile = '';
|
||||
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
||||
//生成配置文件
|
||||
$official_config_url = ADDON_PATH . 'official' . DS . 'config' . DS . 'official_config.php';
|
||||
if (!file_exists($official_config_url)) {
|
||||
$this->error("您的'$official_config_url'文件缺失。",'','',20);
|
||||
} else {
|
||||
$config = include $official_config_url;
|
||||
}
|
||||
|
||||
//重新整理格式
|
||||
$config_all = [];
|
||||
foreach ($config as $key => $value){
|
||||
$config_all[$key] = ['name'=>$key,'value'=>$value];
|
||||
}
|
||||
|
||||
$this->language = (int)cookie('language');
|
||||
$web_default_language = $config_all['web_default_language']['value'];
|
||||
//前端默认语言代码
|
||||
if (empty($this->language) && !empty($web_default_language)){
|
||||
$this->language = $web_default_language;
|
||||
cookie('language', $web_default_language);
|
||||
}
|
||||
$this->assign('language', $this->language);
|
||||
$this->assign('auth', $this->auth);
|
||||
//判断移动PC端
|
||||
if ($this->isMobile()) {
|
||||
$this->Mobile = '_e';
|
||||
}
|
||||
//查询所有栏目
|
||||
$this->getAll0fficiaCategory();
|
||||
//查询轮播图
|
||||
$this->getAllBanners();
|
||||
//网站名称 关键词 介绍
|
||||
$this->language_z = ($this->language == 1) ? '_en' : '';
|
||||
|
||||
|
||||
|
||||
$this->basic_title = $config_all['basic_title' . $this->language_z]['value'] ?? '';
|
||||
$this->keywords = $config_all['keywords' . $this->language_z]['value'] ?? '';
|
||||
$this->description = $config_all['description' . $this->language_z]['value'] ?? '';
|
||||
$this->basic = [
|
||||
'title' => $this->basic_title,
|
||||
'keywords' => $this->keywords,
|
||||
'description' => $this->description,
|
||||
];
|
||||
$this->view->assign('captchaType', config('fastadmin.user_register_captcha'));
|
||||
$this->assign('basic', $this->basic);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* 移动pc判断
|
||||
*/
|
||||
public function isMobile()
|
||||
{
|
||||
return request()->isMobile();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有栏目
|
||||
*/
|
||||
public function getAll0fficiaCategory()
|
||||
{
|
||||
//生成配置文件
|
||||
$official_tree_category_url = ADDON_PATH . 'official' . DS . 'config' . DS . 'official_tree_category.php';
|
||||
if (!file_exists($official_tree_category_url)) {
|
||||
$official_category = (new OfficialCategory())
|
||||
->with(['son'])
|
||||
->where('pid', 0)
|
||||
->field(['content', 'e_content'], true)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->select();
|
||||
$tree_category_all = [];
|
||||
foreach ($official_category as $item) {
|
||||
$tree_category_all[] = $item->toArray();
|
||||
}
|
||||
file_put_contents(
|
||||
$official_tree_category_url,
|
||||
'<?php' . "\n\nreturn " . var_export_short($tree_category_all) . ";\n"
|
||||
);
|
||||
} else {
|
||||
$tree_category_all = include $official_tree_category_url;
|
||||
}
|
||||
$this->assign('all_official_category', $tree_category_all);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有轮播图
|
||||
*/
|
||||
public function getAllBanners()
|
||||
{
|
||||
$cid = (int)input('param.sid');
|
||||
$banners = (new OfficialBanners())
|
||||
->where('status', 1)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null);
|
||||
//栏目id
|
||||
if ($cid) {
|
||||
$banners = $banners->where("FIND_IN_SET(" . $cid . ",official_category_ids)");
|
||||
} else {
|
||||
$banners = $banners->where('is_index', 1);
|
||||
}
|
||||
//查询
|
||||
$banners = $banners
|
||||
->order('weigh', 'desc')
|
||||
->select();
|
||||
$this->assign('banners', $banners);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取栏目数据
|
||||
* @return array|bool|\PDOStatement|string|\think\Model
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function get_cate_pid_in_sid()
|
||||
{
|
||||
$sid = (int)input('param.sid');
|
||||
$pid = (int)input('param.pid');
|
||||
//1.查詢父级
|
||||
$res = [];
|
||||
$official_tree_category_url = ADDON_PATH . 'official' . DS . 'config' . DS . 'official_tree_category.php';
|
||||
if (file_exists($official_tree_category_url)) {
|
||||
$tree_category_all = include $official_tree_category_url;
|
||||
foreach ($tree_category_all as $item) {
|
||||
if ($item['id'] == $pid) {
|
||||
$res = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
//2.判断是否选中
|
||||
if (isset($res['son'])) {
|
||||
foreach ($res['son'] as $key => $item) {
|
||||
//如果不在导航中显示 则删除
|
||||
if ($item['is_nav_show'] != 1) {
|
||||
unset($res['son'][$key]);
|
||||
continue;// 删除后,跳出本次循环
|
||||
}
|
||||
//判断是否选中
|
||||
$res['son'][$key]['is_choose'] = 0;
|
||||
if (!empty($sid)) {
|
||||
if ($item['id'] == $sid) {
|
||||
$res['son'][$key]['is_choose'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
*增加点击量
|
||||
* @param $model 模型
|
||||
* @param $id
|
||||
*/
|
||||
protected function addClick($model, $id)
|
||||
{
|
||||
$model->where('id', $id)->setInc('click');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 网站名称 关键词 介绍
|
||||
* @param int $stu stu == 1 代表是栏目 stu == 2 代表详情
|
||||
* @param string $title
|
||||
* @param string $keywords
|
||||
* @param string $description
|
||||
*/
|
||||
protected function setBasic($stu = 1, $title = '', $keywords = '', $description = '')
|
||||
{
|
||||
$arr = ['title' => $title, 'keywords' => $keywords, 'description' => $description];
|
||||
foreach ($arr as $item => $val) {
|
||||
if ($val) {
|
||||
$this->basic[$item] = $val;
|
||||
}
|
||||
}
|
||||
if ($stu == 1) {
|
||||
$language_z = ($this->language == 1) ? 'e_' : '';
|
||||
$category = db('official_category')->where('id', (int)input('param.sid'))->find();
|
||||
if ($category) {
|
||||
$this->basic = [
|
||||
'title' => $this->basic_title . '|' . $category[$language_z . 'name'],
|
||||
'keywords' => $this->keywords,
|
||||
'description' => $category[$language_z . 'subheading'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->assign('basic', $this->basic);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
|
||||
use addons\official\model\OfficialCategory;
|
||||
use addons\official\model\OfficialListCaseShow;
|
||||
use think\Request;
|
||||
|
||||
class OfficialCaseShow extends OfficialBaseController
|
||||
{
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListCaseShow();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$data = [];
|
||||
$p_id = (int)input('param.pid');
|
||||
$son_id = (int)input('param.sid');
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
|
||||
if ($son_id) {
|
||||
$data = $this
|
||||
->model
|
||||
->where('official_category_id', $son_id)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->field(['id,title,image,createtime'])
|
||||
->paginate(8, $simple = $this->isMobile(), $config = [
|
||||
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
||||
]);
|
||||
}
|
||||
return view("web/official_case_show/list{$this->Mobile}", compact('res', 'data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function details()
|
||||
{
|
||||
$id = input('param.id');
|
||||
//增加点击量
|
||||
$this->addClick($this->model, $id);
|
||||
|
||||
$data = $this->model
|
||||
->where('id', $id)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->find();
|
||||
$this->setBasic(999, $data['title']);
|
||||
$category = (new OfficialCategory())->where('id', $data['official_category_id'])->field(['id,name,e_name'])->find();
|
||||
//前面一个新闻
|
||||
$before = $this->model
|
||||
->where('id', '<', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'desc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
//后面第一个新闻
|
||||
$after = $this->model
|
||||
->where('id', '>', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'asc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
return view("web/official_case_show/details{$this->Mobile}", compact('data', 'category', 'before', 'after'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
use addons\official\model\OfficialListDownload;
|
||||
use think\Request;
|
||||
|
||||
class OfficialDownload extends OfficialBaseController
|
||||
{
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListDownload();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$data = [];
|
||||
$p_id = (int)input('param.pid');
|
||||
$son_id = (int)input('param.sid');
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
|
||||
if ($son_id) {
|
||||
$data = $this
|
||||
->model
|
||||
->where('official_category_id', $son_id)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->field(['id,title'])
|
||||
->paginate(8, $simple = $this->isMobile(), $config = [
|
||||
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
||||
]);
|
||||
}
|
||||
return view("web/official_download/list{$this->Mobile}", compact('res', 'data'));
|
||||
}
|
||||
|
||||
//下载
|
||||
public function download()
|
||||
{
|
||||
$id = (int)input('param.id');
|
||||
//增加模型
|
||||
$this->addClick($this->model, $id);
|
||||
//查询数据
|
||||
$data = $this->model
|
||||
->where('id', $id)
|
||||
->where('deletetime', null)
|
||||
->find();
|
||||
//跳转下载
|
||||
$this->success('即将下载', cdnurl($data['download_file']));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
|
||||
use addons\official\model\OfficialCategory;
|
||||
use addons\official\model\OfficialListJournalism;
|
||||
use think\Request;
|
||||
|
||||
class OfficialJournalism extends OfficialBaseController
|
||||
{
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListJournalism();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$data = [];
|
||||
$p_id = (int)input('param.pid');
|
||||
$son_id = (int)input('param.sid');
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
//如果所有子级别和父级一样
|
||||
$status = 1;
|
||||
if (($p_id == $son_id) && (count($res['son']))) {
|
||||
$status = 2;
|
||||
$ids = [$p_id];
|
||||
foreach ($res['son'] as $item) {
|
||||
if (($res['status'] != $item['status']) || ($res['official_rule_id'] != $item['official_rule_id'])) {
|
||||
$status = 1;
|
||||
}
|
||||
$ids[] = $item['id'];
|
||||
}
|
||||
}
|
||||
if ($son_id) {
|
||||
$data = $this->model;
|
||||
if ($status == 1) {
|
||||
$data = $data->where('official_category_id', $son_id);
|
||||
} else {
|
||||
$data = $data->whereIn('official_category_id', $ids);
|
||||
}
|
||||
$data = $data->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->field(['id,title,image,subheading,createtime'])
|
||||
->paginate(8, $simple = $this->isMobile(), $config = [
|
||||
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
||||
]);
|
||||
}
|
||||
return view("web/official_journalism/list{$this->Mobile}", compact('res', 'data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function details()
|
||||
{
|
||||
$id = (int)input('param.id');
|
||||
//增加点击量
|
||||
$this->addClick($this->model, $id);
|
||||
|
||||
$data = $this->model
|
||||
->where('id', $id)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->find();
|
||||
$this->setBasic(999, $data['title'], '', $data['subheading']);
|
||||
$category = (new OfficialCategory())->where('id', $data['official_category_id'])->field(['id,name,e_name'])->find();
|
||||
//前面一个新闻
|
||||
$before = $this->model
|
||||
->where('id', '<', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'desc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
//后面第一个新闻
|
||||
$after = $this->model
|
||||
->where('id', '>', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'asc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
|
||||
return view("web/official_journalism/details{$this->Mobile}", compact('data', 'category', 'before', 'after'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
|
||||
use addons\official\model\OfficialListOnlineMessage;
|
||||
use think\Request;
|
||||
use think\Validate;
|
||||
|
||||
class OfficialOnlineMessage extends OfficialBaseController
|
||||
{
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListOnlineMessage();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$id = (int)input('param.sid');
|
||||
if (!$id) {
|
||||
$this->error('栏目必须存在');
|
||||
}
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
if ($this->request->isPost()) {
|
||||
$token = $this->request->post('__token__');
|
||||
//验证Token
|
||||
if (!$token || !\think\Validate::is($token, "token", ['__token__' => $token])) {
|
||||
return json_encode(['code' => 0, 'msg' => '请先登录!']);
|
||||
}
|
||||
$user_register_captcha = config('fastadmin.user_register_captcha');
|
||||
$param = input('param.');
|
||||
$rule = [
|
||||
"name" => 'require',
|
||||
"phone" => 'require',
|
||||
"title" => 'require',
|
||||
"content" => 'require',
|
||||
];
|
||||
$msg = [
|
||||
"name.require" => __l('online_message', 'Name') . __l('index', 'No_empty'),
|
||||
"phone.require" => __l('online_message', 'Phone') . __l('index', 'No_empty'),
|
||||
"title.require" => __l('online_message', 'Title') . __l('index', 'No_empty'),
|
||||
"content.require" => __l('online_message', 'Content') . __l('index', 'No_empty'),
|
||||
];
|
||||
$data = [
|
||||
"name" => $param['name'],
|
||||
"phone" => $param['phone'],
|
||||
"title" => $param['title'],
|
||||
"content" => $param['content'],
|
||||
"official_category_id" => $id,
|
||||
"weigh" => time()
|
||||
];
|
||||
if ($user_register_captcha == 'text'){
|
||||
$rule['captcha'] = 'require|captcha';
|
||||
$msg['captcha.require'] = __l('index', 'Captcha') . __l('index', 'No_empty');
|
||||
$msg['captcha.captcha'] = __l('index', 'The verification code is incorrect');
|
||||
$data['captcha'] = $param['captcha'];
|
||||
}
|
||||
//验证规则
|
||||
$validate = new Validate($rule, $msg);
|
||||
$result = $validate->check($data);
|
||||
if (!$result) {
|
||||
return json_encode(['code' => 0, 'msg' => $validate->getError()]);
|
||||
}
|
||||
if (!empty($data['captcha'])){
|
||||
unset($data['captcha']);
|
||||
}
|
||||
//增加数据
|
||||
$official_list_form = $this->model->create($data);
|
||||
if ($official_list_form) {
|
||||
return json_encode(['code' => 1, 'msg' => __l('index', 'Submit successfully')]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('captchaType', config('fastadmin.user_register_captcha'));
|
||||
return view("web/official_online_message/list{$this->Mobile}", compact('res'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
|
||||
use addons\official\model\OfficialCategory;
|
||||
use addons\official\model\OfficialListProduct;
|
||||
use think\Request;
|
||||
|
||||
class OfficialProduct extends OfficialBaseController
|
||||
{
|
||||
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListProduct();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$data = [];
|
||||
$p_id = (int)input('param.pid');
|
||||
$son_id = (int)input('param.sid');
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
//如果所有子级别和父级一样
|
||||
$status = 1;
|
||||
if (($p_id == $son_id) && (count($res['son']))) {
|
||||
$status = 2;
|
||||
$ids = [$p_id];
|
||||
foreach ($res['son'] as $item) {
|
||||
if (($res['status'] != $item['status']) || ($res['official_rule_id'] != $item['official_rule_id'])) {
|
||||
$status = 1;
|
||||
}
|
||||
$ids[] = $item['id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($son_id) {
|
||||
$data = $this->model;
|
||||
if ($status == 1) {
|
||||
$data = $data->where('official_category_id', $son_id);
|
||||
} else {
|
||||
$data = $data->whereIn('official_category_id', $ids);
|
||||
}
|
||||
$data = $data->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->field(['id,title,image,createtime'])
|
||||
->paginate(8, $simple = $this->isMobile(), $config = [
|
||||
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
||||
]);
|
||||
}
|
||||
return view("web/official_product/list{$this->Mobile}", compact('res', 'data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function details()
|
||||
{
|
||||
$id = (int)input('param.id');
|
||||
//增加点击量
|
||||
$this->addClick($this->model, $id);
|
||||
|
||||
$data = $this->model
|
||||
->where('id', $id)
|
||||
->where('deletetime', null)
|
||||
->find();
|
||||
$this->setBasic(999, $data['title']);
|
||||
|
||||
$category = (new OfficialCategory())->where('id', $data['official_category_id'])->field(['id,name'])->find();
|
||||
//前面一个新闻
|
||||
$before = $this->model
|
||||
->where('id', '<', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'desc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
//后面第一个新闻
|
||||
$after = $this->model
|
||||
->where('id', '>', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'asc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
|
||||
return view("web/official_product/details{$this->Mobile}", compact('data', 'category', 'before', 'after'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
|
||||
use addons\official\model\OfficialListForm;
|
||||
use addons\official\model\OfficialListTable;
|
||||
use think\Request;
|
||||
use think\Validate;
|
||||
|
||||
class OfficialTable extends OfficialBaseController
|
||||
{
|
||||
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListTable();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$data = [];
|
||||
$p_id = (int)input('param.pid');
|
||||
$son_id = (int)input('param.sid');
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
//如果所有子级别和父级一样
|
||||
$status = 1;
|
||||
if (($p_id == $son_id) && (count($res['son']))) {
|
||||
$status = 2;
|
||||
$ids = [$p_id];
|
||||
foreach ($res['son'] as $item) {
|
||||
if (($res['status'] != $item['status']) || ($res['official_rule_id'] != $item['official_rule_id'])) {
|
||||
$status = 1;
|
||||
}
|
||||
$ids[] = $item['id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($son_id) {
|
||||
$data = $this->model;
|
||||
if ($status == 1) {
|
||||
$data = $data->where('official_category_id', $son_id);
|
||||
} else {
|
||||
$data = $data->whereIn('official_category_id', $ids);
|
||||
}
|
||||
$data = $data->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->paginate(3, $simple = $this->isMobile(), $config = [
|
||||
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
||||
]);
|
||||
}
|
||||
$sex_list = [0=>__l('table','女'),1=>__l('table','男'),2=>__l('table','不限男女')];
|
||||
return view("web/official_table/list{$this->Mobile}", compact('res', 'data','sex_list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$id = (int)input('param.id');
|
||||
if (!$id) {
|
||||
$this->error('找不到招聘信息');
|
||||
}
|
||||
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$token = $this->request->post('__token__');
|
||||
//验证Token
|
||||
if (!$token || !\think\Validate::is($token, "token", ['__token__' => $token])) {
|
||||
return json_encode(['code' => 0, 'msg' => 'token失效']);
|
||||
}
|
||||
|
||||
$param = input('param.');
|
||||
$official_list_table = $this->model->get($param['official_list_table_id']);
|
||||
if (empty($official_list_table)) {
|
||||
return json_encode(['code' => 0, 'msg' => '该招聘信息查询不到']);
|
||||
}
|
||||
|
||||
$rule = [
|
||||
"official_list_table_id" => 'require',
|
||||
"name" => 'require',
|
||||
"gender" => 'require',
|
||||
"birthday" => 'require',
|
||||
"nationality" => 'require',
|
||||
"politics_status" => 'require',
|
||||
"education" => 'require',
|
||||
"native_place" => 'require',
|
||||
"school" => 'require',
|
||||
"discipline" => 'require',
|
||||
"phone" => 'require',
|
||||
"email" => 'require|email',
|
||||
"address" => 'require',
|
||||
"treatment" => 'require',
|
||||
"detail_requirement" => 'require',
|
||||
"captcha" => 'require|captcha',
|
||||
];
|
||||
$msg = [
|
||||
"official_list_table_id.require" => __l('table', 'Official_list_table_id') . __l('index', 'No_empty'),
|
||||
"name.require" => __l('table', 'Name') . __l('index', 'No_empty'),
|
||||
"gender.require" => __l('table', 'Gender') . __l('index', 'No_empty'),
|
||||
"birthday.require" => __l('table', 'Birthday') . __l('index', 'No_empty'),
|
||||
"nationality.require" => __l('table', 'Nationality') . __l('index', 'No_empty'),
|
||||
"politics_status.require" => __l('table', 'Politics_status') . __l('index', 'No_empty'),
|
||||
"education.require" => __l('table', 'Education') . __l('index', 'No_empty'),
|
||||
"native_place.require" => __l('table', 'Native_place') . __l('index', 'No_empty'),
|
||||
"school.require" => __l('table', 'School') . __l('index', 'No_empty'),
|
||||
"discipline.require" => __l('table', 'Discipline') . __l('index', 'No_empty'),
|
||||
"phone.require" => __l('table', 'Phone') . __l('index', 'No_empty'),
|
||||
"email.require" => __l('table', 'Email') . __l('index', 'No_empty'),
|
||||
"email.email" => __l('table', 'Incorrect email address'),
|
||||
"address.require" => __l('table', 'Address') . __l('index', 'No_empty'),
|
||||
"treatment.require" => __l('table', 'Treatment') . __l('index', 'No_empty'),
|
||||
"detail_requirement.require" => __l('Table', 'detail_requirement') . __l('index', 'No_empty'),
|
||||
"captcha.require" => __l('index', 'Captcha') . __l('index', 'No_empty'),
|
||||
"captcha.captcha" => __l('index', 'The verification code is incorrect'),
|
||||
];
|
||||
$data = [
|
||||
"official_list_table_id" => $param['official_list_table_id'],
|
||||
"name" => $param['name'],
|
||||
"gender" => $param['gender'],
|
||||
"birthday" => $param['birthday'],
|
||||
"nationality" => $param['nationality'],
|
||||
"politics_status" => $param['politics_status'],
|
||||
"education" => $param['education'],
|
||||
"native_place" => $param['native_place'],
|
||||
"school" => $param['school'],
|
||||
"discipline" => $param['discipline'],
|
||||
"phone" => $param['phone'],
|
||||
"email" => $param['email'],
|
||||
"address" => $param['address'],
|
||||
"treatment" => $param['treatment'],
|
||||
"detail_requirement" => $param['detail_requirement'],
|
||||
"captcha" => $param['captcha'],
|
||||
];
|
||||
//验证规则
|
||||
$validate = new Validate($rule, $msg);
|
||||
$result = $validate->check($data);
|
||||
if (!$result) {
|
||||
return json_encode(['code' => 0, 'msg' => $validate->getError()]);
|
||||
}
|
||||
unset($data['captcha']);
|
||||
//增加数据
|
||||
$data['admin_id'] = $official_list_table['admin_id'];
|
||||
$official_list_form = (new OfficialListForm())->create($data);
|
||||
if ($official_list_form) {
|
||||
return json_encode(['code' => 1, 'msg' => __l('index', 'Submit successfully')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//查询数据
|
||||
$table = $this->model
|
||||
->where('id', $id)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->field(['id,job_title'])
|
||||
->find();
|
||||
$this->setBasic(999, $table['job_title']);
|
||||
$this->view->assign('captchaType', config('fastadmin.user_register_captcha'));
|
||||
return view("web/official_table/resume{$this->Mobile}", compact('table'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\official\controller\web;
|
||||
|
||||
|
||||
use addons\official\model\OfficialCategory;
|
||||
use addons\official\model\OfficialListVideo;
|
||||
use think\Request;
|
||||
|
||||
class OfficialVideo extends OfficialBaseController
|
||||
{
|
||||
protected $model;
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
|
||||
public function __construct(Request $request = null)
|
||||
{
|
||||
$this->model = new OfficialListVideo();
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$data = [];
|
||||
$p_id = (int)input('param.pid');
|
||||
$son_id = (int)input('param.sid');
|
||||
$this->setBasic();
|
||||
//查詢父级
|
||||
$res = $this->get_cate_pid_in_sid();
|
||||
|
||||
if ($son_id) {
|
||||
$data = $this
|
||||
->model
|
||||
->where('official_category_id', $son_id)
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('weigh', 'desc')
|
||||
->field(['id,title,image'])
|
||||
->paginate(8, $simple = $this->isMobile(), $config = [
|
||||
'query' => ['pid' => $p_id, 'sid' => $son_id]
|
||||
]);
|
||||
}
|
||||
return view("web/official_video/list{$this->Mobile}", compact('res', 'data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function details()
|
||||
{
|
||||
$id = (int)input('param.id');
|
||||
//增加点击量
|
||||
$this->addClick($this->model, $id);
|
||||
|
||||
$data = $this->model
|
||||
->where('id', $id)
|
||||
->where('deletetime', null)
|
||||
->find();
|
||||
$this->setBasic(999, $data['title'], '', $data['subheading']);
|
||||
$category = (new OfficialCategory())->where('id', $data['official_category_id'])->field(['id,name,e_name'])->find();
|
||||
//前面一个视频
|
||||
$before = $this->model
|
||||
->where('id', '<', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'desc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
//后面第一个视频
|
||||
$after = $this->model
|
||||
->where('id', '>', $data['id'])
|
||||
->where('official_category_id', $data['official_category_id'])
|
||||
->where('language', $this->language)
|
||||
->where('deletetime', null)
|
||||
->order('id', 'asc')
|
||||
->field(['id,title'])
|
||||
->find();
|
||||
|
||||
return view("web/official_video/details{$this->Mobile}", compact('data', 'category', 'before', 'after'));
|
||||
}
|
||||
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户