Authored by 郝肖肖

pc 店铺装修 代码移入

  1 +<?php
  2 +
  3 +namespace LibModels\Web\Product;
  4 +
  5 +use Api\Yohobuy;
  6 +use Api\Sign;
  7 +/**
  8 + * 品牌店铺的接口
  9 + * @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
  10 + * @copyright yoho.inc
  11 + * @author xiaoxiao.hao <xiaoxiao.hao@yoho.cn>
  12 + */
  13 +class ShopData
  14 +{
  15 + /**
  16 + * 获取店铺装修的所有资源接口
  17 + * @param type int $shopId 店铺id
  18 + * @return type []
  19 + */
  20 + public static function shopsDecoratorList($shopId)
  21 + {
  22 + $param = Yohobuy::param();
  23 + $param['method'] = 'app.shopsdecorator.getList';
  24 + $param['shop_id'] = intval($shopId);
  25 + $param['client_secret'] = Sign::getSign($param);
  26 +
  27 + return Yohobuy::get(Yohobuy::API_URL, $param);
  28 + }
  29 + /**
  30 + * 查询店铺介绍接口
  31 + * @param type int $shopId 店铺id
  32 + * @return type []
  33 + */
  34 + public static function getIntro($shopId, $uid = '')
  35 + {
  36 + $param = Yohobuy::param();
  37 + $param['method'] = 'app.shops.getIntro';
  38 + $param['shop_id'] = intval($shopId);
  39 + $param['uid'] = $uid;
  40 + $param['client_secret'] = Sign::getSign($param);
  41 +
  42 + return Yohobuy::get(Yohobuy::API_URL, $param);
  43 + }
  44 +
  45 + /**
  46 + * 查询店铺下面的所有品牌
  47 + * @param type int $shopId 店铺id
  48 + * @return type []
  49 + */
  50 + public static function getShopsBrands($shopId)
  51 + {
  52 + $param = Yohobuy::param();
  53 + $param['method'] = 'app.shops.getShopsBrands';
  54 + $param['shop_id'] = intval($shopId);
  55 + $param['client_secret'] = Sign::getSign($param);
  56 +
  57 + return Yohobuy::get(Yohobuy::API_URL, $param);
  58 + }
  59 +
  60 + /**
  61 + * 搜索店铺内商品 || 查询该店铺下全部商品
  62 + * @param type int $shopId 店铺id
  63 + * @return type []
  64 + */
  65 + public static function getSearch($shopId)
  66 + {
  67 + $param = Yohobuy::param();
  68 + $param['method'] = 'app.search.li';
  69 + $param['shop'] = intval($shopId);
  70 + $param['client_secret'] = Sign::getSign($param);
  71 +
  72 + return Yohobuy::get(Yohobuy::API_URL, $param);
  73 + }
  74 +
  75 + /**
  76 + * 查询该店铺下所有二级品类
  77 + * @param type int $shopId 店铺id
  78 + * @param type string $yhChannel 频道
  79 + * @param type string $gender 性别
  80 + * @return type []
  81 + */
  82 + public static function getSortInfo($shopId, $yhChannel = '', $gender = '')
  83 + {
  84 + $param = Yohobuy::param();
  85 + $param['method'] = 'app.shop.getSortInfo';
  86 + $param['shop_id'] = intval($shopId);
  87 + $param['yh_channel'] = $yhChannel;
  88 + $param['gender'] = $gender;
  89 + $param['client_secret'] = Sign::getSign($param);
  90 +
  91 + return Yohobuy::get(Yohobuy::API_URL, $param);
  92 + }
  93 +
  94 + /**
  95 + * 收藏|取消 店铺接口
  96 + * @param type int $shopId 店铺id
  97 + * @param type Boolean $isfavorite true:收藏,false:取消
  98 + * @param type string $type 收藏的类型,brand、product、shop
  99 + * @return type []
  100 + */
  101 + public static function setFavorite($shopId, $isfavorite, $uid, $type = 'shop')
  102 + {
  103 + $param = Yohobuy::param();
  104 + $param['method'] = $isfavorite ? 'app.favorite.add' : 'app.favorite.cancel';
  105 + $param['id'] = intval($shopId);
  106 + $param['fav_id'] = intval($shopId);
  107 + $param['uid'] = $uid;
  108 + $param['type'] = $type;
  109 + $param['client_secret'] = Sign::getSign($param);
  110 + return Yohobuy::get(Yohobuy::API_URL, $param);
  111 + }
  112 + /**
  113 + * 根据domain查找shop_id
  114 + * @param type string $domain 品牌域名
  115 + * @return type []
  116 + */
  117 + public static function byDomain($domain)
  118 + {
  119 + $param = Yohobuy::param();
  120 + $param['method'] = 'web.brand.byDomain';
  121 + $param['domain'] = $domain;
  122 + $param['client_secret'] = Sign::getSign($param);
  123 + return Yohobuy::get(Yohobuy::API_URL, $param);
  124 + }
  125 +}
@@ -1050,4 +1050,23 @@ class Helpers @@ -1050,4 +1050,23 @@ class Helpers
1050 return true; 1050 return true;
1051 } 1051 }
1052 1052
  1053 + /**
  1054 + * 格式化产品url
  1055 + * @param type int $productId 产品id
  1056 + * @param type $productSkn 产品编号
  1057 + * @param type $productName 产品名称
  1058 + * @param type $cnAlphaBet
  1059 + * @return type url
  1060 + */
  1061 + public static function getProductUrl($productId, $productSkn, $productName = '', $cnAlphaBet = '')
  1062 + {
  1063 + $cnAlphaBet = empty($cnAlphaBet) ? $cnAlphaBet : md5($productName);
  1064 +
  1065 + return self::url(
  1066 + '/product/pro_' . $productId . '_' .
  1067 + $productSkn . '/' . $cnAlphaBet . '.html',
  1068 + null,
  1069 + 'item'
  1070 + );
  1071 + }
1053 } 1072 }
  1 +{{> layout/header}}
  2 +<div class="shop-index-page product-list-page product-page yoho-page center-content home-page">
  3 + <div class="center-content clearfix">
  4 + {{> layout/path-nav}}
  5 +
  6 + {{> product/shop-header}}
  7 +
  8 + <div class="list-left pull-left">
  9 + {{> product/left-content}}
  10 +
  11 + {{> product/shop-sidebar}}
  12 + </div>
  13 + <div class="list-right pull-right">
  14 + {{#if coupon}}
  15 + <div class="coupon clearfix">
  16 + <div class="coupon-title">
  17 + </div>
  18 + </div>
  19 + {{/if}}
  20 + {{#if largeSlideImg}}
  21 + <div class="slider-wrap clearfix">
  22 + <div class="slider-left pull-left">
  23 + <div class="slide-wrapper">
  24 + <ul>
  25 + {{#largeSlideImg}}
  26 + <li>
  27 + <a href="{{url}}"><img src="{{img}}"></a>
  28 + </li>
  29 + {{/largeSlideImg}}
  30 + </ul>
  31 + </div>
  32 + </div>
  33 + <div class="slider-right pull-right">
  34 + {{#oneRowTwoColImages}}
  35 + <a class="slider-item" href="{{url}}"><img src="{{img}}"></a>
  36 + {{/oneRowTwoColImages}}
  37 + </div>
  38 + </div>
  39 + {{/if}}
  40 + {{#newArrivel}}
  41 + <div class="new-arrivel clearfix">
  42 + {{> index/floor-header}}
  43 + {{> product/shop-single-list}}
  44 + </div>
  45 + {{/newArrivel}}
  46 + {{#hotSingle}}
  47 + <div class="hot-single clearfix">
  48 + {{> index/floor-header}}
  49 + {{> product/shop-single-list}}
  50 + </div>
  51 + {{/hotSingle}}
  52 + {{#allGoods}}
  53 + <div class="all-goods clearfix">
  54 + {{> index/floor-header}}
  55 +
  56 + <div class="goods-wrap">
  57 + {{> product/goods-list}}
  58 + </div>
  59 +
  60 + <div class="loading">
  61 + <a href="{{href}}" target= "_blank">查看更多</a>
  62 + </div>
  63 + </div>
  64 + {{/allGoods}}
  65 + {{#trendInfo}}
  66 + <div class="trend-info clearfix">
  67 + {{> index/floor-header}}
  68 +
  69 + <ul class="trend-list">
  70 + {{#each trendList}}
  71 + <li>
  72 + <a href="{{href}}">
  73 + <img src="{{src}}" />
  74 + <div class="main-title">{{mainTitle}}</div>
  75 + <div class="sub-title">{{Subtitle}}</div>
  76 + </a>
  77 + </li>
  78 + {{/each}}
  79 + </ul>
  80 + </div>
  81 + {{/trendInfo}}
  82 + </div>
  83 + </div>
  84 +</div>
  85 +{{> layout/footer}}
  1 +{{> layout/header}}
  2 +<div class="shop-index-page product-list-page product-page yoho-page center-content">
  3 + <div class="center-content clearfix">
  4 + {{> layout/path-nav}}
  5 +
  6 + {{> product/shop-header}}
  7 +
  8 + <div class="list-left pull-left">
  9 + {{> product/left-content}}
  10 +
  11 + {{> product/shop-sidebar}}
  12 + </div>
  13 + <div class="list-right pull-right">
  14 + {{> product/shop-entry}}
  15 +
  16 + {{> product/standard-content}}
  17 +
  18 + {{> product/latest-walk}}
  19 + </div>
  20 + </div>
  21 +</div>
  22 +{{> layout/footer}}
@@ -304,5 +304,10 @@ @@ -304,5 +304,10 @@
304 seajs.use('js/coupon/coupon'); 304 seajs.use('js/coupon/coupon');
305 </script> 305 </script>
306 {{/if}} 306 {{/if}}
307 - 307 +{{!-- 店铺首页 --}}
  308 +{{#if shopIndexPage}}
  309 + <script>
  310 + seajs.use('js/product/shop-index');
  311 + </script>
  312 +{{/if}}
308 313
  1 +<div class="fixed-area">
  2 +{{# goodsMenu}}
  3 + <div class="all-goods-menu">
  4 + <span class="menu-tag">所有商品</span>
  5 + <ul class="menu-list">
  6 + {{#each menuList}}
  7 + <li class="{{#if curMenu}} on {{/if}}"><a class="pjax" href="{{href}}">{{name}}</a></li>
  8 + {{/each}}
  9 + </ul>
  10 + <a href="{{url}}" class="more">MORE</a>
  11 + </div>
  12 +{{/goodsMenu}}
  13 +
  14 +{{# opts}}
  15 + <div class="sort-pager">
  16 + {{# sortType}}
  17 + <a class="sort-type{{#if active}} active{{/if}} pjax" href="{{href}}">
  18 + {{name}}
  19 + {{#if hasSortOrient}}
  20 + {{#if active}}
  21 + {{#if desc}}
  22 + <span class="active-icon iconfont">&#xe603;</span>
  23 + {{^}}
  24 + <span class="active-icon iconfont">&#xe604;</span>
  25 + {{/if}}
  26 + {{^}}
  27 + <span class="iconfont">&#xe614;</span>
  28 + {{/if}}
  29 + {{^}}
  30 + <span class="iconfont">&#xe604;</span>
  31 + {{/if}}
  32 + </a>
  33 + {{/ sortType}}
  34 +
  35 + {{#if list}}
  36 + {{#if oldPage}}
  37 + <div class="pager-wrap">
  38 + <p class="page-orient">
  39 + {{#if preHref}}
  40 + <a class="pjax" href="{{preHref}}">
  41 + <span class="iconfont">&#xe615;</span>
  42 + </a>
  43 + {{^}}
  44 + <span class="dis-icon iconfont">&#xe615;</span>
  45 + {{/if}}
  46 +
  47 + <span>
  48 + <i>{{curPage}}</i>/{{pageCount}}
  49 + </span>
  50 +
  51 + {{#if nextHref}}
  52 + <a class="pjax" href="{{nextHref}}">
  53 + <span class="iconfont">&#xe601;</span>
  54 + </a>
  55 + {{^}}
  56 + <span class="dis-icon iconfont">&#xe601;</span>
  57 + {{/if}}
  58 + </p>
  59 + </div>
  60 + {{^}}
  61 + <div class="page-nav">
  62 + {{#if preHref}}
  63 + <a class="pjax" href="{{preHref}}">
  64 + <span class="page-prev"><i class="arrow-left"></i></span>
  65 + </a>
  66 + {{^}}
  67 + <span class="page-prev"><i class="arrow-left"></i></span>
  68 + {{/if}}
  69 +
  70 + {{#if nextHref}}
  71 + <a class="pjax" href="{{nextHref}}">
  72 + <span class="page-next">
  73 + 下一页
  74 + <i class="arrow-right"></i>
  75 + <i class="pages">{{curPage}}</i>/{{pageCount}}
  76 + </span>
  77 + </a>
  78 + {{^}}
  79 + <span class="page-next">
  80 + 下一页
  81 + <i class="arrow-right"></i>
  82 + <i class="pages">{{curPage}}</i>/{{pageCount}}
  83 + </span>
  84 + {{/if}}
  85 + </div>
  86 + {{/if}}
  87 + {{/if}}
  88 + </div>
  89 +{{/ opts}}
  90 +</div>
  91 +
  92 +<div class="goods-container clearfix">
  93 + {{# list}}
  94 + {{> product/good}}
  95 + {{/list}}
  96 + <div class="good-item-wrapper">
  97 + <div class="good-info-main"></div>
  98 + <div class="good-select-color"></div>
  99 + </div>
  100 +</div>
  1 +{{# shopTopBanner}}
  2 + <div class="shop-banner">
  3 + <div class="banner-img" style="height: {{bannerHeight}}px;background: url({{banner}})"></div>
  4 + {{#if shopsType}}
  5 + <div class="shop-name">
  6 + {{brandName}}
  7 + </div>
  8 + {{/if}}
  9 + <div class="opt-wrap">
  10 + <div class="shop-intro">
  11 + <i class="shop-intro-ico"></i>
  12 + 店铺介绍
  13 + </div>
  14 + <div class="shop-collect" data-id="{{brandIntro.shopId}}">
  15 + <i class="shop-collect-ico {{#if brandIntro.isFavorite}}on{{/if}}"></i>
  16 + <span class="shop-collect-text">
  17 + {{#if brandIntro.isFavorite}}
  18 + 已收藏
  19 + {{else}}
  20 + 收藏
  21 + {{/if}}
  22 + </span>
  23 + </div>
  24 + </div>
  25 + </div>
  26 + {{#brandIntro}}
  27 + <div class="pop-shop-intro">
  28 + <div class="shop-intro-bg"></div>
  29 + <div class="shop-intro-area">
  30 + <i class="close-btn"></i>
  31 + <div class="brand-cont">
  32 + <div class="intro-title">
  33 + <h2>{{brandName}}</h2>
  34 + <p>品牌介绍</p>
  35 + </div>
  36 + <div class="intro-cont">
  37 + {{{brandCont}}}
  38 + </div>
  39 + </div>
  40 + </div>
  41 + </div>
  42 + {{/brandIntro}}
  43 + <div class="mask"></div>
  44 +{{/ shopTopBanner}}
  45 +
  46 +{{#if navigationBar}}
  47 + <ul class="shop-nav clearfix">
  48 + {{#navigationBar}}
  49 + <li class="nav-item {{#if @first}}first{{/if}} {{#if current}}current{{/if}}">
  50 + <a href="{{url}}">
  51 + {{name}}
  52 + {{#if arrow}}
  53 + <span class="iconfont">&#xe63a;</span>
  54 + {{/if}}
  55 + </a>
  56 + </li>
  57 + {{/navigationBar}}
  58 + </ul>
  59 +{{/if}}
  1 +{{#brandBrowse}}
  2 + <div class="brand-collect left-modular">
  3 + <h2 class="title">{{title}}</h2>
  4 + <ul class="left-list">
  5 + {{#each list}}
  6 + <li class="{{#if cur}} on {{/if}}"><a href="{{url}}">{{brandName}}</a></li>
  7 + {{/each}}
  8 + </ul>
  9 + </div>
  10 +{{/brandBrowse}}
  11 +
  12 +{{#recommend}}
  13 + <div class="classic-recommend left-modular">
  14 + <h2 class="title">{{title}}</h2>
  15 + <ul class="left-list">
  16 + {{#each list}}
  17 + <li>
  18 + <a href="{{url}}">
  19 + <div class="classic-name">
  20 + {{#name}}
  21 + <p class="name">{{.}}</p>
  22 + {{/name}}
  23 + {{#enName}}
  24 + <p class="en-name">{{.}}</p>
  25 + {{/enName}}
  26 + </div>
  27 + <img src="{{img}}" />
  28 + </a>
  29 + </li>
  30 + {{/each}}
  31 + </ul>
  32 + </div>
  33 +{{/recommend}}
  34 +
  35 +{{#hotRecommend}}
  36 + <div class="sell-recommend left-modular">
  37 + <h2 class="title">{{title}}</h2>
  38 + <ul class="left-list">
  39 + {{#each list}}
  40 + <li>
  41 + <a target="_blank" href="{{url}}"><img src="{{img}}" alt="{{title}}" /></a>
  42 + </li>
  43 + {{/each}}
  44 + </ul>
  45 + </div>
  46 +{{/hotRecommend}}
  1 +<ul>
  2 + {{#each list}}
  3 + <li>
  4 + <a class="item item-{{@index}}" href="{{url}}" target= "_blank">
  5 + <img class="lazy" data-original="{{img}}"/>
  6 + <p class="title">
  7 + {{title}}
  8 + </p>
  9 + <p class="price">
  10 + {{price}}
  11 + </p>
  12 + {{#if index}}
  13 + <span class="hat">{{index}}</span>
  14 + {{/if}}
  15 + </a>
  16 + </li>
  17 + {{/each}}
  18 +</ul>

21.3 KB | W: | H:

23.7 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
@@ -11,3 +11,5 @@ require('./brand'); @@ -11,3 +11,5 @@ require('./brand');
11 require('./hotrank'); 11 require('./hotrank');
12 12
13 require('./item'); 13 require('./item');
  14 +
  15 +require('./shop-index');
  1 +/**
  2 + * 首页
  3 + * @author: bikai<kai.bi@yoho.cn>
  4 + * @date: 2016/4/26
  5 + */
  6 +
  7 +var $ = require('yoho.jquery'),
  8 + lazyLoad = require('yoho.lazyload'),
  9 + product = require('../product/product');
  10 +
  11 +var $shopIntro = $('.shop-intro'),
  12 + $shopCollect = $('.shop-collect'),
  13 + $sliderLeft = $('.slider-left'),
  14 + $allGoods = $('.all-goods'),
  15 + $fixedArea = $allGoods.find('.fixed-area'),
  16 + fixedAreaTop = $fixedArea.offset() ? $fixedArea.offset().top : 0;
  17 +
  18 +// Pjax
  19 +require('yoho.pjax');
  20 +
  21 +require('../common/slider');
  22 +require('../product/list');
  23 +
  24 +product.init(4);
  25 +
  26 +lazyLoad($('img.lazy'));
  27 +
  28 +if ($sliderLeft.length) {
  29 + $sliderLeft.slider();
  30 +}
  31 +
  32 +$shopIntro.on('click', function() {
  33 + $('.pop-shop-intro').show();
  34 + $('.mask').show();
  35 +});
  36 +
  37 +$('.close-btn, .mask').on('click', function() {
  38 + $('.pop-shop-intro').hide();
  39 + $('.mask').hide();
  40 +});
  41 +
  42 +
  43 +// 收藏店铺
  44 +function colloectAction() {
  45 + var $colloectIcon = $shopCollect.find('.shop-collect-ico'),
  46 + $colloectText = $shopCollect.find('.shop-collect-text'),
  47 + isFavorite = $colloectIcon.hasClass('on'),
  48 + needColloect = window.cookie('needColloect');
  49 +
  50 + $.ajax({
  51 + type: 'post',
  52 + url: '/shoplist/setFavorite',
  53 + data: {
  54 + isFavorite: isFavorite ? 0 : 1,
  55 + needColloect: needColloect,
  56 + shopId: $shopCollect.data('id')
  57 + },
  58 + success: function(res) {
  59 + if (res.code === 200) {
  60 + if (isFavorite) {
  61 + $colloectIcon.removeClass('on');
  62 + $colloectText.html('收藏');
  63 + } else {
  64 + $colloectIcon.addClass('on');
  65 + $colloectText.html('已收藏');
  66 + }
  67 +
  68 + if (needColloect) {
  69 + $colloectIcon.addClass('on');
  70 + $colloectText.html('已收藏');
  71 + }
  72 + } else if (res.code === 401) {
  73 + window.setCookie('needColloect', '1', {
  74 + path: '/',
  75 + domain: '.yohobuy.com',
  76 + expires: 90
  77 + });
  78 + location.href = res.url;
  79 + }
  80 + }
  81 + });
  82 +}
  83 +
  84 +$shopCollect.on('click', function() {
  85 + colloectAction();
  86 +});
  87 +
  88 +if (window.cookie('needColloect') * 1 === 1) {
  89 + colloectAction();
  90 + window.setCookie('needColloect', '', {
  91 + path: '/',
  92 + domain: '.yohobuy.com',
  93 + expires: 1
  94 + });
  95 +}
  96 +
  97 +// 全部商品使用 pjax 翻页
  98 +$allGoods.pjax('a.pjax', '.goods-wrap', {
  99 + timeout: 5000,
  100 + scrollTo: false // 默认滚动没有动画,禁止掉
  101 +}).on('pjax:end', function() {
  102 + product.init(4);
  103 + lazyLoad($('img.lazy'));
  104 +
  105 + $fixedArea = $allGoods.find('.fixed-area'); // 翻页后 fixed-area 区域有变化,需要更新选择器
  106 +
  107 + // 分页后移动到全部商品
  108 + $('html, body').animate({
  109 + scrollTop: $allGoods.offset().top - 30
  110 + });
  111 +}).on('click', '.menu-list li', function() {
  112 + var $this = $(this);
  113 +
  114 + $this.siblings().removeClass('on');
  115 + $this.addClass('on');
  116 +});
  117 +
  118 +$(window).on('scroll', function() {
  119 + var scrollTop = $(this).scrollTop();
  120 +
  121 + if (scrollTop > fixedAreaTop) {
  122 + $fixedArea.css({
  123 + position: 'fixed',
  124 + top: 0
  125 + });
  126 + } else {
  127 + $fixedArea.css({
  128 + position: 'static',
  129 + top: 0
  130 + });
  131 + }
  132 +});
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 @import "hot-rank"; 10 @import "hot-rank";
11 @import "shop-entry"; 11 @import "shop-entry";
12 @import "detail"; 12 @import "detail";
  13 +@import "shop-index";
13 14
14 .product-page { 15 .product-page {
15 /*分页*/ 16 /*分页*/
  1 +.shop-index-page {
  2 + margin: 10px auto 30px;
  3 + width: 1150px;
  4 +
  5 + .shop-banner {
  6 + position: relative;
  7 +
  8 + .shop-name {
  9 + position: absolute;
  10 + left: 260px;
  11 + bottom: 20px;
  12 + font-size: 36px;
  13 + color: #fff;
  14 + }
  15 +
  16 + .banner-img {
  17 + width: 100%;
  18 + height: 150px;
  19 + }
  20 +
  21 + .opt-wrap {
  22 + position: absolute;
  23 + top: 65%;
  24 + right: 0;
  25 + padding: 0 10px;
  26 + }
  27 +
  28 + .shop-intro,
  29 + .shop-collect {
  30 + display: inline-block;
  31 + width: 110px;
  32 + height: 30px;
  33 + margin-right: 10px;
  34 + font-size: 16px;
  35 + line-height: 30px;
  36 + text-align: center;
  37 + color: #fff;
  38 + border: 1px solid #fff;
  39 + cursor: pointer;
  40 +
  41 + i {
  42 + background-repeat: no-repeat;
  43 + float: left;
  44 + position: relative;
  45 + left: 11px;
  46 + top: 5px;
  47 + }
  48 +
  49 + .shop-intro-ico {
  50 + width: 16px;
  51 + height: 20px;
  52 + background-image: resolve(/product/shop-instro.png);
  53 + margin-right: 12px;
  54 + }
  55 +
  56 + .shop-collect-ico {
  57 + width: 20px;
  58 + height: 19px;
  59 + background-image: resolve(/product/shop-collection.png);
  60 + top: 6px;
  61 + margin-right: 12px;
  62 +
  63 + &.on {
  64 + background-image: resolve(/product/shop-collection-on.png);
  65 + }
  66 + }
  67 + }
  68 + }
  69 +
  70 + .shop-nav {
  71 + box-sizing: border-box;
  72 + margin-bottom: 30px;
  73 + padding: 0 20px;
  74 + width: 100%;
  75 + height: 40px;
  76 + color: #fff;
  77 + background: #000;
  78 + font-size: 16px;
  79 +
  80 + a {
  81 + position: relative;
  82 + top: 8px;
  83 + display: inline-block;
  84 + line-height: 26px;
  85 + color: #fff;
  86 + }
  87 +
  88 + .nav-item {
  89 + position: relative;
  90 + float: left;
  91 + width: 160px;
  92 + text-align: center;
  93 +
  94 + &.first {
  95 + width: 100px;
  96 + text-align: left;
  97 + }
  98 + }
  99 +
  100 + .current {
  101 + a {
  102 + border-bottom: 2px solid #fff;
  103 + }
  104 + }
  105 + }
  106 +
  107 + .coupon {
  108 + margin-top: 20px;
  109 + width: 100%;
  110 + height: 80px;
  111 +
  112 + .coupon-title {
  113 + width: 162px;
  114 + height: 100%;
  115 + background: url(/product/coupon-title.png);
  116 + }
  117 + }
  118 +
  119 + .slider-wrap {
  120 + height: 360px;
  121 + }
  122 +
  123 + .slider-left {
  124 + float: left;
  125 + margin-right: 10px;
  126 + width: 660px;
  127 + height: 100%;
  128 + overflow: hidden;
  129 +
  130 + img {
  131 + width: 100%;
  132 + height: 100%;
  133 + }
  134 +
  135 + .slide-pagination,
  136 + .slide-switch {
  137 + display: none;
  138 + }
  139 + }
  140 +
  141 + .slider-right {
  142 + float: left;
  143 + width: 300px;
  144 + height: 100%;
  145 +
  146 + .slider-item {
  147 + display: block;
  148 + margin-bottom: 10px;
  149 + width: 100%;
  150 + height: 175px;
  151 + }
  152 + }
  153 +
  154 + .floor-header {
  155 + margin-top: 50px;
  156 + }
  157 +
  158 + .new-arrivel,
  159 + .hot-single {
  160 + width: 980px;
  161 +
  162 + .item {
  163 + float: left;
  164 + position: relative;
  165 + margin-right: 10px;
  166 + margin-bottom: 20px;
  167 + width: 235px;
  168 + height: 315px;
  169 + font-size: 14px;
  170 + text-align: center;
  171 + line-height: 1.5;
  172 + background: #f5f5f5;
  173 +
  174 + img {
  175 + width: 235px;
  176 + height: 250px;
  177 + }
  178 +
  179 + .title {
  180 + width: 220px;
  181 + padding: 0 5px;
  182 + text-overflow: ellipsis;
  183 + white-space: nowrap;
  184 + overflow: hidden;
  185 + }
  186 + }
  187 +
  188 + .hat {
  189 + position: absolute;
  190 + top: 0;
  191 + right: 0;
  192 + width: 50px;
  193 + height: 50px;
  194 + color: #ffc513;
  195 + text-align: center;
  196 + line-height: 57px;
  197 + background: url(/product/hat.png);
  198 + }
  199 + }
  200 +
  201 + .mask {
  202 + background-color: #000;
  203 + opacity: .5;
  204 + position: fixed;
  205 + top: 0;
  206 + left: 0;
  207 + right: 0;
  208 + bottom: 0;
  209 + z-index: 1001;
  210 + display: none;
  211 + cursor: pointer;
  212 + }
  213 +
  214 + .pop-shop-intro {
  215 + display: none;
  216 + }
  217 +
  218 + .shop-intro-bg {
  219 + width: 908px;
  220 + height: 604px;
  221 + background-color: #000;
  222 + opacity: .5;
  223 + position: fixed;
  224 + left: 50%;
  225 + top: 50%;
  226 + z-index: 1002;
  227 + margin: -302px 0 0 -454px;
  228 + }
  229 +
  230 + .shop-intro-area {
  231 + width: 898px;
  232 + height: 594px;
  233 + padding: 60px 10px 35px 40px;
  234 + background-color: #fff;
  235 + position: fixed;
  236 + left: 50%;
  237 + top: 50%;
  238 + margin: -297px 0 0 -449px;
  239 + z-index: 1003;
  240 + box-sizing: border-box;
  241 +
  242 + .close-btn {
  243 + width: 18px;
  244 + height: 18px;
  245 + background-image: resolve(/product/shop-instro-close.png);
  246 + position: absolute;
  247 + right: 20px;
  248 + top: 20px;
  249 + cursor: pointer;
  250 + }
  251 +
  252 + .brand-cont {
  253 + overflow: auto;
  254 + width: 100%;
  255 + height: 499px;
  256 + padding-right: 30px;
  257 + box-sizing: border-box;
  258 + }
  259 +
  260 + .intro-title {
  261 + float: left;
  262 +
  263 + h2 {
  264 + width: 100%;
  265 + float: left;
  266 + text-align: left;
  267 + font-size: 26px;
  268 + font-weight: bold;
  269 + color: #000;
  270 + font-style: italic;
  271 + }
  272 +
  273 + p {
  274 + font-family: "黑体";
  275 + font-size: 20px;
  276 + text-align: left;
  277 + padding: 10px 0;
  278 + float: left;
  279 + }
  280 + }
  281 +
  282 + .intro-cont {
  283 + width: 100%;
  284 + float: left;
  285 + margin-top: 55px;
  286 + font-size: 14px;
  287 + line-height: 20px;
  288 +
  289 + p {
  290 + text-indent: 2em;
  291 + }
  292 +
  293 + img {
  294 + width: 100%;
  295 + margin-top: 10px;
  296 + }
  297 + }
  298 + }
  299 +
  300 + .fixed-area {
  301 + background: #fff;
  302 + z-index: 1;
  303 + width: 970px;
  304 + }
  305 +
  306 + .all-goods-menu {
  307 + width: 100%;
  308 + height: 40px;
  309 + line-height: 40px;
  310 +
  311 + .menu-tag {
  312 + color: #d0021b;
  313 + font-size: 18px;
  314 + font-weight: bold;
  315 + text-align: left;
  316 + padding: 0 20px 0 10px;
  317 + border-right: 1px solid #000;
  318 + float: left;
  319 + }
  320 +
  321 + .menu-list {
  322 + width: 810px;
  323 + height: 40px;
  324 + overflow: hidden;
  325 + float: left;
  326 + font-size: 14px;
  327 +
  328 + li {
  329 + display: inline-block;
  330 + padding: 0 15px;
  331 + }
  332 +
  333 + .on {
  334 + background: #000;
  335 + height: 28px;
  336 + line-height: 28px;
  337 +
  338 + a {
  339 + color: #fff;
  340 + }
  341 + }
  342 + }
  343 +
  344 + .more {
  345 + font-size: 14px;
  346 + float: right;
  347 + }
  348 + }
  349 +
  350 + .sort-pager .sort-type:first-child .iconfont {
  351 + display: inline-block;
  352 + }
  353 +
  354 + .loading {
  355 + position: relative;
  356 + width: 100%;
  357 + text-align: center;
  358 +
  359 + a {
  360 + display: block;
  361 + height: 35px;
  362 + width: 120px;
  363 + margin: 0 auto 0;
  364 + background-color: #000;
  365 + color: #fff;
  366 + font-size: 14px;
  367 + line-height: 35px;
  368 + text-align: center;
  369 + }
  370 + }
  371 +
  372 + .trend-info {
  373 + width: 100%;
  374 +
  375 + .trend-list {
  376 + width: 100%;
  377 +
  378 + li {
  379 + float: left;
  380 + width: 316px;
  381 + margin-left: 10px;
  382 + text-align: center;
  383 +
  384 + &:first-child {
  385 + margin-left: 0;
  386 + }
  387 + }
  388 +
  389 + img {
  390 + width: 100%;
  391 + height: 181px;
  392 + }
  393 +
  394 + .main-title,
  395 + .sub-title {
  396 + box-sizing: border-box;
  397 + font-size: 16px;
  398 + margin-top: 15px;
  399 + padding: 0 10px;
  400 + width: 100%;
  401 + overflow: hidden;
  402 + text-overflow: ellipsis;
  403 + white-space: nowrap;
  404 + line-height: 24px;
  405 + }
  406 +
  407 + .sub-title {
  408 + margin-top: 0;
  409 + font-size: 14px;
  410 + }
  411 + }
  412 + }
  413 +
  414 + .goods-container {
  415 + .good-info {
  416 + width: 235px;
  417 + height: auto;
  418 + margin-bottom: 35px;
  419 + }
  420 +
  421 + .good-detail-text {
  422 + text-align: left;
  423 + }
  424 + }
  425 +
  426 + .left-modular {
  427 + width: 160px;
  428 + font-size: 14px;
  429 + margin-top: 20px;
  430 + float: left;
  431 +
  432 + .title {
  433 + width: 100%;
  434 + height: 25px;
  435 + line-height: 25px;
  436 + background: #000;
  437 + color: #fff;
  438 + font-family: "黑体";
  439 + padding-left: 14px;
  440 + box-sizing: border-box;
  441 + }
  442 +
  443 + .left-list {
  444 + width: 100%;
  445 + margin-top: 5px;
  446 +
  447 + li {
  448 + width: 100%;
  449 + height: 42px;
  450 + line-height: 42px;
  451 + background: #f5f5f5;
  452 + float: left;
  453 + box-sizing: border-box;
  454 + margin-top: 5px;
  455 + padding-left: 14px;
  456 +
  457 + a {
  458 + color: #000;
  459 + }
  460 +
  461 + &.on {
  462 + border: 1px solid #000;
  463 + }
  464 + }
  465 + }
  466 + }
  467 +
  468 + .classic-recommend {
  469 + .left-list li {
  470 + height: 50px;
  471 + line-height: 50px;
  472 + }
  473 +
  474 + .classic-name {
  475 + width: 96px;
  476 + display: inline-block;
  477 + line-height: 14px;
  478 + vertical-align: middle;
  479 +
  480 + .name {
  481 + font-size: 14px;
  482 + }
  483 +
  484 + .en-name {
  485 + font-size: 12px;
  486 + }
  487 + }
  488 +
  489 + img {
  490 + width: 40px;
  491 + max-height: 40px;
  492 + margin-right: 5px;
  493 + vertical-align: middle;
  494 + }
  495 + }
  496 +
  497 + .sell-recommend {
  498 + .left-list li {
  499 + padding-left: 0;
  500 + height: auto;
  501 + margin-bottom: 25px;
  502 + line-height: inherit;
  503 +
  504 + img {
  505 + width: 100%;
  506 + }
  507 + }
  508 + }
  509 +
  510 + ::-webkit-scrollbar {
  511 + width: 16px;
  512 + height: 16px;
  513 + }
  514 +
  515 + ::-webkit-scrollbar-track,
  516 + ::-webkit-scrollbar-thumb {
  517 + border-radius: 999px;
  518 + border: 5px solid transparent;
  519 + }
  520 +
  521 + ::-webkit-scrollbar-track {
  522 + box-shadow: 0 0 6px rgba(0, 0, 0, 0) inset;
  523 + }
  524 +
  525 + ::-webkit-scrollbar-thumb {
  526 + min-height: 20px;
  527 + background-clip: content-box;
  528 + box-shadow: 0 0 0 6px rgba(0, 0, 0, .3) inset;
  529 + }
  530 +
  531 + ::-webkit-scrollbar-corner {
  532 + background: transparent;
  533 + }
  534 +
  535 + .page-nav {
  536 + padding: 7px 0;
  537 + float: right;
  538 + font-size: 14px;
  539 +
  540 + .page-prev {
  541 + width: 33px;
  542 + height: 33px;
  543 + background: #ccc;
  544 + text-align: center;
  545 + float: left;
  546 + }
  547 +
  548 + .arrow-left {
  549 + width: 10px;
  550 + height: 10px;
  551 + display: inline-block;
  552 + position: relative;
  553 + top: -7px;
  554 + background: resolve(/product/arrow-left.png) no-repeat;
  555 + }
  556 +
  557 + a .page-prev,
  558 + a .page-next {
  559 + background: #000;
  560 + color: #fff;
  561 + }
  562 +
  563 + .page-next {
  564 + min-width: 110px;
  565 + height: 33px;
  566 + background: #a9a9a9;
  567 + float: left;
  568 + margin-left: 1px;
  569 + line-height: 33px;
  570 + padding-left: 10px;
  571 + box-sizing: border-box;
  572 + padding-right: 10px;
  573 + }
  574 +
  575 + .arrow-right {
  576 + width: 10px;
  577 + height: 10px;
  578 + display: inline-block;
  579 + vertical-align: middle;
  580 + background: resolve(/product/arrow-right.png) no-repeat;
  581 + }
  582 +
  583 + .pages {
  584 + margin-left: 10px;
  585 + }
  586 + }
  587 +}
@@ -152,23 +152,12 @@ class BrandsModel @@ -152,23 +152,12 @@ class BrandsModel
152 /** 152 /**
153 * 根据品牌域名处理相关品牌参数 153 * 根据品牌域名处理相关品牌参数
154 * @param $domain (品牌域名) 154 * @param $domain (品牌域名)
155 - * @param $type (根据type调取同一接口不同的数据)  
156 * @return array|bool 155 * @return array|bool
157 */ 156 */
158 - public static function getBrandByDomain($domain, $type) 157 + public static function getBrandByDomain($domain)
159 { 158 {
160 - //根据传来的type值,选择请求需要的数据  
161 - switch ($type) {  
162 - case 1:  
163 - $fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_domain,brand_alif,brand_banner,brand_ico,static_content_code';  
164 - break;  
165 - case 2:  
166 - $fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_banner,brand_ico,brand_intro';  
167 - default:  
168 - break;  
169 - }  
170 //调用接口获得数据 159 //调用接口获得数据
171 - $brandInfo = BrandData::getBrandLogoByDomain($domain, $fields); 160 + $brandInfo = BrandData::getBrandLogoByDomain($domain);
172 $result = array(); 161 $result = array();
173 //组装品牌页顶部banner条需要的数据 162 //组装品牌页顶部banner条需要的数据
174 if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) { 163 if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) {
@@ -178,6 +167,10 @@ class BrandsModel @@ -178,6 +167,10 @@ class BrandsModel
178 $result['brandNameEn'] = isset($brandInfo['data']['brand_name_en']) ? $brandInfo['data']['brand_name_en'] : ''; 167 $result['brandNameEn'] = isset($brandInfo['data']['brand_name_en']) ? $brandInfo['data']['brand_name_en'] : '';
179 $result['brandNameCn'] = isset($brandInfo['data']['brand_name_cn']) ? $brandInfo['data']['brand_name_cn'] : ''; 168 $result['brandNameCn'] = isset($brandInfo['data']['brand_name_cn']) ? $brandInfo['data']['brand_name_cn'] : '';
180 $result['brandAbout'] = isset($brandInfo['data']['brand_intro']) ? $brandInfo['data']['brand_intro'] : ''; 169 $result['brandAbout'] = isset($brandInfo['data']['brand_intro']) ? $brandInfo['data']['brand_intro'] : '';
  170 + $result['shopTemplateType'] = isset($brandInfo['data']['shop_template_type']) ?
  171 + intval($brandInfo['data']['shop_template_type']) : '';
  172 + $result['type'] = isset($brandInfo['data']['type']) ? $brandInfo['data']['type'] : 0;
  173 + $result['shopId'] = isset($brandInfo['data']['shop_id']) ? $brandInfo['data']['shop_id'] : '';
181 } 174 }
182 else { 175 else {
183 return false; 176 return false;
  1 +<?php
  2 +namespace Product;
  3 +use Product\SearchModel;
  4 +use LibModels\Web\Product\SearchData;
  5 +use LibModels\Web\Product\ShopData;
  6 +use Api\Yohobuy;
  7 +use WebPlugin\HelperSearch;
  8 +use LibModels\Web\Guang\ListData as GuangListData;
  9 +use WebPlugin\Helpers;
  10 +/**
  11 + * 品牌店铺的模型
  12 + *
  13 + * @copyright yoho.inc
  14 + * @author xiaoxiao.hao <xiaoxiao.hao@yoho.cn>
  15 + */
  16 +class ShopModel
  17 +{
  18 + private static $shopListUrl = '/shoplist';
  19 +
  20 + public static function getData($shopId, $parameters)
  21 + {
  22 + $data = array('shopTopBanner' => array(), 'hotSingle'=> array());
  23 + $parameters['shopId'] = $shopId;
  24 +
  25 + $shopList = ShopData::shopsDecoratorList($shopId);
  26 + if (isset($shopList['data']['list']) && $shopList['code'] === 200) {
  27 + foreach ($shopList['data']['list'] as $list) {
  28 + $fun = $list['resource_name'];
  29 + if (is_callable("self::$fun")) {
  30 + $list = self::$fun(self::getResourceData($list), $parameters);
  31 + switch ($fun) {
  32 + case 'newProducts':
  33 + $data['newArrivel']['name'] = '新品上架 NEW';
  34 + $data['newArrivel']['list'] = $list;
  35 + break;
  36 + case 'hotProducts':
  37 + $data['hotSingle']['name'] = '人气单品 HOT';
  38 + $data['hotSingle']['list'] = $list;
  39 + break;
  40 + case 'goodsTabBar':
  41 + if (isset($list['hot'])) {
  42 + $data['hotSingle']['navs'] = $list['hot'];
  43 + }
  44 + if ($list['new']) {
  45 + $data['newArrivel']['navs'] = $list['new'];
  46 + }
  47 + break;
  48 + case 'brandBrowse':
  49 + $data['brandBrowse'] = array('title' => '品牌集合', 'list'=> $list);
  50 + break;
  51 + case 'recommend':
  52 + $data['recommend'] = array(
  53 + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '经典推荐',
  54 + 'list'=> $list
  55 + );
  56 + break;
  57 + case 'hotRecommend':
  58 + $data['hotRecommend'] = array(
  59 + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '热销推荐',
  60 + 'list'=> $list
  61 + );
  62 + break;
  63 + default :
  64 + $data[$fun] = $list;
  65 + }
  66 + }
  67 + }
  68 + } else {
  69 + headers_sent() || header('Location: /error.html');
  70 + exit();
  71 + }
  72 +
  73 + //店铺介绍
  74 + $data['brandIntro'] = self::getIntro($shopId, $parameters['uid']);
  75 +
  76 + //搜索店铺全部商品
  77 + $searchCondition = SearchModel::searchCondition($parameters['condition'], $parameters['options']);
  78 +
  79 + // 组合搜索商品url
  80 + $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
  81 + // 组合搜索分类url
  82 + $sortCondition = array();
  83 + if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) {
  84 + $sortCondition['needSmallSort'] = 1;
  85 + }
  86 + $urlList['sort'] = SearchData::getClassesUrl($sortCondition);
  87 +
  88 + //批量调接口获取数据
  89 + $res = Yohobuy::getMulti($urlList);
  90 +
  91 + //新品上架
  92 + if (isset($parameters['navBar']) && $parameters['navBar'] * 1 === 3) {
  93 + $searchCondition['options']['isNew'] = true;
  94 + }
  95 +
  96 + // 组织模板数据
  97 + $result = HelperSearch::getList($res, $searchCondition['options'], $searchCondition['userInput']);
  98 + $data['pathNav'] = array_merge(
  99 + HelperSearch::$listNav,
  100 + array(
  101 + array('href'=> '', 'name' => $data['brandIntro']['brandName'], 'title' => $data['brandIntro']['brandName'])
  102 + )
  103 + );
  104 +
  105 + $sort = self::getSort($res['sort'], $parameters['options']['misort'], $shopId);
  106 + $searchCondition['userInput'] = empty($searchCondition['userInput']) ? array() : $searchCondition['userInput'];
  107 + $param = array_merge($searchCondition['userInput'], array('navBar' => 1));
  108 + $data['allGoods']['list'] = $result['goods'];
  109 + $data['allGoods']['name'] = '全部商品 ALL';
  110 + $data['allGoods']['opts'] = $result['opts'];
  111 + $data['leftContent'] = isset($result['leftContent']) ? $result['leftContent'] : '';
  112 + $data['allGoods']['goodsMenu']['menuList'] = $sort;
  113 + $data['allGoods']['href'] = self::$shopListUrl . '?'.http_build_query($param);
  114 +
  115 + return $data;
  116 + }
  117 +
  118 +
  119 + /**
  120 + * 店铺列表页
  121 + */
  122 + public static function getShopListData($shopId, $parameters)
  123 + {
  124 + $data = array('shopTopBanner' => array(), 'hotSingle'=> array());
  125 + $parameters['shopId'] = $shopId;
  126 +
  127 + $shopList = ShopData::shopsDecoratorList($shopId);
  128 +
  129 + if (isset($shopList['data']['list']) && $shopList['code'] === 200) {
  130 + foreach ($shopList['data']['list'] as $list) {
  131 + $fun = $list['resource_name'];
  132 + if (is_callable("self::$fun")) {
  133 + $list = self::$fun(self::getResourceData($list), $parameters);
  134 + switch ($fun) {
  135 + case 'newProducts':
  136 + case 'hotProducts':
  137 + break;
  138 + case 'goodsTabBar':
  139 + if (isset($list['hot'])) {
  140 + $data['hotSingle']['navs'] = $list['hot'];
  141 + } else if ($list['new']) {
  142 + $data['newArrivel']['navs'] = $list['new'];
  143 + }
  144 + break;
  145 + case 'brandBrowse':
  146 + $data['brandBrowse'] = array('title' => '品牌集合', 'list'=> $list);
  147 + break;
  148 + case 'recommend':
  149 + $data['recommend'] = array(
  150 + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '经典推荐',
  151 + 'list'=> $list
  152 + );
  153 + break;
  154 + case 'hotRecommend':
  155 + $data['hotRecommend'] = array(
  156 + 'title' => isset($list[0]['title']) ? $list[0]['title'] : '热销推荐',
  157 + 'list'=> $list
  158 + );
  159 + break;
  160 + default :
  161 + $data[$fun] = $list;
  162 + }
  163 + }
  164 + }
  165 + }
  166 +
  167 + //店铺介绍
  168 + $data['brandIntro'] = self::getIntro($shopId, $parameters['uid']);
  169 +
  170 +
  171 + //搜索店铺全部商品
  172 + $searchCondition = SearchModel::searchCondition($parameters['condition'], $parameters['options']);
  173 +
  174 + // 组合搜索商品url
  175 + $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
  176 + // 组合搜索分类url
  177 + $sortCondition = array();
  178 + if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) {
  179 + $sortCondition['needSmallSort'] = 1;
  180 + }
  181 + $urlList['sort'] = SearchData::getClassesUrl($sortCondition);
  182 +
  183 + //批量调接口获取数据
  184 + $res = Yohobuy::getMulti($urlList);
  185 +
  186 + //新品上架
  187 + if (isset($parameters['navBar']) && $parameters['navBar'] * 1 === 3) {
  188 + $searchCondition['options']['isNew'] = true;
  189 + }
  190 +
  191 + // 组织模板数据
  192 + $result = HelperSearch::getList($res, $searchCondition['options'], $searchCondition['userInput']);
  193 +
  194 + $data['pathNav'] = $result['pathNav'];
  195 +
  196 + $data['goods'] = $result['goods'];
  197 + $data['opts'] = $result['opts'];
  198 + $data['leftContent'] = isset($result['leftContent']) ? $result['leftContent'] : '';
  199 + $data['filters'] = $result['filters'];
  200 + $data['pathNav'] = $result['pathNav'];
  201 +// $data['name'] = '全部商品 ALL';
  202 +// $sort = self::getSort($res['sort']);
  203 +// $data['goodsMenu']['menuList'] = $sort;
  204 +
  205 + return $data;
  206 +
  207 + }
  208 +
  209 +
  210 + //异步获取全部商品goods数据
  211 + public static function getGoods($condition, $options)
  212 + {
  213 + //搜索店铺全部商品
  214 + $searchCondition = SearchModel::searchCondition($condition, $options);
  215 +
  216 + // 组合搜索商品url
  217 + $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
  218 + // 组合搜索分类url
  219 + $sortCondition = array();
  220 + if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) {
  221 + $sortCondition['needSmallSort'] = 1;
  222 + }
  223 + $urlList['sort'] = SearchData::getClassesUrl($sortCondition);
  224 +
  225 + //批量调接口获取数据
  226 + $res = Yohobuy::getMulti($urlList);
  227 +
  228 + // 组织模板数据
  229 + $result = HelperSearch::getList($res, $searchCondition['options'], $searchCondition['userInput']);
  230 +
  231 + $sort = self::getSort($res['sort'], $options['misort'], $condition['shop']);
  232 + $data['goodsMenu']['menuList'] = $sort;
  233 + $data['list'] = $result['goods'];
  234 + $data['opts'] = $result['opts'];
  235 +
  236 + return $data;
  237 + }
  238 +
  239 +
  240 + /**
  241 + * 店铺Banner 资源位
  242 + * @param type $data []
  243 + */
  244 + public static function shopTopBanner($data)
  245 + {
  246 + $result = array(
  247 + 'banner' => '',
  248 + 'bannerHeight' => 150
  249 + );
  250 +
  251 + if (isset($data['resource_data'][0]['shopSrc'])) {
  252 + $result['banner'] = self::imageView2($data['resource_data'][0]['shopSrc'], 1150, 150);
  253 + }
  254 +
  255 + return $result;
  256 +
  257 + }
  258 + /**
  259 + * 导航栏 资源位
  260 + * @param type $data
  261 + * @return type []
  262 + */
  263 + public static function navigationBar($data, $parameters = array())
  264 + {
  265 + $shopNav = array(
  266 + array(
  267 + 'name' => '店铺首页',
  268 + 'url' => '/?navBar=0',
  269 + ),
  270 + array(
  271 + 'name' => '全部商品',
  272 + 'url' => self::$shopListUrl . '?navBar=1',
  273 + 'arrow' => true,
  274 + ),
  275 + array(
  276 + 'name' => '人气单品',
  277 + 'url' => self::$shopListUrl . '?navBar=2&order=s_n_desc',
  278 + ),
  279 + array(
  280 + 'name' => '新品上架',
  281 + 'url' => self::$shopListUrl . '?navBar=3&order=s_t_desc',
  282 + ),
  283 + );
  284 +
  285 + if(isset($data['resource_data']) && is_array($data['resource_data'])) {
  286 + $shopNav = array_merge($shopNav, array_filter($data['resource_data'], function($v) {
  287 + if (empty($v['url'])) {
  288 + return false;
  289 + }
  290 + return $v;
  291 + }));
  292 + }
  293 +
  294 + //选中状态
  295 + if (isset($parameters['navBar']) && count($shopNav) >= $parameters['navBar'] && $parameters['navBar'] >= 0) {
  296 + $shopNav[$parameters['navBar']]['current'] = true;
  297 + } else {
  298 + $shopNav[0]['current'] = true;
  299 + }
  300 +
  301 + return $shopNav;
  302 + }
  303 + /**
  304 + * 资源位小图
  305 + * @param type $data
  306 + */
  307 + public static function oneRowTwoColImages($data)
  308 + {
  309 + $oneData = array();
  310 + $twoData = array();
  311 +
  312 + foreach ($data['resource_data'] as $resource) {
  313 +
  314 + if (empty($resource['data'])) {
  315 + continue;
  316 + }
  317 +
  318 + foreach ($resource['data'] as $key => $val) {
  319 +
  320 + $temp = array(
  321 + 'img' => self::imageView2($val['src'], 300, 175),
  322 + 'url' => $val['url'],
  323 + );
  324 +
  325 + if ($key === 0) {
  326 + $oneData[] = $temp;
  327 + } else {
  328 + $twoData[] = $temp;
  329 + }
  330 + }
  331 + }
  332 +
  333 + return array_slice(array_merge($oneData, $twoData), 0, 2);
  334 + }
  335 +
  336 + /**
  337 + * 资源位大图
  338 + * @param type $data
  339 + * @return type []
  340 + */
  341 + public static function largeSlideImg($data)
  342 + {
  343 + $result = array();
  344 +
  345 + foreach ($data['resource_data'] as $resource) {
  346 +
  347 + if (empty($resource['data'])) {
  348 + continue;
  349 + }
  350 +
  351 + foreach ($resource['data'] as $val) {
  352 + $result[] = array(
  353 + 'img' => self::imageView2($val['src'], 660, 360),
  354 + 'url' => $val['url'],
  355 + );
  356 + }
  357 + }
  358 +
  359 + return $result;
  360 + }
  361 +
  362 + /**
  363 + * 经典推荐
  364 + * @param type $data
  365 + * @return type []
  366 + */
  367 + public static function recommend($data)
  368 + {
  369 + $result = array();
  370 +
  371 + foreach ($data['resource_data'] as $resource) {
  372 + $result[] = array(
  373 + 'enName'=> $resource['enName'],
  374 + 'name'=> $resource['name'],
  375 + 'img'=> self::imageView2($resource['src'], 50, 50),
  376 + 'title'=> $resource['title'],
  377 + 'url'=> $resource['url'],
  378 + );
  379 + }
  380 +
  381 + return $result;
  382 + }
  383 +
  384 + /**
  385 + * 热门推荐
  386 + * @param type $data
  387 + * @return type []
  388 + */
  389 + public static function hotRecommend($data)
  390 + {
  391 + $result = array();
  392 +
  393 + foreach ($data['resource_data'] as $resource) {
  394 + $result[] = array(
  395 + 'img'=> self::imageView2($resource['src'], 160, 240),
  396 + 'title'=> $resource['title'],
  397 + 'url'=> $resource['url'],
  398 + );
  399 + }
  400 +
  401 + return $result;
  402 + }
  403 +
  404 + /**
  405 + * 品牌一览
  406 + * @param type $data
  407 + * @return type []
  408 + */
  409 + public static function brandBrowse($data, $parameters = array())
  410 + {
  411 + $result = array();
  412 + $brand = isset($parameters['brand']) ? $parameters['brand'] : '';
  413 +
  414 + foreach ($data['resource_data'] as $resource) {
  415 + $result[] = array(
  416 + 'url' => Helpers::url(
  417 + self::$shopListUrl,
  418 + array(
  419 + 'brand' => $resource['id'],
  420 + 'navBar' => 1
  421 + ),
  422 + ''
  423 + ),
  424 + 'brandName' => $resource['brandName'],
  425 + 'cur' => ($brand === strval($resource['id']))
  426 + );
  427 + }
  428 +
  429 + return $result;
  430 + }
  431 + /**
  432 + * 商品标签栏
  433 + * @param type $data
  434 + * @return type []
  435 + */
  436 + public static function goodsTabBar($data)
  437 + {
  438 + $result = array();
  439 +
  440 + if (isset($data['resource_data'])) {
  441 + $result = $data['resource_data'];
  442 + }
  443 + return $result;
  444 + }
  445 +
  446 + /**
  447 + * 新品上架
  448 + * @param type $data
  449 + * @return type []
  450 + */
  451 + public static function newProducts($data)
  452 + {
  453 + $result = array();
  454 +
  455 + foreach ($data['resource_data'] as $resource) {
  456 + $result[] = array(
  457 + 'productId'=> $resource['productId'],
  458 + 'title'=> $resource['productName'],
  459 + 'productSkn'=> $resource['productSkn'],
  460 + 'price'=> '¥' . number_format(trim($resource['salesPrice'], '¥'), 2, '.', ''),
  461 + 'img'=> self::imageView2($resource['src'], 250, 340),
  462 + 'url'=> Helpers::getProductUrl($resource['productId'], $resource['productSkn'], $resource['productName']),
  463 + );
  464 + }
  465 + return $result;
  466 + }
  467 +
  468 + /**
  469 + * 人气单品
  470 + * @param type $data
  471 + * @return type []
  472 + */
  473 + public static function hotProducts($data)
  474 + {
  475 + $result = array();
  476 +
  477 + foreach ($data['resource_data'] as $key => $resource) {
  478 + $result[] = array(
  479 + 'productId'=> $resource['productId'],
  480 + 'title'=> $resource['productName'],
  481 + 'productSkn'=> $resource['productSkn'],
  482 + 'price'=> '¥' . number_format(trim($resource['salesPrice'], '¥'), 2, '.', ''),
  483 + 'img'=> self::imageView2($resource['src'], 250, 340),
  484 + 'url'=> Helpers::getProductUrl($resource['productId'], $resource['productSkn'], $resource['productName']),
  485 + 'index'=> $key + 1
  486 + );
  487 + }
  488 +
  489 + return $result;
  490 + }
  491 + /**
  492 + * 潮流资讯
  493 + * @param type string $tag 搜索内容
  494 + * @return array []
  495 + */
  496 + public static function getArticle($tag = '')
  497 + {
  498 + $result = array();
  499 +
  500 + $article = GuangListData::article('1,2,3', 0, 0, '', 0, $tag, '', 3);
  501 + if (!isset($article['data']['list']['artList'])) {
  502 + return $result;
  503 + }
  504 +
  505 + foreach ($article['data']['list']['artList'] as $artList) {
  506 + $result['trendList'][] = array(
  507 + 'href' => $artList['url'],
  508 + 'src' => self::imageView2(substr($artList['src'], 0, strpos($artList['src'], '?')), 264, 173),
  509 + 'mainTitle' => $artList['title'],
  510 + 'Subtitle' => $artList['intro']
  511 + );
  512 + }
  513 +
  514 + if (count($result['trendList']) < 3) {
  515 + return array();
  516 + }
  517 +
  518 + $result['name'] = '潮流资讯 HOT ITEMS';
  519 +
  520 + return $result;
  521 + }
  522 +
  523 + /**
  524 + * 缩略图
  525 + * @param type $src 图片路径
  526 + * @param type $width 宽
  527 + * @param type $heigh 高
  528 + * @return type string src
  529 + */
  530 + public static function imageView2($src, $width, $heigh)
  531 + {
  532 + $src .= strstr($src, '?') ? '&' : '?';
  533 +
  534 + return "{$src}imageView2/1/w/{$width}/h/{$heigh}";
  535 + }
  536 +
  537 + /**
  538 + * 解析resource_data 参数
  539 + * @param type $data
  540 + * @return type []
  541 + */
  542 + public static function getResourceData($data)
  543 + {
  544 + $data['resource_data'] = isset($data['resource_data']) ? json_decode($data['resource_data'], true) : array();
  545 +
  546 + return $data;
  547 + }
  548 +
  549 + public static function shopsDecoratorList($shopId)
  550 + {
  551 + return ShopData::shopsDecoratorList($shopId);
  552 + }
  553 +
  554 + public static function getIntro($shopId, $uid)
  555 + {
  556 + $data = array('brandName' => '', 'brandCont' => '', 'domain'=> '', 'logo'=> '', 'is_favorite'=> false);
  557 +
  558 + $intro = ShopData::getIntro($shopId, $uid);
  559 +
  560 + if ($intro['code'] === 200 && isset($intro['data'])) {
  561 + $data = array(
  562 + 'brandName'=> $intro['data']['shop_name'],
  563 + 'brandCont'=> $intro['data']['shop_intro'],
  564 + 'domain'=> $intro['data']['shop_domain'],
  565 + 'logo'=> $intro['data']['shop_logo'],
  566 + 'isFavorite'=> ($intro['data']['is_favorite'] === 'Y'),
  567 + 'multBrandShopType'=> $intro['data']['mult_brand_shop_type']
  568 + );
  569 + }
  570 +
  571 + $data['shopId'] = $shopId;
  572 + return $data;
  573 + }
  574 +
  575 +
  576 + //获取二级品类(按库存排名取前15个二级品类)
  577 + public static function getSort($sort, $misort, $shopId)
  578 + {
  579 + $result = array();
  580 + $i=0;
  581 + if (empty($sort['sort'])) {
  582 + return $result;
  583 + }
  584 + foreach($sort['sort'] as $key=>$value) {
  585 + foreach($value['sub'] as $k=>$v) {
  586 + $result[$i]['href'] = '/?msort='.$value['sort_id'].'&misort='.$v['sort_id'].'&shopId='.$shopId;
  587 + $result[$i]['name'] = $v['sort_name'];
  588 + $result[$i]['count'] = $v['count'];
  589 + $result[$i]['orderBy'] = $v['order_by'];
  590 + $result[$i]['misort'] = $v['sort_id'];
  591 + $i++;
  592 + }
  593 + }
  594 + foreach($result as $key=>$value) {
  595 + $count[$key] = $value['count'];
  596 + $sortName[$key] = $value['name'];
  597 + }
  598 +
  599 + $arr=array();
  600 + array_multisort($count,SORT_DESC,$sortName,$result);
  601 + $result = array_slice($result,0,15);
  602 +
  603 + foreach($result as &$value) {
  604 + if($value['misort'] == $misort) {
  605 + $value['curMenu'] = true;
  606 + }
  607 + }
  608 +
  609 + return $result;
  610 + }
  611 +
  612 +
  613 + public static function getShopsBrands($shopId)
  614 + {
  615 + return ShopData::getShopsBrands($shopId);
  616 + }
  617 +
  618 + public static function getSearch($shopId)
  619 + {
  620 + return ShopData::getSearch($shopId);
  621 + }
  622 +
  623 + public static function getSortInfo($shopId, $yhChannel = '', $gender = '')
  624 + {
  625 + return ShopData::getSortInfo($shopId, $yhChannel, $gender);
  626 + }
  627 +
  628 + public static function setFavorite($shopId, $isfavorite, $uid, $type = 'shop')
  629 + {
  630 + return ShopData::setFavorite($shopId, $isfavorite, $uid, $type);
  631 + }
  632 +
  633 + public static function byDomain($domain)
  634 + {
  635 + $data = array('shop_id' => '', 'type' => '');
  636 +
  637 + $result = ShopData::byDomain($domain);
  638 +
  639 + if (isset($result['code']) && $result['code'] === 200 && !empty($result['data'])) {
  640 + $data = $result['data'];
  641 + }
  642 +
  643 + return ShopData::byDomain($domain);
  644 + }
  645 +}
@@ -7,10 +7,11 @@ use Product\HotrankModel; @@ -7,10 +7,11 @@ use Product\HotrankModel;
7 use Index\HomeModel; 7 use Index\HomeModel;
8 use WebPlugin\Helpers; 8 use WebPlugin\Helpers;
9 use LibModels\Web\Product\BrandData; 9 use LibModels\Web\Product\BrandData;
  10 +use Product\ShopModel;
10 11
11 class IndexController extends WebAction 12 class IndexController extends WebAction
12 { 13 {
13 - 14 + private $_information = array('code' => 400, 'message' => '操作失败,请稍后再试!');
14 /** 15 /**
15 * 品牌首页 16 * 品牌首页
16 */ 17 */
@@ -22,11 +23,27 @@ class IndexController extends WebAction @@ -22,11 +23,27 @@ class IndexController extends WebAction
22 $this->go(SITE_MAIN); 23 $this->go(SITE_MAIN);
23 } 24 }
24 //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页 25 //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
25 - $type = 1;  
26 - $result = BrandsModel::getBrandByDomain($domain, $type); 26 + $result = BrandsModel::getBrandByDomain($domain);
27 if (!$result) { 27 if (!$result) {
28 $this->go(SITE_MAIN); 28 $this->go(SITE_MAIN);
29 } 29 }
  30 +
  31 + $type = intval(isset($result['type']) ? $result['type'] : '');
  32 + switch ($type) {
  33 + case 1:
  34 + //无单品店有多品店:1--->搜索页
  35 + $this->go('http://search.yohobuy.com/?query=' . $domain);
  36 + exit(0);
  37 + break;
  38 + case 2:
  39 + //店铺页面
  40 + //$shopTemplateType 1基础模板,2经典模板,
  41 + if ($result['shopTemplateType'] === 2 && !empty($result['shopId'])) {
  42 + $this->shopHome($result['shopId']);
  43 + exit(0);
  44 + }
  45 + break;
  46 + }
30 47
31 //获取uid 48 //获取uid
32 $uid = $this->getUid(); 49 $uid = $this->getUid();
@@ -125,8 +142,7 @@ class IndexController extends WebAction @@ -125,8 +142,7 @@ class IndexController extends WebAction
125 142
126 143
127 //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页 144 //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
128 - $type = 2;  
129 - $result = BrandsModel::getBrandByDomain($domain, $type); 145 + $result = BrandsModel::getBrandByDomain($domain);
130 if (!$result) { 146 if (!$result) {
131 $this->go(SITE_MAIN); 147 $this->go(SITE_MAIN);
132 } 148 }
@@ -260,4 +276,148 @@ class IndexController extends WebAction @@ -260,4 +276,148 @@ class IndexController extends WebAction
260 } 276 }
261 277
262 278
  279 + /**
  280 + * 品牌店铺首页
  281 + */
  282 + public function shopHome($shopId)
  283 + {
  284 + $domain = $this->param('named');
  285 + // 设置头部数据
  286 + $this->setWebNavHeader();
  287 + $misort = $this->get('misort');
  288 +
  289 + $pjax = $this->get('_pjax');
  290 + if ($pjax) {
  291 + $data = ShopModel::getGoods(
  292 + array(
  293 + 'shop' => $shopId
  294 + ),
  295 + array(
  296 + 'controller' => 'Index',
  297 + 'action' => 'index',
  298 + 'misort' => $misort
  299 + )
  300 + );
  301 + $data['shopIndexPage'] = true;
  302 + // 渲染模板
  303 + $this->_view->display('goods-list', $data);
  304 + exit();
  305 + }
  306 +
  307 + //获取uid
  308 + $uid = $this->getUid();
  309 +
  310 + $parameters = array(
  311 + 'condition' => array(
  312 + 'shop' => $shopId
  313 + ),
  314 + 'options' => array(
  315 + 'controller' => 'Index',
  316 + 'action' => 'index',
  317 + 'misort' => $misort
  318 + ),
  319 + 'uid' => $uid,
  320 + 'navBar' => $this->get('navBar', 0),
  321 + 'brand' => $this->get('brand', 0)
  322 + );
  323 +
  324 + $data = array_merge(
  325 + array(
  326 + 'shopIndexPage' => true,
  327 + 'pathNav' => false, // pathNav数据结构同其他页面
  328 + 'coupon' => false, // 先不做
  329 + 'trendInfo' => ShopModel::getArticle($domain),
  330 + ),
  331 + ShopModel::getData($shopId, $parameters)
  332 + );
  333 +
  334 + $this->_view->display('shop-index', $data);
  335 + }
  336 +
  337 + //店铺列表页
  338 + public function shopListAction()
  339 + {
  340 + //品牌域名,没有获取到品牌域名的跳转首页
  341 + $domain = $this->param('named');
  342 +
  343 + //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
  344 + $result = BrandsModel::getBrandByDomain($domain);
  345 +
  346 + if (isset($result['code']) && $result['code'] !== 200 || empty($result['shopId'])) {
  347 + $this->go(SITE_MAIN);
  348 + }
  349 +
  350 + $shopId = $result['shopId'];
  351 +
  352 + //获取uid
  353 + $uid = $this->getUid();
  354 +
  355 + // 设置头部数据
  356 + $this->setWebNavHeader();
  357 +
  358 + $parameters = array(
  359 + 'condition' => array(
  360 + 'shop' => $shopId
  361 + ),
  362 + 'options' => array(
  363 + 'controller' => 'Index',
  364 + 'action' => 'index',
  365 + ),
  366 + 'uid' => $uid,
  367 + 'navBar' => $this->get('navBar', 1),
  368 + 'brand' => $this->get('brand', 0)
  369 + );
  370 +
  371 + $data = array_merge(
  372 + array(
  373 + 'shopIndexPage' => true,
  374 + 'pathNav' => false, // pathNav数据结构同其他页面
  375 + 'coupon' => false, // 先不做
  376 + ),
  377 + ShopModel::getShopListData($shopId, $parameters)
  378 + );
  379 +
  380 + $this->_view->display('shop-list', $data);
  381 +
  382 + }
  383 +
  384 + /**
  385 + * 店铺收藏与取消
  386 + * @return type json
  387 + */
  388 + public function setFavoriteAction()
  389 + {
  390 + $result = $this->_information;
  391 + if (!$this->isAjax()) {
  392 + return;
  393 + }
  394 +
  395 + //获取uid
  396 + $uid = $this->getUid();
  397 +
  398 + do{
  399 + if (empty($uid)) {
  400 + $result = array(
  401 + 'code' => 401,
  402 + 'message' => '请先登录!',
  403 + 'url' => Helpers::url('/signin.html', array(), 'default')
  404 + );
  405 + break;
  406 + }
  407 + $shopId = $this->post('shopId');
  408 + $isFavorite = $this->post('isFavorite');
  409 + $needColloect = $this->post('needColloect', 0);
  410 +
  411 + if (empty($shopId)) {
  412 + break;
  413 + }
  414 +
  415 + //$needColloect 说明刚登录状态 是cookie传的值
  416 + $isFavorite = $needColloect * 1 === 1 ? true : $isFavorite;
  417 + $result = ShopModel::setFavorite($shopId, $isFavorite, $uid);
  418 +
  419 + } while (false);
  420 +
  421 + $this->echoJson($result);
  422 + }
263 } 423 }
@@ -49,6 +49,20 @@ routes.item.route.action = Index @@ -49,6 +49,20 @@ routes.item.route.action = Index
49 routes.item.map.1 = productId 49 routes.item.map.1 = productId
50 routes.item.map.2 = goodsId 50 routes.item.map.2 = goodsId
51 51
  52 +;店铺装修
  53 +routes.brandshopList.type = "rewrite"
  54 +routes.brandshopList.match = "/shoplist"
  55 +routes.brandshopList.route.module = Product
  56 +routes.brandshopList.route.controller = Index
  57 +routes.brandshopList.route.action = shopList
  58 +
  59 +;店铺装修-收藏与取消
  60 +routes.brandFavorite.type = "rewrite"
  61 +routes.brandFavorite.match = "/shoplist/setFavorite"
  62 +routes.brandFavorite.route.module = Product
  63 +routes.brandFavorite.route.controller = Index
  64 +routes.brandFavorite.route.action = setFavorite
  65 +
52 routes.itemshow.type = "regex" 66 routes.itemshow.type = "regex"
53 routes.itemshow.match = "#/product/show_([0-9]+)_([0-9]+).html#" 67 routes.itemshow.match = "#/product/show_([0-9]+)_([0-9]+).html#"
54 routes.itemshow.route.module = Product 68 routes.itemshow.route.module = Product