|
|
define("index", ["zepto","lazyload","swiper","mlellipsis","index"], function(require, exports, module){
|
|
|
var yohobuy;
|
|
|
|
|
|
require("js/passport/index");
|
|
|
require("js/guang/index");
|
|
|
require("js/home/index");
|
|
|
require("js/product/index");
|
|
|
|
|
|
module.exports = yohobuy;
|
|
|
|
|
|
});
|
|
|
define("js/passport/index", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册、登录、密码找回打包入口
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
|
|
|
//注册
|
|
|
require("js/passport/register/register");
|
|
|
require("js/passport/register/code");
|
|
|
require("js/passport/register/password");
|
|
|
|
|
|
//登录
|
|
|
require("js/passport/login/login");
|
|
|
require("js/passport/login/interational");
|
|
|
|
|
|
//密码找回
|
|
|
require("js/passport/back/mobile");
|
|
|
require("js/passport/back/code");
|
|
|
require("js/passport/back/email");
|
|
|
require("js/passport/back/email-success");
|
|
|
require("js/passport/back/new-password");
|
|
|
});
|
|
|
define("js/passport/register/register", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $phoneNum = $('#phone-num'),
|
|
|
$countrySelect = $('#country-select'),
|
|
|
$areaCode = $('#area-code'),
|
|
|
$btnNext = $('#btn-next');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
api.selectCssHack($('#country-select'));
|
|
|
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$phoneNum.bind('input', function() {
|
|
|
if (trim($phoneNum.val()) === '') {
|
|
|
$btnNext.addClass('disable');
|
|
|
} else {
|
|
|
$btnNext.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$countrySelect.change(function() {
|
|
|
$areaCode.text($countrySelect.val());
|
|
|
});
|
|
|
|
|
|
$btnNext.on('touchstart', function() {
|
|
|
var pn = trim($phoneNum.val()),
|
|
|
areaCode = $countrySelect.val();
|
|
|
|
|
|
if ($btnNext.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.phoneRegx[areaCode].test(pn)) {
|
|
|
$.ajax({
|
|
|
url: '/passport/reg/verifymobile',
|
|
|
type: 'POST',
|
|
|
data: {
|
|
|
areaCode: areaCode.replace('+', ''),
|
|
|
phoneNum: pn
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
location.href = data.data;
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('手机号格式不正确,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/passport/api", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 登录注册公用API
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
|
|
|
//邮箱验证规则
|
|
|
var emailRegx = /^([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
|
|
|
|
|
|
//手机号码验证规则
|
|
|
var phoneRegx = {
|
|
|
'+86': /^1[35847]{1}[0-9]{9}$/,
|
|
|
'+852': /^[965]{1}[0-9]{7}$/,
|
|
|
'+853': /^[0-9]{8}$/,
|
|
|
'+886': /^[0-9]{10}$/,
|
|
|
'+65': /^[98]{1}[0-9]{7}$/,
|
|
|
'+60': /^1[1234679]{1}[0-9]{8}$/,
|
|
|
'+1': /^[0-9]{10}$/,
|
|
|
'+82': /^01[0-9]{9}$/,
|
|
|
'+44': /^7[789][0-9]{8}$/,
|
|
|
'+81': /^0[9|8|7][0-9]{9}$/,
|
|
|
'+61': /^[0-9]{11}$/
|
|
|
};
|
|
|
|
|
|
//密码显示隐藏
|
|
|
function bindEyesEvt() {
|
|
|
var $hasEye = $('.has-eye'),
|
|
|
$eye;
|
|
|
|
|
|
$hasEye.append('<div class="eye close"></div>');
|
|
|
$eye = $hasEye.children('.eye');
|
|
|
|
|
|
$eye.on('touchstart', function(e) {
|
|
|
var $this = $(this),
|
|
|
$pwd = $this.siblings('.pwd');
|
|
|
|
|
|
e.preventDefault();
|
|
|
$this.toggleClass('close');
|
|
|
|
|
|
//切换密码显示和文本显示
|
|
|
if ($this.hasClass('close')) {
|
|
|
$pwd.attr('type', 'password');
|
|
|
} else {
|
|
|
$pwd.attr('type', 'text');
|
|
|
}
|
|
|
$pwd.focus();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 清空账号显示
|
|
|
function bindClearEvt() {
|
|
|
var $hasClear = $('.has-clear'),
|
|
|
$clear;
|
|
|
|
|
|
$hasClear.append('<div class="clear-input"></div>');
|
|
|
$clear = $hasClear.children('.clear-input');
|
|
|
|
|
|
$clear.on('touchstart', function(e) {
|
|
|
var $input = $clear.siblings('.input');
|
|
|
|
|
|
$input.val('').trigger('input').focus();
|
|
|
e.preventDefault();
|
|
|
});
|
|
|
|
|
|
//反向逻辑
|
|
|
$hasClear.children('.input').bind('input', function() {
|
|
|
var $this = $(this),
|
|
|
$thisClear = $this.siblings('.clear-input'),
|
|
|
val = trim($this.val());
|
|
|
|
|
|
if (val === '') {
|
|
|
$thisClear.hide();
|
|
|
} else {
|
|
|
$thisClear.show();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 密码长度验证
|
|
|
function pwdValidate(pwd) {
|
|
|
if (pwd.length >= 6 && pwd.length <= 20) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// hack for resolving direction:rtl didn't work in android uc
|
|
|
function selectCssHack($countrySelect) {
|
|
|
var u = navigator.userAgent;
|
|
|
|
|
|
function autoSelectWidth() {
|
|
|
var wordCount = $countrySelect.find('option:selected').text().length;
|
|
|
|
|
|
switch (wordCount) {
|
|
|
|
|
|
//分别有2,3,4个汉字的情况
|
|
|
case 2:
|
|
|
$countrySelect.outerWidth(90);
|
|
|
break;
|
|
|
case 3:
|
|
|
$countrySelect.outerWidth(110);
|
|
|
break;
|
|
|
default:
|
|
|
$countrySelect.outerWidth(130);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (u.match(/uc/i) && u.match(/android/i)) {
|
|
|
$countrySelect.change(function() {
|
|
|
autoSelectWidth();
|
|
|
});
|
|
|
} else {
|
|
|
$countrySelect.removeClass('in-android-uc');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//Exports APIs
|
|
|
module.exports = {
|
|
|
emailRegx: emailRegx,
|
|
|
phoneRegx: phoneRegx,
|
|
|
bindEyesEvt: bindEyesEvt,
|
|
|
bindClearEvt: bindClearEvt,
|
|
|
pwdValidate: pwdValidate,
|
|
|
selectCssHack: selectCssHack
|
|
|
};
|
|
|
});
|
|
|
define("js/plugin/tip", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 弹框提示
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/10
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $tip, tipItime;
|
|
|
|
|
|
/**
|
|
|
* 初始化提示框
|
|
|
*/
|
|
|
(function() {
|
|
|
var tipHtml = '<div id="yoho-tip" class="yoho-tip"></div>';
|
|
|
|
|
|
//插入提示HTML
|
|
|
$('.yoho-page').append(tipHtml);
|
|
|
|
|
|
$tip = $('#yoho-tip');
|
|
|
$tip.on('touchstart', function() {
|
|
|
$tip.hide();
|
|
|
|
|
|
//清除Timeout
|
|
|
clearTimeout(tipItime);
|
|
|
});
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* 显示提示
|
|
|
*/
|
|
|
function show(con, dur) {
|
|
|
var content, duration;
|
|
|
|
|
|
if (typeof con === 'undefined') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
content = con.toString();
|
|
|
duration = (dur && dur > 0) ? dur : 2000;
|
|
|
|
|
|
$tip.text(content).show();
|
|
|
|
|
|
tipItime = setTimeout(function() {
|
|
|
if ($tip.css('display') === 'block') {
|
|
|
$tip.hide();
|
|
|
}
|
|
|
}, duration);
|
|
|
}
|
|
|
|
|
|
exports.show = show;
|
|
|
});
|
|
|
define("js/passport/register/code", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册-验证码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
|
|
|
require("js/passport/code")(true);
|
|
|
});
|
|
|
define("js/passport/code", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册/找回密码-验证码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
module.exports = function(useInRegister) {
|
|
|
var $captcha = $('#captcha'),
|
|
|
$btnNext = $('#btn-next'),
|
|
|
$captchaTip = $('#captcha-tip'),
|
|
|
phoneNum = $('#phone-num').val(),
|
|
|
areaCode = $('#area-code').val().replace('+', '');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
var urlMid = useInRegister ? 'reg' : 'back';
|
|
|
|
|
|
function countDown() {
|
|
|
var count = 59,
|
|
|
itime;
|
|
|
|
|
|
itime = setInterval(function() {
|
|
|
if (count === 0) {
|
|
|
$captchaTip.text('重发验证码').removeClass('disable');
|
|
|
clearInterval(itime);
|
|
|
} else {
|
|
|
$captchaTip.text('重发验证码 (' + count-- + '秒)');
|
|
|
}
|
|
|
}, 1000);
|
|
|
}
|
|
|
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$captcha.bind('input', function() {
|
|
|
if (trim($captcha.val()) !== '') {
|
|
|
$btnNext.removeClass('disable');
|
|
|
} else {
|
|
|
$btnNext.addClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//重新发送验证码
|
|
|
$captchaTip.on('touchstart', function() {
|
|
|
if ($captchaTip.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/' + urlMid + '/sendcode',
|
|
|
data: {
|
|
|
phoneNum: phoneNum,
|
|
|
areaCode: areaCode
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
$captchaTip.text('重发验证码 (60秒)').addClass('disable');
|
|
|
countDown();
|
|
|
} else {
|
|
|
|
|
|
//验证码不正确,显示提示
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$btnNext.on('touchstart', function() {
|
|
|
if ($btnNext.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/' + urlMid + '/verifycode',
|
|
|
data: {
|
|
|
phoneNum: phoneNum,
|
|
|
areaCode: areaCode,
|
|
|
code: trim($captcha.val()),
|
|
|
token: $('#token').val()
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
location.href = data.data;
|
|
|
} else {
|
|
|
|
|
|
//验证码不正确,显示提示
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
countDown();
|
|
|
};
|
|
|
});
|
|
|
define("js/passport/register/password", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册-密码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $pwd = $('#pwd'),
|
|
|
$btnSure = $('#btn-sure');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
api.bindEyesEvt();
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
if (trim($pwd.val()) === '') {
|
|
|
$btnSure.addClass('disable');
|
|
|
} else {
|
|
|
$btnSure.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$btnSure.on('touchstart', function() {
|
|
|
var pwd = trim($pwd.val());
|
|
|
|
|
|
if ($btnSure.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.pwdValidate(pwd) === false) {
|
|
|
showErrTip('密码6-20位,请重新输入');
|
|
|
} else {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/reg/setpassword',
|
|
|
data: {
|
|
|
password: pwd,
|
|
|
phoneNum: $('#phone-num').val(),
|
|
|
areaCode: $('#area-code').val(),
|
|
|
token: $('#token').val()
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
showErrTip('注册成功');
|
|
|
|
|
|
//1000ms后跳转页面
|
|
|
setTimeout(function() {
|
|
|
location.href = data.data;
|
|
|
}, 1000);
|
|
|
} else {
|
|
|
if (data.code === 401 || data.code === 404 || data.code === 505) {
|
|
|
showErrTip(data.message);
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
setTimeout(function() {
|
|
|
location.href = data.data;
|
|
|
}, 1000);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/passport/login/login", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 登录
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/9/30
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $account = $('#account'),
|
|
|
$pwd = $('#pwd'),
|
|
|
$loginBtn = $('#btn-login'),
|
|
|
|
|
|
$mask = $('#retrive-pwd-mask'),
|
|
|
$ways = $('#retrive-pwd-ways'),
|
|
|
|
|
|
accPass = false,
|
|
|
pwdPass = false;
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
//登录按钮状态切换
|
|
|
function switchLoginBtnStatus() {
|
|
|
if (accPass && pwdPass) {
|
|
|
$loginBtn.removeClass('disable');
|
|
|
} else {
|
|
|
$loginBtn.addClass('disable');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//显示找回密码面板
|
|
|
function showRetrivePanel() {
|
|
|
$mask.show();
|
|
|
$ways.show();
|
|
|
}
|
|
|
|
|
|
//隐藏找回密码面板
|
|
|
function hideRetrivePanel() {
|
|
|
$mask.hide();
|
|
|
$ways.hide();
|
|
|
}
|
|
|
|
|
|
//密码显示与隐藏
|
|
|
api.bindEyesEvt();
|
|
|
|
|
|
//清空账号输入框
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$account.bind('input', function() {
|
|
|
if (trim($account.val()) !== '') {
|
|
|
accPass = true;
|
|
|
} else {
|
|
|
accPass = false;
|
|
|
}
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
if (trim($pwd.val()) === '') {
|
|
|
pwdPass = false;
|
|
|
} else {
|
|
|
pwdPass = true;
|
|
|
}
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
|
|
|
// Login
|
|
|
$loginBtn.on('touchstart', function() {
|
|
|
var acc = trim($account.val()),
|
|
|
pwd = trim($pwd.val());
|
|
|
|
|
|
if ($loginBtn.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//验证账号(数字或者邮箱)和密码合理性
|
|
|
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
|
|
data: {
|
|
|
account: acc,
|
|
|
password: pwd
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
showErrTip('登录成功');
|
|
|
|
|
|
//1s后跳转页面
|
|
|
setTimeout(function() {
|
|
|
location.href = data.data;
|
|
|
}, 1000);
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
$('#forget-pwd').on('touchstart', function() {
|
|
|
showRetrivePanel();
|
|
|
});
|
|
|
|
|
|
$mask.on('touchstart', function() {
|
|
|
hideRetrivePanel();
|
|
|
});
|
|
|
|
|
|
$('#cancel-retrive').on('touchstart', function(e) {
|
|
|
e.preventDefault();
|
|
|
hideRetrivePanel();
|
|
|
});
|
|
|
|
|
|
//对初始有默认值的情况去初始化登录按钮状态
|
|
|
$account.trigger('input');
|
|
|
$pwd.trigger('input');
|
|
|
});
|
|
|
define("js/passport/login/interational", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 国际账号登录
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $phoneNum = $('#phone-num'),
|
|
|
$countrySelect = $('#country-select'),
|
|
|
$areaCode = $('#area-code'),
|
|
|
$pwd = $('#pwd'),
|
|
|
$loginBtn = $('#btn-login'),
|
|
|
|
|
|
pnPass = false,
|
|
|
pwdPass = false;
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
//登录按钮状态切换
|
|
|
function switchLoginBtnStatus() {
|
|
|
if (pnPass && pwdPass) {
|
|
|
$loginBtn.removeClass('disable');
|
|
|
} else {
|
|
|
$loginBtn.addClass('disable');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//Android-UC下显示select的direction:rtl无效的临时解决办法
|
|
|
api.selectCssHack($countrySelect);
|
|
|
|
|
|
//显示隐藏密码
|
|
|
api.bindEyesEvt();
|
|
|
|
|
|
//清空手机号码
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$phoneNum.bind('input', function() {
|
|
|
if (trim($phoneNum.val()) === '') {
|
|
|
pnPass = false;
|
|
|
} else {
|
|
|
pnPass = true;
|
|
|
}
|
|
|
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
var pwd = trim($pwd.val());
|
|
|
|
|
|
if (pwd === '') {
|
|
|
pwdPass = false;
|
|
|
} else {
|
|
|
pwdPass = true;
|
|
|
}
|
|
|
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
$countrySelect.change(function() {
|
|
|
$areaCode.text($countrySelect.val());
|
|
|
});
|
|
|
|
|
|
$loginBtn.on('touchstart', function() {
|
|
|
var pn = trim($phoneNum.val()),
|
|
|
areaCode = $countrySelect.val(),
|
|
|
pwd = trim($pwd.val());
|
|
|
|
|
|
if ($loginBtn.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.phoneRegx[areaCode].test(pn) && api.pwdValidate(pwd)) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
|
|
data: {
|
|
|
areaCode: areaCode.replace('+', ''),
|
|
|
account: pn,
|
|
|
password: pwd
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
showErrTip('登录成功');
|
|
|
|
|
|
//1000ms后跳转页面
|
|
|
setTimeout(function() {
|
|
|
location.href = data.data;
|
|
|
}, 1000);
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//对初始有默认值的情况去初始化登录按钮状态
|
|
|
$phoneNum.trigger('input');
|
|
|
$pwd.trigger('input');
|
|
|
});
|
|
|
define("js/passport/back/mobile", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 找回密码-手机
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $phoneNum = $('#phone-num'),
|
|
|
$countrySelect = $('#country-select'),
|
|
|
$areaCode = $('#area-code'),
|
|
|
$btnNext = $('#btn-next');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
api.selectCssHack($('#country-select'));
|
|
|
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$phoneNum.bind('input', function() {
|
|
|
if (trim($phoneNum.val()) === '') {
|
|
|
$btnNext.addClass('disable');
|
|
|
} else {
|
|
|
$btnNext.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$countrySelect.change(function() {
|
|
|
$areaCode.text($countrySelect.val());
|
|
|
});
|
|
|
|
|
|
$btnNext.on('touchstart', function() {
|
|
|
var pn = trim($phoneNum.val()),
|
|
|
area = $countrySelect.val();
|
|
|
|
|
|
if ($btnNext.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.phoneRegx[area].test(pn)) {
|
|
|
$.ajax({
|
|
|
url: '/passport/back/sendcode',
|
|
|
type: 'POST',
|
|
|
data: {
|
|
|
areaCode: area.replace('+', ''),
|
|
|
phoneNum: pn
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
location.href = data.data;
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('手机号格式不正确,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/passport/back/code", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 找回密码-验证码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
|
|
|
require("js/passport/code")(false);
|
|
|
});
|
|
|
define("js/passport/back/email", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 找回密码-邮箱找回
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $email = $('#email'),
|
|
|
$btnSure = $('#btn-sure');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$email.bind('input', function() {
|
|
|
if (trim($email.val()) === '') {
|
|
|
$btnSure.addClass('disable');
|
|
|
} else {
|
|
|
$btnSure.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$btnSure.on('touchstart', function() {
|
|
|
var email = trim($email.val());
|
|
|
|
|
|
if ($btnSure.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.emailRegx.test(email)) {
|
|
|
$.ajax({
|
|
|
url: '/passport/back/sendemail',
|
|
|
type: 'POST',
|
|
|
data: {
|
|
|
email: email
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
location.href = data.data;
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('邮箱格式不正确,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/passport/back/email-success", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 找回密码-邮箱找回成功
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $resend = $('#resend');
|
|
|
|
|
|
var tip = require("js/plugin/tip"),
|
|
|
showErrTip = tip.show;
|
|
|
|
|
|
$resend.on('touchstart', function(e) {
|
|
|
e.preventDefault();
|
|
|
|
|
|
$.ajax({
|
|
|
url: $resend.data('url'),
|
|
|
type: 'GET',
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
showErrTip(data.message);
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
define("js/passport/back/new-password", ["zepto"], function(require, exports, module){
|
|
|
/**
|
|
|
* 密码找回-新密码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var $pwd = $('#pwd'),
|
|
|
$btnOk = $('#btn-ok');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
var $phoneNum = $('#phone-num');
|
|
|
|
|
|
api.bindEyesEvt();
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
if (trim($pwd.val()) === '') {
|
|
|
$btnOk.addClass('disable');
|
|
|
} else {
|
|
|
$btnOk.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$btnOk.on('touchstart', function() {
|
|
|
var pwd = trim($pwd.val()),
|
|
|
mobileBack = true,
|
|
|
setting,
|
|
|
url;
|
|
|
|
|
|
if ($btnOk.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
setting = {
|
|
|
password: pwd
|
|
|
};
|
|
|
|
|
|
if ($phoneNum.length === 0) {
|
|
|
mobileBack = false;
|
|
|
}
|
|
|
|
|
|
if (mobileBack) {
|
|
|
$.extend(setting, {
|
|
|
phoneNum: $phoneNum.val(),
|
|
|
areaCode: $('#areaCode').val(),
|
|
|
token: $('#token').val()
|
|
|
});
|
|
|
|
|
|
url = '/passport/back/passwordByMobile';
|
|
|
} else {
|
|
|
$.extend(setting, {
|
|
|
code: $('#email-code').val()
|
|
|
});
|
|
|
|
|
|
url = '/passport/back/passwordByEmail';
|
|
|
}
|
|
|
|
|
|
|
|
|
if (api.pwdValidate(pwd)) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: url,
|
|
|
data: setting,
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
showErrTip('密码修改成功');
|
|
|
|
|
|
//1000ms后跳转页面
|
|
|
setTimeout(function() {
|
|
|
location.href = data.data;
|
|
|
}, 1000);
|
|
|
} else {
|
|
|
showErrTip(data.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('密码6-20位,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/guang/index", ["zepto","lazyload","swiper","mlellipsis","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 逛打包入口
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/9
|
|
|
*/
|
|
|
|
|
|
require("js/guang/plus-star/list");
|
|
|
require("js/guang/plus-star/detail");
|
|
|
|
|
|
require("js/guang/home");
|
|
|
require("js/guang/list");
|
|
|
});
|
|
|
define("js/guang/plus-star/list", ["zepto","lazyload","swiper","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* PLUS+STAR列表页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/10
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto"),
|
|
|
lazyLoad = require("lazyload"),
|
|
|
Swiper = require("swiper");
|
|
|
|
|
|
var $navs = $('#nav-tab > li'),
|
|
|
$contents = $('#ps-content > .content');
|
|
|
|
|
|
var mySwiper;
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
mySwiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
|
|
pagination: '.swiper-pagination'
|
|
|
});
|
|
|
|
|
|
$('#nav-tab').delegate('li', 'touchstart', function() {
|
|
|
if ($(this).hasClass('focus')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$navs.toggleClass('focus');
|
|
|
$contents.toggleClass('hide');
|
|
|
|
|
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
|
|
});
|
|
|
});
|
|
|
define("js/guang/plus-star/detail", ["zepto","mlellipsis","lazyload"], function(require, exports, module){
|
|
|
/**
|
|
|
* PLUS+STAR详情页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/10
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto"),
|
|
|
ellipsis = require("mlellipsis"),
|
|
|
lazyLoad = require("lazyload");
|
|
|
|
|
|
var $intro = $('#intro'),
|
|
|
$imt = $('#intro-more-txt'),
|
|
|
$infosContainer = $('#related-infos-container');
|
|
|
|
|
|
var info = require("js/guang/info");
|
|
|
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var brandId = $('#brand-info').data('id');
|
|
|
|
|
|
var mIntro, aIntro;
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
//Init LazyLoad
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
//文字介绍文字截取
|
|
|
$intro[0].mlellipsis(3);
|
|
|
|
|
|
//获取截取文字和完整文字
|
|
|
setTimeout(function() {
|
|
|
mIntro = $intro.text();
|
|
|
aIntro = $intro.attr('title');
|
|
|
});
|
|
|
|
|
|
info.initInfosEvt($infosContainer);
|
|
|
|
|
|
//文字介绍收起与展开
|
|
|
$('#more-intro').bind('touchstart', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
$this.toggleClass('spread');
|
|
|
|
|
|
if ($this.hasClass('spread')) {
|
|
|
|
|
|
//显示
|
|
|
$intro.text(aIntro);
|
|
|
$imt.text('收起');
|
|
|
} else {
|
|
|
|
|
|
//隐藏
|
|
|
$intro.text(mIntro);
|
|
|
$imt.text('more');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//品牌收藏
|
|
|
$('#brand-like').bind('touchstart', function(e) {
|
|
|
var opt = 'ok',
|
|
|
$this = $(this);
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
if ($this.hasClass('like')) {
|
|
|
opt = 'cancel';
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: brandId,
|
|
|
opt: opt
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
$this.toggleClass('like');
|
|
|
} else if (data.code === 400) {
|
|
|
tip.show('未登录');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
define("js/guang/info", ["zepto","mlellipsis","lazyload"], function(require, exports, module){
|
|
|
/**
|
|
|
* 资讯相关API
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/10
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto"),
|
|
|
ellipsis = require("mlellipsis"),
|
|
|
lazyLoad = require("lazyload");
|
|
|
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var $loadMoreInfo = $('#load-more-info');
|
|
|
var $loading = $(''),
|
|
|
$noMore = $('');
|
|
|
|
|
|
var loading = false;
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
if ($loadMoreInfo.length > 0) {
|
|
|
$loading = $loadMoreInfo.children('.loading');
|
|
|
$noMore = $loadMoreInfo.children('.no-more');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置指定资讯项的Lazyload和文字截取
|
|
|
* @params $infos 资讯项
|
|
|
*/
|
|
|
function setLazyLoadAndMellipsis($infos) {
|
|
|
lazyLoad($infos.find('img.lazy'));
|
|
|
|
|
|
$infos.each(function() {
|
|
|
var $this = $(this),
|
|
|
$title = $this.find('.info-title'),
|
|
|
$text = $this.find('.info-text');
|
|
|
|
|
|
//减少重复调用
|
|
|
if ($title.attr('title') && $text.attr('title')) {
|
|
|
return;
|
|
|
}
|
|
|
$title[0].mlellipsis(2);
|
|
|
$text[0].mlellipsis(2);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化资讯列表事件绑定
|
|
|
* @params $container 逛资讯列表容器
|
|
|
*/
|
|
|
function initInfosEvt($container) {
|
|
|
$container.delegate('.like-btn', 'touchstart', function(e) {
|
|
|
var $likeBtn = $(e.currentTarget),
|
|
|
$info = $likeBtn.closest('.guang-info'),
|
|
|
opt = 'ok';
|
|
|
|
|
|
if ($likeBtn.hasClass('like')) {
|
|
|
opt = 'cancel';
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/praiseArticle',
|
|
|
data: {
|
|
|
id: $info.data('id'),
|
|
|
opt: opt
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var code = data.code;
|
|
|
|
|
|
if (code === 200) {
|
|
|
$likeBtn.next('.like-count').text(data.data);
|
|
|
|
|
|
//切换点赞状态
|
|
|
$likeBtn.toggleClass('like');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
setLazyLoadAndMellipsis($container.find('.guang-info'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 资讯LoadMore
|
|
|
*/
|
|
|
function loadMore($container, opt) {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (opt.end) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
loading = true;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: ' /guang/list/page',
|
|
|
data: opt,
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
opt.end = true;
|
|
|
loading = false;
|
|
|
|
|
|
//
|
|
|
$loading.addClass('hide');
|
|
|
$noMore.removeClass('hide');
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
$container.append(data);
|
|
|
|
|
|
setLazyLoadAndMellipsis($container.find('.guang-info'));
|
|
|
|
|
|
opt.page++;
|
|
|
|
|
|
loading = false;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
exports.initInfosEvt = initInfosEvt;
|
|
|
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
|
|
|
exports.loadMore = loadMore;
|
|
|
});
|
|
|
define("js/guang/home", ["zepto","swiper","mlellipsis","lazyload","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 逛首页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/10
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto"),
|
|
|
Swiper = require("swiper");
|
|
|
|
|
|
var info = require("js/guang/info"),
|
|
|
setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis,
|
|
|
loadMore = info.loadMore;
|
|
|
|
|
|
var $loadMoreInfo = $('#load-more-info');
|
|
|
var $loading = $(''),
|
|
|
$noMore = $('');
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
loadMoreH = $loadMoreInfo.height();
|
|
|
|
|
|
var $infoList = $('#info-list'),
|
|
|
$infos = $infoList.children('.info-list'),
|
|
|
$nav = $('#guang-nav'),
|
|
|
$curNav = $nav.children('.focus'),
|
|
|
curType = $curNav.data('type');
|
|
|
|
|
|
var state = {};
|
|
|
|
|
|
var mySwiper;
|
|
|
|
|
|
if ($loadMoreInfo.length > 0) {
|
|
|
$loading = $loadMoreInfo.children('.loading');
|
|
|
$noMore = $loadMoreInfo.children('.no-more');
|
|
|
}
|
|
|
|
|
|
mySwiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
|
|
pagination: '.swiper-pagination'
|
|
|
});
|
|
|
|
|
|
info.initInfosEvt($infoList);
|
|
|
|
|
|
//初始化各Nav下资讯加载的状态
|
|
|
(function() {
|
|
|
var gender = $('#gender').val();
|
|
|
|
|
|
$nav.children('.guang-nav-item').each(function() {
|
|
|
var type = $(this).data('type');
|
|
|
|
|
|
state[type] = {
|
|
|
page: 1,
|
|
|
gender: gender,
|
|
|
type: type,
|
|
|
end: false
|
|
|
};
|
|
|
});
|
|
|
}());
|
|
|
|
|
|
$nav.delegate('.guang-nav-item', 'touchstart', function() {
|
|
|
var $this = $(this),
|
|
|
$content,
|
|
|
index;
|
|
|
|
|
|
if ($this.hasClass('focus')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
index = $this.index();
|
|
|
|
|
|
$this.addClass('focus');
|
|
|
$curNav.removeClass('focus');
|
|
|
|
|
|
$infos.not('.hide').addClass('hide');
|
|
|
|
|
|
$content = $infos.eq(index);
|
|
|
$content.removeClass('hide');
|
|
|
|
|
|
//lazyload & mellipsis
|
|
|
setLazyLoadAndMellipsis($content.children('.guang-info'));
|
|
|
|
|
|
$curNav = $this;
|
|
|
curType = $this.data('type');
|
|
|
|
|
|
//重置当前Tab的load-more
|
|
|
if (state[curType].end) {
|
|
|
$loading.addClass('hide');
|
|
|
$noMore.removeClass('hide');
|
|
|
} else {
|
|
|
$loading.removeClass('hide');
|
|
|
$noMore.addClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$(document).scroll(function() {
|
|
|
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
|
|
|
loadMore($infos, state[curType]);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/guang/list", ["zepto","mlellipsis","lazyload"], function(require, exports, module){
|
|
|
/**
|
|
|
* 列表页,编辑页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/10
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto");
|
|
|
|
|
|
var info = require("js/guang/info"),
|
|
|
loadMore = info.loadMore;
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
loadMoreH = $('#load-more').height();
|
|
|
|
|
|
var $author = $('#author-infos');
|
|
|
var $tag = $('#tag');
|
|
|
|
|
|
var setting = {
|
|
|
page: 1,
|
|
|
end: false
|
|
|
};
|
|
|
|
|
|
var $infos = $('#info-list');
|
|
|
|
|
|
info.initInfosEvt($infos);
|
|
|
|
|
|
if ($author.length > 0) {
|
|
|
$.extend(setting, {
|
|
|
authorId: $author.data('id')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if ($tag.length > 0) {
|
|
|
$.extend(setting, {
|
|
|
tag: $tag.val()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$(document).scroll(function() {
|
|
|
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
|
|
|
loadMore($infos, setting);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/home/index", ["zepto","swiper","lazyload","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 首页打包入口
|
|
|
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
|
|
|
* @date: 2015/10/12
|
|
|
*/
|
|
|
|
|
|
require("js/home/home");
|
|
|
require("js/home/maybe-like");
|
|
|
});
|
|
|
define("js/home/home", ["zepto","swiper","lazyload","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 首页
|
|
|
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
|
|
|
* @date: 2015/10/12
|
|
|
*/
|
|
|
var $ = require("zepto"),
|
|
|
Swiper = require("swiper"),
|
|
|
lazyLoad = require("lazyload"),
|
|
|
bannerSwiper,
|
|
|
recommendSwiper,
|
|
|
trendTopicSwiper,
|
|
|
goodsSwiper;
|
|
|
|
|
|
var requestFrame,
|
|
|
thisFunc,
|
|
|
start = 0,
|
|
|
i,
|
|
|
swiperClass,
|
|
|
supportCss3,
|
|
|
$logotrans = $('.home-header .logo'),
|
|
|
isen = true;
|
|
|
|
|
|
require("js/home/maybe-like");
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
//$('img:in-viewport').trigger('appear');
|
|
|
|
|
|
//点击首页汉堡menu图标,滑出侧栏导航
|
|
|
$('.nav-btn').on('click', function (event) {
|
|
|
if (!$(this).hasClass('menu-open')) {
|
|
|
$('.mobile-wrap').addClass('menu-open');
|
|
|
$('.overlay').addClass('show');
|
|
|
$('.side-nav').addClass('on');
|
|
|
|
|
|
//设置boy高宽,页面不能上下滑动
|
|
|
$('body').css({
|
|
|
height: $(window).height(),
|
|
|
width: '100%',
|
|
|
overflow: 'hidden'
|
|
|
});
|
|
|
}
|
|
|
event.stopPropagation();
|
|
|
});
|
|
|
|
|
|
//点击页面主体,收起侧栏导航及二级导航
|
|
|
$('.mobile-wrap').on('click', function () {
|
|
|
if ($(this).hasClass('menu-open')) {
|
|
|
$('.mobile-wrap').removeClass('menu-open');
|
|
|
$('.overlay').removeClass('show');
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
$('.side-nav').removeClass('on');
|
|
|
$('body').css({
|
|
|
height: 'auto',
|
|
|
overflow: 'auto'
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//点击一级导航,弹出二级导航
|
|
|
$('.side-nav').on('click', 'li', function () {
|
|
|
if ($(this).find('.sub-nav').size() > 0) {
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
$(this).find('.sub-nav').addClass('show');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//返回一级导航,收起二级导航
|
|
|
$('.sub-nav').each(function () {
|
|
|
$(this).find('li').eq(0).on('click', function (e) {
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
e.stopPropagation();
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//二级导航样式控制
|
|
|
$('.sub-nav').on('mouseenter', 'li', function () {
|
|
|
if ($(this).index() !== 0) {
|
|
|
$(this).addClass('current').siblings().removeClass('current');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//头部banner轮播
|
|
|
if ($('.banner-swiper').find('li').size() > 1) {
|
|
|
bannerSwiper = new Swiper('.banner-swiper', {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.banner-top .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//热门品牌滑动
|
|
|
// hotBrandsSwiper = new Swiper('.brands-swiper', {
|
|
|
// grabCursor: true,
|
|
|
// slidesPerView: 'auto',
|
|
|
// wrapperClass: 'brands-list',
|
|
|
// slideElement: 'li'
|
|
|
// });
|
|
|
|
|
|
//推荐搭配滑动
|
|
|
recommendSwiper = new Swiper('.recommend-swiper', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
wrapperClass: 'recommend-list',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
|
|
|
//潮品话题轮播
|
|
|
if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
trendTopicSwiper = new Swiper('.trend-topic-swiper', {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.trend-topic-content .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//潮流上装/经典裤装等轮播
|
|
|
$('.category-swiper').each(function (i, index) {
|
|
|
swiperClass = 'category-swiper' + i;
|
|
|
$(this).addClass(swiperClass);
|
|
|
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
|
|
goodsSwiper = new Swiper('.' + swiperClass, {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.' + swiperClass + ' .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
//回到顶部
|
|
|
// $('.back-to-top').bind('touchstart', function (e) {
|
|
|
// e.preventDefault();
|
|
|
// $(window).scrollTop(0);
|
|
|
// });
|
|
|
|
|
|
//关闭头部下载浮层
|
|
|
$('.header-download').on('click', '.close-btn', function () {
|
|
|
$(this).parent().remove();
|
|
|
});
|
|
|
|
|
|
|
|
|
//logo动画
|
|
|
requestFrame = (function () {
|
|
|
var tempFunc = null,
|
|
|
prefixList = ['webkit', 'moz', 'ms'];
|
|
|
|
|
|
for (i = 0; i < prefixList.length; i++) {
|
|
|
thisFunc = prefixList[i] + 'RequestAnimationFrame';
|
|
|
if (window[thisFunc]) {
|
|
|
supportCss3 = true;
|
|
|
tempFunc = thisFunc;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (supportCss3) {
|
|
|
return function (callback) {
|
|
|
window[tempFunc](callback);
|
|
|
};
|
|
|
}
|
|
|
return function (callback) {
|
|
|
window.setTimeout(callback, 67);
|
|
|
};
|
|
|
})();
|
|
|
|
|
|
function tsAnimate() {
|
|
|
start = start + 10;
|
|
|
$logotrans.css({
|
|
|
transform: 'rotateX(' + start + 'deg)',
|
|
|
'-webkit-transform': 'rotateX(' + start + 'deg)',
|
|
|
'-moz-transform': 'rotateX(' + start + 'deg)'
|
|
|
});
|
|
|
if (start / 90 % 2 === 1) {
|
|
|
if (isen) {
|
|
|
$logotrans.addClass('animate');
|
|
|
isen = false;
|
|
|
} else {
|
|
|
$logotrans.removeClass('animate');
|
|
|
isen = true;
|
|
|
}
|
|
|
}
|
|
|
if (start / 90 % 2 === 0 && start % 360 !== 0) {
|
|
|
window.setTimeout(tsAnimate, 3000);
|
|
|
} else {
|
|
|
if (start % 360 === 0) {
|
|
|
window.setTimeout(tsAnimate, 3 * 60 * 1000);
|
|
|
} else {
|
|
|
requestFrame(function () {
|
|
|
tsAnimate();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tsAnimate();
|
|
|
|
|
|
|
|
|
});
|
|
|
define("js/home/maybe-like", ["zepto","lazyload"], function(require, exports, module){
|
|
|
/**
|
|
|
* “你可能喜欢”模块JS
|
|
|
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
|
|
|
* @date: 2015/10/12
|
|
|
*/
|
|
|
|
|
|
var $ = require("zepto"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
lazyLoad = require("lazyload");
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
loadMoreH = $('#load-more').height(),
|
|
|
$goodList = $('#goods-list'),
|
|
|
loading = false,
|
|
|
page = 0,
|
|
|
gender = $('.mobile-wrap').hasClass('boys-wrap') ? '1,3' : '2,3',
|
|
|
kidsType = $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
|
|
|
lifestyleType = $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
|
|
|
num,
|
|
|
url;
|
|
|
|
|
|
var $curNav,
|
|
|
index,
|
|
|
$navList = $('#maybe-like-nav');
|
|
|
|
|
|
//ajax url
|
|
|
if (kidsType) {
|
|
|
url = '/product/recom/maylikekids';
|
|
|
} else if (lifestyleType) {
|
|
|
url = '/product/recom/maylikelife';
|
|
|
} else {
|
|
|
url = '/product/recom/maylike?gender=' + gender;
|
|
|
}
|
|
|
|
|
|
$curNav = $navList.children('.focus');
|
|
|
|
|
|
$('#maybe-like-nav').delegate('li', 'touchstart', function() {
|
|
|
var $this = $(this),
|
|
|
$goods = $('.goods-list'),
|
|
|
$content;
|
|
|
|
|
|
|
|
|
if ($this.hasClass('focus')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
index = $this.index();
|
|
|
|
|
|
$this.addClass('focus');
|
|
|
$curNav.removeClass('focus');
|
|
|
|
|
|
$goods.not('.hide').addClass('hide');
|
|
|
$content = $goods.eq(index);
|
|
|
$content.removeClass('hide');
|
|
|
|
|
|
$curNav = $this;
|
|
|
|
|
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
|
|
});
|
|
|
|
|
|
//srcoll to load more
|
|
|
$(window).scroll(function () {
|
|
|
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
loading = true;
|
|
|
num = $goodList.children('.good-info').length;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: url,
|
|
|
data: {
|
|
|
page: page + 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
loading = true;
|
|
|
return;
|
|
|
}
|
|
|
$goodList.append(data);
|
|
|
|
|
|
//lazyLoad
|
|
|
//lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
|
|
|
lazyLoad($('.good-info').find('img.lazy'));
|
|
|
|
|
|
loading = false;
|
|
|
page++;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
define("js/product/index", ["zepto","swiper","lazyload","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 产品打包入口
|
|
|
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
|
|
|
* @date: 2015/10/12
|
|
|
*/
|
|
|
|
|
|
require("js/product/newsale/newarrival");
|
|
|
require("js/product/newsale/discount");
|
|
|
});
|
|
|
define("js/product/newsale/newarrival", ["zepto","swiper","lazyload","index"], function(require, exports, module){
|
|
|
var $ = require("zepto"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
Swiper = require("swiper"),
|
|
|
lazyLoad = require("lazyload");
|
|
|
|
|
|
var $curNav,
|
|
|
$navList = $('#newarrival-nav'),
|
|
|
$newArrivalList = $('#newarrival-goods-list'),
|
|
|
$goods = $newArrivalList.children('.goods-list');
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
loadMoreH = $('#load-more').height(),
|
|
|
$goodList = $('.goods-list'),
|
|
|
loading = false,
|
|
|
page = 0,
|
|
|
index = 0,
|
|
|
num;
|
|
|
|
|
|
var swiper;
|
|
|
|
|
|
swiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
|
|
pagination: '.swiper-pagination'
|
|
|
});
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$curNav = $navList.children('.focus');
|
|
|
|
|
|
$('#newarrival-nav').delegate('li', 'touchstart', function() {
|
|
|
var $this = $(this),
|
|
|
$content;
|
|
|
|
|
|
|
|
|
if ($this.hasClass('focus')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
index = $this.index();
|
|
|
|
|
|
$this.addClass('focus');
|
|
|
$curNav.removeClass('focus');
|
|
|
|
|
|
$goods.not('.hide').addClass('hide');
|
|
|
$content = $goods.eq(index);
|
|
|
$content.removeClass('hide');
|
|
|
|
|
|
$curNav = $this;
|
|
|
|
|
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
|
|
});
|
|
|
|
|
|
//srcoll to load more
|
|
|
$(window).scroll(function () {
|
|
|
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
loading = true;
|
|
|
num = $goodList.children('.good-info').length;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/newsale/selectNewSale',
|
|
|
data: {
|
|
|
dayLimit: index + 1,
|
|
|
page: page + 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
|
|
|
//opt.end = true;
|
|
|
loading = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$goodList.append(data);
|
|
|
|
|
|
//lazyLoad
|
|
|
//lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
|
|
|
lazyLoad($('.good-info').find('img.lazy'));
|
|
|
|
|
|
loading = false;
|
|
|
page++;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
define("js/product/newsale/discount", ["zepto","swiper","lazyload","index"], function(require, exports, module){
|
|
|
var $ = require("zepto"),
|
|
|
Swiper = require("swiper"),
|
|
|
lazyLoad = require("lazyload");
|
|
|
|
|
|
var $curNav,
|
|
|
$navList = $('#discount-nav'),
|
|
|
$newArrivalList = $('#discount-goods-list'),
|
|
|
$goods = $newArrivalList.children('.goods-list'),
|
|
|
$goodList = $('.goods-list');
|
|
|
|
|
|
var swiper;
|
|
|
var index = 0,
|
|
|
winH = $(window).height(),
|
|
|
loadMoreH = $('#load-more').height(),
|
|
|
loading = false,
|
|
|
page = 0,
|
|
|
pd = "";
|
|
|
|
|
|
swiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
|
|
pagination: '.swiper-pagination'
|
|
|
});
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$curNav = $navList.children('.focus');
|
|
|
|
|
|
$('#discount-nav').delegate('li', 'touchstart', function() {
|
|
|
var $this = $(this),
|
|
|
$content;
|
|
|
|
|
|
if ($this.hasClass('focus')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
index = $this.index();
|
|
|
pd = getSalePdByChoose(index);
|
|
|
|
|
|
$this.addClass('focus');
|
|
|
$curNav.removeClass('focus');
|
|
|
|
|
|
$goods.not('.hide').addClass('hide');
|
|
|
$content = $goods.eq(index);
|
|
|
$content.removeClass('hide');
|
|
|
|
|
|
$curNav = $this;
|
|
|
|
|
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
|
|
});
|
|
|
|
|
|
//srcoll to load more
|
|
|
$(window).scroll(function () {
|
|
|
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
loading = true;
|
|
|
num = $goodList.children('.good-info').length;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/newsale/selectNewSale',
|
|
|
data: {
|
|
|
p_d: pd,
|
|
|
page: page + 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
|
|
|
//opt.end = true;
|
|
|
loading = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$goodList.append(data);
|
|
|
|
|
|
//lazyLoad
|
|
|
//lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
|
|
|
lazyLoad($('.good-info').find('img.lazy'));
|
|
|
|
|
|
loading = false;
|
|
|
page++;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 根据用户的选择获取商品折扣值
|
|
|
*
|
|
|
* @param int index
|
|
|
* @return string
|
|
|
*/
|
|
|
function getSalePdByChoose(index) {
|
|
|
var pd = "0.1,0.3";
|
|
|
switch (index) {
|
|
|
case 0:
|
|
|
pd = "0.1,0.3";
|
|
|
break;
|
|
|
case 1:
|
|
|
pd = "0.4,0.6";
|
|
|
break;
|
|
|
case 2:
|
|
|
pd = "0.7,0.9";
|
|
|
break;
|
|
|
case 3:
|
|
|
pd = "0.1,0.9";
|
|
|
break;
|
|
|
}
|
|
|
return pd;
|
|
|
}
|
|
|
}); |