Authored by ccbikai

增加品牌一览 搜索页面

framework @ 119c247f
1 -Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2 1 +Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
@@ -52,11 +52,60 @@ if ($brandList.length > 0) { @@ -52,11 +52,60 @@ if ($brandList.length > 0) {
52 }); 52 });
53 } 53 }
54 54
55 -myHammer = new Hammer($('#right-bar .con').find('b').unbind()[0]);  
56 -myHammer.on('tap', function(e) {  
57 - var index = $(this).index(); 55 +if ($('#right-bar .con').find('b').unbind()[0]) {
  56 + myHammer = new Hammer($('#right-bar .con').find('b').unbind()[0]);
  57 + myHammer.on('tap', function(e) {
  58 + var index = $(this).index();
58 59
59 - if ($('.bar-' + index).size() > 0) {  
60 - document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);  
61 - } 60 + if ($('.bar-' + index).size() > 0) {
  61 + document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);
  62 + }
  63 + });
  64 +}
  65 +
  66 +function searchResult(type) {
  67 + var keyword = $('#keyword').val(),
  68 + gender = $('#gender').val();
  69 +
  70 + $.get('/brands/search', {
  71 + keyword: keyword,
  72 + gender: gender,
  73 + type: type
  74 + }, function(html) {
  75 + $('.search-result').html(html);
  76 +
  77 + });
  78 +}
  79 +
  80 +$('#keyword').on('keyup', function() {
  81 + searchResult(0);
  82 +}).on('keydown', function() {
  83 + $(this).closest('.search-box').css('width', '11.25rem');
  84 + $('.search-action').show();
  85 +}).on('blur', function() {
  86 + $(this).closest('.search-box').css('width', '12.5rem');
  87 + $('.search-action').hide();
  88 +});
  89 +
  90 +$('#search-btn').on('tap', function() {
  91 + searchResult(1);
  92 +});
  93 +
  94 +$('.clear-text').on('tap', function() {
  95 + $('#keyword').val('').trigger('input');
  96 +});
  97 +
  98 +$('form.search-box').on('submit', function() {
  99 + return false;
  100 +});
  101 +
  102 +$('.clear-history').on('tap', function() {
  103 +
  104 + // setcookie('h_brands', '', {
  105 + // expire: -1,
  106 + // path: '/',
  107 + // domain: '.m.yohobuy.com'
  108 + // });
  109 + $('#history-keyword').remove();
  110 + $(this).hide();
62 }); 111 });
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 z-index: 2; 11 z-index: 2;
12 .search-box { 12 .search-box {
13 position: relative; 13 position: relative;
  14 + width: 500rem / $pxConvertRem;//450
14 height: 60rem / $pxConvertRem; 15 height: 60rem / $pxConvertRem;
15 background-color: #FFF; 16 background-color: #FFF;
16 border-radius: 30rem / $pxConvertRem; 17 border-radius: 30rem / $pxConvertRem;
@@ -37,7 +38,25 @@ @@ -37,7 +38,25 @@
37 line-height: 60rem / $pxConvertRem; 38 line-height: 60rem / $pxConvertRem;
38 color: #bdbdbd; 39 color: #bdbdbd;
39 } 40 }
40 - 41 + .search-input {
  42 + border: none;
  43 + width: 95%;
  44 + height: 60rem / $pxConvertRem;
  45 + line-height: 1;
  46 + padding: 0 10rem / $pxConvertRem;
  47 + }
  48 + .search-action {
  49 + display: none;
  50 + position: absolute;
  51 + top: 0;
  52 + right: -74rem / $pxConvertRem;
  53 + font-size: 32rem / $pxConvertRem;
  54 + line-height: 60rem / $pxConvertRem;
  55 + color: #666;
  56 + }
  57 + .clear-text {
  58 + margin-right: 20rem / $pxConvertRem;
  59 + }
41 } 60 }
42 61
43 } 62 }
  1 +{{> layout/header}}
  2 +<div class="brand-page yoho-page">
  3 + <div class="newbrand-search">
  4 + <form class="search-box clearfix">
  5 + <input type="text" class="search-input" id="keyword" placeholder="查找品牌">
  6 + <input type="hidden" id="gender" name="gender" value="1,3">
  7 + <i class="search-icon iconfont">&#xe60f;</i>
  8 + <div class="search-action">
  9 + <span class="iconfont clear-text">&#xe623;</span>
  10 + <span class="search-btn">搜索</span>
  11 + </div>
  12 + </form>
  13 + </div>
  14 +
  15 + <div class="search-result">
  16 + </div>
  17 +</div>
  18 +{{> layout/footer}}
  19 +{{> layout/download_app}}
@@ -43,4 +43,39 @@ class BrandController extends AbstractAction @@ -43,4 +43,39 @@ class BrandController extends AbstractAction
43 $this->_view->display('index', Category\BrandModel::getBrandByChannel($channel)); 43 $this->_view->display('index', Category\BrandModel::getBrandByChannel($channel));
44 } 44 }
45 45
  46 + /**
  47 + * 品牌一览搜索页
  48 + *
  49 + * @param string gender 老版本中使用的参数, 做兼容判断
  50 + * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
  51 + */
  52 + public function searchAction()
  53 + {
  54 + $this->setTitle('品牌一览');
  55 + $this->setNavHeader('品牌一览');
  56 +
  57 + /* 判断参数是否有效 */
  58 + $channel = null;
  59 + $gender = $this->get('gender');
  60 + if (!empty($gender)) {
  61 + switch ($gender) {
  62 + case '1,3': // 男
  63 + $channel = 1;
  64 + break;
  65 + case '2,3': // 女
  66 + $channel = 2;
  67 + break;
  68 + }
  69 + }
  70 + if (!isset($channel)) {
  71 + $channel = $this->get('channel', 1);
  72 + if (!is_numeric($channel) || intval($channel) > 4) {
  73 + $channel = 1;
  74 + }
  75 + }
  76 +
  77 + // 渲染模板
  78 + $this->_view->display('search', Category\BrandModel::getBrandByChannel($channel));
  79 + }
  80 +
46 } 81 }
@@ -68,6 +68,13 @@ routes.brands.route.module = Category @@ -68,6 +68,13 @@ routes.brands.route.module = Category
68 routes.brands.route.controller = Brand 68 routes.brands.route.controller = Brand
69 routes.brands.route.action = Index 69 routes.brands.route.action = Index
70 70
  71 +; 品牌一览搜索页
  72 +routes.brands.type = "rewrite"
  73 +routes.brands.match = "/brands/search"
  74 +routes.brands.route.module = Category
  75 +routes.brands.route.controller = Brand
  76 +routes.brands.route.action = Search
  77 +
71 ; 新品到着(NEW) 78 ; 新品到着(NEW)
72 routes.productnew.type = "rewrite" 79 routes.productnew.type = "rewrite"
73 routes.productnew.match = "/product/new$" 80 routes.productnew.match = "/product/new$"