Authored by hf

Merge branch 'test' into develop

... ... @@ -745,7 +745,7 @@ class Helpers
*/
public static function syncUserSession($uid, $refer = '', $callback = 'call')
{
return 'http://m1.yohobuy.com/Passport/session/index?callback=' . $callback
return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback
. '&sign=' .md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer;
}
... ... @@ -761,7 +761,7 @@ class Helpers
*/
public static function logoutSession($token, $refer = '', $callback = 'call')
{
return 'http://m1.yohobuy.com/Passport/session/logout?callback=' . $callback
return 'http://mapi.yohobuy.com/Passport/session/logout?callback=' . $callback
. '&sign=' . md5(md5('Js8Yn0!EwPM45-ws')) . '&token=' . $token . '&go=' . $refer;
}
... ...
... ... @@ -15,13 +15,14 @@ require("js/cart/entry");
module.exports = yohobuy;
});
define("js/common", ["jquery"], function(require, exports, module){
define("js/common", ["jquery","hammer"], function(require, exports, module){
/**
* 页面公共逻辑
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/21
*/
var $ = require("jquery");
var $ = require("jquery"),
Hammer = require("hammer");
var $footer = $('#yoho-footer'),
$yohoPage = $('.yoho-page'),
... ... @@ -149,6 +150,8 @@ function reMarginFooter(fixedElement) {
var user = getUser();
var backToTopHammer;
rePosFooter(); //计算底部位置
if (user === 0) {
... ... @@ -169,10 +172,15 @@ function reMarginFooter(fixedElement) {
);
}
$op.find('.back-to-top').on('touchend', function() {
$(window).scrollTop(0);
return false;
});
if ($op.find('.back-to-top').length > 0) {
backToTopHammer = new Hammer($op.find('.back-to-top')[0]);
backToTopHammer.on('tap', function(e) {
$(window).scrollTop(0);
e.srcEvent.preventDefault();
return false;
});
}
$footer.removeClass('hide');
}());
... ... @@ -2209,7 +2217,7 @@ function downLoadApp() {
var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
var clickedAt = new Date();
setTimeout(function () {
setTimeout(function() {
if ((new Date()) - clickedAt < 2000) {
window.location = appUrl;
}
... ... @@ -2245,7 +2253,7 @@ if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
}
});
define("js/index/channel", ["jquery"], function(require, exports, module){
define("js/index/channel", ["jquery","hammer"], function(require, exports, module){
/**
* 频道选择页面顶部搜索
* @author: bikai<kai.bi@yoho.cn>
... ... @@ -2376,6 +2384,8 @@ var tip = require("js/plugin/tip");
var trim = $.trim;
var showErrTip = tip.show;
var requested = false;
api.selectCssHack($('#country-select'));
api.bindClearEvt();
... ... @@ -2400,7 +2410,15 @@ $btnNext.on('touchstart', function() {
return;
}
if (requested) {
return false;
}
if (api.phoneRegx[areaCode].test(pn)) {
requested = true;
$.ajax({
url: '/passport/reg/verifymobile',
type: 'POST',
... ... @@ -2413,13 +2431,19 @@ $btnNext.on('touchstart', function() {
location.href = data.data;
} else {
showErrTip(data.message);
requested = false;
}
},
error: function(err) {
showErrTip('出错了,请重试');
requested = false;
}
});
} else {
showErrTip('手机号格式不正确,请重新输入');
}
});
});
define("js/passport/api", ["jquery"], function(require, exports, module){
/**
... ... @@ -3340,14 +3364,15 @@ var api = require("js/passport/api"),
var trim = $.trim;
var showErrTip = tip.show;
var requesting = false;
var requested = false;
function nextStep(url, mobileNo, areaCode) {
if (requesting) {
if (requested) {
return false;
}
requesting = true;
requested = true;
$btnNext.addClass('disable').html('绑定中...');
$.ajax({
type: 'POST',
... ... @@ -3357,15 +3382,14 @@ function nextStep(url, mobileNo, areaCode) {
areaCode: areaCode.replace('+', '')
},
success: function(res) {
console.log(res.data);
location.href = url;
requesting = false;
// console.log(res.data);
location.href = url;
},
error: function() {
tip.show('出错了,请重试!');
requesting = false;
$btnNext.removeClass('disable').html('下一步');
requested = false;
}
});
}
... ... @@ -3409,7 +3433,8 @@ $btnNext.on('touchstart', function() {
nickname: nickname
},
success: function(res) {
console.log(res);
// console.log(res);
//res : {
// code: 'xxx',
... ... @@ -3482,7 +3507,7 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
dialogTemplate = Handlebars.compile(dialogTpl);
exports.showDialog = function(data, callback) {
exports.showDialog = function(data, callback, callbackForLeft) {
var dialogStr = dialogTemplate(data),
$dialogBox,
... ... @@ -3525,6 +3550,9 @@ exports.showDialog = function(data, callback) {
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();
... ... @@ -4252,6 +4280,9 @@ $.ajax({
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
}
... ... @@ -5154,8 +5185,14 @@ function showFooter() {
showFooter();
require("js/product/detail/like");
lazyLoad($('img.lazy'));
if ($('#goodsDiscount h1').length < 1) {
$('.dropdown').remove();
}
//顶部swiper
goodsSwiper = new Swiper('.banner-swiper', {
lazyLoading: true,
... ... @@ -5217,733 +5254,781 @@ if ($('.good-detail-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
}
require("js/product/detail/like");
});
define("js/product/detail/desc", ["jquery","lazyload","swiper","index"], function(require, exports, module){
define("js/product/detail/like", ["jquery","hammer"], function(require, exports, module){
/**
* 商品详情 --异步加载页面下半部分
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/11/18
* 商品详情 --添加收藏
* @author: Lynnic
* @date: 2015/11/24
*/
var $ = require("jquery"),
lazyLoad = require("lazyload"),
Swiper = require("swiper"),
loading = require("js/plugin/loading"),
tip = require("js/plugin/tip");
var introUrl = $('#introUrl').val(),
winH = $(window).height(),
$productDesc,
searching = false,
end = false;
var sizeSwiper,
refSwiper;
var $ = require("jquery"),
Hammer = require("hammer"),
tip = require("js/plugin/tip"),
chosePanel = require("js/cart/chose-panel");
var likeEle = document.getElementById('likeBtn'),
likeHammer = likeEle && new Hammer(likeEle);
//判断是否要显示向左滑动提示
function hiddenTips($ele) {
var offsetContainer,
offsetLastColumn;
var addToCartEle = document.getElementById('addtoCart'),
addToCartHammer = addToCartEle && new Hammer(addToCartEle),
productId = $('#productId').val();
if ($ele.length > 0) {
offsetContainer = $ele[0].getBoundingClientRect().right;
offsetLastColumn = $ele.find('.swiper-slide:last-child')[0].getBoundingClientRect().right;
if (likeHammer) {
likeHammer.on('tap', function(e) {
var opt,
favorite;
var $this = $(e.target);
if (offsetLastColumn - offsetContainer < 0) {
$ele.next('.tips').css('display', 'none');
if ($this.hasClass('liked')) {
opt = 'cancel';
favorite = 0;
} else {
$ele.next('.tips').css('display', 'block');
opt = 'ok';
favorite = 1;
}
}
}
//function isFlexSupport() {
// var flex = document.createElement('p').style.flex,
// webkitFlex = document.createElement('p').style.webkitFlex,
// flexWrap = document.createElement('p').style.flexWrap;
//
// if ((flex === '' || webkitFlex === '') && flexWrap === '') {
// return true;
// } else {
// return false;
// }
//}
function wrapElements(selector, count) {
var elArr = null;
$.ajax({
type: 'POST',
url: '/product/opt/favoriteProduct',
data: {
id: productId,
opt: opt
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('liked');
$(selector).each(function(idx, el) {
elArr = $(selector).slice(idx, idx + count);
if ('cancel' === opt) {
tip.show('取消收藏成功');
} else if ('ok' === opt) {
tip.show('收藏成功');
}
} else if (data.code === 400) {
location.href = data.data;//未登录跳转登录页
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
if (elArr.length === count && idx % count === 0) {
$(elArr).wrapAll($('<div class="js-wraper"></div>'));
// 统计代码:用于统计用户加入或取消商品收藏的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
fa: favorite
}, true);
}
});
}
if (addToCartHammer) {
addToCartHammer.on('tap', function(e) {
chosePanel.show();
//统计代码:用于统计用户加入购物车的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
by: 1
}, true);
}
function search() {
if (searching || end) {
return;
}
searching = true;
// alert($('#reference-swiper-container .swiper-wrapper').width());
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: introUrl,
success: function(data) {
$productDesc = $('#productDesc');
$productDesc.append(data);
});
}
window.rePosFooter();
});
define("js/cart/chose-panel", ["jquery"], function(require, exports, module){
/**
* 购物车选择尺寸、颜色和数量面板
* 显示时构造当前商品信息的HTML插入yoho-page;消失则是直接清除HTML
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/21
*/
lazyLoad($productDesc.find('img.lazy'));
// bikai
// 增加init函数,异步请求的接口需要重新初始化一下选择列表
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
//尺码信息左右滑动
sizeSwiper = new Swiper('#size-swiper-container',{
slidesPerView: 'auto'
});
var $ = require("jquery"),
tip = require("js/plugin/tip"),
loading = require("js/plugin/loading");
//模特试穿左右滑动
refSwiper = new Swiper('#reference-swiper-container',{
slidesPerView: 'auto'
});
var $chosePanel = $('#chose-panel'),
$num,
$chosed,
$imgsThumb,
$leftNum,
$leftNumHtml,
leftNum,
confirming,
curColorIndex,
curSizeIndex,
hasChooseColor,
hasChooseSize,
$curSizeBlock,
$sizeRowList,
cbFn,
$allChoseItems,
queryString,
$yohoPage = $('.yoho-page');
hiddenTips($('#size-swiper-container'));
hiddenTips($('#reference-swiper-container'));
//if (!isFlexSupport()) {
// $('.detail .column').removeClass('column').addClass('oldbox');
//}
wrapElements('.detail .column', 2);
searching = false;
end = true;
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
//初始化购物车面板显示
function init() {
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
queryString = $.queryString();
$imgsThumb = $('.chose-panel').find('.thumb');
$allChoseItems = $('.chose-items');
$sizeRowList = $('.size-list ul');
$leftNum = $('#left-num');
$leftNumHtml =
$sizeRowList.eq(0).toggleClass('hide');
}
function scrollHandler() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
search();
function checkColorSizeNum() {
if (!hasChooseColor && !hasChooseSize) {
tip.show('请选择颜色和尺码~');
return false;
} else if (!hasChooseColor) {
tip.show('请选择颜色~');
return false;
} else if (!hasChooseSize) {
tip.show('请选择尺码~');
return false;
}
return true;
}
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
function show(html, cb) {
var scrollPosition = [
document.documentElement.scrollLeft || document.body.scrollLeft,
document.documentElement.scrollTop || document.body.scrollTop
],
$html = $('html'); // it would make more sense to apply this to body, but IE7 won't have that
});
define("js/product/detail/comments-consults", ["jquery","hammer"], function(require, exports, module){
/**
* 商品详情 --评论和咨询tab
* @author: Lynnic
* @date: 2015/11/18
*/
var $ = require("jquery"),
tip = require("js/plugin/tip"),
Hammer = require("hammer");
var commentsNum,consultsNum;
var navtabEle = document.getElementById('nav-tab'),
navtabHammer = navtabEle && new Hammer(navtabEle),
gotoConsultEle = document.getElementById('goto-consult'),
gotoConsultHammer = gotoConsultEle && new Hammer(gotoConsultEle);
$html.data('scroll-position', scrollPosition);
$html.data('previous-overflow', $html.css('overflow'));
$html.css('overflow', 'hidden');
window.scrollTo(scrollPosition[0], scrollPosition[1]);
if (html) {
$chosePanel.html(html);
if ($('#promotionId').val() !== '') {
$yohoPage.off('touchstart', '.btn-minus');
$yohoPage.off('touchstart', '.btn-plus');
}
init();
}
$('.chose-panel').show();
$num = $('#good-num');
cbFn = cb;
}
(function() {
consultsNum = $('#nav-tab .consults-num').html() - 0;
commentsNum = $('#nav-tab .comments-num').html() - 0;
$('#nav-tab li').each(function() {
$(this).removeClass('focus');
});
//隐藏当前Panel
function hide() {
var $html = $('html'),
scrollPosition = $html.data('scroll-position');
$('#feedback-content .content').each(function() {
$(this).addClass('hide');
});
if (0 !== commentsNum) {
$('#nav-tab .comment-nav').addClass('focus');
$('#feedback-content .comment-content').removeClass('hide');
// un-lock scroll position
$html.css('overflow', $html.data('previous-overflow'));
window.scrollTo(scrollPosition[0], scrollPosition[1]);
$('.chose-panel').hide();
}
} else if (0 !== consultsNum) {
$('#nav-tab .consult-nav').addClass('focus');
$('#feedback-content .consult-content').removeClass('hide');
//修改加入购物车的文字和背景
function updateConformButtonClassAndText() {
$chosed = $allChoseItems.find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313').html('确定');
}
}
})();
if (navtabHammer) {
navtabHammer.on('tap', function(e) {
var $this = $(e.target).closest('li');
var index = $this.index();
if ($this.hasClass('comment-nav') && 0 === commentsNum) {
tip.show('暂无商品评价');
} else {
if (!$this.hasClass('focus')) {
//重置颜色块的库存为0的样式
function resetColorZeroStock($siblingBlock) {
var numArray,
i;
$('#nav-tab li').each(function() {
$(this).removeClass('focus');
});
$('#feedback-content .content').each(function() {
$(this).addClass('hide');
});
if (!hasChooseSize) {
$siblingBlock.find('ul>li').each(function() {
if (0 === $(this).data('num')) {
$(this).addClass('zero-stock');
} else {
$(this).removeClass('zero-stock');
}
});
$this.addClass('focus');
$('#feedback-content .content:eq(' + index + ')').removeClass('hide');
} else {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
} else {
$siblingBlock.find('.block').eq(i).removeClass('zero-stock');
}
}
});
}
}
if (gotoConsultHammer) {
gotoConsultHammer.on('tap', function() {
location.href = $(gotoConsultEle).find('a').attr('href');
});
// 选择了颜色切换商品图片
function changeGoodImgWhenClickColor() {
if (hasChooseColor && curColorIndex >= 0) {
$imgsThumb.addClass('hide').eq(curColorIndex).removeClass('hide');
}
}
//咨询页面固定header
if ($('.goods-consults-page').length > 0) {
$('#yoho-header').css('position', 'fixed').css('top', '0');
}
init();
$yohoPage.on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
if ($cur.closest('.main').length > 0) {
return;
}
//点击蒙版消失
hide();
});
define("js/product/recommend-for-you-product-desc", ["swiper","jquery","index"], function(require, exports, module){
/**
* 为您优选
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/11/16
*/
$yohoPage.on('touchstart', '.color-list .block', function() {
var $this = $(this),
index,
curSizeBlock,
$preSiblingBlock,
$curSizeRow,
numArray,
i,
curGoodNum;
var Swiper = require("swiper"),
$ = require("jquery");
var $siblingBlock = $this.closest('.block-list').siblings(':first');
var recommendSwiper,
$recommendForYou = $('.recommend-for-you'),
preferenceUrl = $('#preferenceUrl').val(),
winH = $(window).height(),
end = false,
requesting = false;
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
$preSiblingBlock = $siblingBlock.find('.chosed');
$curSizeRow = $sizeRowList.eq(index);
function request() {
if (requesting || end) {
return;
}
// 当前颜色已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
requesting = true;
//颜色原来已经是勾选时,要清空剩余件数的提示
$allChoseItems.find('.num .left-num').html('');
$leftNum.val(0);
hasChooseColor = false;
if (preferenceUrl) {
$.get(preferenceUrl).then(function(html) {
if (html.length < 5) {
$recommendForYou.css('display', 'none');
} else {
$recommendForYou.html(html).show();
if ($('#swiper-recommend').length) {
recommendSwiper = new Swiper('#swiper-recommend', {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'a',
lazyLoading: true,
watchSlidesVisibility: true
});
$this.removeClass('zero-stock');
if ($curSizeBlock) {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$('.color-list .block').eq(i).addClass('zero-stock');
}
}
}
requesting = false;
end = true;
// 当前颜色不是选中状态,选中时
} else {
hasChooseColor = true;
window.rePosFooter();
//把当前选中颜色对应的尺码那一行显示出来
$sizeRowList.addClass('hide');
$curSizeRow.removeClass('hide').addClass('show');
}).fail(function() {
$recommendForYou.hide();
});
}
}
// 之前选中的尺码去掉勾选样式
if ($preSiblingBlock.length > 0) {
$preSiblingBlock.removeClass('chosed');
curSizeBlock = $curSizeRow.children().get(curSizeIndex);
}
function scrollHandler() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
request();
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
if (curSizeBlock) {
curGoodNum = $(curSizeBlock).data('num');
$(curSizeBlock).addClass('chosed');
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if (curGoodNum > 0) {
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
$leftNum.val(curGoodNum);
} else {
$allChoseItems.find('.num .left-num').html('');
$leftNum.val(0);
}
}
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
// 当前颜色块 切换勾选样式
$this.toggleClass('chosed');
curColorIndex = index;
$('#good-num').val(1);
});
define("js/product/detail/like", ["jquery","hammer"], function(require, exports, module){
/**
* 商品详情 --添加收藏
* @author: Lynnic
* @date: 2015/11/24
*/
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor();
// 设置按钮的样式和文字
updateConformButtonClassAndText();
}).on('touchstart', '.size-list .block', function() {
var $this = $(this),
index,
$curSizeRow,
curGoodNum;
var $ = require("jquery"),
Hammer = require("hammer"),
tip = require("js/plugin/tip"),
chosePanel = require("js/cart/chose-panel");
var $siblingBlock = $this.closest('.block-list').siblings(':first');
var likeEle = document.getElementById('likeBtn'),
likeHammer = likeEle && new Hammer(likeEle);
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
$curSizeRow = $sizeRowList.eq(index);
var addToCartEle = document.getElementById('addtoCart'),
addToCartHammer = addToCartEle && new Hammer(addToCartEle),
productId = $('#productId').val();
// 当前尺码已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
if (likeHammer) {
likeHammer.on('tap', function(e) {
var opt,
favorite;
//尺码原来已经是勾选时,要清空剩余件数的提示
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseSize = false;
curSizeIndex = null;
$curSizeBlock = null;
var $this = $(e.target);
// 当前尺码不是选中状态,选中时
} else {
hasChooseSize = true;
curGoodNum = $this.data('num');
if ($this.hasClass('liked')) {
opt = 'cancel';
favorite = 0;
// 之前选中的尺码去掉勾选样式
if ($curSizeBlock) {
$curSizeBlock.removeClass('chosed');
}
// 如果当前有尺码被选中,且数量等于0, 否则显示剩余件数
if (curGoodNum > 0 && hasChooseColor) {
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
opt = 'ok';
favorite = 1;
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
}
if (curGoodNum === 0 && hasChooseColor) {
$this.addClass('zero-stock');
}
curSizeIndex = index;
$curSizeBlock = $this;
}
$this.toggleClass('chosed');
$('#good-num').val(1);
// 重置颜色块的样式
resetColorZeroStock($siblingBlock);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
});
$yohoPage.on('touchstart', '.btn-minus', function() {
var num = parseInt($num.val(), 10);
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
}
if (num === 1 || 0 === leftNum - 0) {
tip.show('您选择的数量不能为零~');
return;
}
if (num < 0) {
tip.show('您选择的数量不能为负数~');
return;
}
$num.val(num - 1);
}).on('touchstart', '.btn-plus', function() {
var num = parseInt($num.val(), 10);
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
}
if (num - 0 === leftNum || 0 === leftNum) {
return;
}
//TODO:库存数验证
if (num > leftNum - 1) {
tip.show('您选择的数量超过了最大库存量~');
return;
}
$num.val(num + 1);
}).on('touchstart', '#chose-btn-sure', function() {
var productSku,
buyNumber = $('#good-num').val() - 0,
promotionId,
isEdit = 0,
num = parseInt($num.val(), 10);
//颜色尺码没有选择
if (!checkColorSizeNum()) {
return;
}
//TODO status change
if ($('#chose-btn-sure').html() === '已售罄') {
return;
}
leftNum = $('#left-num').val() - 0;
if (num > leftNum) {
tip.show('您选择的数量超过了最大库存量~');
return;
}
if (num < 0) {
tip.show('您选择的数量小于一件~');
return;
}
$chosed = $('.block-list>ul>li.chosed');
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
productSku = $curSizeBlock.data('skuid');
promotionId = $('#promotionId').val();
if (confirming) {
return false;
}
confirming = true;
loading.showLoadingMask();
$.ajax({
type: 'POST',
url: '/product/opt/favoriteProduct',
method: 'POST',
url: '/cart/index/add',
data: {
id: productId,
opt: opt
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('liked');
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit,
cartType: queryString.cartType
}
}).done(function(res) {
var cartNum;
if ('cancel' === opt) {
tip.show('取消收藏成功');
} else if ('ok' === opt) {
tip.show('收藏成功');
}
} else if (data.code === 400) {
location.href = data.data;//未登录跳转登录页
} else {
tip.show(data.message);
loading.hideLoadingMask();
if (res.code === 200) {
cartNum = res.data.goods_count;
if (cartNum > 99) {
cartNum = '99+';
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
$('.num-tag').html(cartNum).removeClass('hide');
confirming = false;
// 统计代码:用于统计用户加入或取消商品收藏的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
fa: favorite
}, true);
}
});
}
if (cbFn) {
cbFn();
}
}
if (res.message) {
tip.show(res.message);
}
if (addToCartHammer) {
addToCartHammer.on('tap', function(e) {
chosePanel.show();
hide();
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
confirming = false;
});
}
//统计代码:用于统计用户加入购物车的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
by: 1
}, true);
}
});
});
}
exports.init = init;
exports.show = show;
});
define("js/cart/chose-panel", ["jquery"], function(require, exports, module){
define("js/product/detail/desc", ["jquery","lazyload","swiper","index"], function(require, exports, module){
/**
* 购物车选择尺寸、颜色和数量面板
* 显示时构造当前商品信息的HTML插入yoho-page;消失则是直接清除HTML
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/21
* 商品详情 --异步加载页面下半部分
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/11/18
*/
// bikai
// 增加init函数,异步请求的接口需要重新初始化一下选择列表
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
var $ = require("jquery"),
tip = require("js/plugin/tip"),
loading = require("js/plugin/loading");
lazyLoad = require("lazyload"),
Swiper = require("swiper"),
loading = require("js/plugin/loading"),
tip = require("js/plugin/tip");
var $chosePanel = $('#chose-panel'),
$num,
$chosed,
$imgsThumb,
$leftNum,
leftNum,
confirming,
curColorIndex,
curSizeIndex,
hasChooseColor,
hasChooseSize,
$curSizeBlock,
$sizeRowList,
cbFn,
$allChoseItems,
queryString,
$yohoPage = $('.yoho-page');
var introUrl = $('#introUrl').val(),
winH = $(window).height(),
$productDesc,
searching = false,
end = false;
//初始化购物车面板显示
function init() {
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
queryString = $.queryString();
$imgsThumb = $('.chose-panel').find('.thumb');
$allChoseItems = $('.chose-items');
$sizeRowList = $('.size-list ul');
$leftNum = $('#left-num');
$sizeRowList.eq(0).toggleClass('hide');
}
var sizeSwiper,
refSwiper;
function checkColorSizeNum() {
if (!hasChooseColor && !hasChooseSize) {
tip.show('请选择颜色和尺码~');
return false;
} else if (!hasChooseColor) {
tip.show('请选择颜色~');
return false;
} else if (!hasChooseSize) {
tip.show('请选择尺码~');
return false;
}
return true;
}
function show(html, cb) {
if (html) {
$chosePanel.html(html);
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
cbFn = cb;
}
//判断是否要显示向左滑动提示
function hiddenTips($ele) {
var offsetContainer,
offsetLastColumn;
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
if ($ele.length > 0) {
offsetContainer = $ele[0].getBoundingClientRect().right;
offsetLastColumn = $ele.find('.swiper-slide:last-child')[0].getBoundingClientRect().right;
//修改加入购物车的文字和背景
function updateConformButtonClassAndText() {
$chosed = $allChoseItems.find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313').html('确定');
if (offsetLastColumn - offsetContainer < 0) {
$ele.next('.tips').css('display', 'none');
} else {
$ele.next('.tips').css('display', 'block');
}
}
}
//重置颜色块的库存为0的样式
function resetColorZeroStock($siblingBlock) {
var numArray,
i;
//function isFlexSupport() {
// var flex = document.createElement('p').style.flex,
// webkitFlex = document.createElement('p').style.webkitFlex,
// flexWrap = document.createElement('p').style.flexWrap;
//
// if ((flex === '' || webkitFlex === '') && flexWrap === '') {
// return true;
// } else {
// return false;
// }
//}
function wrapElements(selector, count) {
var elArr = null;
if (!hasChooseSize) {
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if (0 === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
$(selector).each(function(idx, el) {
elArr = $(selector).slice(idx, idx + count);
} else {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
if (elArr.length === count && idx % count === 0) {
$(elArr).wrapAll($('<div class="js-wraper"></div>'));
}
}
}
// 选择了颜色切换商品图片
function changeGoodImgWhenClickColor() {
if (hasChooseColor && curColorIndex) {
$imgsThumb.addClass('hide').eq(curColorIndex).removeClass('hide');
}
});
}
init();
$yohoPage.on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
if ($cur.closest('.main').length > 0) {
function search() {
if (searching || end) {
return;
}
searching = true;
//点击蒙版消失
hide();
});
$yohoPage.on('touchstart', '.color-list .block', function() {
var $this = $(this),
index,
curSizeBlock,
$preSiblingBlock,
$curSizeRow,
numArray,
i,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
// alert($('#reference-swiper-container .swiper-wrapper').width());
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
loading.showLoadingMask();
$preSiblingBlock = $siblingBlock.find('.chosed');
$curSizeRow = $sizeRowList.eq(index);
$.ajax({
type: 'GET',
url: introUrl,
success: function(data) {
$productDesc = $('#productDesc');
$productDesc.append(data);
// 当前颜色已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
window.rePosFooter();
//颜色原来已经是勾选时,要清空剩余件数的提示
$allChoseItems.find('.num .left-num').html('');
$leftNum.val(0);
hasChooseColor = false;
lazyLoad($productDesc.find('img.lazy'));
$this.removeClass('zero-stock');
if ($curSizeBlock) {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$('.color-list .block').eq(i).addClass('zero-stock');
}
}
}
//尺码信息左右滑动
sizeSwiper = new Swiper('#size-swiper-container',{
slidesPerView: 'auto'
});
// 当前颜色不是选中状态,选中时
} else {
hasChooseColor = true;
//模特试穿左右滑动
refSwiper = new Swiper('#reference-swiper-container',{
slidesPerView: 'auto'
});
//把当前选中颜色对应的尺码那一行显示出来
$sizeRowList.addClass('hide');
$curSizeRow.removeClass('hide').addClass('show');
hiddenTips($('#size-swiper-container'));
hiddenTips($('#reference-swiper-container'));
// 之前选中的尺码去掉勾选样式
if ($preSiblingBlock.length > 0) {
$preSiblingBlock.removeClass('chosed');
curSizeBlock = $curSizeRow.children().get(curSizeIndex);
//if (!isFlexSupport()) {
// $('.detail .column').removeClass('column').addClass('oldbox');
//}
wrapElements('.detail .column', 2);
searching = false;
end = true;
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
}
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
if (curSizeBlock) {
curGoodNum = $(curSizeBlock).data('num');
$(curSizeBlock).addClass('chosed');
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if (curGoodNum > 0) {
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
$leftNum.val(curGoodNum);
} else {
$allChoseItems.find('.num .left-num').html('');
$leftNum.val(0);
}
}
function scrollHandler() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
search();
}
}
// 当前颜色块 切换勾选样式
$this.toggleClass('chosed');
curColorIndex = index;
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
// 设置按钮的样式和文字
updateConformButtonClassAndText();
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor();
}).on('touchstart', '.size-list .block', function() {
var $this = $(this),
index,
$curSizeRow,
curGoodNum;
});
define("js/product/detail/comments-consults", ["jquery","hammer"], function(require, exports, module){
/**
* 商品详情 --评论和咨询tab
* @author: Lynnic
* @date: 2015/11/18
*/
var $ = require("jquery"),
tip = require("js/plugin/tip"),
Hammer = require("hammer");
var $siblingBlock = $this.closest('.block-list').siblings(':first');
var commentsNum,consultsNum;
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
$curSizeRow = $sizeRowList.eq(index);
var navtabEle = document.getElementById('nav-tab'),
navtabHammer = navtabEle && new Hammer(navtabEle),
// 当前尺码已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
gotoConsultEle = document.getElementById('goto-consult'),
gotoConsultHammer = gotoConsultEle && new Hammer(gotoConsultEle);
//尺码原来已经是勾选时,要清空剩余件数的提示
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseSize = false;
// 当前尺码不是选中状态,选中时
} else {
hasChooseSize = true;
(function() {
consultsNum = $('#nav-tab .consults-num').html() - 0;
curGoodNum = $this.data('num');
commentsNum = $('#nav-tab .comments-num').html() - 0;
// 之前选中的尺码去掉勾选样式
if ($curSizeBlock) {
$curSizeBlock.removeClass('chosed');
}
$('#nav-tab li').each(function() {
$(this).removeClass('focus');
});
// 如果当前有尺码被选中,且数量等于0, 否则显示剩余件数
if (curGoodNum > 0 && hasChooseColor) {
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
}
$('#feedback-content .content').each(function() {
$(this).addClass('hide');
});
if (0 !== commentsNum) {
$('#nav-tab .comment-nav').addClass('focus');
$('#feedback-content .comment-content').removeClass('hide');
} else if (0 !== consultsNum) {
$('#nav-tab .consult-nav').addClass('focus');
$('#feedback-content .consult-content').removeClass('hide');
}
$this.toggleClass('chosed');
curSizeIndex = index;
$curSizeBlock = $this;
// 设置按钮的样式和文字
updateConformButtonClassAndText();
// 重置颜色块的样式
resetColorZeroStock($siblingBlock);
});
$yohoPage.on('touchstart', '.btn-minus', function() {
var num = parseInt($num.val(), 10);
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
}
})();
if (num === 1 || 0 === leftNum - 0) {
return;
}
if (navtabHammer) {
navtabHammer.on('tap', function(e) {
var $this = $(e.target).closest('li');
var index = $this.index();
$num.val(num - 1);
}).on('touchstart', '.btn-plus', function() {
var num = parseInt($num.val(), 10);
if ($this.hasClass('comment-nav') && 0 === commentsNum) {
tip.show('暂无商品评价');
} else {
if (!$this.hasClass('focus')) {
leftNum = $('#left-num').val();
$('#nav-tab li').each(function() {
$(this).removeClass('focus');
});
$('#feedback-content .content').each(function() {
$(this).addClass('hide');
});
if (!checkColorSizeNum()) {
return;
}
$this.addClass('focus');
$('#feedback-content .content:eq(' + index + ')').removeClass('hide');
}
}
});
}
if (gotoConsultHammer) {
gotoConsultHammer.on('tap', function() {
location.href = $(gotoConsultEle).find('a').attr('href');
});
}
if (num - 0 === leftNum || 0 === leftNum) {
return;
}
//咨询页面固定header
if ($('.goods-consults-page').length > 0) {
$('#yoho-header').css('position', 'fixed').css('top', '0');
}
//TODO:库存数验证
$num.val(num + 1);
}).on('touchstart', '#chose-btn-sure', function() {
var productSku,
buyNumber = $('#good-num').val() - 0,
});
define("js/product/recommend-for-you-product-desc", ["swiper","jquery","index"], function(require, exports, module){
/**
* 为您优选
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/11/16
*/
promotionId,
isEdit = 0,
numInCart = $('.num-tag').html() - 0,
num = $num.val();
//颜色尺码没有选择
if (!checkColorSizeNum()) {
return;
}
var Swiper = require("swiper"),
$ = require("jquery");
//TODO status change
if ($('#chose-btn-sure').html() === '已售罄') {
return;
}
var recommendSwiper,
$recommendForYou = $('.recommend-for-you'),
preferenceUrl = $('#preferenceUrl').val(),
winH = $(window).height(),
end = false,
requesting = false;
leftNum = $('#left-num').val();
if (num > leftNum) {
tip.show('您选择的数量超过了最大库存量~');
function request() {
if (requesting || end) {
return;
}
$chosed = $('.block-list>ul>li.chosed');
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
productSku = $curSizeBlock.data('skuid');
promotionId = $('#promotionId').val();
if (confirming) {
return false;
}
confirming = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/cart/index/add',
data: {
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit,
cartType: queryString.cartType
}
}).done(function(res) {
loading.hideLoadingMask();
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
confirming = false;
requesting = true;
if (cbFn) {
cbFn();
if (preferenceUrl) {
$.get(preferenceUrl).then(function(html) {
if (html.length < 5) {
$recommendForYou.css('display', 'none');
} else {
$recommendForYou.html(html).show();
if ($('#swiper-recommend').length) {
recommendSwiper = new Swiper('#swiper-recommend', {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'a',
lazyLoading: true,
watchSlidesVisibility: true
});
}
}
if (res.message) {
tip.show(res.message);
}
hide();
requesting = false;
end = true;
window.rePosFooter();
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
confirming = false;
$recommendForYou.hide();
});
}
}
});
function scrollHandler() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
request();
}
}
exports.init = init;
exports.show = show;
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
});
define("js/product/detail/consultform", ["jquery"], function(require, exports, module){
... ... @@ -6430,14 +6515,11 @@ optHammer.on('tap', function(e) {
}
}).then(function(res) {
$('#dialog-wrapper').hide();
if (!res) {
tip.show('网络错误');
if ($.type(res) !== 'object') {
return;
}
if (res.code === 200) {
tip.show('删除成功');
} else {
tip.show(res.message || '网络错误');
if (res.message) {
tip.show(res.message);
}
window.location.href = '/home/orders';
}).fail(function() {
... ... @@ -6462,14 +6544,11 @@ optHammer.on('tap', function(e) {
}
}).then(function(res) {
$('#dialog-wrapper').hide();
if (!res) {
tip.show('网络错误');
if ($.type(res) !== 'object') {
return;
}
if (res.code === 200) {
tip.show('取消成功');
} else {
tip.show(res.message || '网络错误');
if (res.message) {
tip.show(res.message);
}
window.location.href = '/home/orders';
}).fail(function() {
... ... @@ -8565,7 +8644,7 @@ $(window).scroll(function() {
ajaxCurrencyDetail(page);
});
define("js/cart/entry", ["jquery","lazyload","hammer","mlellipsis","handlebars","source-map"], function(require, exports, module){
define("js/cart/entry", ["jquery","lazyload","hammer","handlebars","source-map","mlellipsis","swiper","index"], function(require, exports, module){
/**
* 购物车打包入口
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -8579,7 +8658,7 @@ require("js/cart/select-coupon");
require("js/cart/select-address");
});
define("js/cart/cart", ["jquery","lazyload","hammer","mlellipsis","handlebars","source-map"], function(require, exports, module){
define("js/cart/cart", ["jquery","lazyload","hammer","handlebars","source-map","mlellipsis","swiper","index"], function(require, exports, module){
/**
* 购物车Logic
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -8591,21 +8670,79 @@ var $ = require("jquery"),
Hammer = require("hammer");
var chosePanel = require("js/cart/chose-panel"),
dialog = require("js/me/dialog"),
tip = require("js/plugin/tip");
var $cartContent = $('.cart-content');
var $cartContent = $('.cart-content'),
cartType = $('#cartType').val(),
hasShowCartPresellTip = false;
var navHammer,
cartType = $('#cartType').val();
advanceBuyHammer,
freebieHammer;
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
function shouldSelectGift() {
var $freebie = $('.freebie');
if ($freebie.length <= 0) {
return false;
}
return true;
}
function shouldLowStocks() {
var $lowStocks = $('.low-stocks'),
result = false;
if ($lowStocks.length <= 0) {
return result;
}
$lowStocks.each(function(idx, item) {
if ($(item).parent().parent().parent().siblings('.checkbox').hasClass('icon-cb-checked')) {
result = true;
return false;
}
});
var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
return result;
}
function showChooseGifDialog() {
dialog.showDialog({
dialogText: '您还未选择赠品,是否去选择赠品',
hasFooter: {
leftBtnText: '我不要赠品',
rightBtnText: '去选择'
}
}, function() {
window.location.href = $('.freebie').find('a').attr('href');
}, function() {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
}
require("js/cart/good");
lazyLoad($('img.lazy'));
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
$('#presell-tip').removeClass('show').addClass('hide');
hasShowCartPresellTip = true;
} else {
$('#presell-tip').removeClass('hide').addClass('show');
}
if ('advance' === cartType) {
$cartContent.toggleClass('hide');
$('#common-cart-nav').removeClass('active');
$('#presell-cart-nav').addClass('active');
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
}
if ($('.cart-nav').length > 0) {
... ... @@ -8617,10 +8754,16 @@ if ($('.cart-nav').length > 0) {
return;
}
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
if (cartType === 'ordinary') {
cartType = 'advance';
$('#cartType').val('advance');
} else {
cartType = 'ordinary';
$('#cartType').val('ordinary');
}
$this.siblings('.active').removeClass('active');
... ... @@ -8629,24 +8772,45 @@ if ($('.cart-nav').length > 0) {
//切换普通商品和预售商品购物车显示
$cartContent.toggleClass('hide');
hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false;
//trigger lazyload
$(window).trigger('scroll');
});
setTimeout(function() {
$('#presell-tip').addClass('hide');
}, 3000);
if (!hasShowCartPresellTip) {
setTimeout(function() {
$('#presell-tip').removeClass('show').addClass('hide');
window.setCookie('_hasShowCartPresellTip', 'y');
}, 3000);
}
}
$('.advance-buy').on('touchend', function() {
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
});
if ($('.advance-buy').length > 0) {
advanceBuyHammer = new Hammer(document.getElementsByClassName('advance-buy')[0]);
advanceBuyHammer.on('tap', function(e) {
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
});
}
$('.freebie').on('touchend', function() {
window.location.href = '/cart/index/gift?cartType=' + cartType;
});
if ($('.freebie').length > 0) {
freebieHammer = new Hammer(document.getElementsByClassName('freebie')[0]);
freebieHammer.on('tap', function(e) {
window.location.href = '/cart/index/gift?cartType=' + cartType;
});
}
$('.btn-balance').on('touchend', function() {
if (shouldLowStocks()) {
tip.show('库存不足无法结算');
return false;
}
if (shouldSelectGift()) {
showChooseGifDialog();
return false;
}
if (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
... ... @@ -8655,13 +8819,27 @@ $('.btn-balance').on('touchend', function() {
});
$('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
if ($('.shopping-cart-good').length <= 0) {
require("js/product/recommend-for-you");
}
function notAllowScroll() {
var docH = $(document).height(),
winH = $(window).height();
if (docH - winH <= 10) {
$('body').css('overflow', 'hidden');
}
}
notAllowScroll();
//提前触发lazyload
$(window).scrollTop(1).scrollTop(0);
});
define("js/cart/good", ["jquery","mlellipsis","lazyload","handlebars","source-map","hammer"], function(require, exports, module){
/**
... ... @@ -8680,7 +8858,6 @@ var dialog = require("js/me/dialog"),
orderInfo = require("js/cart/order-info").orderInfo;
var $selectAllBtn = $('.balance .checkbox'),
cartType = $('#cartType').val(),
requesting = false;
ellipsis.init();
... ... @@ -8689,9 +8866,18 @@ lazyLoad({
try_again_css: 'good-failure'
});
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
setTimeout(function() {
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
}, 0);
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
... ... @@ -8700,30 +8886,19 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
id = $good.data('id');
var goodsList = [],
goodInfo = {},
isSelected = true;
if ($this.hasClass('icon-cb-checked')) {
isSelected = true;
} else {
isSelected = false;
}
goodInfo = {};
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
if (!$this.hasClass('icon-cb-checked') && $this.siblings('.info').find('.low-stocks').length > 0) {
tip.show('库存不足,无法购买');
return false;
}
goodInfo.goods_type = cartType;
goodInfo.selected = isSelected ? 'N' : 'Y';
goodInfo.goods_type = $('#cartType').val();
goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y';
goodInfo.product_sku = id;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
goodsList.push(new GoodInfo(goodInfo));
$.ajax({
type: 'post',
url: 'select',
... ... @@ -8737,7 +8912,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
window.history.go(0);
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
} else if (data.code === 400) {
tip.show('网络异常');
}
... ... @@ -8756,8 +8931,8 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
rightBtnText: '确定'
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id');
var count = $this.data('count');
var id = $this.closest('.shopping-cart-good').data('id'),
count = $this.data('count');
$.ajax({
method: 'post',
... ... @@ -8775,7 +8950,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
orderInfo('couponCode', null);
orderInfo('couponName', null);
history.go(0);
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
} else {
tip.show(data.message);
}
... ... @@ -8783,7 +8958,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
tip.show('网络异常');
});
});
});
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
... ... @@ -8804,7 +8978,7 @@ function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
tip.show(res.message);
}
},
error: function(err) {
error: function() {
tip.show('网络异常');
},
complete: function() {
... ... @@ -8840,17 +9014,10 @@ function didUpdateAllGoodsCheckStatus() {
}
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
var goodInfo = {};
var $goods = $('.cart-content:not(.hide) .shopping-cart-good');
var $good = null;
var goodsList = [];
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
var goodInfo = {},
$goods = $('.cart-content:not(.hide) .shopping-cart-good'),
$good = null,
goodsList = [];
goodInfo.goods_type = type;
goodInfo.selected = isSelected ? 'N' : 'Y';
... ... @@ -8867,26 +9034,15 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
}
//是否要全选
function willBeSelected($this) {
var isSelected = true;
if ($this.hasClass('icon-cb-checked')) {
isSelected = true;
} else {
isSelected = false;
}
return isSelected;
}
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
var $this = $(this);
var isSelect = $(this).hasClass('icon-cb-checked');
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
if (!isSelect && $('.low-stocks').length > 0) {
tip.show('所选商品中含有库存不足的商品');
return false;
}
bottomCheckBoxHandeler(isSelect, $('#cartType').val(), didUpdateAllGoodsCheckStatus);
});
$('.down').on('touchend', function() {
... ... @@ -8940,7 +9096,7 @@ exports.orderInfo = function(key, value) {
};
});
define("js/cart/gift-advance", ["jquery","lazyload"], function(require, exports, module){
define("js/cart/gift-advance", ["jquery","lazyload","hammer"], function(require, exports, module){
/**
* 赠品/加价购
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -8949,6 +9105,7 @@ define("js/cart/gift-advance", ["jquery","lazyload"], function(require, exports,
var $ = require("jquery"),
lazyLoad = require("lazyload"),
Hammer = require("hammer"),
tip = require("js/plugin/tip"),
loading = require("js/plugin/loading"),
chosePanel = require("js/cart/chose-panel");
... ... @@ -8978,14 +9135,26 @@ function getProductInfo(skn, promotionId) {
});
}
$page.on('touchend', '.chose', function() {
var $this = $(this),
id = $this.closest('.gift-advance-good').data('id'),
promotionId = $this.closest('.advance-block').data('promotion-id');
$page.find('.chose').each(function(i, elem) {
var choseHammer = new Hammer(elem);
choseHammer.on('tap', function(e) {
var $this = $(e.target),
id = $this.closest('.gift-advance-good').data('id'),
promotionId = $this.closest('.advance-block').data('promotion-id');
getProductInfo(id, promotionId);
getProductInfo(id, promotionId);
});
});
// $page.on('touchend', '.chose', function() {
// var $this = $(this),
// id = $this.closest('.gift-advance-good').data('id'),
// promotionId = $this.closest('.advance-block').data('promotion-id');
//
// getProductInfo(id, promotionId);
// });
});
define("js/cart/order-ensure", ["jquery","lazyload","hammer","handlebars","source-map"], function(require, exports, module){
/**
... ... @@ -9008,10 +9177,13 @@ var dispatchModeHammer,
$price = $('.price-cal'),
$couponUse = $('.coupon-use.used'),
$addressWrap = $('.address-wrap'),
$coinCheck = $('.coin-check'),
$coinUsed = $('.coin .used'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString(),
orderInfo = order.orderInfo;
orderInfo = order.orderInfo,
isSubmiting;
lazyLoad();
... ... @@ -9081,19 +9253,18 @@ function orderCompute() {
}).then(function(res) {
var priceHtml;
if (!res) {
tip.show('网络出错');
if ($.type(res) !== 'object') {
window.location.reload();
} else {
/*if (res.order_amount) {
res.order_amount = (+res.order_amount).toFixed(2);
}
if (res.discount_amount) {
res.discount_amount = (+res.discount_amount).toFixed(2);
}*/
if (res.last_order_amount) {
res.last_order_amount = (+res.last_order_amount).toFixed(2);
}
if (res.use_yoho_coin) {
$coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin);
$coinUsed.html('已抵¥' + res.use_yoho_coin);
$coinCheck.find('em').show();
$coinUsed.show();
}
priceHtml = priceTmpl({
cartPayData: res.promotion_formula_list,
price: res.last_order_amount
... ... @@ -9102,7 +9273,6 @@ function orderCompute() {
$price.html(priceHtml);
}
}).fail(function() {
tip.show('网络出错');
window.location.reload();
});
}
... ... @@ -9111,6 +9281,13 @@ function submitOrder() {
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
msg = $('#msg').find('input').val() || orderInfo('msg');
if (orderInfo('deliveryId') === 2 && !$addressWrap.data('support')) {
tip.show('当前地址不支持顺丰快递');
return;
}
if (isSubmiting) {
return false;
}
if (orderInfo('invoice')) {
if (!invoiceText) {
tip.show('请输入发票抬头');
... ... @@ -9128,6 +9305,7 @@ function submitOrder() {
}
}
loading.showLoadingMask();
isSubmiting = true;
$.ajax({
method: 'POST',
url: '/cart/index/orderSub',
... ... @@ -9149,7 +9327,6 @@ function submitOrder() {
var url;
if (!res) {
loading.hideLoadingMask();
tip.show('网络出错');
return;
}
... ... @@ -9163,13 +9340,14 @@ function submitOrder() {
}
window.setCookie('order-info', '');
window.location.href = url;
} else {
loading.hideLoadingMask();
tip.show(res.message || '网络出错');
} else if (res.message) {
tip.show(res.message);
}
}).fail(function() {
loading.hideLoadingMask();
tip.show('网络出错');
}).always(function() {
isSubmiting = false;
loading.hideLoadingMask();
});
}
... ... @@ -9178,7 +9356,7 @@ if (!orderInfo('addressId')) {
orderInfo('addressId', $addressWrap.data('id'));
}
$('.dispatch-mode').on('touchstart', 'li', function() {
$('.dispatch-mode').on('touchend', 'li', function() {
var $defaultMode = $('.dispatch-mode [data-id="1"]');
if (!$addressWrap.data('support') && $(this).data('id') === 2) {
... ... @@ -9201,10 +9379,12 @@ $('.coin').on('touchend', function() {
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
orderInfo('yohoCoin', $this.data('yoho-coin'));
$this.find('.coin-check em').show();
$this.find('.can-use').hide();
} else {
orderInfo('yohoCoin', 0);
$this.find('.coin-check em').hide();
$this.find('.can-use').show();
$this.find('.used').hide();
}
orderCompute();
});
... ... @@ -9234,6 +9414,10 @@ $('.pay-mode').on('click', 'li', function() {
submitOrder();
});
$('form').on('submit', function() {
return false;
});
});
define("js/cart/select-coupon", ["jquery","handlebars","source-map","mlellipsis"], function(require, exports, module){
/**
... ... @@ -9254,10 +9438,27 @@ var page = 1,
isGetData;
var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
$newCoupon = $('#new-coupon');
var winH = $(window).height();
// conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
function fixedLayOut() {
var $null = $('.null'),
navH = $('.nav-title').height(),
nullH = $null.height();
if ($null.length === 0) {
return false;
}
$null.css({
top: winH / 2 - nullH / 2 + navH
});
}
ellipsis.init();
$newCoupon.on('submit', function() {
... ... @@ -9291,6 +9492,16 @@ $('#coupon-list').on('touchend', '.employ-main', function() {
orderInfo('couponCode', $this.data('coupon-code'));
orderInfo('couponName', $this.data('coupon-name'));
}).on('touchstart', '.employ-main', function() {
var $this = $(this);
$this.siblings().removeClass('focus');
$this.addClass('focus');
}).on('touchend touchcancel', '.employ-main', function() {
var $this = $(this);
$this.siblings().removeClass('focus');
$this.removeClass('focus');
});
$('body').on('touchend', '.not-use', function() {
... ... @@ -9344,6 +9555,7 @@ function getCouponHandle(coupons) {
// 第一页张数为 0 ,显示优惠券为空
if (!coupons.length && page === 2) {
$('.coupin-wrap').html($('#tmpl-no-coupon').html());
fixedLayOut();
return;
}
... ... @@ -9358,14 +9570,15 @@ function getCouponHandle(coupons) {
coupons: coupons
}));
// 产品说,暂时不做不可使用的优惠券
// if (notAvailableCoupons.length) {
// $('.not-avaliable-coupon-line').show();
// }
// $('#coupon-list-not').append(conponNotAvaliableTmpl({
// notAvailableCoupons: notAvailableCoupons
// }));
if (notAvailableCoupons.length) {
$('.not-avaliable-coupon-line').show();
}
$('#coupon-list-not').append(conponNotAvaliableTmpl({
notAvailableCoupons: notAvailableCoupons
}));
window.rePosFooter();
}
function getCouponDate() {
... ... @@ -9397,13 +9610,14 @@ function getCouponDate() {
});
}
getCouponDate();
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
getCouponDate();
}
});
// $(window).scroll(function() {
// if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
// getCouponDate();
// }
// });
});
define("js/cart/select-address", ["jquery"], function(require, exports, module){
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Thu Dec 17 13:53:30 2015
Created by FontForge 20120731 at Mon Dec 21 17:16:11 2015
By Ads
</metadata>
<defs>
... ... @@ -16,10 +16,10 @@ Created by FontForge 20120731 at Thu Dec 17 13:53:30 2015
ascent="896"
descent="-128"
x-height="792"
bbox="-0.75 -224 3943 833"
bbox="-0.75 -224 3943 893"
underline-thickness="50"
underline-position="-100"
unicode-range="U+0078-E640"
unicode-range="U+0078-E641"
/>
<missing-glyph horiz-adv-x="374"
d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" />
... ... @@ -263,5 +263,10 @@ q0 -2 2 -5l15 -32q9 -30 39 -38v-3h392l18 1v2q14 4 24.5 14t14.5 24l98 217q40 77 1
q0 7 3 12.5t9 9t12 3.5h119l3 -1h2q1 0 2 -1l4 -2q2 -1 4 -3q1 -1 2 -1.5t1 -1.5l4 -6l38 -83h619q8 0 10 -3q3 -6 1 -19t-7.5 -29.5t-13.5 -31.5zM470 107q-33 0 -56.5 -23t-23.5 -56q0 -22 10.5 -40.5t29 -29t40.5 -10.5q33 0 56.5 23.5t23.5 56.5t-23.5 56t-56.5 23z
M470 -23q-21 0 -36 15t-15 36t15 36t36 15q14 0 25.5 -7t18.5 -19t7 -25q0 -22 -15 -36.5t-36 -14.5zM747 107q-33 0 -56.5 -23t-23.5 -56q0 -22 10.5 -40.5t29 -29t40.5 -10.5q33 0 56.5 23.5t23.5 56.5t-23.5 56t-56.5 23zM747 -23q-14 0 -26 6.5t-18.5 18.5t-6.5 25.5
t6.5 25.5t18.5 19t26 7q21 0 36 -15t15 -36t-15 -36t-36 -15z" />
<glyph glyph-name="uniE641" unicode="&#xe641;" horiz-adv-x="1045"
d="M522 893q-103 0 -197 -40t-162 -108t-108.5 -162t-40.5 -197.5t40.5 -197.5t108.5 -162t162 -108t197.5 -40t197.5 40t162 108t108 162t40 197.5t-40 197.5t-108 162t-162 108t-198 40zM522 -49q-88 0 -168.5 34.5t-138.5 93t-92.5 138.5t-34.5 168.5t34.5 169
t92.5 138.5t138.5 92.5t169 34.5t168.5 -34.5t138.5 -92.5t93 -138.5t34.5 -169t-34.5 -168.5t-93 -138.5t-138.5 -93t-169 -34.5zM775 268l-105 61q-11 4 -21 6.5t-18 2.5t-15 -0.5t-13 -4t-10 -5.5t-9 -6l-6 -7q-2 -2 -6 -7l-3 -4l-6 -10q-34 -4 -59 21l-51 50
q-24 25 -20 60l9 4q3 5 16 16t17 18t4 25t-11 43h-1l-60 105q-8 13 -20.5 20t-26 7t-27.5 -7l-62 -36q-3 -1 -6 -4l-6 -6l-6 -6q-3 -3 -5.5 -6t-4.5 -5t-3 -4l-1 -1q-14 -87 24.5 -183.5t121.5 -174.5q72 -68 157 -101.5t165 -29.5q4 1 10.5 2.5t20.5 10t21 20.5l36 62
q11 20 5.5 41.5t-25.5 32.5z" />
</font>
</defs></svg>
... ...