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 000000000..72bccfa6f Binary files /dev/null and b/service/Public/Home/Default/Images/home-mini-nav-cart-icon.png differ 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 000000000..038849145 Binary files /dev/null and b/service/Public/Home/Default/Images/home-mini-nav-category-icon.png differ 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 000000000..d6610ad03 Binary files /dev/null and b/service/Public/Home/Default/Images/home-mini-nav-seconds-icon.png differ diff --git a/service/Public/Home/Default/Images/home-mini-nav-user-icon.png b/service/Public/Home/Default/Images/home-mini-nav-user-icon.png new file mode 100644 index 000000000..427e89488 Binary files /dev/null and b/service/Public/Home/Default/Images/home-mini-nav-user-icon.png differ