Authored by whb

h5的brand事件

... ... @@ -6,7 +6,8 @@
define('mobile', function(require, exports) {
var $ = require('zepto'),
swipe = require("plugins/swipe");
swipe = require("plugins/swipe"),
common = require("common");
exports.index = function() {
//大banner滑动
swipe.init({
... ... @@ -29,6 +30,34 @@ define('mobile', function(require, exports) {
};
exports.brand = function() {
var getBrand = function()
{
var brand = $.trim($("input[type='text']").val());
var template = '<ul class="brand-list cooperation-list clearfix">{li}</ul>';
var noSearchTemplate = '<div class="no-search" style="display:block;"><p>未搜索到“{brand}”的相关品牌</p><a href="javascript:;" class="all_brand"><查看全部品牌</a></div>';
var html = '';
$.ajax({
type: "post",
url: "/brand/getbrand",
data: {
brand: brand
},
dataType:'json',
success: function(data) {
var brands = data.data;
if (data.code == 200 && brands != "") {
$.each(brands, function(k, v) {
html += '<li><a href=""javascript:void(0);" target="_blank" title="' + v.name + '"><div class="img-box" brand_id="' + v.id + '">' +
'<img src="' + common.getImages(v.logo, '0145x0097', 'blogimg', 'primary') + '" alt="" alt="' + v.name + '"></div>' +
'<p>' + v.name + '</p></a></li>';
});
$(".brand-content").html(template.replace('{li}', html));
} else {
$(".brand-content").html(noSearchTemplate.replace('{brand}', brand));
}
}
});
};
//大banner滑动
swipe.init({
slideBox: '.slide-box',
... ... @@ -37,13 +66,20 @@ define('mobile', function(require, exports) {
auto: 3000,
continuous: true
});
//搜索框获得焦点
$('.search-wrap input').on('focus', function() {
var offsetTop = $('.search-wrap').offset().top;
$('.overlay').addClass('show');
//document.body.scrollTop = offsetTop;
});
$('.search-wrap').find('input').on('keyup', function(event) {
var keycode = event.which;
getBrand();
if(keycode == 13)
{
$('.search-wrap input').blur();
}
});
$('.search-btn').on('tap', function() {
$('.search-wrap input').focus().addClass('hasVal');
});
... ... @@ -54,8 +90,9 @@ define('mobile', function(require, exports) {
txtInput.removeClass('hasVal');
} else {
txtInput.addClass('hasVal');
}
};
});
getBrand();
};
exports.scene = function() {
... ...
... ... @@ -71,6 +71,10 @@ class Controller_Abstract extends Framework_YController
$callback = $cookieUrl;
}
}
if($this->_request->isAjax())
{
$this->_platform = 'web';
}
//yohobuy.com连接,自动跳转到客户端
if(strpos($callback, 'yohobuy.com') !== false)
{
... ...
... ... @@ -27,6 +27,7 @@
<div class="bd">
<?php $this->_block('main');$this->_endblock();?>
</div>
<div class="overlay"></div>
</div>
<?php $this->_js('index.js', array(
SITE_JS . '/lib/seajs.js',
... ...
<?php $this->_extends('layout/default_layout_mobile');?>
<?php $this->_block('main');?>
<div class="mobile-position">
<a class="mobile-back" href="<?php echo $this->view->callback;?>"></a>
<h2>品牌</h2>
</div>
<div class="mobile-container">
<div class="brand-list">
<ul class="clearfix">
<?php foreach ($this->view->list as $val):?>
<?php if($val['pics'] && $val['pics']!='[]'):?>
<li>
<a href="<?php echo url('brand/detail',array('id' => $val['id']))?>" title="<?php echo $val['name'];?>">
<img src="<?php echo Lib_Images::getImageUrl($val['logo'],'source','fragmentimg');?>" alt="<?php echo $val['name'];?>"/>
<p><?php echo $val['name']?></p>
</a>
</li>
<?php endif;?>
<?php endforeach;?>
</ul>
<div class="search-wrap">
<input type="text">
<a href="javascript:;" class="search-btn"><span class="iconfont">&#xe611;</span><em>搜索</em></a>
</div>
<div class="slide-main">
<div class="slide-box">
<div class="slide-wrap clearfix">
<?php foreach($this->view->banners as $banner):?>
<div class="box">
<a href="<?php echo $banner['url'];?>" target="_blank" title="<?php echo $banner['text'];?>">
<img src="<?php echo Lib_Images::getImageUrl($banner['res'],'0360x0174','fragmentimg');?>" alt=""/></a>
</div>
<?php endforeach;?>
</div>
</div>
<div class="slide-navigator">
<div class="dib clearfix">
<?php echo '<a href="javascript:;" class="on"></a>'.str_repeat('<a href="javascript:;"></a>', count($this->view->banners) - 1);?>
</div>
<?php $this->_endblock();?>
\ No newline at end of file
</div>
</div>
<div class="brand-main">
<div class="brand-content" >
</div>
</div>
<?php $this->_endblock();?>
<?php $this->_block('js');?>
<script type="text/javascript">
seajs.use(['zepto', 'mobile'],function($, mobile){
mobile.brand();
})
</script>
<?php $this->_endblock();?>
\ No newline at end of file
... ...