feat/task1-c-wallet
parent
8f467d3492
commit
2416e02732
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Api\Controller;
|
||||
|
||||
use Service\BannerService;
|
||||
use Service\GoodsService;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @author Devil
|
||||
|
|
@ -61,20 +64,10 @@ class IndexController extends CommonController
|
|||
}
|
||||
|
||||
// 轮播图片
|
||||
$banner = M('Slide')->field('jump_url,jump_url_type,images_url,name')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->select();
|
||||
if(!empty($banner))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($banner as &$v)
|
||||
{
|
||||
$v['images_url'] = $images_host.$v['images_url'];
|
||||
$v['jump_url'] = empty($v['jump_url']) ? null : $v['jump_url'];
|
||||
}
|
||||
$result['banner'] = $banner;
|
||||
}
|
||||
$result['banner'] = BannerService::Home();
|
||||
|
||||
// 商品分类
|
||||
$result['category'] = $this->GetGoodsCategoryList();
|
||||
$result['category'] = GoodsService::GoodsCategoryList();
|
||||
|
||||
// 返回数据
|
||||
$this->ajaxReturn(L('common_operation_success'), 0, $result);
|
||||
|
|
|
|||
|
|
@ -30,12 +30,10 @@
|
|||
* @param string $c [控制器名称]
|
||||
* @param string $a [方法名称]
|
||||
* @param array $params [参数]
|
||||
* @param string $suffix [后缀名]
|
||||
* @param boolean $is_url [是否显示域名]
|
||||
*/
|
||||
function HomeUrl($c='Index', $a='Index', $params=[], $suffix='', $is_url=false)
|
||||
function HomeUrl($c='Index', $a='Index', $params=[])
|
||||
{
|
||||
return str_replace('admin.php', 'index.php', U("Home/{$c}/{$a}", $params, $suffix, $is_url));
|
||||
return str_replace('admin.php', 'index.php', U("Home/{$c}/{$a}", $params));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Think\Controller;
|
||||
use Service\GoodsService;
|
||||
use Service\NavigationService;
|
||||
|
||||
/**
|
||||
* 前台
|
||||
|
|
@ -185,7 +188,7 @@ class CommonController extends Controller
|
|||
$this->assign('user_nav_menu', L('user_nav_menu'));
|
||||
|
||||
// 商品大分类
|
||||
$this->assign('goods_category_list', $this->GetCommonGoodsCategory());
|
||||
$this->assign('goods_category_list', GoodsService::GoodsCategory());
|
||||
|
||||
// 当前控制器名称
|
||||
$this->assign('controller_name', CONTROLLER_NAME);
|
||||
|
|
@ -200,132 +203,9 @@ class CommonController extends Controller
|
|||
*/
|
||||
private function NavInit()
|
||||
{
|
||||
// 读取缓存数据
|
||||
$this->nav_header = S(C('cache_common_home_nav_header_key'));
|
||||
$this->nav_footer = S(C('cache_common_home_nav_footer_key'));
|
||||
|
||||
// 导航模型
|
||||
$m = M('Navigation');
|
||||
$field = array('id', 'pid', 'name', 'url', 'value', 'data_type', 'is_new_window_open');
|
||||
|
||||
// 缓存没数据则从数据库重新读取,顶部菜单
|
||||
if(empty($this->nav_header))
|
||||
{
|
||||
$this->nav_header = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
|
||||
if(!empty($this->nav_header))
|
||||
{
|
||||
foreach($this->nav_header as $k=>$v)
|
||||
{
|
||||
$this->nav_header[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
|
||||
}
|
||||
}
|
||||
S(C('cache_common_home_nav_header_key'), $this->nav_header);
|
||||
}
|
||||
|
||||
// 底部导航
|
||||
if(empty($this->nav_footer))
|
||||
{
|
||||
$this->nav_footer = NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
|
||||
S(C('cache_common_home_nav_footer_key'), $this->nav_footer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [GetClassList 获取班级列表,二级]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-30T13:26:00+0800
|
||||
* @return [array] [班级列表]
|
||||
*/
|
||||
protected function GetClassList()
|
||||
{
|
||||
$m = M('Class');
|
||||
$data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $k=>$v)
|
||||
{
|
||||
$data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select();
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* [GetRoomList 获取教室列表,二级]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-30T13:26:00+0800
|
||||
* @return [array] [班级列表]
|
||||
*/
|
||||
protected function GetRoomList()
|
||||
{
|
||||
$m = M('Room');
|
||||
$data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $k=>$v)
|
||||
{
|
||||
$data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select();
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* [GetLayoutList 获取布局-模块列表]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-02-22T10:15:40+0800
|
||||
* @param [string] $type [布局类型(home, channel, detail)]
|
||||
* @return [array] [布局+模块数据]
|
||||
*/
|
||||
protected function GetLayoutList($type = 'home')
|
||||
{
|
||||
// 布局+模块列表
|
||||
$data = M('Layout')->field(array('id', 'value'))->where(array('is_enable'=>1, 'type'=>$type))->order('sort asc, id desc')->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
// 布局模块处理驱动
|
||||
$lay = \My\LayoutModule::SetInstance();
|
||||
|
||||
// 开始处理布局数据
|
||||
foreach($data as $k=>$v)
|
||||
{
|
||||
// 模块
|
||||
$item = M('LayoutModule')->where(array('layout_id'=>$v['id']))->select();
|
||||
if(!empty($item))
|
||||
{
|
||||
foreach($item as $ik=>$iv)
|
||||
{
|
||||
// 获取文章数据
|
||||
$article = LayoutArticleList($lay->GetLayoutMouleWhere($iv), $iv);
|
||||
|
||||
// 模块数据生成
|
||||
$fun = GetViewTitleStyleFun($iv['title_style']);
|
||||
if(method_exists($lay, $fun))
|
||||
{
|
||||
$html = $lay->$fun($article, $iv);
|
||||
$iv = $lay->GetRules();
|
||||
} else {
|
||||
$html = '';
|
||||
}
|
||||
|
||||
// 重新赋值
|
||||
$item[$ik] = $html;
|
||||
|
||||
// 模板赋值
|
||||
$this->assign('data_'.$iv['id'], $article);
|
||||
$this->assign('rules_'.$iv['id'], $iv);
|
||||
}
|
||||
}
|
||||
$data[$k]['item'] = $item;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
$navigation = NavigationService::Home();
|
||||
$this->nav_header = $navigation['header'];
|
||||
$this->nav_footer = $navigation['footer'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -470,205 +350,5 @@ class CommonController extends Controller
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取大分类
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-10
|
||||
* @desc description
|
||||
*/
|
||||
protected function GetCommonGoodsCategory()
|
||||
{
|
||||
$data = $this->GetGoodsCategoryList(0);
|
||||
if(!empty($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['items'] = $this->GetGoodsCategoryList($v['id']);
|
||||
if(!empty($v['items']))
|
||||
{
|
||||
foreach($v['items'] as &$vs)
|
||||
{
|
||||
$vs['items'] = $this->GetGoodsCategoryList($vs['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pid获取商品分类列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-10
|
||||
* @desc description
|
||||
* @param integer $pid [description]
|
||||
*/
|
||||
protected function GetGoodsCategoryList($pid = 0)
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
$field = 'id,pid,icon,name,vice_name,describe,bg_color,big_images,sort,is_home_recommended';
|
||||
$data = M('GoodsCategory')->field($field)->where(['is_enable'=>1, 'pid'=>$pid])->order('sort asc')->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
|
||||
$v['big_images'] = empty($v['big_images']) ? null : $images_host.$v['big_images'];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-10
|
||||
* @desc description
|
||||
* @param array $params [ 输入参数: where, field, is_photo ]
|
||||
*/
|
||||
protected function GetCommonGoodsList($params = [])
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
$field = empty($params['field']) ? 'g.*' : $params['field'];
|
||||
$is_photo = (isset($params['is_photo']) && $params['is_photo'] == true) ? true : false;
|
||||
$is_attribute = (isset($params['is_attribute']) && $params['is_attribute'] == true) ? true : false;
|
||||
$order_by = empty($params['order_by']) ? 'g.id desc' : trim($params['order_by']);
|
||||
$m = isset($params['m']) ? intval($params['m']) : 0;
|
||||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
$data = M('Goods')->alias('g')->join(' INNER JOIN __GOODS_CATEGORY_JOIN__ AS gci ON g.id=gci.goods_id') ->field($field)->where($where)->group('g.id')->order($order_by)->limit($m, $n)->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
if(isset($v['images']))
|
||||
{
|
||||
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
|
||||
}
|
||||
if(isset($v['home_recommended_images']))
|
||||
{
|
||||
$v['home_recommended_images'] = empty($v['home_recommended_images']) ? (empty($v['images']) ? null : $v['images']) : $images_host.$v['home_recommended_images'];
|
||||
}
|
||||
if(isset($v['content_web']))
|
||||
{
|
||||
$v['content_web'] = ContentStaticReplace($v['content_web'], 'get');
|
||||
}
|
||||
|
||||
// 获取相册
|
||||
if($is_photo && !empty($v['id']))
|
||||
{
|
||||
$v['photo'] = M('GoodsPhoto')->where(['goods_id'=>$v['id'], 'is_show'=>1])->order('sort asc')->getField('images', true);
|
||||
if(!empty($v['photo']))
|
||||
{
|
||||
foreach($v['photo'] as &$vs)
|
||||
{
|
||||
$vs = $images_host.$vs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取属性
|
||||
if($is_attribute && !empty($v['id']))
|
||||
{
|
||||
$v['attribute'] = $this->GetGoodsAttribute($v['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品属性
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-07-10
|
||||
* @desc description
|
||||
* @param [int] $goods_id [商品id]
|
||||
* @return [array] [属性]
|
||||
*/
|
||||
protected function GetGoodsAttribute($goods_id)
|
||||
{
|
||||
$result = [];
|
||||
$data = M('GoodsAttributeType')->where(['goods_id'=>$goods_id])->field('id,type,name')->order('sort asc')->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $v)
|
||||
{
|
||||
$v['find'] = M('GoodsAttribute')->field('id,name')->where(['goods_id'=>$goods_id, 'attribute_type_id'=>$v['id']])->order('sort asc')->select();
|
||||
$result[$v['type']][] = $v;
|
||||
}
|
||||
} else {
|
||||
$data = [];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类下的所有分类id
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-10
|
||||
* @desc description
|
||||
* @param [type] $category_id [商品分类ID]
|
||||
*/
|
||||
protected function GetCommonGoodsCategoryItemsIds($category_id)
|
||||
{
|
||||
$data = M('GoodsCategory')->where(['pid'=>$category_id, 'is_enable'=>1])->getField('id', true);
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $v)
|
||||
{
|
||||
$temp = $this->GetCommonGoodsCategoryItemsIds($v);
|
||||
if(!empty($temp))
|
||||
{
|
||||
$data = array_merge($data, $temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-23
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
protected function GetCommonArticleList($params)
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
$field = empty($params['field']) ? 'a.*' : $params['field'];
|
||||
$m = isset($params['m']) ? intval($params['m']) : 0;
|
||||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
|
||||
$data = M('Article')->alias('a')->join(' INNER JOIN __ARTICLE_CATEGORY__ AS ac ON a.article_category_id=ac.id') ->field($field)->where($where)->order('a.id desc')->limit($m, $n)->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
if(isset($v['content']))
|
||||
{
|
||||
$v['content'] = ContentStaticReplace($v['content'], 'get');
|
||||
}
|
||||
if(isset($v['add_time']))
|
||||
{
|
||||
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Service\GoodsService;
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* @author Devil
|
||||
|
|
@ -42,7 +44,7 @@ class GoodsController extends CommonController
|
|||
'is_photo' => true,
|
||||
'is_attribute' => true,
|
||||
];
|
||||
$goods = $this->GetCommonGoodsList($params);
|
||||
$goods = GoodsService::GoodsList($params);
|
||||
$this->assign('goods', $goods[0]);
|
||||
$this->assign('home_seo_site_title', $goods[0]['title']);
|
||||
|
||||
|
|
@ -56,8 +58,7 @@ class GoodsController extends CommonController
|
|||
'field' => 'g.id,g.title,g.title_color,g.price,g.images',
|
||||
'n' => 10,
|
||||
];
|
||||
$left_goods = $this->GetCommonGoodsList($params);
|
||||
$this->assign('left_goods', $left_goods);
|
||||
$this->assign('left_goods', GoodsService::GoodsList($params));
|
||||
|
||||
// 详情tab商品 猜你喜欢
|
||||
$params = [
|
||||
|
|
@ -70,8 +71,7 @@ class GoodsController extends CommonController
|
|||
'field' => 'g.id,g.title,g.title_color,g.price,g.images,g.home_recommended_images',
|
||||
'n' => 16,
|
||||
];
|
||||
$detail_like_goods = $this->GetCommonGoodsList($params);
|
||||
$this->assign('detail_like_goods', $detail_like_goods);
|
||||
$this->assign('detail_like_goods', GoodsService::GoodsList($params));
|
||||
|
||||
$this->display('Index');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Service\BannerService;
|
||||
use Service\GoodsService;
|
||||
use Service\ArticleService;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @author Devil
|
||||
|
|
@ -34,63 +38,21 @@ class IndexController extends CommonController
|
|||
public function Index()
|
||||
{
|
||||
// 首页轮播
|
||||
$this->assign('banner_list', $this->GetHomeBanner());
|
||||
$this->assign('banner_list', BannerService::Home());
|
||||
|
||||
// 楼层数据
|
||||
$this->assign('goods_floor_list', $this->GetHomeFloorList());
|
||||
$this->assign('goods_floor_list', GoodsService::HomeFloorList());
|
||||
|
||||
// 新闻
|
||||
$this->assign('article_list', $this->GetCommonArticleList(['where'=>['a.is_enable'=>1, 'is_home_recommended'=>1], 'field'=>'a.id,a.title,a.title_color,ac.name AS category_name', 'm'=>0, 'n'=>9]));
|
||||
$params = [
|
||||
'where' => ['a.is_enable'=>1, 'is_home_recommended'=>1],
|
||||
'field' => 'a.id,a.title,a.title_color,ac.name AS category_name',
|
||||
'm' => 0,
|
||||
'n' => 9,
|
||||
];
|
||||
$this->assign('article_list', ArticleService::ArticleList($params));
|
||||
|
||||
$this->display('Index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页楼层数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-10
|
||||
* @desc description
|
||||
*/
|
||||
private function GetHomeFloorList()
|
||||
{
|
||||
// 商品大分类
|
||||
$goods_category = $this->GetCommonGoodsCategory();
|
||||
if(!empty($goods_category))
|
||||
{
|
||||
foreach($goods_category as &$v)
|
||||
{
|
||||
$category_all = $this->GetCommonGoodsCategoryItemsIds($v['id']);
|
||||
$v['goods'] = $this->GetCommonGoodsList(['where'=>['gci.category_id'=>['in', $category_all], 'is_home_recommended'=>1], 'm'=>0, 'n'=>6]);
|
||||
}
|
||||
}
|
||||
return $goods_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页banner
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-10
|
||||
* @desc description
|
||||
*/
|
||||
private function GetHomeBanner()
|
||||
{
|
||||
// 轮播图片
|
||||
$banner = M('Slide')->field('jump_url,jump_url_type,images_url,name,bg_color')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->select();
|
||||
if(!empty($banner))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($banner as &$v)
|
||||
{
|
||||
$v['images_url'] = $images_host.$v['images_url'];
|
||||
$v['jump_url'] = empty($v['jump_url']) ? null : $v['jump_url'];
|
||||
}
|
||||
$result['banner'] = $banner;
|
||||
}
|
||||
return $banner;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -192,12 +192,12 @@
|
|||
<foreach name="left_goods" key="key" item="v">
|
||||
<li <if condition="$key eq 0">class="first"</if>>
|
||||
<div class="p-img">
|
||||
<a href="{{:U('/Home/Goods/Index', ['id'=>$v['id']])}}">
|
||||
<a href="{{:$v['goods_url']}}">
|
||||
<img alt="{{$v.title}}" src="{{$v.images}}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="p-name">
|
||||
<a href="{{:U('/Home/Goods/Index', ['id'=>$v['id']])}}">{{$v.title}}</a>
|
||||
<a href="{{:$v['goods_url']}}">{{$v.title}}</a>
|
||||
</div>
|
||||
<div class="p-price"><strong>¥{{$v.price}}</strong></div>
|
||||
</li>
|
||||
|
|
@ -260,7 +260,7 @@
|
|||
<foreach name="detail_like_goods" key="key" item="v">
|
||||
<li>
|
||||
<div class="i-pic limit">
|
||||
<a href="{{:U('/Home/Goods/Index', ['id'=>$v['id']])}}">
|
||||
<a href="{{:$v['goods_url']}}">
|
||||
<img alt="{{$v.title}}" src="{{$v.home_recommended_images}}" />
|
||||
</a>
|
||||
<p class="ellipsis">{{$v.title}}</p>
|
||||
|
|
|
|||
|
|
@ -17,25 +17,37 @@
|
|||
|
||||
<div class="am-container slideall">
|
||||
<!-- 轮播右侧-内容1 -->
|
||||
<div class="am-g am-g-fixed smallnav">
|
||||
<div class="am-g am-g-fixed small-nav">
|
||||
<div class="am-u-sm-3">
|
||||
<a href="sort.html"><img src="__PUBLIC__/Home/{{$default_theme}}/Images/navsmall.jpg" />
|
||||
<div class="title">商品分类</div>
|
||||
<a href="sort.html">
|
||||
<div class="nav-icon mini-nav-goods-category">
|
||||
<img src="__PUBLIC__/Home/{{$default_theme}}/Images/home-mini-nav-category-icon.png" />
|
||||
</div>
|
||||
<div class="mini-nav-title">分类</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="am-u-sm-3">
|
||||
<a href="#"><img src="__PUBLIC__/Home/{{$default_theme}}/Images/huismall.jpg" />
|
||||
<div class="title">大聚惠</div>
|
||||
<a href="#">
|
||||
<div class="nav-icon mini-nav-cart">
|
||||
<img src="__PUBLIC__/Home/{{$default_theme}}/Images/home-mini-nav-cart-icon.png" />
|
||||
</div>
|
||||
<div class="mini-nav-title">购物车</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="am-u-sm-3">
|
||||
<a href="#"><img src="__PUBLIC__/Home/{{$default_theme}}/Images/mansmall.jpg" />
|
||||
<div class="title">个人中心</div>
|
||||
<a href="#">
|
||||
<div class="nav-icon mini-nav-user">
|
||||
<img src="__PUBLIC__/Home/{{$default_theme}}/Images/home-mini-nav-user-icon.png" />
|
||||
</div>
|
||||
<div class="mini-nav-title">我的</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="am-u-sm-3">
|
||||
<a href="#"><img src="__PUBLIC__/Home/{{$default_theme}}/Images/moneysmall.jpg" />
|
||||
<div class="title">投资理财</div>
|
||||
<a href="#">
|
||||
<div class="nav-icon mini-nav-seconds">
|
||||
<img src="__PUBLIC__/Home/{{$default_theme}}/Images/home-mini-nav-seconds-icon.png" />
|
||||
</div>
|
||||
<div class="mini-nav-title">秒杀</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -138,7 +150,6 @@
|
|||
<div class="triangle-topright"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<if condition="!empty($floor.goods)">
|
||||
<foreach name="floor.goods" item="goods">
|
||||
<div class="goods-items <if condition="in_array($key, [0,1])">am-u-sm-7 am-u-md-4 text-two<else />am-u-sm-6 am-u-md-2 text-three</if> <if condition="in_array($key, [0,3])">sug</if> <if condition="in_array($key, [2,5])">big</if> <if condition="$key eq 5">last</if>">
|
||||
|
|
@ -146,7 +157,7 @@
|
|||
<div class="goods-title ellipsis">{{$goods.title}}</div>
|
||||
<div class="price">¥{{$goods.price}}</div>
|
||||
</div>
|
||||
<a href="{{:U('/Home/Goods/Index', ['id'=>$goods['id']])}}">
|
||||
<a href="{{$goods['goods_url']}}">
|
||||
<img src="{{$goods.home_recommended_images}}" />
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Service;
|
||||
|
||||
/**
|
||||
* 文章
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class ArticleService
|
||||
{
|
||||
/**
|
||||
* 获取文章列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ArticleList($params)
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
$field = empty($params['field']) ? 'a.*' : $params['field'];
|
||||
$m = isset($params['m']) ? intval($params['m']) : 0;
|
||||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
|
||||
$data = M('Article')->alias('a')->join(' INNER JOIN __ARTICLE_CATEGORY__ AS ac ON a.article_category_id=ac.id') ->field($field)->where($where)->order('a.id desc')->limit($m, $n)->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
if(isset($v['content']))
|
||||
{
|
||||
$v['content'] = ContentStaticReplace($v['content'], 'get');
|
||||
}
|
||||
if(isset($v['add_time']))
|
||||
{
|
||||
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Service;
|
||||
|
||||
/**
|
||||
* 轮播
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class BannerService
|
||||
{
|
||||
/**
|
||||
* 获取首页轮播
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Home($params = [])
|
||||
{
|
||||
// 轮播图片
|
||||
$banner = M('Slide')->field('jump_url,jump_url_type,images_url,name,bg_color')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->select();
|
||||
if(!empty($banner))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($banner as &$v)
|
||||
{
|
||||
$v['images_url'] = $images_host.$v['images_url'];
|
||||
$v['jump_url'] = empty($v['jump_url']) ? null : $v['jump_url'];
|
||||
}
|
||||
$result['banner'] = $banner;
|
||||
}
|
||||
return $banner;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
<?php
|
||||
|
||||
namespace Service;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class GoodsService
|
||||
{
|
||||
/**
|
||||
* 获取大分类
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsCategory($params = [])
|
||||
{
|
||||
$data = self::GoodsCategoryList(['pid'=>0]);
|
||||
if(!empty($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['items'] = self::GoodsCategoryList(['pid'=>$v['id']]);
|
||||
if(!empty($v['items']))
|
||||
{
|
||||
foreach($v['items'] as &$vs)
|
||||
{
|
||||
$vs['items'] = self::GoodsCategoryList(['pid'=>$vs['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pid获取商品分类列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsCategoryList($params = [])
|
||||
{
|
||||
$pid = isset($params['pid']) ? intval($params['pid']) : 0;
|
||||
$images_host = C('IMAGE_HOST');
|
||||
$field = 'id,pid,icon,name,vice_name,describe,bg_color,big_images,sort,is_home_recommended';
|
||||
$data = M('GoodsCategory')->field($field)->where(['is_enable'=>1, 'pid'=>$pid])->order('sort asc')->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
|
||||
$v['big_images'] = empty($v['big_images']) ? null : $images_host.$v['big_images'];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页楼层数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function HomeFloorList($params = [])
|
||||
{
|
||||
// 商品大分类
|
||||
$goods_category = self::GoodsCategory();
|
||||
if(!empty($goods_category))
|
||||
{
|
||||
foreach($goods_category as &$v)
|
||||
{
|
||||
$category_all = self::GoodsCategoryItemsIds($v['id']);
|
||||
$v['goods'] = self::GoodsList(['where'=>['gci.category_id'=>['in', $category_all], 'is_home_recommended'=>1], 'm'=>0, 'n'=>6]);
|
||||
}
|
||||
}
|
||||
return $goods_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类下的所有分类id
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsCategoryItemsIds($params = [])
|
||||
{
|
||||
$data = M('GoodsCategory')->where(['pid'=>$params['category_id'], 'is_enable'=>1])->getField('id', true);
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $v)
|
||||
{
|
||||
$temp = self::GoodsCategoryItemsIds(['category_id'=>$v]);
|
||||
if(!empty($temp))
|
||||
{
|
||||
$data = array_merge($data, $temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param array $params [输入参数: where, field, is_photo]
|
||||
*/
|
||||
public static function GoodsList($params = [])
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
$field = empty($params['field']) ? 'g.*' : $params['field'];
|
||||
$order_by = empty($params['order_by']) ? 'g.id desc' : trim($params['order_by']);
|
||||
|
||||
$is_photo = (isset($params['is_photo']) && $params['is_photo'] == true) ? true : false;
|
||||
$is_attribute = (isset($params['is_attribute']) && $params['is_attribute'] == true) ? true : false;
|
||||
$is_category = (isset($params['is_category']) && $params['is_category'] == true) ? true : false;
|
||||
|
||||
$m = isset($params['m']) ? intval($params['m']) : 0;
|
||||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
$data = M('Goods')->alias('g')->join(' INNER JOIN __GOODS_CATEGORY_JOIN__ AS gci ON g.id=gci.goods_id') ->field($field)->where($where)->group('g.id')->order($order_by)->limit($m, $n)->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
// 商品url地址
|
||||
if(!empty($v['id']))
|
||||
{
|
||||
$v['goods_url'] = HomeUrl('Goods', 'Index', ['id'=>$v['id']]);
|
||||
}
|
||||
|
||||
// 商品封面图片
|
||||
if(isset($v['images']))
|
||||
{
|
||||
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
|
||||
}
|
||||
|
||||
// 商品首页推荐图片,不存在则使用商品封面图片
|
||||
if(isset($v['home_recommended_images']))
|
||||
{
|
||||
$v['home_recommended_images'] = empty($v['home_recommended_images']) ? (empty($v['images']) ? null : $v['images']) : $images_host.$v['home_recommended_images'];
|
||||
}
|
||||
|
||||
// PC内容处理
|
||||
if(isset($v['content_web']))
|
||||
{
|
||||
$v['content_web'] = ContentStaticReplace($v['content_web'], 'get');
|
||||
}
|
||||
|
||||
// 产地
|
||||
if(!empty($v['place_origin']))
|
||||
{
|
||||
$v['place_origin_text'] = M('Region')->where(['id'=>$v['place_origin']])->getField('name');
|
||||
}
|
||||
|
||||
// 时间
|
||||
if(!empty($v['add_time']))
|
||||
{
|
||||
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
|
||||
}
|
||||
if(!empty($v['upd_time']))
|
||||
{
|
||||
$v['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
|
||||
}
|
||||
|
||||
// 是否需要分类名称
|
||||
if($is_category && !empty($v['id']))
|
||||
{
|
||||
$category_id = M('GoodsCategoryJoin')->where(['goods_id'=>$v['id']])->getField('category_id', true);
|
||||
$category_name = M('GoodsCategory')->where(['id'=>['in', $category_id]])->getField('name', true);
|
||||
$v['category_text'] = implode(',', $category_name);
|
||||
}
|
||||
|
||||
// 获取相册
|
||||
if($is_photo && !empty($v['id']))
|
||||
{
|
||||
$v['photo'] = M('GoodsPhoto')->where(['goods_id'=>$v['id'], 'is_show'=>1])->order('sort asc')->getField('images', true);
|
||||
if(!empty($v['photo']))
|
||||
{
|
||||
foreach($v['photo'] as &$vs)
|
||||
{
|
||||
$vs = $images_host.$vs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取属性
|
||||
if($is_attribute && !empty($v['id']))
|
||||
{
|
||||
$v['attribute'] = self::GoodsAttribute(['goods_id'=>$v['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品属性
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsAttribute($params = [])
|
||||
{
|
||||
$result = [];
|
||||
$data = M('GoodsAttributeType')->where(['goods_id'=>$params['goods_id']])->field('id,type,name')->order('sort asc')->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $v)
|
||||
{
|
||||
$v['find'] = M('GoodsAttribute')->field('id,name')->where(['goods_id'=>$params['goods_id'], 'attribute_type_id'=>$v['id']])->order('sort asc')->select();
|
||||
$result[$v['type']][] = $v;
|
||||
}
|
||||
} else {
|
||||
$data = [];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Service;
|
||||
|
||||
/**
|
||||
* 导航
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class NavigationService
|
||||
{
|
||||
/**
|
||||
* 获取首页导航
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Home($params = [])
|
||||
{
|
||||
// 读取缓存数据
|
||||
$header = S(C('cache_common_home_nav_header_key'));
|
||||
$footer = S(C('cache_common_home_nav_footer_key'));
|
||||
|
||||
// 导航模型
|
||||
$m = M('Navigation');
|
||||
$field = array('id', 'pid', 'name', 'url', 'value', 'data_type', 'is_new_window_open');
|
||||
|
||||
// 缓存没数据则从数据库重新读取,顶部菜单
|
||||
if(empty($header))
|
||||
{
|
||||
$header = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
|
||||
if(!empty($header))
|
||||
{
|
||||
foreach($header as $k=>$v)
|
||||
{
|
||||
$header[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
|
||||
}
|
||||
}
|
||||
S(C('cache_common_home_nav_header_key'), $header);
|
||||
}
|
||||
|
||||
// 底部导航
|
||||
if(empty($footer))
|
||||
{
|
||||
$footer = NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
|
||||
S(C('cache_common_home_nav_footer_key'), $footer);
|
||||
}
|
||||
|
||||
return [
|
||||
'header' => $header,
|
||||
'footer' => $footer,
|
||||
];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -113,7 +113,8 @@ color: #F5F5F2;font-size: 14px;cursor:pointer;border-radius:0px 0px ;}
|
|||
.mui-mbar-tabs{ display:none;}
|
||||
|
||||
/* 顶部小导航 */
|
||||
.header-top { background-color: #eee; }
|
||||
.header-top { background-color: #F5F5F5; border-bottom: solid 1px #E5E5E5; }
|
||||
.header-top a, .header-top span { color: #555; }
|
||||
.header{ display:none; max-width:1000px; margin:0px auto; font-size:12px;}
|
||||
|
||||
.am-footer { border-top: 2px solid #d2364c; }
|
||||
|
|
@ -189,7 +190,6 @@ color: #F5F5F2;font-size: 14px;cursor:pointer;border-radius:0px 0px ;}
|
|||
@media only screen and (min-width: 1025px)
|
||||
{
|
||||
.am-container { padding-left:0rem;padding-right:0rem;max-width: 1000px;}
|
||||
.smallnav,.only-phone{ display:none;}
|
||||
.shop-nav{margin:0px;border-bottom: 2px solid #d2364c; height: 45px;}
|
||||
|
||||
.mui-mbar-tabs{ display:block;}
|
||||
|
|
|
|||
|
|
@ -7,22 +7,23 @@ ul, li, ol {list-style: none;}
|
|||
.am-container {padding-left:0px;padding-right:0px ;}
|
||||
.am-container > .am-g {margin-left: 0px;margin-right:0px ;}
|
||||
img{width:100%;}
|
||||
.slideall{background:#fff ;}
|
||||
.smallnav img,.smallnav a,.am-g.smallnav {border:none;}
|
||||
.small-nav img,.small-nav a,.am-g.small-nav {border:none;}
|
||||
a:hover {color:#000000;}
|
||||
.e-price{color:red; font-size:14px;}
|
||||
.method3 img{border:none;}
|
||||
.method3 li{border:none;border-left:1px #e8e8e8 solid;border-top:1px #e8e8e8 solid}
|
||||
dt + dd {margin-top: 0;}
|
||||
.am-slider-default{margin-bottom: 0px;}
|
||||
/*轮播图按钮*/
|
||||
.am-slider-default .am-control-nav {width: 100%;position: absolute;bottom: 15px;text-align: center;}
|
||||
.am-u-sm-3 {text-align:center;}
|
||||
.am-control-nav li { float:none;}
|
||||
.am-slider-default .am-direction-nav{ opacity: 0;}
|
||||
|
||||
/*手机专享*/
|
||||
.smallnav{padding:10px 0px; font-size:12px;}
|
||||
.smallnav img{max-width:40px;}
|
||||
.small-nav {padding:10px 0px; font-size:12px;}
|
||||
.small-nav .am-u-sm-3 { text-align: center; margin: 5px 0; }
|
||||
.small-nav .nav-icon {max-width: 48px; padding: 8px; margin: 0 auto; border-radius: 50px; background-color: #d2364c; }
|
||||
.small-nav .am-u-sm-3:last-child { float: left; }
|
||||
.small-nav .mini-nav-title { margin-top: 5px; }
|
||||
.small-nav .mini-nav-goods-category { background-color: #FB6E52; }
|
||||
.small-nav .mini-nav-cart { background-color: #48CFAE; }
|
||||
.small-nav .mini-nav-user { background-color: #49acfa; }
|
||||
.small-nav .mini-nav-seconds { background-color: #fa506c; }
|
||||
|
||||
#navOpen{padding:0px 0px;}
|
||||
.list .word{display: none;}
|
||||
|
|
@ -131,8 +132,8 @@ text-align: center;float:none}
|
|||
/*推荐*/
|
||||
.flood li {width: 50%;float: left;text-align: center;}
|
||||
@media only screen and (min-width: 480px) {
|
||||
.smallnav img{max-width:60px;}
|
||||
.smallnav{ font-size:14px;}
|
||||
.small-nav img{max-width:60px;}
|
||||
.small-nav{ font-size:14px;}
|
||||
.flood li{width:33.3%;}
|
||||
|
||||
/*第二套各类活动*/
|
||||
|
|
@ -220,6 +221,7 @@ text-align: center;float:none}
|
|||
|
||||
@media only screen and (min-width: 1025px)
|
||||
{
|
||||
.small-nav { display:none;}
|
||||
.am-g-fixed{max-width:1000px;}
|
||||
.flood li{width:20%;}
|
||||
.banner-news{ margin-left: 0px;}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 894 B |
Binary file not shown.
|
After Width: | Height: | Size: 730 B |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 879 B |
Loading…
Reference in New Issue