...
|
...
|
@@ -2,7 +2,8 @@ define("index", ["jquery","handlebars","source-map","index","lazyload","jquery.p |
|
|
var webYohobuy;
|
|
|
|
|
|
require("js/common");
|
|
|
|
|
|
require("js/header");
|
|
|
require("js/simple-header");
|
|
|
require("js/product/entry");
|
|
|
require("js/home/entry");
|
|
|
require("js/passport/entry");
|
...
|
...
|
@@ -10,7 +11,7 @@ require("js/passport/entry"); |
|
|
module.exports = webYohobuy;
|
|
|
|
|
|
});
|
|
|
define("js/common", ["jquery","handlebars","source-map","index"], function(require, exports, module){
|
|
|
define("js/common", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 页面公共逻辑和接口
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
...
|
...
|
@@ -18,8 +19,10 @@ define("js/common", ["jquery","handlebars","source-map","index"], function(requi |
|
|
*/
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
require("js/footer");
|
|
|
|
|
|
var $body = $('body');
|
|
|
|
|
|
require("js/footer");
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -109,33 +112,52 @@ function getShoppingKey() { |
|
|
}
|
|
|
|
|
|
//YAS统计代码
|
|
|
//(function(w, d, s, j, f) {
|
|
|
// var a = d.createElement(s);
|
|
|
// var m = d.getElementsByTagName(s)[0];
|
|
|
//
|
|
|
// w.YohoAcquisitionObject = f;
|
|
|
//
|
|
|
// w[f] = function() {
|
|
|
// w[f].p = arguments;
|
|
|
// };
|
|
|
//
|
|
|
// a.async = 1;
|
|
|
// a.src = j;
|
|
|
// m.parentNode.insertBefore(a, m);
|
|
|
//})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
|
|
|
(function(w, d, s, j, f) {
|
|
|
var a = d.createElement(s);
|
|
|
var m = d.getElementsByTagName(s)[0];
|
|
|
|
|
|
w.YohoAcquisitionObject = f;
|
|
|
|
|
|
w[f] = function() {
|
|
|
w[f].p = arguments;
|
|
|
};
|
|
|
|
|
|
a.async = 1;
|
|
|
a.src = j;
|
|
|
m.parentNode.insertBefore(a, m);
|
|
|
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
|
|
|
|
|
|
(function() {
|
|
|
var uid = getUid();
|
|
|
|
|
|
uid = uid === 0 ? '' : uid;
|
|
|
|
|
|
window._ozuid = uid;//暴露ozuid
|
|
|
window._ozuid = uid; //暴露ozuid
|
|
|
|
|
|
if (window._yas) {
|
|
|
window._yas(1 * new Date(), '1.0.14', 'yohobuy_web', uid, '', '');
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
//window.resize在width<1180时适配成990
|
|
|
$(window).on('resize', function() {
|
|
|
var w = $(this).width();
|
|
|
|
|
|
//return top
|
|
|
if (w < 1360) {
|
|
|
$('.return-top').addClass('min');
|
|
|
} else {
|
|
|
$('.return-top').removeClass('min');
|
|
|
}
|
|
|
|
|
|
//body
|
|
|
if (w < 1180) {
|
|
|
$body.addClass('min-screen');
|
|
|
} else {
|
|
|
$body.removeClass('min-screen');
|
|
|
}
|
|
|
}).trigger('resize');
|
|
|
|
|
|
window.cookie = cookie;
|
|
|
|
|
|
window.setCookie = setCookie;
|
...
|
...
|
@@ -145,11 +167,6 @@ window.getUser = getUser; |
|
|
window.getUid = getUid;
|
|
|
|
|
|
window.getShoppingKey = getShoppingKey;
|
|
|
if($('.simple-header').hasClass('simple-header')){
|
|
|
require("js/simple-header");
|
|
|
}else{
|
|
|
require("js/header");
|
|
|
}
|
|
|
|
|
|
|
|
|
});
|
...
|
...
|
@@ -315,109 +332,6 @@ actionhomeFootChange(); |
|
|
//暴露给有可能通AJAX改变内容的页面去用
|
|
|
window.rePosReturnTop = rePosReturn;
|
|
|
});
|
|
|
define("js/simple-header", ["jquery"], function(require, exports, module){
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
if ($('.simple-header').size() > 0) {
|
|
|
$('.tool-options').on('mouseenter', function() {
|
|
|
$(this).find('.tool-select').fadeIn();
|
|
|
}).on('mouseleave', function() {
|
|
|
$(this).find('.tool-select').fadeOut();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 格式化用户名
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function formatUsernName(userName) {
|
|
|
var name,
|
|
|
char,
|
|
|
_num = 0,
|
|
|
_length = 0,
|
|
|
t;
|
|
|
|
|
|
for (t = 0; 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;
|
|
|
name = '';
|
|
|
for (t = 0; 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 += '...';
|
|
|
}
|
|
|
}
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置简单头部登陆状态
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function setLoginStatus(_data) {
|
|
|
var loginHtml,
|
|
|
name;
|
|
|
|
|
|
if (_data && _data.href && _data.href.user) {
|
|
|
name = formatUsernName(_data.href.user);
|
|
|
loginHtml = '<span>Hi~</span><a href="">' +
|
|
|
name + '</a> <a href="' + _data.href.logout + '">[退出]</a>';
|
|
|
} else {
|
|
|
name = formatUsernName(_data.user);
|
|
|
loginHtml = '<span>Hi~</span><a href="">' +
|
|
|
name + '</a> <a href="http://www.yohobuy.com/signin.html">[请登录]</a>' +
|
|
|
'<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>';
|
|
|
}
|
|
|
$('.header-tool li').eq(0).html(loginHtml);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取登录信息
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function actionLoginInfo() {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/common/getSimpleHeader',
|
|
|
data: {},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
setLoginStatus(data.data);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化函数
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function init() {
|
|
|
actionLoginInfo(); //获取登录信息
|
|
|
}
|
|
|
|
|
|
init();
|
|
|
});
|
|
|
define("js/header", ["jquery","handlebars","source-map","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 头部
|
...
|
...
|
@@ -1930,7 +1844,7 @@ function actionLoginInfo() { |
|
|
* 初始化函数
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function init() {
|
|
|
exports.init = function() {
|
|
|
actionNav(); //处理导航
|
|
|
actionTipPic(); //鼠标移入后查询
|
|
|
actionExeTemplate(); //处理模板
|
...
|
...
|
@@ -1954,9 +1868,112 @@ function init() { |
|
|
actionLoginInfo(); //获取登录信息
|
|
|
actionCover(); //初次登录弹框
|
|
|
actionAddKeyWords(); //增加关键字
|
|
|
};
|
|
|
|
|
|
|
|
|
});
|
|
|
define("js/simple-header", ["jquery"], function(require, exports, module){
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
if ($('.simple-header').size() > 0) {
|
|
|
$('.tool-options').on('mouseenter', function() {
|
|
|
$(this).find('.tool-select').fadeIn();
|
|
|
}).on('mouseleave', function() {
|
|
|
$(this).find('.tool-select').fadeOut();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
init();
|
|
|
/**
|
|
|
* 格式化用户名
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function formatUsernName(userName) {
|
|
|
var name,
|
|
|
char,
|
|
|
_num = 0,
|
|
|
_length = 0,
|
|
|
t;
|
|
|
|
|
|
for (t = 0; 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;
|
|
|
name = '';
|
|
|
for (t = 0; 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 += '...';
|
|
|
}
|
|
|
}
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置简单头部登陆状态
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function setLoginStatus(_data) {
|
|
|
var loginHtml,
|
|
|
name;
|
|
|
|
|
|
if (_data && _data.href && _data.href.user) {
|
|
|
name = formatUsernName(_data.href.user);
|
|
|
loginHtml = '<span>Hi~</span><a href="">' +
|
|
|
name + '</a> <a href="' + _data.href.logout + '">[退出]</a>';
|
|
|
} else {
|
|
|
name = formatUsernName(_data.user);
|
|
|
loginHtml = '<span>Hi~</span><a href="">' +
|
|
|
name + '</a> <a href="http://www.yohobuy.com/signin.html">[请登录]</a>' +
|
|
|
'<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>';
|
|
|
}
|
|
|
$('.header-tool li').eq(0).html(loginHtml);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取登录信息
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function actionLoginInfo() {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/common/getSimpleHeader',
|
|
|
data: {},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
setLoginStatus(data.data);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化函数
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.init = function() {
|
|
|
actionLoginInfo(); //获取登录信息
|
|
|
};
|
|
|
|
|
|
|
|
|
});
|
|
|
define("js/product/entry", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -2535,11 +2552,6 @@ exports.init = function(num) { |
|
|
wrapperPt, //鼠标移入时弹层的上内边距
|
|
|
containerPt; //商品列表容器的上内边距
|
|
|
|
|
|
// 获取图片之前,先把获取上一张图片的ajax请求取消。 网络差的时候会出现错误
|
|
|
// if (getProductAjax && getProductAjax.readyState!= 4) {
|
|
|
// getProductAjax.abort();
|
|
|
// }
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/product/list/getProductPic',
|
...
|
...
|
@@ -2614,11 +2626,6 @@ $(document).on('hover', '.good-select-color li', function() { |
|
|
$goodInfoMain.on('click', '.col-btn', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if (!window.getUid()) {
|
|
|
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/product/list/changeFavorite',
|
...
|
...
|
@@ -2629,17 +2636,28 @@ $goodInfoMain.on('click', '.col-btn', function() { |
|
|
}).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
$this.toggleClass('coled');
|
|
|
} else if (res.code === 403) {
|
|
|
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 左侧导航
|
|
|
$productListNav.click(function() {
|
|
|
$productListNav.click(function(event) {
|
|
|
|
|
|
if (!$(event.target).hasClass('product-list-nav')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
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');
|
|
|
});
|
|
|
|
...
|
...
|
@@ -2760,40 +2778,37 @@ module.exports = function($o, rowWidth) { |
|
|
};
|
|
|
});
|
|
|
define("js/product/brand", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 品牌页面
|
|
|
* @auhtor: bikai<kai.bi@yoho.cn>
|
|
|
* @date: 2016/1/21
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
$('#brand-favor').on('click', function() {
|
|
|
var $this = $(this),
|
|
|
uid = window.getUid();
|
|
|
|
|
|
if (!uid) {
|
|
|
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/product/index/favoriteBrand',
|
|
|
data: {
|
|
|
uid: uid,
|
|
|
brandId: $this.data('id')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
if (res.message === 'add') {
|
|
|
$this.find('i').addClass('coled');
|
|
|
} else {
|
|
|
$this.find('i').removeClass('coled');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
/**
|
|
|
* 品牌页面
|
|
|
* @auhtor: bikai<kai.bi@yoho.cn>
|
|
|
* @date: 2016/1/21
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
$('#brand-favor').on('click', function() {
|
|
|
var $this = $(this),
|
|
|
uid = window.getUid();
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/product/index/favoriteBrand',
|
|
|
data: {
|
|
|
uid: uid,
|
|
|
brandId: $this.data('id')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
if (res.message === 'add') {
|
|
|
$this.find('i').addClass('coled');
|
|
|
} else {
|
|
|
$this.find('i').removeClass('coled');
|
|
|
}
|
|
|
} else if (res.code === 403) {
|
|
|
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/product/hotrank", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
|
...
|
...
|
@@ -4741,8 +4756,8 @@ function msgCaptchaAjaxFn(page, callback) { |
|
|
function validateRule(page, $element, callback) {
|
|
|
|
|
|
var val = $.trim($element.val()),
|
|
|
regionCode;
|
|
|
|
|
|
regionCode,
|
|
|
pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi;
|
|
|
|
|
|
//手机号校验
|
|
|
if ($element.hasClass('phone-num')) {
|
...
|
...
|
@@ -4809,6 +4824,7 @@ function validateRule(page, $element, callback) { |
|
|
} else {
|
|
|
validateResult[2].message = '短信验证码错误';
|
|
|
validateResult[2].status = false;
|
|
|
callback();
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -4822,8 +4838,8 @@ function validateRule(page, $element, callback) { |
|
|
validateResult[3].message = '密码只支持6-20位字符';
|
|
|
validateResult[3].status = false;
|
|
|
|
|
|
} else if (/\s/.test($element.val())) {
|
|
|
validateResult[3].message = '密码不能包含空格';
|
|
|
} else if (!pwdReg.test($element.val())) {
|
|
|
validateResult[3].message = '密码只能包含字母,数字,半角标点符号';
|
|
|
validateResult[3].status = false;
|
|
|
|
|
|
} else {
|
...
|
...
|
@@ -4963,10 +4979,8 @@ exports.init = function(page) { |
|
|
|
|
|
$('#agree-terms').click(function() {
|
|
|
if ($(this).attr('notchecked')) {
|
|
|
console.log(1);
|
|
|
$(this).removeAttr('notchecked');
|
|
|
} else {
|
|
|
console.log(2);
|
|
|
$(this).attr('notchecked', 'true');
|
|
|
}
|
|
|
|
...
|
...
|
|