Authored by 梁志锋

提交gulp ge 文件

... ... @@ -237,9 +237,9 @@ $yohoPage.on('touchstart', '.tap-hightlight', function() {
$(this).removeClass('highlight');
});
// $('.nav-home').on('touchstart', function() {
// $('.homebuttom').toggleClass('none');
// });
$('.nav-home').on('touchstart', function() {
$('.homebuttom').toggleClass('hide');
});
(function() {
var lastTime = 0,
... ... @@ -459,8 +459,6 @@ var brandsData,
loading.showLoadingMask();
lazyLoad($('img.lazy'));
$('.yoho-header').css({
'z-index': 2,
... ... @@ -755,7 +753,7 @@ $('#nav-tab').on('touchstart', function(e) {
$navs.removeClass('bytouch');
});
});
define("js/guang/plus-star/detail", ["jquery","hammer","mlellipsis","lazyload"], function(require, exports, module){
define("js/guang/plus-star/detail", ["jquery","hammer","mlellipsis","lazyload","swiper","index"], function(require, exports, module){
/**
* PLUS+STAR详情页
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -865,7 +863,7 @@ likeHammer.on('tap', function(e) {
});
});
});
define("js/guang/info", ["jquery","hammer","mlellipsis","lazyload"], function(require, exports, module){
define("js/guang/info", ["jquery","hammer","mlellipsis","lazyload","swiper","index"], function(require, exports, module){
/**
* 资讯相关API
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -875,16 +873,19 @@ define("js/guang/info", ["jquery","hammer","mlellipsis","lazyload"], function(re
var $ = require("jquery"),
Hammer = require("hammer"),
ellipsis = require("mlellipsis"),
lazyLoad = require("lazyload");
lazyLoad = require("lazyload"),
Swiper = require("swiper");
var tip = require("js/plugin/tip");
var loading = require("js/plugin/loading");
var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
$noMore = $('');
$noMore = $(''),
$swiper = $('');
var searching = false;
var mySwiper = {};
ellipsis.init();
... ... @@ -893,6 +894,19 @@ if ($loadMoreInfo.length > 0) {
$noMore = $loadMoreInfo.children('.no-more');
}
//初始化swiper
function initSwiper(typeId) {
if (typeof typeId === undefined) {
return;
}
mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
lazyLoading: true,
wrapperClass: 'swiper-wrap-' + typeId,
pagination: '.swiper-pagi-' + typeId,
autoplay: 3000
});
}
/**
* 设置指定资讯项的Lazyload和文字截取
* @params $infos 资讯项
... ... @@ -1043,6 +1057,14 @@ function loadMore($container, opt, url) {
$container.append(data);
$swiper = $container.find('.swiper-container');
if ($swiper.length) {
$swiper.addClass('swiper-cont-' + opt.type);
$swiper.children('.swiper-wrapper').addClass('swiper-wrap-' + opt.type);
$swiper.children('.swiper-pagination').addClass('swiper-pagi-' + opt.type);
initSwiper(opt.type);
}
if (num > 0) {
$newItems = $container.find('.guang-info:gt(' + (num - 1) + ')');
} else {
... ... @@ -1062,14 +1084,19 @@ function loadMore($container, opt, url) {
opt.page++;
searching = false;
delete opt.isTab;
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
delete opt.isTab;
}
});
}
exports.mySwiper = mySwiper;
exports.initSwiper = initSwiper;
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
... ... @@ -1213,15 +1240,14 @@ module.exports = function() {
});
};
});
define("js/guang/home", ["jquery","swiper","hammer","mlellipsis","lazyload","index"], function(require, exports, module){
define("js/guang/home", ["jquery","hammer","mlellipsis","lazyload","swiper","index"], function(require, exports, module){
/**
* 逛首页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/10
*/
var $ = require("jquery"),
Swiper = require("swiper");
var $ = require("jquery");
var info = require("js/guang/info"),
loadMore = info.loadMore;
... ... @@ -1240,18 +1266,12 @@ var $infoList = $('#info-list'),
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',
autoplay: 3000
});
info.initSwiper(curType);
info.initInfosEvt($infoList);
... ... @@ -1302,6 +1322,7 @@ $nav.on('touchend touchcancel', function(e) {
$loading.addClass('hide');
$noMore.addClass('hide');
state[curType].isTab = true;
loadMore($content, state[curType]);
} else {
... ... @@ -1344,7 +1365,7 @@ $nav.on('touchstart', function(e) {
$nav.find('li').removeClass('bytouch');
});
});
define("js/guang/list", ["jquery","hammer","mlellipsis","lazyload"], function(require, exports, module){
define("js/guang/list", ["jquery","hammer","mlellipsis","lazyload","swiper","index"], function(require, exports, module){
/**
* 列表页,编辑页
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -1693,6 +1714,12 @@ $('.nav-btn').on('touchstart', function(event) {
event.preventDefault();
event.stopPropagation();
openSideNav = true;
//设置boy高宽,页面不能上下滑动
$('body').css({
height: $(window).height(),
overflow: 'hidden'
});
return false;
});
... ... @@ -1703,6 +1730,10 @@ function hideSideBar() {
$('.overlay').hide();
$('.sub-nav').removeClass('show');
$sideNav.removeClass('on');
$('body').css({
height: 'auto',
overflow: 'auto'
});
}
}
... ... @@ -1711,18 +1742,13 @@ $('.overlay').on('touchstart', function(e) {
return false;
});
//禁止在侧边栏可以上下滚动
$('.side-nav').on('touchmove', function() {
return false;
});
//点击一级导航,弹出二级导航
$sideNav.on('touchstart', 'li', function(e) {
if ($(this).find('.sub-nav').size() > 0) {
$('.sub-nav').removeClass('show');
$(this).find('.sub-nav').addClass('show');
}
e.stopPropagation();
if (e.target.pathname === location.pathname) {
hideSideBar();
return false;
... ... @@ -1731,9 +1757,8 @@ $sideNav.on('touchstart', 'li', function(e) {
//返回一级导航,收起二级导航
$subNav.each(function() {
$(this).find('li').eq(0).on('touchstart', function(e) {
$(this).find('li').eq(0).on('touchstart', function() {
$('.sub-nav').removeClass('show');
e.stopPropagation();
return false;
});
}).on('touchstart', function(e) {
... ... @@ -1743,12 +1768,16 @@ $subNav.each(function() {
});
// 侧边栏点击背景色变化
$sideNav.children('ul').children('li').on('touchstart', function() {
$sideNav.children('ul').children('li').css('background', '#fff');
$(this).css('background', '#eee');
}).on('touchend touchcancel', function() {
$(this).css('background', '#fff');
});
function highlight($elem) {
$elem.find('li').on('touchstart', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', function() {
$(this).removeClass('highlight');
});
}
highlight($sideNav);
highlight($subNav);
//头部banner轮播
if ($('.banner-swiper').find('li').size() > 1) {
... ... @@ -1890,6 +1919,8 @@ module.exports = function(specificGender) {
index,
$navList = $('#maybe-like-nav');
var $footer;
//ajax url
if (kidsType) {
url = '/product/recom/maylikekids';
... ... @@ -1903,11 +1934,6 @@ module.exports = function(specificGender) {
url = '/product/recom/maylike?gender=' + gender;
}
//以防cookie异常,强制加载男首
if (specificGender === 'boys') {
url = '/product/recom/maylike?gender=1,3';
}
$curNav = $navList.children('.focus');
if (lifestyleType) {
... ... @@ -1958,15 +1984,11 @@ module.exports = function(specificGender) {
page: page + 1
},
success: function(data) {
if (data === ' ') {
searching = false;
loading.hideLoadingMask();
//修复有货币页面最后一条数据显示被遮挡的问题
if (specificGender) {
window.rePosFooter();
}
// 有货币页面不加载底部
if (gender && !specificGender) {
if (gender === '1,3') {
... ... @@ -1992,6 +2014,12 @@ module.exports = function(specificGender) {
return;
}
//加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置
if (data.length > 1) {
$footer ? null : $footer = $('#yoho-footer');
$footer.hasClass('bottom') ? $footer.removeClass('bottom') : null;
}
num = $goodList.find('.good-info').length;
$goodList.append(data);
... ... @@ -3275,7 +3303,7 @@ var $ = require("jquery");
var $resend = $('#resend');
var tip = require("js/plugin/tip"),
showErrTip = tip.show;
showTip = tip.show;
$resend.on('touchstart', function(e) {
e.preventDefault();
... ... @@ -3284,11 +3312,7 @@ $resend.on('touchstart', function(e) {
url: $resend.data('url'),
type: 'GET',
success: function(data) {
if (data.code === 200) {
showErrTip(data.message);
} else {
showErrTip(data.message);
}
showTip(data.message);
}
});
});
... ... @@ -3513,111 +3537,111 @@ $btnNext.on('touchstart', function() {
});
define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
/*
* @Description: dialog
* @Time: 2015/11/18
* @author: chenglong.wang
*/
var $ = require("jquery"),
Handlebars = require("handlebars"),
Hammer = require("hammer");
var $dialogWrapper,
dialogTpl,
dialogTemplate;
function getInstance() {
if (dialogTpl === undefined) {
dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
'<div class="dialog-box">' +
'{{# hasHeader}}' +
'{{/ hasHeader}}' +
'<div class="dialog-content">{{dialogText}}</div>' +
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
'</div>' +
'</div>';
dialogTemplate = Handlebars.compile(dialogTpl);
}
return dialogTemplate;
}
exports.showDialog = function(data, callback, callbackForLeft) {
var dialogTemplate = getInstance(),
dialogStr = dialogTemplate(data),
$dialogBox,
defaultHideDuraton,
dialogWrapperHammer;
$('.dialog-wrapper').remove();
$('body').append($(dialogStr));
$dialogBox = $('.dialog-box');
$dialogWrapper = $('.dialog-wrapper');
dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper'));
// 显示
if (data.fast) {
$dialogWrapper.css({
display: 'block'
});
} else {
$dialogWrapper.fadeIn();
}
$dialogBox.css({
top: '50%',
marginTop: -($dialogBox.height() / 2)
});
//隐藏
if (data.autoHide) {
defaultHideDuraton = 1000;
if (data.autoHide > 1) {
defaultHideDuraton = data.autoHide;
}
setTimeout(function() {
$dialogWrapper.fadeOut();
}, defaultHideDuraton);
}
//禁止在dialog上可以上下滚动
$dialogWrapper.on('touchmove', function() {
return false;
});
dialogWrapperHammer.on('tap', function(event) {
if ($(event.target).hasClass('dialog-left-btn')) {
if (typeof callbackForLeft === 'function') {
callbackForLeft();
}
$dialogWrapper.fadeOut();
} else if ($(event.target).hasClass('dialog-right-btn')) {
callback();
}
// 防止出现点透问题
event.preventDefault();
event.srcEvent.stopPropagation();
});
};
exports.hideDialog = function() {
$('.dialog-wrapper').remove();
};
/*
* @Description: dialog
* @Time: 2015/11/18
* @author: chenglong.wang
*/
var $ = require("jquery"),
Handlebars = require("handlebars"),
Hammer = require("hammer");
var $dialogWrapper,
dialogTpl,
dialogTemplate;
function getInstance() {
if (dialogTpl === undefined) {
dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
'<div class="dialog-box">' +
'{{# hasHeader}}' +
'{{/ hasHeader}}' +
'<div class="dialog-content">{{dialogText}}</div>' +
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
'</div>' +
'</div>';
dialogTemplate = Handlebars.compile(dialogTpl);
}
return dialogTemplate;
}
exports.showDialog = function(data, callback, callbackForLeft) {
var dialogTemplate = getInstance(),
dialogStr = dialogTemplate(data),
$dialogBox,
defaultHideDuraton,
dialogWrapperHammer;
$('.dialog-wrapper').remove();
$('body').append($(dialogStr));
$dialogBox = $('.dialog-box');
$dialogWrapper = $('.dialog-wrapper');
dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper'));
// 显示
if (data.fast) {
$dialogWrapper.css({
display: 'block'
});
} else {
$dialogWrapper.fadeIn();
}
$dialogBox.css({
top: '50%',
marginTop: -($dialogBox.height() / 2)
});
//隐藏
if (data.autoHide) {
defaultHideDuraton = 1000;
if (data.autoHide > 1) {
defaultHideDuraton = data.autoHide;
}
setTimeout(function() {
$dialogWrapper.fadeOut();
}, defaultHideDuraton);
}
//禁止在dialog上可以上下滚动
$dialogWrapper.on('touchmove', function() {
return false;
});
dialogWrapperHammer.on('tap', function(event) {
if ($(event.target).hasClass('dialog-left-btn')) {
if (typeof callbackForLeft === 'function') {
callbackForLeft();
}
$dialogWrapper.fadeOut();
} else if ($(event.target).hasClass('dialog-right-btn')) {
callback();
}
// 防止出现点透问题
event.preventDefault();
event.srcEvent.stopPropagation();
});
};
exports.hideDialog = function() {
$('.dialog-wrapper').remove();
};
});
define("js/passport/bind/code", ["jquery"], function(require, exports, module){
... ... @@ -3654,32 +3678,32 @@ var nickname = $('#nickname').val(),
areaCode = $('#area-code').val().replace('+', '');
function startBind(password) {
$.ajax({
url: '/passport/bind/bindMobile',
type: 'post',
data: {
areaCode: areaCode.replace('+', ''),
phoneNum: phoneNum,
openId: openId,
sourceType: sourceType,
nickname: nickname,
password: password
},
success: function(res) {
if (res.code === 200) {
tip.show('登录成功');
setTimeout(function() {
location.href = res.data.refer;
}, 2000);
} else {
tip.show(res.message);
}
},
error: function(err) {
tip.show('登录失败,请重试!');
$.ajax({
url: '/passport/bind/bindMobile',
type: 'post',
data: {
areaCode: areaCode.replace('+', ''),
phoneNum: phoneNum,
openId: openId,
sourceType: sourceType,
nickname: nickname,
password: password
},
success: function(res) {
if (res.code === 200) {
tip.show('登录成功');
setTimeout(function() {
location.href = res.data.refer;
}, 2000);
} else {
tip.show(res.message);
}
});
}
},
error: function(err) {
tip.show('登录失败,请重试!');
}
});
}
api.bindEyesEvt({
status: 'open' //默认眼睛打开
... ... @@ -5432,6 +5456,11 @@ var $chosePanel = $('#chose-panel'),
$soonSoldOut = $('.soonSoldOut-tag'),
$yohoPage = $('.yoho-page');
//购物车编辑标相关变量
var isEdit,
isSelected,
oldSknId;
//初始化购物车面板显示
function init() {
hasChooseColor = false;
... ... @@ -5445,6 +5474,37 @@ function init() {
$leftNum = $('#left-num');
curColorIndex = 0;
curSizeIndex = 0;
isEdit = 0;
}
/*
* 设置当前面板为编辑模式
*
* @param {String} sknId. 当前编辑商品的sknId
*
* @param {Bool} isThisGoodSelected. 当前编辑商品的在购物车中是否被选中
*
* @return {undefined}
*/
function setEditModeWithSknId(sknId, isThisGoodSelected) {
$('#chose-btn-sure').html('确认');
isEdit = 1;
oldSknId = sknId;
isSelected = isThisGoodSelected;
}
//删除面板
function removePannel() {
var $pannel = $('.chose-panel'),
$promotionId = $('#promotionId');
if ($pannel) {
$pannel.remove();
}
if ($promotionId) {
$promotionId.remove();
}
}
function checkColorSizeNum() {
... ... @@ -5461,6 +5521,17 @@ function checkColorSizeNum() {
return true;
}
//禁用数字编辑
function disableNumEdit() {
var $numBtn = $('.chose-panel').find('.num .btn>.iconfont');
//添加disabled样式
$numBtn.hasClass('disabled') ? null : $numBtn.addClass('disabled');
$yohoPage.off('touchstart', '.btn-minus');
$yohoPage.off('touchstart', '.btn-plus');
}
function show(html, cb) {
var scrollPosition = [
... ... @@ -5478,8 +5549,7 @@ function show(html, cb) {
if (html) {
$chosePanel.html(html);
if ($('#promotionId').val() !== '') {
$yohoPage.off('touchstart', '.btn-minus');
$yohoPage.off('touchstart', '.btn-plus');
disableNumEdit();
}
init();
}
... ... @@ -5506,7 +5576,7 @@ function updateConformButtonClassAndText() {
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313').html('加入购物车');
$('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车');
}
}
... ... @@ -5753,7 +5823,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
buyNumber = $('#good-num').val() - 0,
promotionId,
isEdit = 0,
cartGoodData,
url,
num = parseInt($num.val(), 10);
//颜色尺码没有选择
... ... @@ -5761,7 +5832,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
return;
}
//TODO status change
if ($('#chose-btn-sure').html() === '已售罄') {
return;
}
... ... @@ -5787,21 +5857,39 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
confirming = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/cart/index/add',
data: {
//针对是否处于编辑模式设置不同的url和需要post的数据
if (isEdit) {
cartGoodData = {
new_product_sku: productSku,
old_product_sku: oldSknId,
buy_number: buyNumber,
selected: isSelected
};
url = '/cart/index/modify';
} else {
cartGoodData = {
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit,
cartType: queryString.cartType
}
};
url = '/cart/index/add';
}
$.ajax({
method: 'POST',
url: url,
data: cartGoodData
}).done(function(res) {
var cartNum;
loading.hideLoadingMask();
if (res.code === 200) {
if (res.code === 200 && !isEdit) {
cartNum = res.data.goods_count;
if (cartNum > 99) {
cartNum = '99+';
... ... @@ -5813,11 +5901,22 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
cbFn();
}
}
if (res.message) {
if (res.message && !isEdit) {
tip.show(res.message);
}
hide();
if (isEdit) {
loading.showLoadingMask();
//延迟刷新,否则面板可能无法隐藏
setTimeout(function() {
//获取当前页面商品类型:普通商品/预售商品
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
}, 1);
}
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
... ... @@ -5829,6 +5928,11 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
exports.init = init;
exports.show = show;
exports.remove = removePannel;
exports.setEditModeWithSknId = setEditModeWithSknId;
exports.disableNumEdit = disableNumEdit;
});
define("js/product/detail/desc", ["jquery","lazyload","swiper","index"], function(require, exports, module){
/**
... ... @@ -6732,440 +6836,451 @@ optHammer.on('tap', function(e) {
});
define("js/me/fav", ["jquery","hammer","swiper","handlebars","source-map","index"], function(require, exports, module){
/**
* 个人中心--收藏
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require("jquery"),
Hammer = require("hammer"),
Swiper = require("swiper");
var diaLog = require("js/me/dialog");
var $navLi = $('#fav-tab > li'),
$favContainer = $('.fav-content > .fav-type'),
swiperObj = {},
favTabHammer,
favContentHammer,
$loadMore = $('.fav-load-more'),
$brandLoadMore = $('.fav-brand-load-more'),
winH = $(window).height(),
footerH = $('#yoho-footer').height(),
$favProductList = $('.fav-product-list'),
$favBrandList = $('.fav-brand-swiper-wrapper'),
pageId = 1,
brandPageId = 1, //收藏品牌的当前页数
lockId = true,
brandLockId = true, //收藏品牌是否可下拉加载更多
brandTab = false; //当前是否停留在收藏品牌页
function showFavTab(index) {
$navLi.filter('.active').removeClass('active');
$navLi.eq(index).addClass('active');
$favContainer.filter('.show').removeClass('show');
$favContainer.eq(index).addClass('show');
}
//初始化swiper
function initSwiper(data) {
var i,
idStrReg = /container-(\d+)['"]{1}/gi,
idReg = /\d+/,
idArr = data.match(idStrReg),
idArrLen = idArr.length,
containerId;
//$swiperList = $('.swiper-container');
for (i = 0; i < idArrLen; i++) {
/*id = $swiperList.eq(i).attr('data-id');
if (!!swiperObj[id]) {
swiperObj[id].destroy(true, true);
}*/
containerId = idArr[i].match(idReg)[0];
swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'li',
wrapperClass: 'swiper-wrapper-' + containerId,
lazyLoading: true,
watchSlidesVisibility: true
});
}
}
// 上拉加载更多
function loadData($parent, url, page) {
if (url === 'favBrand') {
brandLockId = true;
} else {
lockId = true;
}
$.ajax({
method: 'post',
url: '/home/' + url,
data: {
page: page
},
success: function(data) {
if (url === 'favBrand') {
$brandLoadMore.addClass('hide');
} else {
$loadMore.addClass('hide');
}
if (data === ' ') {
$parent.closest('.fav-type').find('.fav-content-loading').addClass('hide');
$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
} else if (data === 'end') {
$parent.closest('.fav-type').find('.fav-load-background')
.removeClass('fav-load-background').html('没有更多了');
// hf: fixes bug to 修改没有数据还调接口,加载错误页面问题
brandLockId = true;
lockId = true;
} else if (data.length > 10) {
$parent.append(data);
$parent.closest('.fav-type').find('.fav-content-loading').remove();
if (url === 'favBrand') {
initSwiper(data);//如果是收藏品牌需要初始化swiper
brandLockId = false;//请求成功后解锁品牌收藏page++
} else {
lockId = false;//请求成功后解锁商品收藏page++
/**
* 个人中心--收藏
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require("jquery"),
Hammer = require("hammer"),
Swiper = require("swiper");
var diaLog = require("js/me/dialog");
var $navLi = $('#fav-tab > li'),
$favContainer = $('.fav-content > .fav-type'),
swiperObj = {},
favTabHammer,
favContentHammer,
$loadMore = $('.fav-load-more'),
$brandLoadMore = $('.fav-brand-load-more'),
winH = $(window).height(),
footerH = $('#yoho-footer').height(),
$favProductList = $('.fav-product-list'),
$favBrandList = $('.fav-brand-swiper-wrapper'),
pageId = 1,
brandPageId = 1, //收藏品牌的当前页数
lockId = true,
brandLockId = true, //收藏品牌是否可下拉加载更多
brandTab = false; //当前是否停留在收藏品牌页
function showFavTab(index) {
$navLi.filter('.active').removeClass('active');
$navLi.eq(index).addClass('active');
$favContainer.filter('.show').removeClass('show');
$favContainer.eq(index).addClass('show');
}
//初始化swiper
function initSwiper(data) {
var i,
idStrReg = /container-(\d+)['"]{1}/gi,
idReg = /\d+/,
idArr = data.match(idStrReg),
idArrLen = idArr.length,
containerId;
//$swiperList = $('.swiper-container');
for (i = 0; i < idArrLen; i++) {
/*id = $swiperList.eq(i).attr('data-id');
if (!!swiperObj[id]) {
swiperObj[id].destroy(true, true);
}*/
containerId = idArr[i].match(idReg)[0];
swiperObj[containerId] = new Swiper('#swiper-container-' + containerId, {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'li',
wrapperClass: 'swiper-wrapper-' + containerId,
lazyLoading: true,
watchSlidesVisibility: true
});
}
}
// 上拉加载更多
function loadData($parent, url, page) {
if (url === 'favBrand') {
brandLockId = true;
} else {
lockId = true;
}
$.ajax({
method: 'post',
url: '/home/' + url,
data: {
page: page
},
success: function(data) {
var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading');
if (url === 'favBrand') {
$brandLoadMore.addClass('hide');
} else {
$loadMore.addClass('hide');
}
if (data === ' ') {
$loadingMask.addClass('hide');
$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
} else if (data === 'end') {
//处理data等于end时如果loadingMask存在且没有hide样式的情况
if ($loadingMask && !$loadingMask.hasClass('hide')) {
$loadingMask.addClass('hide');
$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
}
}
window.rePosFooter();
}
});
}
// 如果从品牌收藏入口进入
if ($('#fav-tab').hasClass('brand-tab')) {
showFavTab(1);
loadData($favBrandList, 'favBrand', 1);
brandTab = true;
window.rePosFooter();
} else {
showFavTab(0);
loadData($favProductList, 'favProduct', 1);
brandTab = false;
window.rePosFooter();
}
favTabHammer = new Hammer(document.getElementById('fav-tab'));
favTabHammer.on('tap', function(e) {
var $cur = $(e.target).closest('li'),
index;
if ($cur.length === 0 || $cur.hasClass('active')) {
return;
}
index = $cur.index();
if (index === 0) {
brandTab = false;
if ($favProductList.find('li').length === 0 &&
$favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favProductList, 'favProduct', 1);
}
} else {
brandTab = true;
if ($favBrandList.find('div').length === 0 &&
$favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favBrandList, 'favBrand', 1);
}
}
showFavTab(index);
window.rePosFooter();
});
//删除收藏的商品
favContentHammer = new Hammer(document.getElementById('fav-content'));
favContentHammer.on('tap', function(e) {
var id = '';
if (!$(e.target).hasClass('del-fav')) {
return;
}
diaLog.showDialog({
dialogText: '您确定要取消收藏吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
id = $(e.target).closest('li').attr('data-id');
$.ajax({
method: 'post',
url: '/home/favoriteDel',
data: {
id: id
}
}).then(function(data) {
if (data.code === 200) {
diaLog.showDialog({
autoHide: true,
fast: true,
dialogText: '已经取消收藏'
});
$(e.target).closest('li').remove();
} else if (data.code === 400) {
diaLog.showDialog({
autoHide: true,
fast: true,
dialogText: data.message
});
} else {
diaLog.showDialog({
autoHide: true,
fast: true,
dialogText: '取消收藏失败'
});
}
}).fail(function() {
//TODO
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
});
function scrollHandler() {
//距离底部未1/4列表高度+底部高度的时候加载更多
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) {
if (brandTab) {
$brandLoadMore.filter('.hide').removeClass('hide');
if (!brandLockId) {
brandPageId++;
loadData($favBrandList, 'favBrand', brandPageId);
}
} else {
$loadMore.filter('.hide').removeClass('hide');
if (!lockId) {
pageId++;
loadData($favProductList, 'favProduct', pageId);
}
}
}
}
//srcoll to load more
$(window).scroll(scrollHandler);
$(document).on('touchend', '.swiper-header', function() {
var url = $(this).find('.fav-more').attr('href');
$parent.closest('.fav-type').find('.fav-load-background')
.removeClass('fav-load-background').html('没有更多了');
if (url) {
window.location.href = url;
}
});
// hf: fixes bug to 修改没有数据还调接口,加载错误页面问题
brandLockId = true;
lockId = true;
} else if (data.length > 10) {
$parent.append(data);
//如果有数据loadingMask会被remove掉
$loadingMask.remove();
if (url === 'favBrand') {
initSwiper(data);//如果是收藏品牌需要初始化swiper
brandLockId = false;//请求成功后解锁品牌收藏page++
} else {
lockId = false;//请求成功后解锁商品收藏page++
}
}
window.rePosFooter();
}
});
}
// 如果从品牌收藏入口进入
if ($('#fav-tab').hasClass('brand-tab')) {
showFavTab(1);
loadData($favBrandList, 'favBrand', 1);
brandTab = true;
window.rePosFooter();
} else {
showFavTab(0);
loadData($favProductList, 'favProduct', 1);
brandTab = false;
window.rePosFooter();
}
favTabHammer = new Hammer(document.getElementById('fav-tab'));
favTabHammer.on('tap', function(e) {
var $cur = $(e.target).closest('li'),
index;
if ($cur.length === 0 || $cur.hasClass('active')) {
return;
}
index = $cur.index();
if (index === 0) {
brandTab = false;
if ($favProductList.find('li').length === 0 &&
$favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favProductList, 'favProduct', 1);
}
} else {
brandTab = true;
if ($favBrandList.find('div').length === 0 &&
$favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favBrandList, 'favBrand', 1);
}
}
showFavTab(index);
window.rePosFooter();
});
//删除收藏的商品
favContentHammer = new Hammer(document.getElementById('fav-content'));
favContentHammer.on('tap', function(e) {
var id = '';
if (!$(e.target).hasClass('del-fav')) {
return;
}
diaLog.showDialog({
dialogText: '您确定要取消收藏吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
id = $(e.target).closest('li').attr('data-id');
$.ajax({
method: 'post',
url: '/home/favoriteDel',
data: {
id: id
}
}).then(function(data) {
if (data.code === 200) {
diaLog.showDialog({
autoHide: true,
fast: true,
dialogText: '已经取消收藏'
});
$(e.target).closest('li').remove();
} else if (data.code === 400) {
diaLog.showDialog({
autoHide: true,
fast: true,
dialogText: data.message
});
} else {
diaLog.showDialog({
autoHide: true,
fast: true,
dialogText: '取消收藏失败'
});
}
}).fail(function() {
//TODO
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
});
function scrollHandler() {
//距离底部未1/4列表高度+底部高度的时候加载更多
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) {
if (brandTab) {
$brandLoadMore.filter('.hide').removeClass('hide');
if (!brandLockId) {
brandPageId++;
loadData($favBrandList, 'favBrand', brandPageId);
}
} else {
$loadMore.filter('.hide').removeClass('hide');
if (!lockId) {
pageId++;
loadData($favProductList, 'favProduct', pageId);
}
}
}
}
//srcoll to load more
$(window).scroll(scrollHandler);
$(document).on('touchend', '.swiper-header', function() {
var url = $(this).find('.fav-more').attr('href');
if (url) {
window.location.href = url;
}
});
});
define("js/me/suggest", ["jquery","hammer","lazyload","handlebars","source-map"], function(require, exports, module){
/**
* 个人中心--意见反馈
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require("jquery"),
Hammer = require("hammer"),
lazyLoad = require("lazyload"),
Handlebars = require("handlebars");
var diaLog = require("js/me/dialog");
var $uploadImgList = $('.upload-img-list'),
headerNavHammer,
formHammer,
imgTpl,
imgTemplate,
$likeBtn = $('.suggest-item .like-btn'),
$disLikeBtn = $('.suggest-item .dislike-btn'),
$imgAdd = $('.img-add'),
imgStr = '',
uploadImgNum = 0;
require("js/me/jquery.upload");
imgTpl = '{{# imgList}}' +
'<li>' +
'{{# imgUrl}}<img src="{{.}}" />' +
'<span class="upload-img-remove"></span>{{/ imgUrl}}' +
'</li>' +
'{{/ imgList}}';
imgTemplate = Handlebars.compile(imgTpl);
$('#upload-img').upload({
auto: true,
fileType: 'image/*',
uploadScript: '/home/suggestimgUpload',
fileObjName: 'fileData',
fileSizeLimit: 300,
height: '100%',
width: '100%',
multi: false,
onAddQueueItem: function(files) {
//TODO
$uploadImgList.html(imgTemplate({
imgList: true
}));
},
onUploadComplete: function(file, data) {
$uploadImgList.html('');
imgStr = JSON.parse(data).imgList[0].imgRelUrl;
$uploadImgList.html(imgTemplate(JSON.parse(data)));
$imgAdd.hide();
uploadImgNum++;
}
});
lazyLoad();
headerNavHammer = new Hammer(document.getElementById('yoho-header'));
headerNavHammer.on('tap', function(e) {
var suggestText = $('#suggest-textarea').val(),
textReg = /\S+/;
if ($(e.target).hasClass('nav-btn')) {
if (!textReg.test(suggestText)) {
diaLog.showDialog({
autoHide: true,
dialogText: '意见不能为空'
});
return;
}
$.ajax({
method: 'post',
url: '/home/savesuggest',
data: {
content: suggestText,
image: imgStr
}
}).then(function(data) {
if (data.code === 200) {
diaLog.showDialog({
autoHide: true,
dialogText: '提交成功'
});
setTimeout(function() {
location.pathname = 'home/suggest';
}, 2000);
} else {
diaLog.showDialog({
autoHide: true,
dialogText: '提交失败~'
});
}
}).fail(function() {
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
}
});
if (document.getElementById('img-form') !== null) {
formHammer = new Hammer(document.getElementById('img-form'));
formHammer.on('tap', function(e) {
if ($(e.target).hasClass('upload-img-remove')) {
$uploadImgList.html('');
imgStr = '';
uploadImgNum--;
setTimeout(function() {
$imgAdd.show();
}, 50);
}
});
}
// 点赞与取消点赞
$likeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
$.ajax({
method: 'post',
url: '/home/upAndDown',
data: {
suggest_id: id,
reliable: 1
}
}).then(function(data) {
if (data.code === 200) {
$that.closest('.suggest-type').removeClass('show');
$that.closest('.suggest-item').find('.suggest-good').addClass('show');
}
}).fail(function(data) {
//TODO
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
$disLikeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
$.ajax({
method: 'post',
url: '/home/upAndDown',
data: {
suggest_id: id,
reliable: 2
}
}).then(function(data) {
if (data.code === 200) {
$that.closest('.suggest-type').removeClass('show');
$that.closest('.suggest-item').find('.suggest-bad').addClass('show');
}
}).fail(function(data) {
//TODO
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
/**
* 个人中心--意见反馈
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require("jquery"),
Hammer = require("hammer"),
lazyLoad = require("lazyload"),
Handlebars = require("handlebars");
var diaLog = require("js/me/dialog");
var $uploadImgList = $('.upload-img-list'),
headerNavHammer,
formHammer,
imgTpl,
imgTemplate,
$likeBtn = $('.suggest-item .like-btn'),
$disLikeBtn = $('.suggest-item .dislike-btn'),
$imgAdd = $('.img-add'),
imgStr = '',
uploadImgNum = 0;
require("js/me/jquery.upload");
imgTpl = '{{# imgList}}' +
'<li>' +
'{{# imgUrl}}<img src="{{.}}" />' +
'<span class="upload-img-remove"></span>{{/ imgUrl}}' +
'</li>' +
'{{/ imgList}}';
imgTemplate = Handlebars.compile(imgTpl);
$('#upload-img').upload({
auto: true,
fileType: 'image/*',
uploadScript: '/home/suggestimgUpload',
fileObjName: 'fileData',
fileSizeLimit: 300,
height: '100%',
width: '100%',
multi: false,
onAddQueueItem: function(files) {
//TODO
$uploadImgList.html(imgTemplate({
imgList: true
}));
},
onUploadComplete: function(file, data) {
$uploadImgList.html('');
imgStr = JSON.parse(data).imgList[0].imgRelUrl;
$uploadImgList.html(imgTemplate(JSON.parse(data)));
$imgAdd.hide();
uploadImgNum++;
}
});
lazyLoad();
headerNavHammer = new Hammer(document.getElementById('yoho-header'));
headerNavHammer.on('tap', function(e) {
var suggestText = $('#suggest-textarea').val(),
textReg = /\S+/;
if ($(e.target).hasClass('nav-btn')) {
if (!textReg.test(suggestText)) {
diaLog.showDialog({
autoHide: true,
dialogText: '意见不能为空'
});
return;
}
$.ajax({
method: 'post',
url: '/home/savesuggest',
data: {
content: suggestText,
image: imgStr
}
}).then(function(data) {
if (data.code === 200) {
diaLog.showDialog({
autoHide: true,
dialogText: '提交成功'
});
setTimeout(function() {
location.pathname = 'home/suggest';
}, 2000);
} else {
diaLog.showDialog({
autoHide: true,
dialogText: '提交失败~'
});
}
}).fail(function() {
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
}
});
if (document.getElementById('img-form') !== null) {
formHammer = new Hammer(document.getElementById('img-form'));
formHammer.on('tap', function(e) {
if ($(e.target).hasClass('upload-img-remove')) {
$uploadImgList.html('');
imgStr = '';
uploadImgNum--;
setTimeout(function() {
$imgAdd.show();
}, 50);
}
});
}
// 点赞与取消点赞
$likeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
$.ajax({
method: 'post',
url: '/home/upAndDown',
data: {
suggest_id: id,
reliable: 1
}
}).then(function(data) {
if (data.code === 200) {
$that.closest('.suggest-type').removeClass('show');
$that.closest('.suggest-item').find('.suggest-good').addClass('show');
}
}).fail(function(data) {
//TODO
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
$disLikeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
$.ajax({
method: 'post',
url: '/home/upAndDown',
data: {
suggest_id: id,
reliable: 2
}
}).then(function(data) {
if (data.code === 200) {
$that.closest('.suggest-type').removeClass('show');
$that.closest('.suggest-item').find('.suggest-bad').addClass('show');
}
}).fail(function(data) {
//TODO
diaLog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
});
define("js/me/jquery.upload", ["jquery"], function(require, exports, module){
... ... @@ -8481,6 +8596,7 @@ $addressForm.on('submit', function() {
isSubmiting = true;
loading.showLoadingMask();
$submit.css('background', '#777');
$.ajax({
method: 'POST',
url: '/home/saveAddress',
... ... @@ -8503,6 +8619,8 @@ $addressForm.on('submit', function() {
}).fail(function() {
tip.show('网络出了点问题~');
isSubmiting = false;
loading.hideLoadingMask();
$submit.css('background', '#444');
});
return false;
});
... ... @@ -8608,7 +8726,7 @@ if (chinaAddressList) {
}
});
define("js/me/logistic", ["jquery"], function(require, exports, module){
define("js/me/logistic", ["jquery","hammer","lazyload"], function(require, exports, module){
/**
* 物流信息页面
* @author: 赵彪<bill.zhao@yoho.cn>
... ... @@ -8632,9 +8750,14 @@ function addFooterTopBorder() {
$(document).ready(addFooterTopBorder);
function getGender() {
return window.cookie('_Channel') || 'boys';
}
require("js/home/maybe-like")(getGender());
//提前触发lazyload
$(window).scrollTop(1).scrollTop(0);
... ... @@ -8664,7 +8787,7 @@ var appIconPosition = {
bank: '-4rem'
};
//隐藏微信分享选项
// 隐藏微信分享选项
if (window.wx) {
wx.hideOptionMenu();
}
... ... @@ -8687,10 +8810,10 @@ if (typeof WeixinJSBridge === undefined) {
onBridgeReady();
}
//调用微信JS api 支付
// 调用微信JS api 支付
function jsApiCall(orderCode, jsApiParameters) {
//防止重复操作弹框
// 防止重复操作弹框
window.WeixinJSBridge && window.WeixinJSBridge.invoke(
'getBrandWCPayRequest',
jsApiParameters,
... ... @@ -8700,7 +8823,7 @@ function jsApiCall(orderCode, jsApiParameters) {
);
}
//微信支付
// 微信支付
function callpay(orderCode) {
var jsApiParameters;
... ... @@ -8735,11 +8858,7 @@ function callpay(orderCode) {
function isWXOpen() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') > 0) {
return true;
} else {
return false;
}
return ua.indexOf('micromessenger') > 0;
}
function hideWeChatPay() {
... ... @@ -8781,9 +8900,7 @@ function loadIcon() {
}
function showPage() {
var $pageList = $('.payapp-list');
$pageList.css('visibility', 'visible');
$('.payapp-list').css('visibility', 'visible');
}
if (wxHammer) {
... ... @@ -9123,7 +9240,6 @@ $cartNav.on('touchstart', 'li', function(e) {
//提前触发lazyload
$(window).scrollTop(1).scrollTop(0);
});
define("js/cart/good", ["jquery","mlellipsis","lazyload","handlebars","source-map","hammer"], function(require, exports, module){
/**
... ... @@ -9135,6 +9251,7 @@ define("js/cart/good", ["jquery","mlellipsis","lazyload","handlebars","source-ma
var $ = require("jquery"),
ellipsis = require("mlellipsis"),
chosePanel = require("js/cart/chose-panel"),
loading = require("js/plugin/loading"),
lazyLoad = require("lazyload");
var dialog = require("js/me/dialog"),
... ... @@ -9143,6 +9260,9 @@ var dialog = require("js/me/dialog"),
var $selectAllBtn = $('.balance .checkbox'),
requesting = false;
//上次编辑的商品skn
var previousEditSkn;
ellipsis.init();
lazyLoad({
... ... @@ -9204,6 +9324,96 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
});
/*
* 显示购物车编辑面板。
*
* @param {String} html. chose-pannel模板,由服务端返回
*
* @param {String} id. 商品skuid
*
* @param {Bool} isSelected. 所要编辑的商品是否被选中
*
* @param {Bool} isEditNum. 所要编辑的商品是否被选中
*
* @return false or undefined
*
*/
function showEditPannelWithSku(html, id, isSelected, isEditNum) {
if (html.length < 2) {
tip.show('出错啦!');
return false;
}
//删掉页面上原有的pannel
chosePanel.remove();
$(html).appendTo('#mainCart');
chosePanel.init();
chosePanel.setEditModeWithSknId(id, isSelected);
if (!isEditNum) {
chosePanel.disableNumEdit();
}
chosePanel.show();
}
$('.icon-edit').on('touchstart', function(e) {
var $this = $(this),
skn = $this.closest('.shopping-cart-good').data('skn');
var $checkBox,
$tag;
var id,
count,
canEditNum;
//如果点击的是上次编辑的商品,直接显示chose-pannel
if (skn === previousEditSkn) {
chosePanel.show();
return;
}
previousEditSkn = skn;
$checkBox = $this.closest('.info').siblings('.checkbox');
$tag = $this.closest('.deps').siblings('.few-tag');
id = $this.closest('.shopping-cart-good').data('id');
count = $this.data('count');
//加价购或者赠品不能编辑数量
canEditNum = $tag.hasClass('gift-tag') || $tag.hasClass('plus-tag') ? false : true;
e.stopPropagation();
loading.showLoadingMask();
$.ajax({
url: '/cart/index/goodinfo',
data: {
skn: skn,
buy_num: count
},
success: function(res) {
showEditPannelWithSku(res, id, $checkBox.hasClass('icon-cb-checked'), canEditNum);
},
error: function() {
tip.show('网络异常');
window.location.reload();
},
complete: function() {
loading.hideLoadingMask();
}
});
});
$('.icon-del').on('touchstart', function(e) {
var $this = $(this);
... ... @@ -9502,6 +9712,7 @@ $invoice.on('touchend', '.checkbox', function() {
function orderCompute() {
var yohoCoin = orderInfo('yohoCoin');
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/cart/index/orderCompute',
... ... @@ -9536,6 +9747,8 @@ function orderCompute() {
}
}).fail(function() {
window.location.reload();
}).always(function() {
loading.hideLoadingMask();
});
}
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.