diff --git a/library/LibModels/Web/Product/ShopData.php b/library/LibModels/Web/Product/ShopData.php new file mode 100644 index 0000000..9f80f20 --- /dev/null +++ b/library/LibModels/Web/Product/ShopData.php @@ -0,0 +1,125 @@ +<?php + +namespace LibModels\Web\Product; + +use Api\Yohobuy; +use Api\Sign; +/** + * 品牌店铺的接口 + * @info http://git.dev.yoho.cn/yoho-documents/api-interfaces/blob/master/%E5%95%86%E5%93%81%E5%88%97%E8%A1%A8/brandShops.md + * @copyright yoho.inc + * @author xiaoxiao.hao <xiaoxiao.hao@yoho.cn> + */ +class ShopData +{ + /** + * 获取店铺装修的所有资源接口 + * @param type int $shopId 店铺id + * @return type [] + */ + public static function shopsDecoratorList($shopId) + { + $param = Yohobuy::param(); + $param['method'] = 'app.shopsdecorator.getList'; + $param['shop_id'] = intval($shopId); + $param['client_secret'] = Sign::getSign($param); + + return Yohobuy::get(Yohobuy::API_URL, $param); + } + /** + * 查询店铺介绍接口 + * @param type int $shopId 店铺id + * @return type [] + */ + public static function getIntro($shopId, $uid = '') + { + $param = Yohobuy::param(); + $param['method'] = 'app.shops.getIntro'; + $param['shop_id'] = intval($shopId); + $param['uid'] = $uid; + $param['client_secret'] = Sign::getSign($param); + + return Yohobuy::get(Yohobuy::API_URL, $param); + } + + /** + * 查询店铺下面的所有品牌 + * @param type int $shopId 店铺id + * @return type [] + */ + public static function getShopsBrands($shopId) + { + $param = Yohobuy::param(); + $param['method'] = 'app.shops.getShopsBrands'; + $param['shop_id'] = intval($shopId); + $param['client_secret'] = Sign::getSign($param); + + return Yohobuy::get(Yohobuy::API_URL, $param); + } + + /** + * 搜索店铺内商品 || 查询该店铺下全部商品 + * @param type int $shopId 店铺id + * @return type [] + */ + public static function getSearch($shopId) + { + $param = Yohobuy::param(); + $param['method'] = 'app.search.li'; + $param['shop'] = intval($shopId); + $param['client_secret'] = Sign::getSign($param); + + return Yohobuy::get(Yohobuy::API_URL, $param); + } + + /** + * 查询该店铺下所有二级品类 + * @param type int $shopId 店铺id + * @param type string $yhChannel 频道 + * @param type string $gender 性别 + * @return type [] + */ + public static function getSortInfo($shopId, $yhChannel = '', $gender = '') + { + $param = Yohobuy::param(); + $param['method'] = 'app.shop.getSortInfo'; + $param['shop_id'] = intval($shopId); + $param['yh_channel'] = $yhChannel; + $param['gender'] = $gender; + $param['client_secret'] = Sign::getSign($param); + + return Yohobuy::get(Yohobuy::API_URL, $param); + } + + /** + * 收藏|取消 店铺接口 + * @param type int $shopId 店铺id + * @param type Boolean $isfavorite true:收藏,false:取消 + * @param type string $type 收藏的类型,brand、product、shop + * @return type [] + */ + public static function setFavorite($shopId, $isfavorite, $uid, $type = 'shop') + { + $param = Yohobuy::param(); + $param['method'] = $isfavorite ? 'app.favorite.add' : 'app.favorite.cancel'; + $param['id'] = intval($shopId); + $param['fav_id'] = intval($shopId); + $param['uid'] = $uid; + $param['type'] = $type; + $param['client_secret'] = Sign::getSign($param); + return Yohobuy::get(Yohobuy::API_URL, $param); + } + /** + * 根据domain查找shop_id + * @param type string $domain 品牌域名 + * @return type [] + */ + public static function byDomain($domain) + { + $param = Yohobuy::param(); + $param['method'] = 'web.brand.byDomain'; + $param['domain'] = $domain; + $param['client_secret'] = Sign::getSign($param); + return Yohobuy::get(Yohobuy::API_URL, $param); + } +} diff --git a/library/WebPlugin/Helpers.php b/library/WebPlugin/Helpers.php index eef65b8..d3c2ac5 100644 --- a/library/WebPlugin/Helpers.php +++ b/library/WebPlugin/Helpers.php @@ -1050,4 +1050,23 @@ class Helpers return true; } + /** + * 格式化产品url + * @param type int $productId 产品id + * @param type $productSkn 产品编号 + * @param type $productName 产品名称 + * @param type $cnAlphaBet + * @return type url + */ + public static function getProductUrl($productId, $productSkn, $productName = '', $cnAlphaBet = '') + { + $cnAlphaBet = empty($cnAlphaBet) ? $cnAlphaBet : md5($productName); + + return self::url( + '/product/pro_' . $productId . '_' . + $productSkn . '/' . $cnAlphaBet . '.html', + null, + 'item' + ); + } } diff --git a/template/www.yohobuy.com/actions/product/index/goods-list.phtml b/template/www.yohobuy.com/actions/product/index/goods-list.phtml new file mode 100644 index 0000000..fe943ab --- /dev/null +++ b/template/www.yohobuy.com/actions/product/index/goods-list.phtml @@ -0,0 +1 @@ +{{> product/goods-list}} \ No newline at end of file diff --git a/template/www.yohobuy.com/actions/product/index/shop-index.phtml b/template/www.yohobuy.com/actions/product/index/shop-index.phtml new file mode 100644 index 0000000..5e1d138 --- /dev/null +++ b/template/www.yohobuy.com/actions/product/index/shop-index.phtml @@ -0,0 +1,85 @@ +{{> layout/header}} +<div class="shop-index-page product-list-page product-page yoho-page center-content home-page"> + <div class="center-content clearfix"> + {{> layout/path-nav}} + + {{> product/shop-header}} + + <div class="list-left pull-left"> + {{> product/left-content}} + + {{> product/shop-sidebar}} + </div> + <div class="list-right pull-right"> + {{#if coupon}} + <div class="coupon clearfix"> + <div class="coupon-title"> + </div> + </div> + {{/if}} + {{#if largeSlideImg}} + <div class="slider-wrap clearfix"> + <div class="slider-left pull-left"> + <div class="slide-wrapper"> + <ul> + {{#largeSlideImg}} + <li> + <a href="{{url}}"><img src="{{img}}"></a> + </li> + {{/largeSlideImg}} + </ul> + </div> + </div> + <div class="slider-right pull-right"> + {{#oneRowTwoColImages}} + <a class="slider-item" href="{{url}}"><img src="{{img}}"></a> + {{/oneRowTwoColImages}} + </div> + </div> + {{/if}} + {{#newArrivel}} + <div class="new-arrivel clearfix"> + {{> index/floor-header}} + {{> product/shop-single-list}} + </div> + {{/newArrivel}} + {{#hotSingle}} + <div class="hot-single clearfix"> + {{> index/floor-header}} + {{> product/shop-single-list}} + </div> + {{/hotSingle}} + {{#allGoods}} + <div class="all-goods clearfix"> + {{> index/floor-header}} + + <div class="goods-wrap"> + {{> product/goods-list}} + </div> + + <div class="loading"> + <a href="{{href}}" target= "_blank">查看更多</a> + </div> + </div> + {{/allGoods}} + {{#trendInfo}} + <div class="trend-info clearfix"> + {{> index/floor-header}} + + <ul class="trend-list"> + {{#each trendList}} + <li> + <a href="{{href}}"> + <img src="{{src}}" /> + <div class="main-title">{{mainTitle}}</div> + <div class="sub-title">{{Subtitle}}</div> + </a> + </li> + {{/each}} + </ul> + </div> + {{/trendInfo}} + </div> + </div> +</div> +{{> layout/footer}} diff --git a/template/www.yohobuy.com/actions/product/index/shop-list.phtml b/template/www.yohobuy.com/actions/product/index/shop-list.phtml new file mode 100644 index 0000000..9d0f674 --- /dev/null +++ b/template/www.yohobuy.com/actions/product/index/shop-list.phtml @@ -0,0 +1,22 @@ +{{> layout/header}} +<div class="shop-index-page product-list-page product-page yoho-page center-content"> + <div class="center-content clearfix"> + {{> layout/path-nav}} + + {{> product/shop-header}} + + <div class="list-left pull-left"> + {{> product/left-content}} + + {{> product/shop-sidebar}} + </div> + <div class="list-right pull-right"> + {{> product/shop-entry}} + + {{> product/standard-content}} + + {{> product/latest-walk}} + </div> + </div> +</div> +{{> layout/footer}} diff --git a/template/www.yohobuy.com/partials/layout/use.phtml b/template/www.yohobuy.com/partials/layout/use.phtml index 94afb51..8de1e73 100644 --- a/template/www.yohobuy.com/partials/layout/use.phtml +++ b/template/www.yohobuy.com/partials/layout/use.phtml @@ -304,5 +304,10 @@ seajs.use('js/coupon/coupon'); </script> {{/if}} - +{{!-- 店铺首页 --}} +{{#if shopIndexPage}} + <script> + seajs.use('js/product/shop-index'); + </script> +{{/if}} diff --git a/template/www.yohobuy.com/partials/product/goods-list.phtml b/template/www.yohobuy.com/partials/product/goods-list.phtml new file mode 100644 index 0000000..885bc94 --- /dev/null +++ b/template/www.yohobuy.com/partials/product/goods-list.phtml @@ -0,0 +1,100 @@ +<div class="fixed-area"> +{{# goodsMenu}} + <div class="all-goods-menu"> + <span class="menu-tag">所有商品</span> + <ul class="menu-list"> + {{#each menuList}} + <li class="{{#if curMenu}} on {{/if}}"><a class="pjax" href="{{href}}">{{name}}</a></li> + {{/each}} + </ul> + <a href="{{url}}" class="more">MORE</a> + </div> +{{/goodsMenu}} + +{{# opts}} + <div class="sort-pager"> + {{# sortType}} + <a class="sort-type{{#if active}} active{{/if}} pjax" href="{{href}}"> + {{name}} + {{#if hasSortOrient}} + {{#if active}} + {{#if desc}} + <span class="active-icon iconfont"></span> + {{^}} + <span class="active-icon iconfont"></span> + {{/if}} + {{^}} + <span class="iconfont"></span> + {{/if}} + {{^}} + <span class="iconfont"></span> + {{/if}} + </a> + {{/ sortType}} + + {{#if list}} + {{#if oldPage}} + <div class="pager-wrap"> + <p class="page-orient"> + {{#if preHref}} + <a class="pjax" href="{{preHref}}"> + <span class="iconfont"></span> + </a> + {{^}} + <span class="dis-icon iconfont"></span> + {{/if}} + + <span> + <i>{{curPage}}</i>/{{pageCount}} + </span> + + {{#if nextHref}} + <a class="pjax" href="{{nextHref}}"> + <span class="iconfont"></span> + </a> + {{^}} + <span class="dis-icon iconfont"></span> + {{/if}} + </p> + </div> + {{^}} + <div class="page-nav"> + {{#if preHref}} + <a class="pjax" href="{{preHref}}"> + <span class="page-prev"><i class="arrow-left"></i></span> + </a> + {{^}} + <span class="page-prev"><i class="arrow-left"></i></span> + {{/if}} + + {{#if nextHref}} + <a class="pjax" href="{{nextHref}}"> + <span class="page-next"> + 下一页 + <i class="arrow-right"></i> + <i class="pages">{{curPage}}</i>/{{pageCount}} + </span> + </a> + {{^}} + <span class="page-next"> + 下一页 + <i class="arrow-right"></i> + <i class="pages">{{curPage}}</i>/{{pageCount}} + </span> + {{/if}} + </div> + {{/if}} + {{/if}} + </div> +{{/ opts}} +</div> + +<div class="goods-container clearfix"> + {{# list}} + {{> product/good}} + {{/list}} + <div class="good-item-wrapper"> + <div class="good-info-main"></div> + <div class="good-select-color"></div> + </div> +</div> diff --git a/template/www.yohobuy.com/partials/product/shop-header.phtml b/template/www.yohobuy.com/partials/product/shop-header.phtml new file mode 100644 index 0000000..96e6376 --- /dev/null +++ b/template/www.yohobuy.com/partials/product/shop-header.phtml @@ -0,0 +1,59 @@ +{{# shopTopBanner}} + <div class="shop-banner"> + <div class="banner-img" style="height: {{bannerHeight}}px;background: url({{banner}})"></div> + {{#if shopsType}} + <div class="shop-name"> + {{brandName}} + </div> + {{/if}} + <div class="opt-wrap"> + <div class="shop-intro"> + <i class="shop-intro-ico"></i> + 店铺介绍 + </div> + <div class="shop-collect" data-id="{{brandIntro.shopId}}"> + <i class="shop-collect-ico {{#if brandIntro.isFavorite}}on{{/if}}"></i> + <span class="shop-collect-text"> + {{#if brandIntro.isFavorite}} + 已收藏 + {{else}} + 收藏 + {{/if}} + </span> + </div> + </div> + </div> + {{#brandIntro}} + <div class="pop-shop-intro"> + <div class="shop-intro-bg"></div> + <div class="shop-intro-area"> + <i class="close-btn"></i> + <div class="brand-cont"> + <div class="intro-title"> + <h2>{{brandName}}</h2> + <p>品牌介绍</p> + </div> + <div class="intro-cont"> + {{{brandCont}}} + </div> + </div> + </div> + </div> + {{/brandIntro}} + <div class="mask"></div> +{{/ shopTopBanner}} + +{{#if navigationBar}} + <ul class="shop-nav clearfix"> + {{#navigationBar}} + <li class="nav-item {{#if @first}}first{{/if}} {{#if current}}current{{/if}}"> + <a href="{{url}}"> + {{name}} + {{#if arrow}} + <span class="iconfont"></span> + {{/if}} + </a> + </li> + {{/navigationBar}} + </ul> +{{/if}} diff --git a/template/www.yohobuy.com/partials/product/shop-sidebar.phtml b/template/www.yohobuy.com/partials/product/shop-sidebar.phtml new file mode 100644 index 0000000..86d52b9 --- /dev/null +++ b/template/www.yohobuy.com/partials/product/shop-sidebar.phtml @@ -0,0 +1,46 @@ +{{#brandBrowse}} + <div class="brand-collect left-modular"> + <h2 class="title">{{title}}</h2> + <ul class="left-list"> + {{#each list}} + <li class="{{#if cur}} on {{/if}}"><a href="{{url}}">{{brandName}}</a></li> + {{/each}} + </ul> + </div> +{{/brandBrowse}} + +{{#recommend}} + <div class="classic-recommend left-modular"> + <h2 class="title">{{title}}</h2> + <ul class="left-list"> + {{#each list}} + <li> + <a href="{{url}}"> + <div class="classic-name"> + {{#name}} + <p class="name">{{.}}</p> + {{/name}} + {{#enName}} + <p class="en-name">{{.}}</p> + {{/enName}} + </div> + <img src="{{img}}" /> + </a> + </li> + {{/each}} + </ul> + </div> +{{/recommend}} + +{{#hotRecommend}} + <div class="sell-recommend left-modular"> + <h2 class="title">{{title}}</h2> + <ul class="left-list"> + {{#each list}} + <li> + <a target="_blank" href="{{url}}"><img src="{{img}}" alt="{{title}}" /></a> + </li> + {{/each}} + </ul> + </div> +{{/hotRecommend}} diff --git a/template/www.yohobuy.com/partials/product/shop-single-list.phtml b/template/www.yohobuy.com/partials/product/shop-single-list.phtml new file mode 100644 index 0000000..34a828d --- /dev/null +++ b/template/www.yohobuy.com/partials/product/shop-single-list.phtml @@ -0,0 +1,18 @@ +<ul> + {{#each list}} + <li> + <a class="item item-{{@index}}" href="{{url}}" target= "_blank"> + <img class="lazy" data-original="{{img}}"/> + <p class="title"> + {{title}} + </p> + <p class="price"> + {{price}} + </p> + {{#if index}} + <span class="hat">{{index}}</span> + {{/if}} + </a> + </li> + {{/each}} +</ul> diff --git a/web-static/img/product/arrow-left.png b/web-static/img/product/arrow-left.png new file mode 100644 index 0000000..0ec978d Binary files /dev/null and b/web-static/img/product/arrow-left.png differ diff --git a/web-static/img/product/arrow-right.png b/web-static/img/product/arrow-right.png new file mode 100644 index 0000000..a275d09 Binary files /dev/null and b/web-static/img/product/arrow-right.png differ diff --git a/web-static/img/product/hat.png b/web-static/img/product/hat.png new file mode 100644 index 0000000..883859d Binary files /dev/null and b/web-static/img/product/hat.png differ diff --git a/web-static/img/product/shop-collection-on.png b/web-static/img/product/shop-collection-on.png new file mode 100644 index 0000000..b7d203c Binary files /dev/null and b/web-static/img/product/shop-collection-on.png differ diff --git a/web-static/img/product/shop-collection.png b/web-static/img/product/shop-collection.png new file mode 100644 index 0000000..f71f4f4 Binary files /dev/null and b/web-static/img/product/shop-collection.png differ diff --git a/web-static/img/product/shop-instro-close.png b/web-static/img/product/shop-instro-close.png new file mode 100644 index 0000000..67ae027 Binary files /dev/null and b/web-static/img/product/shop-instro-close.png differ diff --git a/web-static/img/product/shop-instro.png b/web-static/img/product/shop-instro.png new file mode 100644 index 0000000..d405d92 Binary files /dev/null and b/web-static/img/product/shop-instro.png differ diff --git a/web-static/img/sprite.order.png b/web-static/img/sprite.order.png index d12c71c..3215ae0 100644 Binary files a/web-static/img/sprite.order.png and b/web-static/img/sprite.order.png differ diff --git a/web-static/img/sprite.product.png b/web-static/img/sprite.product.png new file mode 100644 index 0000000..2bb4646 Binary files /dev/null and b/web-static/img/sprite.product.png differ diff --git a/web-static/js/product/entry.js b/web-static/js/product/entry.js index 03a85c2..5c0be9a 100644 --- a/web-static/js/product/entry.js +++ b/web-static/js/product/entry.js @@ -11,3 +11,5 @@ require('./brand'); require('./hotrank'); require('./item'); + +require('./shop-index'); diff --git a/web-static/js/product/shop-index.js b/web-static/js/product/shop-index.js new file mode 100644 index 0000000..383f0c3 --- /dev/null +++ b/web-static/js/product/shop-index.js @@ -0,0 +1,132 @@ +/** + * 首页 + * @author: bikai<kai.bi@yoho.cn> + * @date: 2016/4/26 + */ + +var $ = require('yoho.jquery'), + lazyLoad = require('yoho.lazyload'), + product = require('../product/product'); + +var $shopIntro = $('.shop-intro'), + $shopCollect = $('.shop-collect'), + $sliderLeft = $('.slider-left'), + $allGoods = $('.all-goods'), + $fixedArea = $allGoods.find('.fixed-area'), + fixedAreaTop = $fixedArea.offset() ? $fixedArea.offset().top : 0; + +// Pjax +require('yoho.pjax'); + +require('../common/slider'); +require('../product/list'); + +product.init(4); + +lazyLoad($('img.lazy')); + +if ($sliderLeft.length) { + $sliderLeft.slider(); +} + +$shopIntro.on('click', function() { + $('.pop-shop-intro').show(); + $('.mask').show(); +}); + +$('.close-btn, .mask').on('click', function() { + $('.pop-shop-intro').hide(); + $('.mask').hide(); +}); + + +// 收藏店铺 +function colloectAction() { + var $colloectIcon = $shopCollect.find('.shop-collect-ico'), + $colloectText = $shopCollect.find('.shop-collect-text'), + isFavorite = $colloectIcon.hasClass('on'), + needColloect = window.cookie('needColloect'); + + $.ajax({ + type: 'post', + url: '/shoplist/setFavorite', + data: { + isFavorite: isFavorite ? 0 : 1, + needColloect: needColloect, + shopId: $shopCollect.data('id') + }, + success: function(res) { + if (res.code === 200) { + if (isFavorite) { + $colloectIcon.removeClass('on'); + $colloectText.html('收藏'); + } else { + $colloectIcon.addClass('on'); + $colloectText.html('已收藏'); + } + + if (needColloect) { + $colloectIcon.addClass('on'); + $colloectText.html('已收藏'); + } + } else if (res.code === 401) { + window.setCookie('needColloect', '1', { + path: '/', + domain: '.yohobuy.com', + expires: 90 + }); + location.href = res.url; + } + } + }); +} + +$shopCollect.on('click', function() { + colloectAction(); +}); + +if (window.cookie('needColloect') * 1 === 1) { + colloectAction(); + window.setCookie('needColloect', '', { + path: '/', + domain: '.yohobuy.com', + expires: 1 + }); +} + +// 全部商品使用 pjax 翻页 +$allGoods.pjax('a.pjax', '.goods-wrap', { + timeout: 5000, + scrollTo: false // 默认滚动没有动画,禁止掉 +}).on('pjax:end', function() { + product.init(4); + lazyLoad($('img.lazy')); + + $fixedArea = $allGoods.find('.fixed-area'); // 翻页后 fixed-area 区域有变化,需要更新选择器 + + // 分页后移动到全部商品 + $('html, body').animate({ + scrollTop: $allGoods.offset().top - 30 + }); +}).on('click', '.menu-list li', function() { + var $this = $(this); + + $this.siblings().removeClass('on'); + $this.addClass('on'); +}); + +$(window).on('scroll', function() { + var scrollTop = $(this).scrollTop(); + + if (scrollTop > fixedAreaTop) { + $fixedArea.css({ + position: 'fixed', + top: 0 + }); + } else { + $fixedArea.css({ + position: 'static', + top: 0 + }); + } +}); diff --git a/web-static/sass/product/_index.css b/web-static/sass/product/_index.css index cee6579..9f12522 100644 --- a/web-static/sass/product/_index.css +++ b/web-static/sass/product/_index.css @@ -10,6 +10,7 @@ @import "hot-rank"; @import "shop-entry"; @import "detail"; +@import "shop-index"; .product-page { /*分页*/ diff --git a/web-static/sass/product/_shop-index.css b/web-static/sass/product/_shop-index.css new file mode 100644 index 0000000..3cb151c --- /dev/null +++ b/web-static/sass/product/_shop-index.css @@ -0,0 +1,587 @@ +.shop-index-page { + margin: 10px auto 30px; + width: 1150px; + + .shop-banner { + position: relative; + + .shop-name { + position: absolute; + left: 260px; + bottom: 20px; + font-size: 36px; + color: #fff; + } + + .banner-img { + width: 100%; + height: 150px; + } + + .opt-wrap { + position: absolute; + top: 65%; + right: 0; + padding: 0 10px; + } + + .shop-intro, + .shop-collect { + display: inline-block; + width: 110px; + height: 30px; + margin-right: 10px; + font-size: 16px; + line-height: 30px; + text-align: center; + color: #fff; + border: 1px solid #fff; + cursor: pointer; + + i { + background-repeat: no-repeat; + float: left; + position: relative; + left: 11px; + top: 5px; + } + + .shop-intro-ico { + width: 16px; + height: 20px; + background-image: resolve(/product/shop-instro.png); + margin-right: 12px; + } + + .shop-collect-ico { + width: 20px; + height: 19px; + background-image: resolve(/product/shop-collection.png); + top: 6px; + margin-right: 12px; + + &.on { + background-image: resolve(/product/shop-collection-on.png); + } + } + } + } + + .shop-nav { + box-sizing: border-box; + margin-bottom: 30px; + padding: 0 20px; + width: 100%; + height: 40px; + color: #fff; + background: #000; + font-size: 16px; + + a { + position: relative; + top: 8px; + display: inline-block; + line-height: 26px; + color: #fff; + } + + .nav-item { + position: relative; + float: left; + width: 160px; + text-align: center; + + &.first { + width: 100px; + text-align: left; + } + } + + .current { + a { + border-bottom: 2px solid #fff; + } + } + } + + .coupon { + margin-top: 20px; + width: 100%; + height: 80px; + + .coupon-title { + width: 162px; + height: 100%; + background: url(/product/coupon-title.png); + } + } + + .slider-wrap { + height: 360px; + } + + .slider-left { + float: left; + margin-right: 10px; + width: 660px; + height: 100%; + overflow: hidden; + + img { + width: 100%; + height: 100%; + } + + .slide-pagination, + .slide-switch { + display: none; + } + } + + .slider-right { + float: left; + width: 300px; + height: 100%; + + .slider-item { + display: block; + margin-bottom: 10px; + width: 100%; + height: 175px; + } + } + + .floor-header { + margin-top: 50px; + } + + .new-arrivel, + .hot-single { + width: 980px; + + .item { + float: left; + position: relative; + margin-right: 10px; + margin-bottom: 20px; + width: 235px; + height: 315px; + font-size: 14px; + text-align: center; + line-height: 1.5; + background: #f5f5f5; + + img { + width: 235px; + height: 250px; + } + + .title { + width: 220px; + padding: 0 5px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + } + } + + .hat { + position: absolute; + top: 0; + right: 0; + width: 50px; + height: 50px; + color: #ffc513; + text-align: center; + line-height: 57px; + background: url(/product/hat.png); + } + } + + .mask { + background-color: #000; + opacity: .5; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1001; + display: none; + cursor: pointer; + } + + .pop-shop-intro { + display: none; + } + + .shop-intro-bg { + width: 908px; + height: 604px; + background-color: #000; + opacity: .5; + position: fixed; + left: 50%; + top: 50%; + z-index: 1002; + margin: -302px 0 0 -454px; + } + + .shop-intro-area { + width: 898px; + height: 594px; + padding: 60px 10px 35px 40px; + background-color: #fff; + position: fixed; + left: 50%; + top: 50%; + margin: -297px 0 0 -449px; + z-index: 1003; + box-sizing: border-box; + + .close-btn { + width: 18px; + height: 18px; + background-image: resolve(/product/shop-instro-close.png); + position: absolute; + right: 20px; + top: 20px; + cursor: pointer; + } + + .brand-cont { + overflow: auto; + width: 100%; + height: 499px; + padding-right: 30px; + box-sizing: border-box; + } + + .intro-title { + float: left; + + h2 { + width: 100%; + float: left; + text-align: left; + font-size: 26px; + font-weight: bold; + color: #000; + font-style: italic; + } + + p { + font-family: "黑体"; + font-size: 20px; + text-align: left; + padding: 10px 0; + float: left; + } + } + + .intro-cont { + width: 100%; + float: left; + margin-top: 55px; + font-size: 14px; + line-height: 20px; + + p { + text-indent: 2em; + } + + img { + width: 100%; + margin-top: 10px; + } + } + } + + .fixed-area { + background: #fff; + z-index: 1; + width: 970px; + } + + .all-goods-menu { + width: 100%; + height: 40px; + line-height: 40px; + + .menu-tag { + color: #d0021b; + font-size: 18px; + font-weight: bold; + text-align: left; + padding: 0 20px 0 10px; + border-right: 1px solid #000; + float: left; + } + + .menu-list { + width: 810px; + height: 40px; + overflow: hidden; + float: left; + font-size: 14px; + + li { + display: inline-block; + padding: 0 15px; + } + + .on { + background: #000; + height: 28px; + line-height: 28px; + + a { + color: #fff; + } + } + } + + .more { + font-size: 14px; + float: right; + } + } + + .sort-pager .sort-type:first-child .iconfont { + display: inline-block; + } + + .loading { + position: relative; + width: 100%; + text-align: center; + + a { + display: block; + height: 35px; + width: 120px; + margin: 0 auto 0; + background-color: #000; + color: #fff; + font-size: 14px; + line-height: 35px; + text-align: center; + } + } + + .trend-info { + width: 100%; + + .trend-list { + width: 100%; + + li { + float: left; + width: 316px; + margin-left: 10px; + text-align: center; + + &:first-child { + margin-left: 0; + } + } + + img { + width: 100%; + height: 181px; + } + + .main-title, + .sub-title { + box-sizing: border-box; + font-size: 16px; + margin-top: 15px; + padding: 0 10px; + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + line-height: 24px; + } + + .sub-title { + margin-top: 0; + font-size: 14px; + } + } + } + + .goods-container { + .good-info { + width: 235px; + height: auto; + margin-bottom: 35px; + } + + .good-detail-text { + text-align: left; + } + } + + .left-modular { + width: 160px; + font-size: 14px; + margin-top: 20px; + float: left; + + .title { + width: 100%; + height: 25px; + line-height: 25px; + background: #000; + color: #fff; + font-family: "黑体"; + padding-left: 14px; + box-sizing: border-box; + } + + .left-list { + width: 100%; + margin-top: 5px; + + li { + width: 100%; + height: 42px; + line-height: 42px; + background: #f5f5f5; + float: left; + box-sizing: border-box; + margin-top: 5px; + padding-left: 14px; + + a { + color: #000; + } + + &.on { + border: 1px solid #000; + } + } + } + } + + .classic-recommend { + .left-list li { + height: 50px; + line-height: 50px; + } + + .classic-name { + width: 96px; + display: inline-block; + line-height: 14px; + vertical-align: middle; + + .name { + font-size: 14px; + } + + .en-name { + font-size: 12px; + } + } + + img { + width: 40px; + max-height: 40px; + margin-right: 5px; + vertical-align: middle; + } + } + + .sell-recommend { + .left-list li { + padding-left: 0; + height: auto; + margin-bottom: 25px; + line-height: inherit; + + img { + width: 100%; + } + } + } + + ::-webkit-scrollbar { + width: 16px; + height: 16px; + } + + ::-webkit-scrollbar-track, + ::-webkit-scrollbar-thumb { + border-radius: 999px; + border: 5px solid transparent; + } + + ::-webkit-scrollbar-track { + box-shadow: 0 0 6px rgba(0, 0, 0, 0) inset; + } + + ::-webkit-scrollbar-thumb { + min-height: 20px; + background-clip: content-box; + box-shadow: 0 0 0 6px rgba(0, 0, 0, .3) inset; + } + + ::-webkit-scrollbar-corner { + background: transparent; + } + + .page-nav { + padding: 7px 0; + float: right; + font-size: 14px; + + .page-prev { + width: 33px; + height: 33px; + background: #ccc; + text-align: center; + float: left; + } + + .arrow-left { + width: 10px; + height: 10px; + display: inline-block; + position: relative; + top: -7px; + background: resolve(/product/arrow-left.png) no-repeat; + } + + a .page-prev, + a .page-next { + background: #000; + color: #fff; + } + + .page-next { + min-width: 110px; + height: 33px; + background: #a9a9a9; + float: left; + margin-left: 1px; + line-height: 33px; + padding-left: 10px; + box-sizing: border-box; + padding-right: 10px; + } + + .arrow-right { + width: 10px; + height: 10px; + display: inline-block; + vertical-align: middle; + background: resolve(/product/arrow-right.png) no-repeat; + } + + .pages { + margin-left: 10px; + } + } +} diff --git a/yohobuy/www.yohobuy.com/application/models/Product/Brands.php b/yohobuy/www.yohobuy.com/application/models/Product/Brands.php index 698a949..c1de60b 100644 --- a/yohobuy/www.yohobuy.com/application/models/Product/Brands.php +++ b/yohobuy/www.yohobuy.com/application/models/Product/Brands.php @@ -152,23 +152,12 @@ class BrandsModel /** * 根据品牌域名处理相关品牌参数 * @param $domain (品牌域名) - * @param $type (根据type调取同一接口不同的数据) * @return array|bool */ - public static function getBrandByDomain($domain, $type) + public static function getBrandByDomain($domain) { - //根据传来的type值,选择请求需要的数据 - switch ($type) { - case 1: - $fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_domain,brand_alif,brand_banner,brand_ico,static_content_code'; - break; - case 2: - $fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_banner,brand_ico,brand_intro'; - default: - break; - } //调用接口获得数据 - $brandInfo = BrandData::getBrandLogoByDomain($domain, $fields); + $brandInfo = BrandData::getBrandLogoByDomain($domain); $result = array(); //组装品牌页顶部banner条需要的数据 if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) { @@ -178,6 +167,10 @@ class BrandsModel $result['brandNameEn'] = isset($brandInfo['data']['brand_name_en']) ? $brandInfo['data']['brand_name_en'] : ''; $result['brandNameCn'] = isset($brandInfo['data']['brand_name_cn']) ? $brandInfo['data']['brand_name_cn'] : ''; $result['brandAbout'] = isset($brandInfo['data']['brand_intro']) ? $brandInfo['data']['brand_intro'] : ''; + $result['shopTemplateType'] = isset($brandInfo['data']['shop_template_type']) ? + intval($brandInfo['data']['shop_template_type']) : ''; + $result['type'] = isset($brandInfo['data']['type']) ? $brandInfo['data']['type'] : 0; + $result['shopId'] = isset($brandInfo['data']['shop_id']) ? $brandInfo['data']['shop_id'] : ''; } else { return false; diff --git a/yohobuy/www.yohobuy.com/application/models/Product/Shop.php b/yohobuy/www.yohobuy.com/application/models/Product/Shop.php new file mode 100644 index 0000000..8d62f66 --- /dev/null +++ b/yohobuy/www.yohobuy.com/application/models/Product/Shop.php @@ -0,0 +1,645 @@ +<?php +namespace Product; +use Product\SearchModel; +use LibModels\Web\Product\SearchData; +use LibModels\Web\Product\ShopData; +use Api\Yohobuy; +use WebPlugin\HelperSearch; +use LibModels\Web\Guang\ListData as GuangListData; +use WebPlugin\Helpers; +/** + * 品牌店铺的模型 + * + * @copyright yoho.inc + * @author xiaoxiao.hao <xiaoxiao.hao@yoho.cn> + */ +class ShopModel +{ + private static $shopListUrl = '/shoplist'; + + public static function getData($shopId, $parameters) + { + $data = array('shopTopBanner' => array(), 'hotSingle'=> array()); + $parameters['shopId'] = $shopId; + + $shopList = ShopData::shopsDecoratorList($shopId); + if (isset($shopList['data']['list']) && $shopList['code'] === 200) { + foreach ($shopList['data']['list'] as $list) { + $fun = $list['resource_name']; + if (is_callable("self::$fun")) { + $list = self::$fun(self::getResourceData($list), $parameters); + switch ($fun) { + case 'newProducts': + $data['newArrivel']['name'] = '新品上架 NEW'; + $data['newArrivel']['list'] = $list; + break; + case 'hotProducts': + $data['hotSingle']['name'] = '人气单品 HOT'; + $data['hotSingle']['list'] = $list; + break; + case 'goodsTabBar': + if (isset($list['hot'])) { + $data['hotSingle']['navs'] = $list['hot']; + } + if ($list['new']) { + $data['newArrivel']['navs'] = $list['new']; + } + break; + case 'brandBrowse': + $data['brandBrowse'] = array('title' => '品牌集合', 'list'=> $list); + break; + case 'recommend': + $data['recommend'] = array( + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '经典推荐', + 'list'=> $list + ); + break; + case 'hotRecommend': + $data['hotRecommend'] = array( + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '热销推荐', + 'list'=> $list + ); + break; + default : + $data[$fun] = $list; + } + } + } + } else { + headers_sent() || header('Location: /error.html'); + exit(); + } + + //店铺介绍 + $data['brandIntro'] = self::getIntro($shopId, $parameters['uid']); + + //搜索店铺全部商品 + $searchCondition = SearchModel::searchCondition($parameters['condition'], $parameters['options']); + + // 组合搜索商品url + $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); + // 组合搜索分类url + $sortCondition = array(); + if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) { + $sortCondition['needSmallSort'] = 1; + } + $urlList['sort'] = SearchData::getClassesUrl($sortCondition); + + //批量调接口获取数据 + $res = Yohobuy::getMulti($urlList); + + //新品上架 + if (isset($parameters['navBar']) && $parameters['navBar'] * 1 === 3) { + $searchCondition['options']['isNew'] = true; + } + + // 组织模板数据 + $result = HelperSearch::getList($res, $searchCondition['options'], $searchCondition['userInput']); + $data['pathNav'] = array_merge( + HelperSearch::$listNav, + array( + array('href'=> '', 'name' => $data['brandIntro']['brandName'], 'title' => $data['brandIntro']['brandName']) + ) + ); + + $sort = self::getSort($res['sort'], $parameters['options']['misort'], $shopId); + $searchCondition['userInput'] = empty($searchCondition['userInput']) ? array() : $searchCondition['userInput']; + $param = array_merge($searchCondition['userInput'], array('navBar' => 1)); + $data['allGoods']['list'] = $result['goods']; + $data['allGoods']['name'] = '全部商品 ALL'; + $data['allGoods']['opts'] = $result['opts']; + $data['leftContent'] = isset($result['leftContent']) ? $result['leftContent'] : ''; + $data['allGoods']['goodsMenu']['menuList'] = $sort; + $data['allGoods']['href'] = self::$shopListUrl . '?'.http_build_query($param); + + return $data; + } + + + /** + * 店铺列表页 + */ + public static function getShopListData($shopId, $parameters) + { + $data = array('shopTopBanner' => array(), 'hotSingle'=> array()); + $parameters['shopId'] = $shopId; + + $shopList = ShopData::shopsDecoratorList($shopId); + + if (isset($shopList['data']['list']) && $shopList['code'] === 200) { + foreach ($shopList['data']['list'] as $list) { + $fun = $list['resource_name']; + if (is_callable("self::$fun")) { + $list = self::$fun(self::getResourceData($list), $parameters); + switch ($fun) { + case 'newProducts': + case 'hotProducts': + break; + case 'goodsTabBar': + if (isset($list['hot'])) { + $data['hotSingle']['navs'] = $list['hot']; + } else if ($list['new']) { + $data['newArrivel']['navs'] = $list['new']; + } + break; + case 'brandBrowse': + $data['brandBrowse'] = array('title' => '品牌集合', 'list'=> $list); + break; + case 'recommend': + $data['recommend'] = array( + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '经典推荐', + 'list'=> $list + ); + break; + case 'hotRecommend': + $data['hotRecommend'] = array( + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '热销推荐', + 'list'=> $list + ); + break; + default : + $data[$fun] = $list; + } + } + } + } + + //店铺介绍 + $data['brandIntro'] = self::getIntro($shopId, $parameters['uid']); + + + //搜索店铺全部商品 + $searchCondition = SearchModel::searchCondition($parameters['condition'], $parameters['options']); + + // 组合搜索商品url + $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); + // 组合搜索分类url + $sortCondition = array(); + if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) { + $sortCondition['needSmallSort'] = 1; + } + $urlList['sort'] = SearchData::getClassesUrl($sortCondition); + + //批量调接口获取数据 + $res = Yohobuy::getMulti($urlList); + + //新品上架 + if (isset($parameters['navBar']) && $parameters['navBar'] * 1 === 3) { + $searchCondition['options']['isNew'] = true; + } + + // 组织模板数据 + $result = HelperSearch::getList($res, $searchCondition['options'], $searchCondition['userInput']); + + $data['pathNav'] = $result['pathNav']; + + $data['goods'] = $result['goods']; + $data['opts'] = $result['opts']; + $data['leftContent'] = isset($result['leftContent']) ? $result['leftContent'] : ''; + $data['filters'] = $result['filters']; + $data['pathNav'] = $result['pathNav']; +// $data['name'] = '全部商品 ALL'; +// $sort = self::getSort($res['sort']); +// $data['goodsMenu']['menuList'] = $sort; + + return $data; + + } + + + //异步获取全部商品goods数据 + public static function getGoods($condition, $options) + { + //搜索店铺全部商品 + $searchCondition = SearchModel::searchCondition($condition, $options); + + // 组合搜索商品url + $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); + // 组合搜索分类url + $sortCondition = array(); + if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) { + $sortCondition['needSmallSort'] = 1; + } + $urlList['sort'] = SearchData::getClassesUrl($sortCondition); + + //批量调接口获取数据 + $res = Yohobuy::getMulti($urlList); + + // 组织模板数据 + $result = HelperSearch::getList($res, $searchCondition['options'], $searchCondition['userInput']); + + $sort = self::getSort($res['sort'], $options['misort'], $condition['shop']); + $data['goodsMenu']['menuList'] = $sort; + $data['list'] = $result['goods']; + $data['opts'] = $result['opts']; + + return $data; + } + + + /** + * 店铺Banner 资源位 + * @param type $data [] + */ + public static function shopTopBanner($data) + { + $result = array( + 'banner' => '', + 'bannerHeight' => 150 + ); + + if (isset($data['resource_data'][0]['shopSrc'])) { + $result['banner'] = self::imageView2($data['resource_data'][0]['shopSrc'], 1150, 150); + } + + return $result; + + } + /** + * 导航栏 资源位 + * @param type $data + * @return type [] + */ + public static function navigationBar($data, $parameters = array()) + { + $shopNav = array( + array( + 'name' => '店铺首页', + 'url' => '/?navBar=0', + ), + array( + 'name' => '全部商品', + 'url' => self::$shopListUrl . '?navBar=1', + 'arrow' => true, + ), + array( + 'name' => '人气单品', + 'url' => self::$shopListUrl . '?navBar=2&order=s_n_desc', + ), + array( + 'name' => '新品上架', + 'url' => self::$shopListUrl . '?navBar=3&order=s_t_desc', + ), + ); + + if(isset($data['resource_data']) && is_array($data['resource_data'])) { + $shopNav = array_merge($shopNav, array_filter($data['resource_data'], function($v) { + if (empty($v['url'])) { + return false; + } + return $v; + })); + } + + //选中状态 + if (isset($parameters['navBar']) && count($shopNav) >= $parameters['navBar'] && $parameters['navBar'] >= 0) { + $shopNav[$parameters['navBar']]['current'] = true; + } else { + $shopNav[0]['current'] = true; + } + + return $shopNav; + } + /** + * 资源位小图 + * @param type $data + */ + public static function oneRowTwoColImages($data) + { + $oneData = array(); + $twoData = array(); + + foreach ($data['resource_data'] as $resource) { + + if (empty($resource['data'])) { + continue; + } + + foreach ($resource['data'] as $key => $val) { + + $temp = array( + 'img' => self::imageView2($val['src'], 300, 175), + 'url' => $val['url'], + ); + + if ($key === 0) { + $oneData[] = $temp; + } else { + $twoData[] = $temp; + } + } + } + + return array_slice(array_merge($oneData, $twoData), 0, 2); + } + + /** + * 资源位大图 + * @param type $data + * @return type [] + */ + public static function largeSlideImg($data) + { + $result = array(); + + foreach ($data['resource_data'] as $resource) { + + if (empty($resource['data'])) { + continue; + } + + foreach ($resource['data'] as $val) { + $result[] = array( + 'img' => self::imageView2($val['src'], 660, 360), + 'url' => $val['url'], + ); + } + } + + return $result; + } + + /** + * 经典推荐 + * @param type $data + * @return type [] + */ + public static function recommend($data) + { + $result = array(); + + foreach ($data['resource_data'] as $resource) { + $result[] = array( + 'enName'=> $resource['enName'], + 'name'=> $resource['name'], + 'img'=> self::imageView2($resource['src'], 50, 50), + 'title'=> $resource['title'], + 'url'=> $resource['url'], + ); + } + + return $result; + } + + /** + * 热门推荐 + * @param type $data + * @return type [] + */ + public static function hotRecommend($data) + { + $result = array(); + + foreach ($data['resource_data'] as $resource) { + $result[] = array( + 'img'=> self::imageView2($resource['src'], 160, 240), + 'title'=> $resource['title'], + 'url'=> $resource['url'], + ); + } + + return $result; + } + + /** + * 品牌一览 + * @param type $data + * @return type [] + */ + public static function brandBrowse($data, $parameters = array()) + { + $result = array(); + $brand = isset($parameters['brand']) ? $parameters['brand'] : ''; + + foreach ($data['resource_data'] as $resource) { + $result[] = array( + 'url' => Helpers::url( + self::$shopListUrl, + array( + 'brand' => $resource['id'], + 'navBar' => 1 + ), + '' + ), + 'brandName' => $resource['brandName'], + 'cur' => ($brand === strval($resource['id'])) + ); + } + + return $result; + } + /** + * 商品标签栏 + * @param type $data + * @return type [] + */ + public static function goodsTabBar($data) + { + $result = array(); + + if (isset($data['resource_data'])) { + $result = $data['resource_data']; + } + return $result; + } + + /** + * 新品上架 + * @param type $data + * @return type [] + */ + public static function newProducts($data) + { + $result = array(); + + foreach ($data['resource_data'] as $resource) { + $result[] = array( + 'productId'=> $resource['productId'], + 'title'=> $resource['productName'], + 'productSkn'=> $resource['productSkn'], + 'price'=> '¥' . number_format(trim($resource['salesPrice'], '¥'), 2, '.', ''), + 'img'=> self::imageView2($resource['src'], 250, 340), + 'url'=> Helpers::getProductUrl($resource['productId'], $resource['productSkn'], $resource['productName']), + ); + } + return $result; + } + + /** + * 人气单品 + * @param type $data + * @return type [] + */ + public static function hotProducts($data) + { + $result = array(); + + foreach ($data['resource_data'] as $key => $resource) { + $result[] = array( + 'productId'=> $resource['productId'], + 'title'=> $resource['productName'], + 'productSkn'=> $resource['productSkn'], + 'price'=> '¥' . number_format(trim($resource['salesPrice'], '¥'), 2, '.', ''), + 'img'=> self::imageView2($resource['src'], 250, 340), + 'url'=> Helpers::getProductUrl($resource['productId'], $resource['productSkn'], $resource['productName']), + 'index'=> $key + 1 + ); + } + + return $result; + } + /** + * 潮流资讯 + * @param type string $tag 搜索内容 + * @return array [] + */ + public static function getArticle($tag = '') + { + $result = array(); + + $article = GuangListData::article('1,2,3', 0, 0, '', 0, $tag, '', 3); + if (!isset($article['data']['list']['artList'])) { + return $result; + } + + foreach ($article['data']['list']['artList'] as $artList) { + $result['trendList'][] = array( + 'href' => $artList['url'], + 'src' => self::imageView2(substr($artList['src'], 0, strpos($artList['src'], '?')), 264, 173), + 'mainTitle' => $artList['title'], + 'Subtitle' => $artList['intro'] + ); + } + + if (count($result['trendList']) < 3) { + return array(); + } + + $result['name'] = '潮流资讯 HOT ITEMS'; + + return $result; + } + + /** + * 缩略图 + * @param type $src 图片路径 + * @param type $width 宽 + * @param type $heigh 高 + * @return type string src + */ + public static function imageView2($src, $width, $heigh) + { + $src .= strstr($src, '?') ? '&' : '?'; + + return "{$src}imageView2/1/w/{$width}/h/{$heigh}"; + } + + /** + * 解析resource_data 参数 + * @param type $data + * @return type [] + */ + public static function getResourceData($data) + { + $data['resource_data'] = isset($data['resource_data']) ? json_decode($data['resource_data'], true) : array(); + + return $data; + } + + public static function shopsDecoratorList($shopId) + { + return ShopData::shopsDecoratorList($shopId); + } + + public static function getIntro($shopId, $uid) + { + $data = array('brandName' => '', 'brandCont' => '', 'domain'=> '', 'logo'=> '', 'is_favorite'=> false); + + $intro = ShopData::getIntro($shopId, $uid); + + if ($intro['code'] === 200 && isset($intro['data'])) { + $data = array( + 'brandName'=> $intro['data']['shop_name'], + 'brandCont'=> $intro['data']['shop_intro'], + 'domain'=> $intro['data']['shop_domain'], + 'logo'=> $intro['data']['shop_logo'], + 'isFavorite'=> ($intro['data']['is_favorite'] === 'Y'), + 'multBrandShopType'=> $intro['data']['mult_brand_shop_type'] + ); + } + + $data['shopId'] = $shopId; + return $data; + } + + + //获取二级品类(按库存排名取前15个二级品类) + public static function getSort($sort, $misort, $shopId) + { + $result = array(); + $i=0; + if (empty($sort['sort'])) { + return $result; + } + foreach($sort['sort'] as $key=>$value) { + foreach($value['sub'] as $k=>$v) { + $result[$i]['href'] = '/?msort='.$value['sort_id'].'&misort='.$v['sort_id'].'&shopId='.$shopId; + $result[$i]['name'] = $v['sort_name']; + $result[$i]['count'] = $v['count']; + $result[$i]['orderBy'] = $v['order_by']; + $result[$i]['misort'] = $v['sort_id']; + $i++; + } + } + foreach($result as $key=>$value) { + $count[$key] = $value['count']; + $sortName[$key] = $value['name']; + } + + $arr=array(); + array_multisort($count,SORT_DESC,$sortName,$result); + $result = array_slice($result,0,15); + + foreach($result as &$value) { + if($value['misort'] == $misort) { + $value['curMenu'] = true; + } + } + + return $result; + } + + + public static function getShopsBrands($shopId) + { + return ShopData::getShopsBrands($shopId); + } + + public static function getSearch($shopId) + { + return ShopData::getSearch($shopId); + } + + public static function getSortInfo($shopId, $yhChannel = '', $gender = '') + { + return ShopData::getSortInfo($shopId, $yhChannel, $gender); + } + + public static function setFavorite($shopId, $isfavorite, $uid, $type = 'shop') + { + return ShopData::setFavorite($shopId, $isfavorite, $uid, $type); + } + + public static function byDomain($domain) + { + $data = array('shop_id' => '', 'type' => ''); + + $result = ShopData::byDomain($domain); + + if (isset($result['code']) && $result['code'] === 200 && !empty($result['data'])) { + $data = $result['data']; + } + + return ShopData::byDomain($domain); + } +} \ No newline at end of file diff --git a/yohobuy/www.yohobuy.com/application/modules/Product/controllers/Index.php b/yohobuy/www.yohobuy.com/application/modules/Product/controllers/Index.php index 9a7c262..43fd003 100644 --- a/yohobuy/www.yohobuy.com/application/modules/Product/controllers/Index.php +++ b/yohobuy/www.yohobuy.com/application/modules/Product/controllers/Index.php @@ -7,10 +7,11 @@ use Product\HotrankModel; use Index\HomeModel; use WebPlugin\Helpers; use LibModels\Web\Product\BrandData; +use Product\ShopModel; class IndexController extends WebAction { - + private $_information = array('code' => 400, 'message' => '操作失败,请稍后再试!'); /** * 品牌首页 */ @@ -22,11 +23,27 @@ class IndexController extends WebAction $this->go(SITE_MAIN); } //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页 - $type = 1; - $result = BrandsModel::getBrandByDomain($domain, $type); + $result = BrandsModel::getBrandByDomain($domain); if (!$result) { $this->go(SITE_MAIN); } + + $type = intval(isset($result['type']) ? $result['type'] : ''); + switch ($type) { + case 1: + //无单品店有多品店:1--->搜索页 + $this->go('http://search.yohobuy.com/?query=' . $domain); + exit(0); + break; + case 2: + //店铺页面 + //$shopTemplateType 1基础模板,2经典模板, + if ($result['shopTemplateType'] === 2 && !empty($result['shopId'])) { + $this->shopHome($result['shopId']); + exit(0); + } + break; + } //获取uid $uid = $this->getUid(); @@ -125,8 +142,7 @@ class IndexController extends WebAction //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页 - $type = 2; - $result = BrandsModel::getBrandByDomain($domain, $type); + $result = BrandsModel::getBrandByDomain($domain); if (!$result) { $this->go(SITE_MAIN); } @@ -260,4 +276,148 @@ class IndexController extends WebAction } + /** + * 品牌店铺首页 + */ + public function shopHome($shopId) + { + $domain = $this->param('named'); + // 设置头部数据 + $this->setWebNavHeader(); + $misort = $this->get('misort'); + + $pjax = $this->get('_pjax'); + if ($pjax) { + $data = ShopModel::getGoods( + array( + 'shop' => $shopId + ), + array( + 'controller' => 'Index', + 'action' => 'index', + 'misort' => $misort + ) + ); + $data['shopIndexPage'] = true; + // 渲染模板 + $this->_view->display('goods-list', $data); + exit(); + } + + //获取uid + $uid = $this->getUid(); + + $parameters = array( + 'condition' => array( + 'shop' => $shopId + ), + 'options' => array( + 'controller' => 'Index', + 'action' => 'index', + 'misort' => $misort + ), + 'uid' => $uid, + 'navBar' => $this->get('navBar', 0), + 'brand' => $this->get('brand', 0) + ); + + $data = array_merge( + array( + 'shopIndexPage' => true, + 'pathNav' => false, // pathNav数据结构同其他页面 + 'coupon' => false, // 先不做 + 'trendInfo' => ShopModel::getArticle($domain), + ), + ShopModel::getData($shopId, $parameters) + ); + + $this->_view->display('shop-index', $data); + } + + //店铺列表页 + public function shopListAction() + { + //品牌域名,没有获取到品牌域名的跳转首页 + $domain = $this->param('named'); + + //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页 + $result = BrandsModel::getBrandByDomain($domain); + + if (isset($result['code']) && $result['code'] !== 200 || empty($result['shopId'])) { + $this->go(SITE_MAIN); + } + + $shopId = $result['shopId']; + + //获取uid + $uid = $this->getUid(); + + // 设置头部数据 + $this->setWebNavHeader(); + + $parameters = array( + 'condition' => array( + 'shop' => $shopId + ), + 'options' => array( + 'controller' => 'Index', + 'action' => 'index', + ), + 'uid' => $uid, + 'navBar' => $this->get('navBar', 1), + 'brand' => $this->get('brand', 0) + ); + + $data = array_merge( + array( + 'shopIndexPage' => true, + 'pathNav' => false, // pathNav数据结构同其他页面 + 'coupon' => false, // 先不做 + ), + ShopModel::getShopListData($shopId, $parameters) + ); + + $this->_view->display('shop-list', $data); + + } + + /** + * 店铺收藏与取消 + * @return type json + */ + public function setFavoriteAction() + { + $result = $this->_information; + if (!$this->isAjax()) { + return; + } + + //获取uid + $uid = $this->getUid(); + + do{ + if (empty($uid)) { + $result = array( + 'code' => 401, + 'message' => '请先登录!', + 'url' => Helpers::url('/signin.html', array(), 'default') + ); + break; + } + $shopId = $this->post('shopId'); + $isFavorite = $this->post('isFavorite'); + $needColloect = $this->post('needColloect', 0); + + if (empty($shopId)) { + break; + } + + //$needColloect 说明刚登录状态 是cookie传的值 + $isFavorite = $needColloect * 1 === 1 ? true : $isFavorite; + $result = ShopModel::setFavorite($shopId, $isFavorite, $uid); + + } while (false); + + $this->echoJson($result); + } } diff --git a/yohobuy/www.yohobuy.com/configs/routes.product.ini b/yohobuy/www.yohobuy.com/configs/routes.product.ini index a1c04a0..23528ac 100644 --- a/yohobuy/www.yohobuy.com/configs/routes.product.ini +++ b/yohobuy/www.yohobuy.com/configs/routes.product.ini @@ -49,6 +49,20 @@ routes.item.route.action = Index routes.item.map.1 = productId routes.item.map.2 = goodsId +;店铺装修 +routes.brandshopList.type = "rewrite" +routes.brandshopList.match = "/shoplist" +routes.brandshopList.route.module = Product +routes.brandshopList.route.controller = Index +routes.brandshopList.route.action = shopList + +;店铺装修-收藏与取消 +routes.brandFavorite.type = "rewrite" +routes.brandFavorite.match = "/shoplist/setFavorite" +routes.brandFavorite.route.module = Product +routes.brandFavorite.route.controller = Index +routes.brandFavorite.route.action = setFavorite + routes.itemshow.type = "regex" routes.itemshow.match = "#/product/show_([0-9]+)_([0-9]+).html#" routes.itemshow.route.module = Product