Files
shopxo/application/index/controller/Index.php

127 lines
3.8 KiB
PHP
Raw Normal View History

2018-12-28 18:58:37 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2019-02-18 13:52:07 +08:00
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
2018-12-28 18:58:37 +08:00
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\index\controller;
2019-04-22 18:35:00 +08:00
use think\facade\Hook;
use app\service\BannerService;
use app\service\GoodsService;
use app\service\ArticleService;
use app\service\OrderService;
2019-07-03 21:03:28 +08:00
use app\service\AppHomeNavService;
2018-12-28 18:58:37 +08:00
/**
* 首页
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Index extends Common
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-30
* @desc description
*/
public function __construct()
{
parent::__construct();
}
/**
* 首页
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-12-02T11:11:49+0800
*/
public function Index()
{
// 首页轮播
2020-08-11 22:45:56 +08:00
$banner = BannerService::Banner();
$this->assign('banner_list', $banner);
2018-12-28 18:58:37 +08:00
2019-04-22 14:41:20 +08:00
// H5导航
2019-07-03 21:03:28 +08:00
$this->assign('navigation', AppHomeNavService::AppHomeNav());
2019-04-22 14:41:20 +08:00
2018-12-28 18:58:37 +08:00
// 楼层数据
$this->assign('goods_floor_list', GoodsService::HomeFloorList());
// 新闻
$params = [
2020-06-19 18:44:38 +08:00
'where' => ['is_enable'=>1, 'is_home_recommended'=>1],
'field' => 'id,title,title_color,article_category_id',
2018-12-28 18:58:37 +08:00
'm' => 0,
'n' => 9,
];
$article_list = ArticleService::ArticleList($params);
$this->assign('article_list', $article_list['data']);
// 用户订单状态
$user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1]);
$this->assign('user_order_status', $user_order_status['data']);
2019-04-22 18:35:00 +08:00
2020-08-11 22:45:56 +08:00
// 加载百度地图api
// 存在地图事件则载入
if(in_array(3, array_column($banner, 'event_type')))
{
$this->assign('is_load_baidu_map_api', 1);
}
2019-04-22 18:35:00 +08:00
// 钩子
$this->PluginsHook();
2019-02-09 09:15:23 +08:00
2018-12-28 18:58:37 +08:00
return $this->fetch();
}
2019-04-22 18:35:00 +08:00
/**
* 钩子处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-04-22
* @desc description
* @param [array] $params [输入参数]
*/
private function PluginsHook($params = [])
{
2019-07-29 15:44:55 +08:00
// 楼层数据顶部钩子
$hook_name = 'plugins_view_home_floor_top';
$this->assign($hook_name.'_data', Hook::listen($hook_name,
2019-04-22 18:35:00 +08:00
[
2019-07-29 15:44:55 +08:00
'hook_name' => $hook_name,
'is_backend' => false,
'user' => $this->user,
]));
// 楼层数据底部钩子
$hook_name = 'plugins_view_home_floor_bottom';
$this->assign($hook_name.'_data', Hook::listen($hook_name,
[
'hook_name' => $hook_name,
'is_backend' => false,
'user' => $this->user,
]));
// 轮播混合数据底部钩子
$hook_name = 'plugins_view_home_banner_mixed_bottom';
$this->assign($hook_name.'_data', Hook::listen($hook_name,
[
'hook_name' => $hook_name,
2019-04-22 18:35:00 +08:00
'is_backend' => false,
2019-04-23 12:13:43 +08:00
'user' => $this->user,
2019-04-22 18:35:00 +08:00
]));
}
2018-12-28 18:58:37 +08:00
}
?>