...
|
...
|
@@ -301,13 +301,14 @@ define("js/header", ["jquery","handlebars","source-map","index"], function(requi |
|
|
* @author: wangqing<robin.wang@yoho.cn>
|
|
|
* @date: 2015/12/01
|
|
|
*/
|
|
|
|
|
|
|
|
|
var $ = require("jquery");
|
|
|
var handlebars = require("handlebars");
|
|
|
var json2 = require("index");
|
|
|
var noticeSuccess = false;
|
|
|
|
|
|
var vipInfoCombine = null;
|
|
|
var loginInfoCombine = null;
|
|
|
var apiDomain = 'http://api.open.yohobuy.com';
|
|
|
var cartTpl = '';
|
|
|
/**
|
|
|
* 判断为1的helper
|
|
|
* @param {[type]} v1 [description]
|
...
|
...
|
@@ -322,6 +323,37 @@ handlebars.registerHelper('equalone', function(v1, options) { |
|
|
return options.inverse(this);
|
|
|
}
|
|
|
});
|
|
|
/**
|
|
|
* 判断等级为3的helper
|
|
|
* @param {[type]} v1 [description]
|
|
|
* @param {[type]} options) { if (v1 [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
|
|
|
handlebars.registerHelper('equallevelthree', function(v1, options) {
|
|
|
|
|
|
if (v1 === '3') {
|
|
|
return options.fn(this);
|
|
|
} else {
|
|
|
return options.inverse(this);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 判断为0的helper
|
|
|
* @param {[type]} v1 [description]
|
|
|
* @param {[type]} options) { if (v1 [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
|
|
|
handlebars.registerHelper('equalzero', function(v1, options) {
|
|
|
|
|
|
if (v1 === '0') {
|
|
|
return options.fn(this);
|
|
|
} else {
|
|
|
return options.inverse(this);
|
|
|
}
|
|
|
});
|
|
|
require("plugin/yohocookie");
|
|
|
require("plugin/yohocart");
|
|
|
/**
|
...
|
...
|
@@ -566,13 +598,15 @@ function fadeAnimate() { |
|
|
}
|
|
|
window.$logotrans.fadeOut(window.loopdurationtime, function() {
|
|
|
window.isen = false;
|
|
|
|
|
|
window.$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo.png)');
|
|
|
window.$logotrans.fadeIn(window.loopdurationtime, function() {
|
|
|
window.onetimeoout = window.setTimeout(function() {
|
|
|
window.$logotrans.fadeOut(window.loopdurationtime, function() {
|
|
|
window.clearTimeout(window.onetimeoout);
|
|
|
window.isen = true;
|
|
|
window.$logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
|
|
|
window.$logotrans.css('background-image',
|
|
|
'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
|
|
|
window.$logotrans.fadeIn(window.loopdurationtime, function() {
|
|
|
window.globaltimeout = window.setTimeout(fadeAnimate, 1 * 60 * 1000);
|
|
|
});
|
...
|
...
|
@@ -857,7 +891,7 @@ function loadCartData() { |
|
|
shoppingData,
|
|
|
strK;
|
|
|
|
|
|
$.getData(window.apiDomain, {
|
|
|
$.getData(apiDomain, {
|
|
|
method: 'open.Shoppingcart.getCartData',
|
|
|
shopping_key: $.getShoppingKey()
|
|
|
}, function(jsonData) {
|
...
|
...
|
@@ -894,7 +928,7 @@ function loadCartData() { |
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function delCartGoods(id, isreduce) {
|
|
|
$.getData(window.apiDomain, {
|
|
|
$.getData(apiDomain, {
|
|
|
method: 'open.Shoppingcart.delone',
|
|
|
shopping_key: $.getShoppingKey(),
|
|
|
id: id,
|
...
|
...
|
@@ -912,8 +946,7 @@ function delCartGoods(id, isreduce) { |
|
|
actionUpdateCartNum();
|
|
|
});
|
|
|
}
|
|
|
window.apiDomain = 'http://api.open.yohobuy.com';
|
|
|
window.cartTpl = '';
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 监听购物车删除
|
...
|
...
|
@@ -1115,6 +1148,7 @@ function actionExeTemplate() { |
|
|
var resulthtml = $('#goodcartempwarpper').html().replace(/\\/g, '');
|
|
|
|
|
|
$('#goodcartempwarpper').html(resulthtml);
|
|
|
vipInfoCombine = handlebars.compile($('#tmpl-my-login-new').html());
|
|
|
}
|
|
|
/**
|
|
|
* 执行搜索
|
...
|
...
|
@@ -1126,6 +1160,148 @@ function actionSearch() { |
|
|
$('#query_key').search(searchDomain);
|
|
|
}
|
|
|
/**
|
|
|
* 获取登录状态
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function actionLoginState(_data) {
|
|
|
var timestamp = new Date().getTime();
|
|
|
var noLoginHtml = '<span>Hi~</span>[<a href="http://www.yohobuy.com/signin.html" class="list-a login-out ">' +
|
|
|
'请登录</a>] ' +
|
|
|
'[<a href="http://www.yohobuy.com/reg.html" class="list-a login-out" onclick="">免费注册</a>]';
|
|
|
var loginHtml = '<span>Hi~<a href="http://www.yohobuy.com/home?t=' + timestamp +
|
|
|
'">{{user_name}}</a></span> ' +
|
|
|
'{{#equalone islogin}}' +
|
|
|
'[<a href="{{logout}}" class="list-a login-out">退出</a>]' +
|
|
|
'{{else}}' +
|
|
|
'[<a href="http://www.yohobuy.com/signin.html" class="list-a login-out">请登录</a>] ' +
|
|
|
'[<a href="http://www.yohobuy.com/reg.html" onclick="" class="list-a login-out">免费注册</a>]' +
|
|
|
'{{/equalone}}';
|
|
|
var $boxObj = $('#loginBox');
|
|
|
var info = $.cookie('_UID')||'';
|
|
|
var name = _data.data.profile_name||'';
|
|
|
var _length = 0;
|
|
|
var t = 0;
|
|
|
var char = '';
|
|
|
var user = info.split('::')||'';
|
|
|
var userName = user[0] || ' ';
|
|
|
var _logout = '';
|
|
|
var islogin = '1';
|
|
|
var _num = 0;
|
|
|
var data = {
|
|
|
user_name: name,
|
|
|
logout: _logout,
|
|
|
random: Math.random()
|
|
|
};
|
|
|
|
|
|
|
|
|
loginInfoCombine = handlebars.compile(loginHtml);
|
|
|
if (typeof info === 'undefined' || info === null) {
|
|
|
$boxObj.html(noLoginHtml);
|
|
|
return false;
|
|
|
}
|
|
|
if (typeof user === 'undefined' || user.length < 4) {
|
|
|
$boxObj.html(noLoginHtml);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
for (t; t < userName.length; t++) {
|
|
|
char = userName.substr(t, 1);
|
|
|
if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
|
|
|
_length += 2;
|
|
|
} else {
|
|
|
_length += 1;
|
|
|
}
|
|
|
}
|
|
|
if (_length <= 10) {
|
|
|
name = userName;
|
|
|
} else {
|
|
|
_num = 0;
|
|
|
for (t; t < userName.length; t++) {
|
|
|
if (_num < 10) {
|
|
|
char = userName.substr(t, 1);
|
|
|
if (char !== '*') {
|
|
|
if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
|
|
|
_num += 2;
|
|
|
} else {
|
|
|
_num += 1;
|
|
|
}
|
|
|
}
|
|
|
name += char;
|
|
|
}
|
|
|
}
|
|
|
if (name.length < userName.length) {
|
|
|
name += '...';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (/http:\/\//.test(user[3])) {
|
|
|
_logout = user[3].replace('www.yohobuy.com', 'www.yohobuy.com');
|
|
|
} else {
|
|
|
_logout = 'http://www.yohobuy.com/logout_' + user[3] + '.html';
|
|
|
}
|
|
|
if (_data.result === -1) {
|
|
|
islogin = '-1';
|
|
|
}
|
|
|
data.islogin = islogin;
|
|
|
$boxObj.html(loginInfoCombine(data));
|
|
|
}
|
|
|
/**
|
|
|
* 获得vip用户信息
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function actionVipInfo(_data) {
|
|
|
var vipInfo = _data.data;
|
|
|
var headUrl = '';
|
|
|
|
|
|
if (_data.result === 1) {
|
|
|
if (typeof vipInfo === undefined || vipInfo.length < 1) {
|
|
|
return false;
|
|
|
}
|
|
|
$('#myYohoBox').mouseenter(function() {
|
|
|
$(this).addClass('acttags');
|
|
|
$('#myYohoBox .myyoho-info').show().html(vipInfoCombine(vipInfo));
|
|
|
headUrl = $('.myyoho-photo img').attr('data-url');
|
|
|
if ($._checkUrlState === 1) {
|
|
|
$('.myyoho-photo').show().find('img').attr('src', headUrl);
|
|
|
return;
|
|
|
}
|
|
|
if (headUrl === '' || $._checkUrl !== '') {
|
|
|
return;
|
|
|
}
|
|
|
$.ajax({
|
|
|
url: headUrl,
|
|
|
type: 'GET',
|
|
|
complete: function(response) {
|
|
|
if (response.status === 200 || response.status === 0) {
|
|
|
$('.myyoho-photo').show().find('img').attr('src', headUrl);
|
|
|
$._checkUrlState = 1;
|
|
|
}
|
|
|
$._checkUrl = headUrl;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
$('#myYohoBox').mouseleave(function() {
|
|
|
$(this).removeClass('acttags');
|
|
|
$('#myYohoBox .myyoho-info').hide();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 获取登录信息
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function actionLoginInfo() {
|
|
|
var param = {
|
|
|
method: 'open.passport.get'
|
|
|
};
|
|
|
|
|
|
$.getData(apiDomain, param, function(_data) {
|
|
|
actionLoginState(_data); // 更改登录状态
|
|
|
actionVipInfo(_data); //获得vip;
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 初始化函数
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
...
|
...
|
@@ -1147,6 +1323,7 @@ function init() { |
|
|
actionClickMiniCartBox(); //点击购物车跳转
|
|
|
actionListenDelCarGoods(); //监听购物车删除
|
|
|
actionListenCartMore(); //
|
|
|
actionLoginInfo(); //获取登录信息
|
|
|
}
|
|
|
|
|
|
init();
|
...
|
...
|
@@ -1717,6 +1894,8 @@ exports.init = function(num) { |
|
|
|
|
|
productList = null;
|
|
|
|
|
|
$goodItem.unbind();
|
|
|
|
|
|
productList = productEvent($goodItem, num);
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1834,25 +2013,25 @@ exports.init = function(num) { |
|
|
display: 'none'
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
//鼠标放在颜色列表上效果
|
|
|
$(document).on('hover', '.good-select-color li', function() {
|
|
|
var coverImg = $(this).find('img').attr('data-cover'),
|
|
|
$coverImg = $(this).closest('.good-item-wrapper').find('.good-detail-img').find('img');
|
|
|
//鼠标放在颜色列表上效果
|
|
|
$(document).on('hover', '.good-select-color li', function() {
|
|
|
var coverImg = $(this).find('img').attr('data-cover'),
|
|
|
$coverImg = $(this).closest('.good-item-wrapper').find('.good-detail-img').find('img');
|
|
|
|
|
|
$coverImg.attr('src', coverImg);
|
|
|
});
|
|
|
$coverImg.attr('src', coverImg);
|
|
|
});
|
|
|
|
|
|
// 左侧导航
|
|
|
$productListNav.click(function() {
|
|
|
if ($(this).hasClass('active')) {
|
|
|
$(this).find('.sort-child-list').stop(true, true).slideUp();
|
|
|
} else {
|
|
|
$(this).find('.sort-child-list').stop(true, true).slideDown();
|
|
|
}
|
|
|
$(this).toggleClass('active');
|
|
|
});
|
|
|
};
|
|
|
// 左侧导航
|
|
|
$productListNav.click(function() {
|
|
|
if ($(this).hasClass('active')) {
|
|
|
$(this).find('.sort-child-list').stop(true, true).slideUp();
|
|
|
} else {
|
|
|
$(this).find('.sort-child-list').stop(true, true).slideDown();
|
|
|
}
|
|
|
$(this).toggleClass('active');
|
|
|
});
|
|
|
});
|
|
|
define("js/common/product-event", ["jquery"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -1966,8 +2145,6 @@ module.exports = function($o, rowWidth) { |
|
|
|
|
|
$o.bind('mouseenter', handleEvent);
|
|
|
|
|
|
//$o.bind('mouseleave', handleEvent);
|
|
|
|
|
|
return pMouseHover;
|
|
|
};
|
|
|
});
|
...
|
...
|
|