From 2416e0273294e1480d5aff0e707ade49f0e63536 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Wed, 29 Aug 2018 18:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Controller/IndexController.class.php | 17 +- .../Application/Common/Common/function.php | 6 +- .../Controller/CommonController.class.php | 334 +----------------- .../Home/Controller/GoodsController.class.php | 10 +- .../Home/Controller/IndexController.class.php | 64 +--- .../Home/View/Default/Goods/Index.html | 6 +- .../Home/View/Default/Index/Index.html | 33 +- .../Service/ArticleService.class.php | 48 +++ .../Service/BannerService.class.php | 40 +++ .../Service/GoodsService.class.php | 244 +++++++++++++ .../Service/NavigationService.class.php | 60 ++++ service/Public/Home/Default/Css/Common.css | 4 +- service/Public/Home/Default/Css/Index.css | 26 +- .../Images/home-mini-nav-cart-icon.png | Bin 0 -> 894 bytes .../Images/home-mini-nav-category-icon.png | Bin 0 -> 730 bytes .../Images/home-mini-nav-seconds-icon.png | Bin 0 -> 3391 bytes .../Images/home-mini-nav-user-icon.png | Bin 0 -> 879 bytes 17 files changed, 465 insertions(+), 427 deletions(-) create mode 100644 service/Application/Service/ArticleService.class.php create mode 100644 service/Application/Service/BannerService.class.php create mode 100644 service/Application/Service/GoodsService.class.php create mode 100644 service/Application/Service/NavigationService.class.php create mode 100644 service/Public/Home/Default/Images/home-mini-nav-cart-icon.png create mode 100644 service/Public/Home/Default/Images/home-mini-nav-category-icon.png create mode 100644 service/Public/Home/Default/Images/home-mini-nav-seconds-icon.png create mode 100644 service/Public/Home/Default/Images/home-mini-nav-user-icon.png diff --git a/service/Application/Api/Controller/IndexController.class.php b/service/Application/Api/Controller/IndexController.class.php index 0b4365439..c214caf19 100755 --- a/service/Application/Api/Controller/IndexController.class.php +++ b/service/Application/Api/Controller/IndexController.class.php @@ -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); diff --git a/service/Application/Common/Common/function.php b/service/Application/Common/Common/function.php index bd46d4bfb..665d6e597 100755 --- a/service/Application/Common/Common/function.php +++ b/service/Application/Common/Common/function.php @@ -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)); } /** diff --git a/service/Application/Home/Controller/CommonController.class.php b/service/Application/Home/Controller/CommonController.class.php index c49f77e85..419f2854f 100755 --- a/service/Application/Home/Controller/CommonController.class.php +++ b/service/Application/Home/Controller/CommonController.class.php @@ -1,7 +1,10 @@ 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; - } } ?> \ No newline at end of file diff --git a/service/Application/Home/Controller/GoodsController.class.php b/service/Application/Home/Controller/GoodsController.class.php index 37158522d..a9a514d14 100644 --- a/service/Application/Home/Controller/GoodsController.class.php +++ b/service/Application/Home/Controller/GoodsController.class.php @@ -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'); } diff --git a/service/Application/Home/Controller/IndexController.class.php b/service/Application/Home/Controller/IndexController.class.php index 5cf558cfe..5a658f528 100755 --- a/service/Application/Home/Controller/IndexController.class.php +++ b/service/Application/Home/Controller/IndexController.class.php @@ -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; - } } ?> \ No newline at end of file diff --git a/service/Application/Home/View/Default/Goods/Index.html b/service/Application/Home/View/Default/Goods/Index.html index dc529475b..556a1a3fd 100644 --- a/service/Application/Home/View/Default/Goods/Index.html +++ b/service/Application/Home/View/Default/Goods/Index.html @@ -192,12 +192,12 @@
  • class="first">
    ¥{{$v.price}}
  • @@ -260,7 +260,7 @@
  • - + {{$v.title}}

    {{$v.title}}

    diff --git a/service/Application/Home/View/Default/Index/Index.html b/service/Application/Home/View/Default/Index/Index.html index 402f05ba8..9d756ed1e 100755 --- a/service/Application/Home/View/Default/Index/Index.html +++ b/service/Application/Home/View/Default/Index/Index.html @@ -17,25 +17,37 @@
    - -
    am-u-sm-7 am-u-md-4 text-twoam-u-sm-6 am-u-md-2 text-three sug big last"> @@ -146,7 +157,7 @@
    {{$goods.title}}
    ¥{{$goods.price}}
    - +
    diff --git a/service/Application/Service/ArticleService.class.php b/service/Application/Service/ArticleService.class.php new file mode 100644 index 000000000..a36118bab --- /dev/null +++ b/service/Application/Service/ArticleService.class.php @@ -0,0 +1,48 @@ +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; + } +} +?> \ No newline at end of file diff --git a/service/Application/Service/BannerService.class.php b/service/Application/Service/BannerService.class.php new file mode 100644 index 000000000..b11f62e16 --- /dev/null +++ b/service/Application/Service/BannerService.class.php @@ -0,0 +1,40 @@ +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; + } +} +?> \ No newline at end of file diff --git a/service/Application/Service/GoodsService.class.php b/service/Application/Service/GoodsService.class.php new file mode 100644 index 000000000..3d725e8d0 --- /dev/null +++ b/service/Application/Service/GoodsService.class.php @@ -0,0 +1,244 @@ +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; + } +} +?> \ No newline at end of file diff --git a/service/Application/Service/NavigationService.class.php b/service/Application/Service/NavigationService.class.php new file mode 100644 index 000000000..e271d1619 --- /dev/null +++ b/service/Application/Service/NavigationService.class.php @@ -0,0 +1,60 @@ +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, + ]; + } +} +?> \ No newline at end of file diff --git a/service/Public/Home/Default/Css/Common.css b/service/Public/Home/Default/Css/Common.css index d6eaf3c97..1cb907db2 100755 --- a/service/Public/Home/Default/Css/Common.css +++ b/service/Public/Home/Default/Css/Common.css @@ -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;} diff --git a/service/Public/Home/Default/Css/Index.css b/service/Public/Home/Default/Css/Index.css index 50acd10cf..d38459cdb 100755 --- a/service/Public/Home/Default/Css/Index.css +++ b/service/Public/Home/Default/Css/Index.css @@ -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;} diff --git a/service/Public/Home/Default/Images/home-mini-nav-cart-icon.png b/service/Public/Home/Default/Images/home-mini-nav-cart-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..72bccfa6f0204a7e35a12f308815c5fbd1ae1503 GIT binary patch literal 894 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S903?%u>HW~mamUKs7M+SzC{oH>NS%G}U;vjb? zhIQv;UIIA=0X`wFKADC8NddnOcea4cFA4GsX1M!qw^FE}u}j*SRUI?SxANG9GcYh+ z^mK6yi8#D9vb(57fybm_&!NZv|8EoBu{x}^W5Vv8Gs{X`PvlM8pd;+8VBI3$wkFr6 zO_ojeKl|jx3x0A&_cu*b&oR$&Tk`n6$AucNZ3(m9XkJj{jXv9Ojq}!-hG{v?$25&6 z{W$#Nw1fJ&3wnHA#cb;rFL+#aX;tEdbj_y38xJR$JWu$zc;|rxZtgPfyvv&k|M2$z zGoMpzcbDn^Lf<%+wOcP`aW6a~7IZ>{+fh99(1+{)%ide^s{46Y#Pj{>J@N7T(*yVR z?5K|Adr}%#FQT>QnnmGvpF2SdKMU&xzqbw+jQFm8Z`JbohmYD{+QVzg`^&2OD@R70 zX41vAtKa>cH7n>txY45b9G{OLkCQxEe)?8%b!yA?W1(u%`!`7MTNN|cXwfURlSk_o zU*1r5)6n61%Hy?WZ;!n961&aFE1kPLc4>z0Iv>yF&=TDNt!$v)T4r1MtSE}9)@ znY-j(f{(W96At1uE+hegt`Aof5qbcQ~6AiM> zTQXyhR*9UN^oi@XWYyvsjnfw9tucG6{(Gj=(pN`rO+GPia+|Pwa(BDYYQrP)Zb6l- zhs`cL)=71KA}XDI)Bm&0vhc#(d!O^>$cdSHN-0NAe;7Dtl|+Axh27HJXVqW6G%9~N zy(RE`=9*cRchA2OaqyY_=7iHbD_ibK#ix5WEssB7b=jnPb7z~>T~(hK5qD&Ldk*Q@ zMoTlv-{P};H|bMwL|(`}x1CxUq6@BVv6$uLywdBXlJ@s>!&R5I+w3`XYg$`B$MiF% zER{tp8xQUM&oOoGLspY*dwXrw81Mbowop+z`l6e8%X$%m@{jIU-+W}&bn5NSbFcJW zxopSMj*_d7_Xlh_Q0;AVS4WOPcG@1cRYxywdF5DG*JNuH{rqzGsZHF!c`7GvyF2@j z-mmlrE9OmEHm8C&cEak-yds>n>f5zl_7CJQ={Drfyf)=KFx@kFy85}S Ib4q9e0Hln+B>(^b literal 0 HcmV?d00001 diff --git a/service/Public/Home/Default/Images/home-mini-nav-category-icon.png b/service/Public/Home/Default/Images/home-mini-nav-category-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0388491450174b303d89a6c8ff7cf205726110d2 GIT binary patch literal 730 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S913?xsr#TWu9g8-ipSD(zn|D=FlhdWz$VIGOkSQYjv*CsZ?7@7hy+Tof3UxM!uQ*aC+~tx zt&WIpdlThZv_*8f1nX7JKAlH7jcfUGJw$JLsdO!L4)YM=^z`J~Eih*?FP}?UQhD+1 zzq2cky?Ik*oZrvA#Xgzm-@Tsm-=9@S@YXI}qMf=>+t}6k^If2r}dW|ynk+PqFH0k*4M$ya+$&<9vNvc)tSy#EBLeU zPV!~n#m2IZ+srQb9}Zu#_t94WzLUMt3ej~@`nxlA4+?Bg*dX>sOS;4G49B`jY^U7n+OkBfo!6=BG zk15Liz4?NICPr3`7o5M`d{!Je^`$3lLD{c^z5eTNu77b-lkxvdySKNq6Zb9upxo?~ zeW&G;-7h2!W``sAd?o%{8VKPiiP^ykbDhfQ`HyZ%pJCls=9lf(ULjhFVD r3Kgqwx6Io2KknYwONY9?{$=$ld>^P2z4R+E!7+Hc`njxgN@xNAwH##X literal 0 HcmV?d00001 diff --git a/service/Public/Home/Default/Images/home-mini-nav-seconds-icon.png b/service/Public/Home/Default/Images/home-mini-nav-seconds-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d6610ad0372e9b6989f4ffe55ade4c0927a4d1b5 GIT binary patch literal 3391 zcmaJ^c|6nqA4leXy8?$V52uZ12m6FJ!l8BNcQhdK5 z5u?L5SMIM+BuA3`rf>EA{qgJfc|1O!_wjf>pReor&*zkjlZ~v@Rw*GNAz3?HoSR_v zS$`$O1YgraOA*1M!p4)>?#y5|Cy+%IvZOGBs35zr!2MJ=Y9J*#qJ?TMB(y<~P9(8O z1V=QP8D;N2LIITtMu2&1wCLENxVMkJbR0sgLw7VOurpa>azFpbR)M?;|;4#$vVWXNRghr&@P6cmPlA`lP(0umX`UCQ@SQ^-pzRou>_7&YYKOA`3sem0bPC$q3T9%2GPbmW8Joi4c%&&D zX^At!BakSB)h@WP@lP&}Nj?}xWw3v8DgSb@zvZsmAuL=F8AoN&qo@>X7BdX=y=*l7 z_qmw(%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