Authored by ccbikai

频道选择页面 顶部搜索

@@ -6,6 +6,10 @@ @@ -6,6 +6,10 @@
6 6
7 var $ = require('yoho.zepto'); 7 var $ = require('yoho.zepto');
8 8
  9 +var $searchBox = $('.search-box'),
  10 + $indexSearch = $('.index-search'),
  11 + $indexLogo = $('.index-logo');
  12 +
9 function downLoadApp() { 13 function downLoadApp() {
10 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'; 14 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
11 var clickedAt = new Date(); 15 var clickedAt = new Date();
@@ -40,3 +44,42 @@ if (!window.cookie('_float-layer-app')) { @@ -40,3 +44,42 @@ if (!window.cookie('_float-layer-app')) {
40 $('#float-layer-app').hide(); 44 $('#float-layer-app').hide();
41 } 45 }
42 46
  47 +/**
  48 + * 频道选择页面顶部搜索
  49 + * @author: bikai<kai.bi@yoho.cn>
  50 + * @date: 2015/10/28
  51 + */
  52 +
  53 +$searchBox.find('input').on('focus', function () {
  54 + $indexLogo.css({
  55 + width: 0,
  56 + display: 'none'
  57 + });
  58 + $searchBox.css({
  59 + width: '12.8rem'
  60 + });
  61 + $indexSearch.css({
  62 + width: '15.5rem'
  63 + });
  64 + $('.clear-text, .no-search').show();
  65 +}).on('blur', function () {
  66 + $indexLogo.css({
  67 + width: '5.4rem',
  68 + display: 'block'
  69 + });
  70 + $searchBox.css({
  71 + width: '8.8rem'
  72 + });
  73 + $indexSearch.css({
  74 + width: '9.6rem'
  75 + });
  76 + $('.clear-text, .no-search').hide();
  77 +});
  78 +
  79 +$searchBox.find('.clear-text').tap(function () {
  80 + $searchBox.find('input').val('').trigger('focus');
  81 +});
  82 +
  83 +$searchBox.find('.search-icon').tap(function () {
  84 + $indexSearch.submit();
  85 +});
@@ -2,7 +2,71 @@ @@ -2,7 +2,71 @@
2 width: 100%; 2 width: 100%;
3 overflow: hidden; 3 overflow: hidden;
4 margin: 0 auto; 4 margin: 0 auto;
  5 + .index-header {
  6 + padding: 0 20rem / $pxConvertRem;
  7 + width: 100%;
  8 + height: 96rem / $pxConvertRem;
  9 + line-height: 96rem / $pxConvertRem;
5 10
  11 + .index-logo {
  12 + float: left;
  13 + font-size: 50rem / $pxConvertRem;
  14 + width: 216rem / $pxConvertRem;
  15 + color: #343434;
  16 + }
  17 +
  18 + .index-search {
  19 + float: right;
  20 + width: 384rem / $pxConvertRem;
  21 + .search-box {
  22 + float: left;
  23 + position: relative;
  24 + top: 20rem / $pxConvertRem;
  25 + width: 352rem / $pxConvertRem;
  26 + height: 56rem / $pxConvertRem;
  27 + padding-right: 40rem / $pxConvertRem;
  28 + z-index: 1;
  29 + transition: width 400ms;
  30 + box-sizing: border-box;
  31 + border: 1px solid #ccc;
  32 + overflow: hidden;
  33 + }
  34 + input {
  35 + float: left;
  36 + width: 100%;
  37 + font-size: 28rem / $pxConvertRem;
  38 + padding: 10rem / $pxConvertRem;
  39 + color: #999;
  40 + overflow: hidden;
  41 + border: none;
  42 + }
  43 + .iconfont {
  44 + position: absolute;
  45 + top: 8rem / $pxConvertRem;
  46 + width: 40rem / $pxConvertRem;
  47 + font-size: 28rem / $pxConvertRem;
  48 + z-index: 1;
  49 + line-height: 40rem / $pxConvertRem;
  50 + }
  51 + .clear-text {
  52 + display: none;
  53 + right: 50rem / $pxConvertRem;
  54 + color: #ccc;
  55 + }
  56 + .search-icon {
  57 + right: 10rem / $pxConvertRem;
  58 + color: #e6e6e6;
  59 + }
  60 + }
  61 +
  62 + .no-search {
  63 + display: none;
  64 + float: left;
  65 + margin-right: 10rem / $pxConvertRem;
  66 + color: #999;
  67 + font-size: 28rem / $pxConvertRem;
  68 + }
  69 + }
6 .index-container { 70 .index-container {
7 position: relative; 71 position: relative;
8 @include transition(transform 0.5s); 72 @include transition(transform 0.5s);
@@ -3,6 +3,17 @@ @@ -3,6 +3,17 @@
3 <div class="index-page yoho-page"> 3 <div class="index-page yoho-page">
4 4
5 <div class="index-container"> 5 <div class="index-container">
  6 + <div class="index-header clearfix">
  7 + <div class="iconfont index-logo">&#xe60e;</div>
  8 + <form action="http://search.m.yohobuy.com" class="index-search">
  9 + <a href="javascript:void(0);" class="no-search">取消</a>
  10 + <div class="search-box">
  11 + <input type="text" name="query" placeholder="搜索">
  12 + <span class="iconfont clear-text">&#xe623;</span>
  13 + <span class="iconfont search-icon">&#xe60f;</span>
  14 + </div>
  15 + </form>
  16 + </div>
6 17
7 <div class="index-channel"> 18 <div class="index-channel">
8 <img class="img" src="{{background}}" alt=""> 19 <img class="img" src="{{background}}" alt="">