提交 6096edde 编写于 作者: D Devil

地区新增全量数据接口

上级 14ac66a9
......@@ -35,11 +35,12 @@ class Region extends Common
}
/**
* [Index 获取地区]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-04-08T15:08:01+0800
* 获取地区节点
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-12-29
* @desc description
*/
public function Index()
{
......@@ -52,5 +53,18 @@ class Region extends Common
$data = RegionService::RegionNode($params);
return DataReturn('success', 0, $data);
}
/**
* 获取地区所有数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-12-29
* @desc description
*/
public function All()
{
return RegionService::RegionAll();
}
}
?>
\ No newline at end of file
......@@ -35,7 +35,7 @@ class Region extends Common
}
/**
* 获取地区
* 获取地区节点
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
......@@ -59,5 +59,18 @@ class Region extends Common
$data = RegionService::RegionNode($params);
return DataReturn('操作成功', 0, $data);
}
/**
* 获取地区所有数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-12-29
* @desc description
*/
public function All()
{
return RegionService::RegionAll();
}
}
?>
\ No newline at end of file
......@@ -22,20 +22,7 @@
<!-- 轮播上内容 -->
<div class="am-container slideall">
<!-- 轮播-手机导航 -->
{{if !empty($navigation)}}
<div class="am-g am-g-fixed small-nav">
{{foreach $navigation as $nav}}
<div class="am-u-sm-3">
<a {{if $nav['is_need_login'] eq 1 and empty($user)}} href="javascript:;" class="login-event" {{else /}} href="{{$nav.event_value}}" {{/if}} >
<div class="nav-icon" style="{{if !empty($nav['bg_color'])}}background:{{$nav.bg_color}};{{/if}}">
<img src="{{$nav.images_url}}" alt="{{$nav.name}}" />
</div>
<div class="mini-nav-title">{{$nav.name}}</div>
</a>
</div>
{{/foreach}}
</div>
{{/if}}
{{include file="public/home_nav" /}}
<!-- 轮播-聚合内容 -->
{{if MyC('home_index_banner_right_status', 1) eq 1}}
......
<!-- 首页轮播 start -->
<div class="banner">
<div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{&quot;directionNav&quot;:false}'>
<ul class="am-slides">
......@@ -25,5 +24,4 @@
{{/if}}
</ul>
</div>
</div>
<!-- 首页轮播 end -->
\ No newline at end of file
</div>
\ No newline at end of file
{{if !empty($navigation)}}
<div class="am-g am-g-fixed small-nav">
{{foreach $navigation as $nav}}
<div class="am-u-sm-3">
{{switch nav.event_type}}
{{case 3}}
<!-- 地图 -->
<a href="javascript:;" {{if $nav['is_need_login'] eq 1 and empty($user)}} class="login-event" {{else /}}{{if !empty($nav['event_value_data']) and !empty($nav['event_value_data'][2]) and !empty($nav['event_value_data'][3])}}class="submit-map-popup" data-lng="{{$nav['event_value_data'][2]}}" data-lat="{{$nav['event_value_data'][3]}}"{{/if}}{{/if}}>
{{/case}}
{{case 4}}
<!-- 电话 -->
<a {{if $nav['is_need_login'] eq 1 and empty($user)}} href="javascript:;" class="login-event" {{else /}}{{if !empty($nav['event_value'])}}href="tel:{{$nav.event_value}}"{{else /}}href="javascript:;"{{/if}}{{/if}}>
{{/case}}
{{default /}}
<!-- 默认url地址 -->
<a {{if $nav['is_need_login'] eq 1 and empty($user)}} href="javascript:;" class="login-event" {{else /}}{{if !empty($nav['event_value'])}}href="{{$nav.event_value}}" target="_blank"{{else /}}href="javascript:;"{{/if}}{{/if}}>
{{/switch}}
<div class="nav-icon" style="{{if !empty($nav['bg_color'])}}background:{{$nav.bg_color}};{{/if}}">
<img src="{{$nav.images_url}}" alt="{{$nav.name}}" />
</div>
<div class="mini-nav-title">{{$nav.name}}</div>
</a>
</div>
{{/foreach}}
</div>
{{/if}}
\ No newline at end of file
......@@ -287,9 +287,23 @@ class AppHomeNavService
{
foreach($data as &$v)
{
// 图片地址
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']);
$v['event_value'] = empty($v['event_value']) ? null : $v['event_value'];
// 事件值
if(!empty($v['event_value']))
{
// 地图
if($v['event_type'] == 3)
{
$v['event_value_data'] = explode('|', $v['event_value']);
}
$v['event_value'] = $v['event_value'];
} else {
$v['event_value'] = null;
}
}
}
......
......@@ -225,5 +225,81 @@ class RegionService
$data = empty($data) ? $ids : array_unique(array_merge($ids, $data));
return $data;
}
/**
* 获取地区所有数据、最多三级
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-12-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function RegionAll($params = [])
{
// 缓存
$key = config('shopxo.cache_region_all_key');
$data = cache($key);
if(empty($data))
{
// 所有一级
$field = 'id,pid,name';
$data = self::RegionNode(['field'=>$field,'where'=>['pid'=>0]]);
if(!empty($data))
{
// 所有二级
$two = self::RegionNode(['field'=>$field,'where'=>['pid'=>array_column($data, 'id')]]);
$two_group = [];
$three_group = [];
if(!empty($two))
{
// 所有三级
$three = self::RegionNode(['field'=>$field,'where'=>['pid'=>array_column($two, 'id')]]);
if(!empty($three))
{
// 三级集合组
foreach($three as $v)
{
if(!array_key_exists($v['pid'], $three_group))
{
$three_group[$v['pid']] = [];
}
$pid = $v['pid'];
unset($v['pid']);
$three_group[$pid][] = $v;
}
}
// 二级集合
foreach($two as $v)
{
// 是否存在三级数据
$v['items'] = array_key_exists($v['id'], $three_group) ? $three_group[$v['id']] : [];
// 集合组
if(!array_key_exists($v['pid'], $two_group))
{
$two_group[$v['pid']] = [];
}
$pid = $v['pid'];
unset($v['pid']);
$two_group[$pid][] = $v;
}
}
// 一级集合
foreach($data as $k=>$v)
{
$data[$k]['items'] = array_key_exists($v['id'], $two_group) ? $two_group[$v['id']] : [];
}
// 存储缓存
cache($key, $data, 60);
}
}
return DataReturn('success', 0, $data);
}
}
?>
\ No newline at end of file
......@@ -34,71 +34,92 @@ return array (
),
'plugins_css' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\limitedtimediscount\\Hook',
0 => 'app\\plugins\\share\\Hook',
1 => 'app\\plugins\\points\\Hook',
2 => 'app\\plugins\\limitedtimediscount\\Hook',
),
'plugins_js' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\limitedtimediscount\\Hook',
0 => 'app\\plugins\\share\\Hook',
1 => 'app\\plugins\\points\\Hook',
2 => 'app\\plugins\\limitedtimediscount\\Hook',
),
'plugins_view_common_bottom' =>
array (
0 => 'app\\plugins\\share\\Hook',
),
'plugins_common_page_bottom' =>
array (
0 => 'app\\plugins\\share\\Hook',
),
'plugins_view_goods_detail_photo_bottom' =>
array (
0 => 'app\\plugins\\share\\Hook',
),
'plugins_service_navigation_header_handle' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\limitedtimediscount\\Hook',
),
'plugins_service_goods_handle_end' =>
'plugins_service_quick_navigation_pc' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\limitedtimediscount\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_view_buy_form_inside' =>
'plugins_service_quick_navigation_h5' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_view_buy_base_confirm_top' =>
'plugins_service_quick_navigation_weixin' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_service_buy_group_goods_handle' =>
'plugins_service_quick_navigation_alipay' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_service_buy_order_insert_end' =>
'plugins_service_quick_navigation_baidu' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_service_order_status_change_history_success_handle' =>
'plugins_service_quick_navigation_qq' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_service_quick_navigation_pc' =>
'plugins_service_quick_navigation_toutiao' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\signin\\Hook',
),
'plugins_service_quick_navigation_h5' =>
'plugins_service_goods_handle_end' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\limitedtimediscount\\Hook',
),
'plugins_service_quick_navigation_weixin' =>
'plugins_view_buy_form_inside' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
),
'plugins_service_quick_navigation_alipay' =>
'plugins_view_buy_base_confirm_top' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
),
'plugins_service_quick_navigation_baidu' =>
'plugins_service_buy_group_goods_handle' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
),
'plugins_service_quick_navigation_qq' =>
'plugins_service_buy_order_insert_end' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
),
'plugins_service_quick_navigation_toutiao' =>
'plugins_service_order_status_change_history_success_handle' =>
array (
0 => 'app\\plugins\\signin\\Hook',
0 => 'app\\plugins\\points\\Hook',
),
'plugins_service_users_center_left_menu_handle' =>
array (
......
......@@ -73,6 +73,9 @@ return [
// 快捷导航缓存信息
'cache_quick_navigation_key' => 'cache_quick_navigation_data_',
// 地区所有数据缓存、1~3级
'cache_region_all_key' => 'cache_region_all_data',
// 附件host、最后不要带/斜杠结尾, 数据库图片地址以/static/...开头
'attachment_host' => $cdn_attachment_host,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册