提交 37248aaf 编写于 作者: G gongfuxiang

api细节优化

上级 6cc1bb58
...@@ -18,7 +18,7 @@ use app\service\GoodsCommentsService; ...@@ -18,7 +18,7 @@ use app\service\GoodsCommentsService;
use app\service\ResourcesService; use app\service\ResourcesService;
use app\service\GoodsFavorService; use app\service\GoodsFavorService;
use app\service\GoodsBrowseService; use app\service\GoodsBrowseService;
use app\service\NavigationService; use app\service\AppService;
/** /**
* 商品 * 商品
...@@ -114,7 +114,7 @@ class Goods extends Common ...@@ -114,7 +114,7 @@ class Goods extends Common
$middle_tabs_nav = GoodsService::GoodsDetailMiddleTabsNavList($goods); $middle_tabs_nav = GoodsService::GoodsDetailMiddleTabsNavList($goods);
// 导航更多列表 // 导航更多列表
$nav_more_list = NavigationService::PageNavMoreList(['page'=>'goods']); $nav_more_list = AppService::GoodsNavMoreList(['page'=>'goods']);
// 商品购买按钮列表 // 商品购买按钮列表
$buy_button = GoodsService::GoodsBuyButtonList($goods); $buy_button = GoodsService::GoodsBuyButtonList($goods);
......
...@@ -18,6 +18,8 @@ use app\service\AppHomeNavService; ...@@ -18,6 +18,8 @@ use app\service\AppHomeNavService;
use app\service\BuyService; use app\service\BuyService;
use app\service\LayoutService; use app\service\LayoutService;
use app\service\ArticleService; use app\service\ArticleService;
use app\service\MessageService;
use app\service\AppService;
/** /**
* 首页 * 首页
...@@ -58,13 +60,22 @@ class Index extends Common ...@@ -58,13 +60,22 @@ class Index extends Common
$data_list = GoodsService::HomeFloorList(); $data_list = GoodsService::HomeFloorList();
} }
// 购物车数量
$common_cart_total = BuyService::UserCartTotal(['user'=>$this->user]);
// 未读消息总数
$params = ['user'=>$this->user, 'is_more'=>1, 'is_read'=>0];
$common_message_total = MessageService::UserMessageTotal($params);
// 返回数据 // 返回数据
$result = [ $result = [
'navigation' => AppHomeNavService::AppHomeNav(), 'navigation' => AppHomeNavService::AppHomeNav(),
'banner_list' => BannerService::Banner(), 'banner_list' => BannerService::Banner(),
'data_list' => $data_list, 'data_list' => $data_list,
'article_list' => ArticleService::HomeArticleList(), 'article_list' => ArticleService::HomeArticleList(),
'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]), 'right_icon_list' => AppService::HomeRightIconList(['message_total'=>$common_message_total]),
'common_cart_total' => $common_cart_total,
'common_message_total' => $common_message_total,
]; ];
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result)); return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
} }
......
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://opensource.org/licenses/mit-license.php )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\service;
/**
* app服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class AppService
{
/**
* 商品详情导航更多列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param [array] $params [输入信息]
*/
public static function GoodsNavMoreList($params = [])
{
$data = [];
if(!empty($params['page']))
{
switch($params['page'])
{
// 商品页面
// icon 参考各终端
// web http://amazeui.shopxo.net/css/icon
// uniapp https://hellouniapp.dcloud.net.cn/pages/extUI/icons/icons
case 'goods' :
$data = [
[
'name' => '我的收藏',
'url' => '/pages/user-favor/user-favor',
'icon' => 'heart'
],
[
'name' => '我浏览过',
'url' => '/pages/user-goods-browse/user-goods-browse',
'icon' => 'eye'
],
[
'name' => '回到首页',
'url' => '/pages/index/index',
'icon' => 'home'
]
];
break;
}
}
// 导航更多信息钩子
$hook_name = 'plugins_service_app_goods_more_list';
MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
'data' => &$data,
]);
return $data;
}
/**
* 首页右侧icon列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-11-26
* @desc description
* @param [array] $params [输入参数]
*/
public static function HomeRightIconList($params = [])
{
// 消息总数
$message_total = empty($params['message_total']) ? 0 : $params['message_total'];
// 列表数据
// name 名称(必填)
// icon 图标(必填、参考uniapp扩展图标文档)
// url 访问地址(可选)
$data = [
[
'name' => '所有店铺',
'icon' => 'shop',
'url' => '/pages/plugins/shop/index/index',
],
[
'name' => '我的收藏',
'icon' => 'heart',
'url' => '/pages/user-favor/user-favor',
],
[
'name' => '我的消息',
'icon' => 'chat',
'badge' => $message_total,
'url' => '/pages/message/message',
]
];
// 钩子
$hook_name = 'plugins_service_app_home_right_icon_list';
MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'data' => &$data,
'params' => $params,
]);
return $data;
}
}
?>
\ No newline at end of file
...@@ -1085,59 +1085,5 @@ class NavigationService ...@@ -1085,59 +1085,5 @@ class NavigationService
return $data; return $data;
} }
/**
* 导航更多列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param [array] $params [输入信息]
*/
public static function PageNavMoreList($params = [])
{
$data = [];
if(!empty($params['page']))
{
switch($params['page'])
{
// 商品页面
// icon 参考各终端
// web http://amazeui.shopxo.net/css/icon
// uniapp https://hellouniapp.dcloud.net.cn/pages/extUI/icons/icons
case 'goods' :
$data = [
[
'name' => '我的收藏',
'url' => '/pages/user-favor/user-favor',
'icon' => 'heart'
],
[
'name' => '我浏览过',
'url' => '/pages/user-goods-browse/user-goods-browse',
'icon' => 'eye'
],
[
'name' => '回到首页',
'url' => '/pages/index/index',
'icon' => 'home'
]
];
break;
}
}
// 导航更多信息钩子
$hook_name = 'plugins_service_page_navigation_more_list_handle';
MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
'data' => &$data,
]);
return $data;
}
} }
?> ?>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册