...
|
...
|
@@ -10,6 +10,7 @@ require("js/index/entry"); |
|
|
require("js/passport/entry");
|
|
|
require("js/product/entry");
|
|
|
require("js/me/entry");
|
|
|
require("js/cart/entry");
|
|
|
|
|
|
module.exports = yohobuy;
|
|
|
|
...
|
...
|
@@ -2327,7 +2328,7 @@ $channelLink.on('touchstart', function() { |
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/passport/entry", ["jquery"], function(require, exports, module){
|
|
|
define("js/passport/entry", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册、登录、密码找回打包入口
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
...
|
...
|
@@ -2349,6 +2350,12 @@ require("js/passport/back/code"); |
|
|
require("js/passport/back/email");
|
|
|
require("js/passport/back/email-success");
|
|
|
require("js/passport/back/new-password");
|
|
|
|
|
|
//绑定手机
|
|
|
require("js/passport/bind/bind");
|
|
|
require("js/passport/bind/code");
|
|
|
require("js/passport/bind/password");
|
|
|
|
|
|
});
|
|
|
define("js/passport/register/register", ["jquery"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -2907,6 +2914,7 @@ $loginBtn.on('touchstart', function() { |
|
|
});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -3055,6 +3063,7 @@ $loginBtn.on('touchstart', function() { |
|
|
});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -3308,6 +3317,310 @@ $btnOk.on('touchstart', function() { |
|
|
}
|
|
|
});
|
|
|
});
|
|
|
define("js/passport/bind/bind", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
var $phoneNum = $('#phone-num'),
|
|
|
$countrySelect = $('#country-select'),
|
|
|
$areaCode = $('#area-code'),
|
|
|
$openId = $('#openId'),
|
|
|
$nickname = $('#nickname'),
|
|
|
$sourceType = $('#sourceType'),
|
|
|
$btnNext = $('#btn-next');
|
|
|
|
|
|
var api = require("js/passport/api"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
dialog = require("js/me/dialog");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
var requesting = false;
|
|
|
|
|
|
function nextStep(url, mobileNo, areaCode) {
|
|
|
if (requesting) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
requesting = true;
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/bind/sendBindMsg',
|
|
|
data: {
|
|
|
phoneNum: mobileNo,
|
|
|
areaCode: areaCode.replace('+', '')
|
|
|
},
|
|
|
success: function(res) {
|
|
|
console.log(res.data);
|
|
|
location.href = url;
|
|
|
|
|
|
requesting = false;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('出错了,请重试!');
|
|
|
|
|
|
requesting = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
api.selectCssHack($('#country-select'));
|
|
|
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$phoneNum.bind('input', function() {
|
|
|
if (trim($phoneNum.val()) === '') {
|
|
|
$btnNext.addClass('disable');
|
|
|
} else {
|
|
|
$btnNext.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$countrySelect.change(function() {
|
|
|
$areaCode.text($countrySelect.val());
|
|
|
});
|
|
|
|
|
|
$btnNext.on('touchstart', function() {
|
|
|
var pn = trim($phoneNum.val()),
|
|
|
openId = trim($openId.val()),
|
|
|
nickname = trim($nickname.val()),
|
|
|
sourceType = trim($sourceType.val()),
|
|
|
areaCode = $countrySelect.val();
|
|
|
|
|
|
if ($btnNext.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.phoneRegx[areaCode].test(pn)) {
|
|
|
$.ajax({
|
|
|
url: '/passport/bind/bindCheck',
|
|
|
type: 'POST',
|
|
|
data: {
|
|
|
areaCode: areaCode.replace('+', ''),
|
|
|
phoneNum: pn,
|
|
|
openId: openId,
|
|
|
sourceType: sourceType,
|
|
|
nickname: nickname
|
|
|
},
|
|
|
success: function(res) {
|
|
|
console.log(res);
|
|
|
|
|
|
//res : {
|
|
|
// code: 'xxx',
|
|
|
// data: {
|
|
|
// isReg: 0,
|
|
|
// next: 'xxxx'
|
|
|
// },
|
|
|
// message: 'xxxx',
|
|
|
//}
|
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
if (res.data.isReg === 1) {
|
|
|
dialog.showDialog({
|
|
|
dialogText: '该手机号已注册过有货\n' + pn + ',确定绑定吗?',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '更换号码',
|
|
|
rightBtnText: '继续绑定'
|
|
|
}
|
|
|
}, function() {
|
|
|
nextStep(res.data.next, pn, areaCode);
|
|
|
});
|
|
|
} else {
|
|
|
nextStep(res.data.next, pn, areaCode);
|
|
|
}
|
|
|
} else {
|
|
|
showErrTip(res.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
showErrTip('手机号格式不正确,请重新输入');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
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;
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
exports.showDialog = function(data, callback) {
|
|
|
|
|
|
var 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);
|
|
|
}
|
|
|
|
|
|
dialogWrapperHammer.on('tap', function(event) {
|
|
|
|
|
|
if ($(event.target).hasClass('dialog-left-btn')) {
|
|
|
$dialogWrapper.fadeOut();
|
|
|
} else if ($(event.target).hasClass('dialog-right-btn')) {
|
|
|
callback();
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
});
|
|
|
define("js/passport/bind/code", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册-验证码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
|
|
|
require("js/passport/code")(true, true);
|
|
|
|
|
|
});
|
|
|
define("js/passport/bind/password", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 注册-密码
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/8
|
|
|
*/
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
var $pwd = $('#pwd'),
|
|
|
$btnSure = $('#btn-sure');
|
|
|
|
|
|
var api = require("js/passport/api");
|
|
|
var tip = require("js/plugin/tip");
|
|
|
|
|
|
var trim = $.trim;
|
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
var nickname = $('#nickname').val(),
|
|
|
sourceType = $('#sourceType').val(),
|
|
|
openId = $('#openId').val(),
|
|
|
phoneNum = $('#phone-num').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('登录失败,请重试!');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
api.bindEyesEvt({
|
|
|
status: 'open' //默认眼睛打开
|
|
|
});
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
if (trim($pwd.val()) === '') {
|
|
|
$btnSure.addClass('disable');
|
|
|
} else {
|
|
|
$btnSure.removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$btnSure.on('touchstart', function() {
|
|
|
var pwd = trim($pwd.val());
|
|
|
|
|
|
if ($btnSure.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (api.pwdValidate(pwd) === false) {
|
|
|
showErrTip('密码6-20位,请重新输入');
|
|
|
} else {
|
|
|
startBind(pwd);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/product/entry", ["jquery","swiper","lazyload","hammer","index"], function(require, exports, module){
|
|
|
/**
|
|
|
* 产品打包入口
|
...
|
...
|
@@ -3932,11 +4245,18 @@ $.ajax({ |
|
|
type: 'GET',
|
|
|
url: '/cart/index/count',
|
|
|
success: function(data) {
|
|
|
var count;
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
$cart.find('.cart-count').html(data.data.cart_goods_count).removeClass('hide');
|
|
|
count = data.data.cart_goods_count;
|
|
|
if (count > 99) {
|
|
|
count = '99+';
|
|
|
}
|
|
|
$cart.find('.cart-count').html(count).removeClass('hide');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/product/newsale/discount", ["jquery","swiper","lazyload","hammer","index"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -4878,8 +5198,17 @@ $.ajax({ |
|
|
type: 'GET',
|
|
|
url: '/cart/index/count',
|
|
|
success: function(data) {
|
|
|
var count;
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
$cart.find('.num-tag').html(data.data.cart_goods_count).removeClass('hide');
|
|
|
count = data.data.cart_goods_count || 0;
|
|
|
if (count === 0) {
|
|
|
return false;
|
|
|
}
|
|
|
if (count > 99) {
|
|
|
count = '99+';
|
|
|
}
|
|
|
$cart.find('.num-tag').html(count).removeClass('hide');
|
|
|
}
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -5088,7 +5417,7 @@ if (navtabHammer) { |
|
|
|
|
|
if (gotoConsultHammer) {
|
|
|
gotoConsultHammer.on('tap', function() {
|
|
|
location.href = $(gotoConsultEle).data('href');
|
|
|
location.href = $(gotoConsultEle).find('a').attr('href');
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -5260,72 +5589,119 @@ define("js/cart/chose-panel", ["jquery"], function(require, exports, module){ |
|
|
* @date: 2015/10/21
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
loading = require("js/plugin/loading");
|
|
|
|
|
|
// Handlebars = require('yoho.handlebars');
|
|
|
// bikai
|
|
|
// 增加init函数,异步请求的接口需要重新初始化一下选择列表
|
|
|
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
|
|
|
|
|
|
// var $page = $('.yoho-page');
|
|
|
var $ = require("jquery"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
loading = require("js/plugin/loading");
|
|
|
|
|
|
var $num,
|
|
|
var $chosePanel = $('#chose-panel'),
|
|
|
$num,
|
|
|
$chosed,
|
|
|
re = /\d+/,
|
|
|
$imgsThumb,
|
|
|
$leftNum,
|
|
|
leftNum,
|
|
|
$colorList = $('.color-list ul>li'),
|
|
|
$sizeList = $('.size-list ul>li'),
|
|
|
firstColorId = $colorList.eq(0).data('id'),
|
|
|
colorIndex,
|
|
|
confirming;
|
|
|
confirming,
|
|
|
curColorIndex,
|
|
|
curSizeIndex,
|
|
|
hasChooseColor,
|
|
|
hasChooseSize,
|
|
|
$curSizeBlock,
|
|
|
$sizeRowList,
|
|
|
cbFn,
|
|
|
$allChoseItems,
|
|
|
queryString,
|
|
|
$yohoPage = $('.yoho-page');
|
|
|
|
|
|
//初始化购物车面板显示
|
|
|
$sizeList.each(function() {
|
|
|
colorIndex = $(this).data('colorid');
|
|
|
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');
|
|
|
}
|
|
|
|
|
|
if (colorIndex === firstColorId) {
|
|
|
$(this).removeClass('hide');
|
|
|
function checkColorSizeNum() {
|
|
|
if (!hasChooseColor && !hasChooseSize) {
|
|
|
tip.show('请选择颜色和尺码~');
|
|
|
return false;
|
|
|
} else if (!hasChooseColor) {
|
|
|
tip.show('请选择颜色~');
|
|
|
return false;
|
|
|
} else if (!hasChooseSize) {
|
|
|
tip.show('请选择尺码~');
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// var tpl;
|
|
|
|
|
|
//读取partials
|
|
|
// $.ajax({
|
|
|
// type: 'GET',
|
|
|
// url: '/shoppingCart/tpl',
|
|
|
// success: function(data) {
|
|
|
// tpl = Handlebars.compile(data);
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
|
|
|
//显示
|
|
|
// function show(data) {
|
|
|
// // var html = tpl(data);
|
|
|
// $('.chose-panel').show();
|
|
|
// // $page.append(html);
|
|
|
// $('.chose-panel')
|
|
|
// $num = $('#good-num');
|
|
|
// }
|
|
|
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
function show() {
|
|
|
function show(html, cb) {
|
|
|
if (html) {
|
|
|
$chosePanel.html(html);
|
|
|
init();
|
|
|
}
|
|
|
$('.chose-panel').show();
|
|
|
|
|
|
$('body').css('overflow', 'hidden');
|
|
|
$num = $('#good-num');
|
|
|
cbFn = cb;
|
|
|
}
|
|
|
|
|
|
//移除当前Panel
|
|
|
function remove() {
|
|
|
//隐藏当前Panel
|
|
|
function hide() {
|
|
|
$('.chose-panel').hide();
|
|
|
$('body').css('overflow', 'auto');
|
|
|
}
|
|
|
|
|
|
$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
|
|
|
//修改加入购物车的文字和背景
|
|
|
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('确定');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//重置颜色块的库存为0的样式
|
|
|
function resetColorZeroStock($siblingBlock) {
|
|
|
var numArray,
|
|
|
i;
|
|
|
|
|
|
if (!hasChooseSize) {
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
} 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');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 选择了颜色切换商品图片
|
|
|
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) {
|
...
|
...
|
@@ -5333,145 +5709,143 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
}
|
|
|
|
|
|
//点击蒙版消失
|
|
|
remove();
|
|
|
}).on('touchstart', '#chose-btn-sure', function() {
|
|
|
hide();
|
|
|
});
|
|
|
|
|
|
var productSku,
|
|
|
buyNumber = $('#good-num').val() - 0,
|
|
|
$yohoPage.on('touchstart', '.color-list .block', function() {
|
|
|
var $this = $(this),
|
|
|
index,
|
|
|
curSizeBlock,
|
|
|
$preSiblingBlock,
|
|
|
$curSizeRow,
|
|
|
numArray,
|
|
|
i,
|
|
|
curGoodNum;
|
|
|
|
|
|
promotionId,
|
|
|
isEdit = 0,
|
|
|
numInCart = $('.num-tag').html() - 0;
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
|
|
|
|
// goodsType,
|
|
|
// isEdit;
|
|
|
$this.siblings('.chosed').removeClass('chosed');
|
|
|
index = $this.index();
|
|
|
|
|
|
$chosed = $('.block-list>ul>li.chosed');
|
|
|
$preSiblingBlock = $siblingBlock.find('.chosed');
|
|
|
$curSizeRow = $sizeRowList.eq(index);
|
|
|
|
|
|
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
|
|
|
productSku = $sizeList.closest('.chosed').data('skuid');
|
|
|
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
|
|
|
if (confirming) {
|
|
|
return false;
|
|
|
}
|
|
|
// 当前颜色已经是选中状态,再点击时
|
|
|
if ($this.hasClass('chosed')) {
|
|
|
|
|
|
confirming = true;
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/add',
|
|
|
data: {
|
|
|
productSku: productSku,
|
|
|
buyNumber: buyNumber,
|
|
|
promotionId: promotionId,
|
|
|
isEdit: isEdit
|
|
|
}
|
|
|
}).done(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
loading.hideLoadingMask();
|
|
|
$('.num-tag').html(numInCart + buyNumber);
|
|
|
$('.num-tag').removeClass('hide');
|
|
|
confirming = false;
|
|
|
remove();
|
|
|
//颜色原来已经是勾选时,要清空剩余件数的提示
|
|
|
$allChoseItems.find('.num .left-num').html('');
|
|
|
$leftNum.val(0);
|
|
|
hasChooseColor = false;
|
|
|
|
|
|
$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');
|
|
|
}
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出了点问题~');
|
|
|
}
|
|
|
|
|
|
confirming = false;
|
|
|
});
|
|
|
// 当前颜色不是选中状态,选中时
|
|
|
} else {
|
|
|
hasChooseColor = true;
|
|
|
|
|
|
//把当前选中颜色对应的尺码那一行显示出来
|
|
|
$sizeRowList.addClass('hide');
|
|
|
$curSizeRow.removeClass('hide').addClass('show');
|
|
|
|
|
|
// 之前选中的尺码去掉勾选样式
|
|
|
if ($preSiblingBlock.length > 0) {
|
|
|
$preSiblingBlock.removeClass('chosed');
|
|
|
curSizeBlock = $curSizeRow.children().get(curSizeIndex);
|
|
|
}
|
|
|
|
|
|
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}).on('touchstart', '.block', function(e) {
|
|
|
// 当前颜色块 切换勾选样式
|
|
|
$this.toggleClass('chosed');
|
|
|
curColorIndex = index;
|
|
|
|
|
|
// 设置按钮的样式和文字
|
|
|
updateConformButtonClassAndText();
|
|
|
|
|
|
// 修改颜色时修改商品图片
|
|
|
changeGoodImgWhenClickColor();
|
|
|
}).on('touchstart', '.size-list .block', function() {
|
|
|
var $this = $(this),
|
|
|
$that = $(e.target).closest('.chose-items'),
|
|
|
numArray,
|
|
|
index,
|
|
|
i;
|
|
|
$curSizeRow,
|
|
|
curGoodNum;
|
|
|
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first'),
|
|
|
currentNumArray = ($this.data('numstr') + '').split('/');
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
|
|
|
|
$this.siblings('.chosed').removeClass('chosed');
|
|
|
$this.toggleClass('chosed');
|
|
|
index = $this.index();
|
|
|
$chosed = $('.block-list>ul>li.chosed');
|
|
|
|
|
|
//根据颜色切换图片
|
|
|
if ($this.closest('.block-list').hasClass('color-list')) {
|
|
|
$('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');
|
|
|
}
|
|
|
$curSizeRow = $sizeRowList.eq(index);
|
|
|
|
|
|
if ($chosed.length === 0) {
|
|
|
$this.closest('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
// 当前尺码已经是选中状态,再点击时
|
|
|
if ($this.hasClass('chosed')) {
|
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
|
|
|
if ($this.closest('.block-list').hasClass('color-list')) {
|
|
|
//尺码原来已经是勾选时,要清空剩余件数的提示
|
|
|
$allChoseItems.find('.num .left-num').html('');
|
|
|
$('#left-num').val(0);
|
|
|
hasChooseSize = false;
|
|
|
|
|
|
$sizeList.addClass('hide');
|
|
|
// 当前尺码不是选中状态,选中时
|
|
|
} else {
|
|
|
hasChooseSize = true;
|
|
|
|
|
|
//切换尺码信息
|
|
|
$sizeList.each(function() {
|
|
|
colorIndex = $(this).data('colorid');
|
|
|
if (colorIndex === $this.data('id')) {
|
|
|
$(this).removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
curGoodNum = $this.data('num');
|
|
|
|
|
|
numArray = ($chosed.data('numstr') + '').split('/');
|
|
|
$siblingBlock.find('.block').removeClass('zero-stock');
|
|
|
for (i = 0; i < numArray.length; i++) {
|
|
|
if (0 === numArray[i] - 0) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
// 之前选中的尺码去掉勾选样式
|
|
|
if ($curSizeBlock) {
|
|
|
$curSizeBlock.removeClass('chosed');
|
|
|
}
|
|
|
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
$that.find('.num .left-num').html('');
|
|
|
} else if ($chosed.length === 2) {
|
|
|
$siblingBlock.find('.block').removeClass('zero-stock');
|
|
|
for (i = 0; i < currentNumArray.length; i++) {
|
|
|
if (0 === currentNumArray[i] - 0) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
|
|
numArray = $siblingBlock.find('.chosed').data('numstr').split('/');
|
|
|
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
|
|
|
if (2 === $chosed.closest('.zero-stock').length) {
|
|
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
|
|
$('#chose-btn-sure').html('已售罄');
|
|
|
// 如果当前有尺码被选中,且数量等于0, 否则显示剩余件数
|
|
|
if (curGoodNum > 0 && hasChooseColor) {
|
|
|
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
|
|
|
$('#left-num').val(curGoodNum);
|
|
|
} else {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
$allChoseItems.find('.num .left-num').html('');
|
|
|
$('#left-num').val(0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}).on('touchstart', '.btn-minus', function() {
|
|
|
var num = +$num.val(),
|
|
|
$chosed = $('.block-list>ul>li.chosed'),
|
|
|
leftNum = re.exec($('.num .left-num').html());
|
|
|
$this.toggleClass('chosed');
|
|
|
curSizeIndex = index;
|
|
|
$curSizeBlock = $this;
|
|
|
|
|
|
// 设置按钮的样式和文字
|
|
|
updateConformButtonClassAndText();
|
|
|
|
|
|
// 重置颜色块的样式
|
|
|
resetColorZeroStock($siblingBlock);
|
|
|
});
|
|
|
|
|
|
$yohoPage.on('touchstart', '.btn-minus', function() {
|
|
|
var num = parseInt($num.val(), 10);
|
|
|
|
|
|
//若颜色和尺码没有被同时选中,则不能点击
|
|
|
if ($chosed.length < 2) {
|
|
|
leftNum = $('#left-num').val();
|
|
|
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -5481,23 +5855,96 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
|
|
|
$num.val(num - 1);
|
|
|
}).on('touchstart', '.btn-plus', function() {
|
|
|
var num = +$num.val();
|
|
|
var num = parseInt($num.val(), 10);
|
|
|
|
|
|
leftNum = $('#left-num').val();
|
|
|
|
|
|
//若颜色和尺码没有被同时选中,则不能点击
|
|
|
if ($('.block-list>ul>li.chosed').length < 2) {
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
|
|
}
|
|
|
leftNum = re.exec($('.num .left-num').html());
|
|
|
if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
|
|
|
|
|
|
|
|
|
if (num - 0 === leftNum || 0 === leftNum) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//TODO:库存数验证
|
|
|
$num.val(num + 1);
|
|
|
});
|
|
|
}).on('touchstart', '#chose-btn-sure', function() {
|
|
|
|
|
|
var productSku,
|
|
|
buyNumber = $('#good-num').val() - 0,
|
|
|
|
|
|
promotionId,
|
|
|
isEdit = 0,
|
|
|
numInCart = $('.num-tag').html() - 0,
|
|
|
num = $num.val();
|
|
|
|
|
|
//颜色尺码没有选择
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//TODO status change
|
|
|
if ($('#chose-btn-sure').html() === '已售罄') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
leftNum = $('#left-num').val();
|
|
|
|
|
|
if (num > leftNum) {
|
|
|
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({
|
|
|
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;
|
|
|
|
|
|
if (cbFn) {
|
|
|
cbFn();
|
|
|
}
|
|
|
}
|
|
|
if (res.message) {
|
|
|
tip.show(res.message);
|
|
|
}
|
|
|
|
|
|
hide();
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出了点问题~');
|
|
|
}).always(function() {
|
|
|
confirming = false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
exports.init = init;
|
|
|
exports.show = show;
|
|
|
|
|
|
});
|
|
|
define("js/product/detail/consultform", ["jquery"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -5939,120 +6386,33 @@ $(window).scroll(function() { |
|
|
getOrders();
|
|
|
|
|
|
});
|
|
|
define("js/me/dialog", ["jquery","handlebars","source-map","hammer"], function(require, exports, module){
|
|
|
/*
|
|
|
* @Description: dialog
|
|
|
* @Time: 2015/11/18
|
|
|
* @author: chenglong.wang
|
|
|
define("js/me/order-detail", ["jquery","lazyload","hammer","handlebars","source-map"], function(require, exports, module){
|
|
|
/**
|
|
|
* 订单详情页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/11/16
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
Handlebars = require("handlebars"),
|
|
|
Hammer = require("hammer");
|
|
|
|
|
|
var $dialogWrapper,
|
|
|
dialogTpl,
|
|
|
dialogTemplate;
|
|
|
|
|
|
|
|
|
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>';
|
|
|
lazyLoad = require("lazyload"),
|
|
|
Hammer = require("hammer"),
|
|
|
dialog = require("js/me/dialog"),
|
|
|
tip = require("js/plugin/tip");
|
|
|
|
|
|
dialogTemplate = Handlebars.compile(dialogTpl);
|
|
|
var orderId = $('#order-detail').data('id');
|
|
|
|
|
|
exports.showDialog = function(data, callback) {
|
|
|
var optHammer;
|
|
|
|
|
|
var dialogStr = dialogTemplate(data),
|
|
|
$dialogBox,
|
|
|
defaultHideDuraton,
|
|
|
dialogWrapperHammer;
|
|
|
lazyLoad({
|
|
|
try_again_css: 'order-failure'
|
|
|
});
|
|
|
|
|
|
$('.dialog-wrapper').remove();
|
|
|
//订单删除
|
|
|
optHammer = new Hammer(document.getElementsByClassName('opt')[0]);
|
|
|
optHammer.on('tap', function(e) {
|
|
|
var $cur = $(e.target);
|
|
|
|
|
|
$('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);
|
|
|
}
|
|
|
|
|
|
dialogWrapperHammer.on('tap', function(event) {
|
|
|
|
|
|
if ($(event.target).hasClass('dialog-left-btn')) {
|
|
|
$dialogWrapper.fadeOut();
|
|
|
} else if ($(event.target).hasClass('dialog-right-btn')) {
|
|
|
callback();
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
});
|
|
|
define("js/me/order-detail", ["jquery","lazyload","hammer","handlebars","source-map"], function(require, exports, module){
|
|
|
/**
|
|
|
* 订单详情页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/11/16
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
lazyLoad = require("lazyload"),
|
|
|
Hammer = require("hammer"),
|
|
|
dialog = require("js/me/dialog"),
|
|
|
tip = require("js/plugin/tip");
|
|
|
|
|
|
var orderId = $('#order-detail').data('id');
|
|
|
|
|
|
var optHammer;
|
|
|
|
|
|
lazyLoad({
|
|
|
try_again_css: 'order-failure'
|
|
|
});
|
|
|
|
|
|
//订单删除
|
|
|
optHammer = new Hammer(document.getElementsByClassName('opt')[0]);
|
|
|
optHammer.on('tap', function(e) {
|
|
|
var $cur = $(e.target);
|
|
|
|
|
|
if ($cur.hasClass('btn-del')) {
|
|
|
if ($cur.hasClass('btn-del')) {
|
|
|
|
|
|
//删除订单
|
|
|
dialog.showDialog({
|
...
|
...
|
@@ -6072,6 +6432,7 @@ optHammer.on('tap', function(e) { |
|
|
$('#dialog-wrapper').hide();
|
|
|
if (!res) {
|
|
|
tip.show('网络错误');
|
|
|
return;
|
|
|
}
|
|
|
if (res.code === 200) {
|
|
|
tip.show('删除成功');
|
...
|
...
|
@@ -6103,6 +6464,7 @@ optHammer.on('tap', function(e) { |
|
|
$('#dialog-wrapper').hide();
|
|
|
if (!res) {
|
|
|
tip.show('网络错误');
|
|
|
return;
|
|
|
}
|
|
|
if (res.code === 200) {
|
|
|
tip.show('取消成功');
|
...
|
...
|
@@ -7865,7 +8227,7 @@ $addressForm.on('submit', function() { |
|
|
loading.hideLoadingMask();
|
|
|
} else {
|
|
|
if (queryString.refer === 'shopping') {
|
|
|
window.location.href = '/shoppingCart/selectAddress';
|
|
|
window.location.href = '/cart/index/selectAddress';
|
|
|
} else {
|
|
|
window.location.href = '/home/address';
|
|
|
}
|
...
|
...
|
@@ -8203,3 +8565,873 @@ $(window).scroll(function() { |
|
|
|
|
|
ajaxCurrencyDetail(page);
|
|
|
});
|
|
|
define("js/cart/entry", ["jquery","lazyload","hammer","mlellipsis","handlebars","source-map"], function(require, exports, module){
|
|
|
/**
|
|
|
* 购物车打包入口
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/23
|
|
|
*/
|
|
|
|
|
|
require("js/cart/cart");
|
|
|
require("js/cart/gift-advance");
|
|
|
require("js/cart/order-ensure");
|
|
|
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){
|
|
|
/**
|
|
|
* 购物车Logic
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/20
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
lazyLoad = require("lazyload"),
|
|
|
Hammer = require("hammer");
|
|
|
|
|
|
var chosePanel = require("js/cart/chose-panel"),
|
|
|
tip = require("js/plugin/tip");
|
|
|
|
|
|
var $cartContent = $('.cart-content');
|
|
|
|
|
|
var navHammer,
|
|
|
cartType = $('#cartType').val();
|
|
|
|
|
|
var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
|
|
|
|
|
|
require("js/cart/good");
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
if ('advance' === cartType) {
|
|
|
$cartContent.toggleClass('hide');
|
|
|
}
|
|
|
|
|
|
if ($('.cart-nav').length > 0) {
|
|
|
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
|
|
|
navHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target).closest('li');
|
|
|
|
|
|
if ($this.hasClass('active')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (cartType === 'ordinary') {
|
|
|
cartType = 'advance';
|
|
|
} else {
|
|
|
cartType = 'ordinary';
|
|
|
}
|
|
|
|
|
|
$this.siblings('.active').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
//切换普通商品和预售商品购物车显示
|
|
|
$cartContent.toggleClass('hide');
|
|
|
|
|
|
//trigger lazyload
|
|
|
$(window).trigger('scroll');
|
|
|
});
|
|
|
|
|
|
setTimeout(function() {
|
|
|
$('#presell-tip').addClass('hide');
|
|
|
}, 3000);
|
|
|
}
|
|
|
|
|
|
$('.advance-buy').on('touchend', function() {
|
|
|
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
|
|
|
});
|
|
|
|
|
|
$('.freebie').on('touchend', function() {
|
|
|
window.location.href = '/cart/index/gift?cartType=' + cartType;
|
|
|
});
|
|
|
|
|
|
$('.btn-balance').on('touchend', function() {
|
|
|
if (hasChecked) {
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
} else {
|
|
|
tip.show('请先勾选商品');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.chose').on('touchend', function() {
|
|
|
|
|
|
//var id = $(this).closest('.gift-advance-good').data('id');
|
|
|
chosePanel.show();
|
|
|
});
|
|
|
|
|
|
//提前触发lazyload
|
|
|
$(window).scrollTop(1).scrollTop(0);
|
|
|
});
|
|
|
define("js/cart/good", ["jquery","mlellipsis","lazyload","handlebars","source-map","hammer"], function(require, exports, module){
|
|
|
/**
|
|
|
* 购物车商品
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/20
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
ellipsis = require("mlellipsis"),
|
|
|
chosePanel = require("js/cart/chose-panel"),
|
|
|
lazyLoad = require("lazyload");
|
|
|
|
|
|
var dialog = require("js/me/dialog"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
orderInfo = require("js/cart/order-info").orderInfo;
|
|
|
|
|
|
var $selectAllBtn = $('.balance .checkbox'),
|
|
|
cartType = $('#cartType').val(),
|
|
|
requesting = false;
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
lazyLoad({
|
|
|
try_again_css: 'good-failure'
|
|
|
});
|
|
|
|
|
|
$('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
|
|
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
|
|
$('.cart-goods').on('touchstart', '.checkbox', function() {
|
|
|
var $this = $(this),
|
|
|
$good = $this.closest('.shopping-cart-good'),
|
|
|
id = $good.data('id');
|
|
|
|
|
|
var goodsList = [],
|
|
|
goodInfo = {},
|
|
|
isSelected = true;
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
isSelected = true;
|
|
|
} else {
|
|
|
isSelected = false;
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
goodInfo.goods_type = cartType;
|
|
|
goodInfo.selected = isSelected ? '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',
|
|
|
data: {
|
|
|
skuList: JSON.stringify(goodsList)
|
|
|
}
|
|
|
}).then(function(data) {
|
|
|
if (data.code === 200) {
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
} else {
|
|
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
}
|
|
|
window.history.go(0);
|
|
|
} else if (data.code === 400) {
|
|
|
tip.show('网络异常');
|
|
|
}
|
|
|
}, function() {
|
|
|
tip.show('网络异常');
|
|
|
});
|
|
|
}).on('touchstart', '.icon-del', function(e) {
|
|
|
var $this = $(this);
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
dialog.showDialog({
|
|
|
dialogText: '您确定要从购物车中删除吗?',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '取消',
|
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
var id = $this.closest('.shopping-cart-good').data('id');
|
|
|
var count = $this.data('count');
|
|
|
|
|
|
$.ajax({
|
|
|
method: 'post',
|
|
|
url: '/cart/index/del',
|
|
|
data: {
|
|
|
sku: id,
|
|
|
count: count
|
|
|
}
|
|
|
}).then(function(data) {
|
|
|
if (data.code === 200) {
|
|
|
dialog.showDialog({
|
|
|
dialogText: '删除成功',
|
|
|
autoHide: true,
|
|
|
fast: true
|
|
|
});
|
|
|
orderInfo('couponCode', null);
|
|
|
orderInfo('couponName', null);
|
|
|
history.go(0);
|
|
|
} else {
|
|
|
tip.show(data.message);
|
|
|
}
|
|
|
}, function() {
|
|
|
tip.show('网络异常');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
|
|
|
if (requesting) {
|
|
|
return;
|
|
|
}
|
|
|
requesting = true;
|
|
|
$.ajax({
|
|
|
url: 'select',
|
|
|
type: 'post',
|
|
|
data: {
|
|
|
skuList: JSON.stringify(theGoods)
|
|
|
},
|
|
|
success: function(res) {
|
|
|
if (res.code === 200) {
|
|
|
successHandeler();
|
|
|
} else {
|
|
|
tip.show(res.message);
|
|
|
}
|
|
|
},
|
|
|
error: function(err) {
|
|
|
tip.show('网络异常');
|
|
|
},
|
|
|
complete: function() {
|
|
|
requesting = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function didUpdateAllGoodsCheckStatus() {
|
|
|
var $checkedBoxs = $('.shopping-cart-good .icon-cb-checked'),
|
|
|
$uncheckedBoxs = $('.shopping-cart-good .icon-checkbox');
|
|
|
|
|
|
var shouldSelectAll;
|
|
|
|
|
|
if ($selectAllBtn.hasClass('icon-cb-checked')) {
|
|
|
$selectAllBtn.removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
shouldSelectAll = true;
|
|
|
} else {
|
|
|
$selectAllBtn.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
shouldSelectAll = false;
|
|
|
}
|
|
|
|
|
|
if (!shouldSelectAll) {
|
|
|
$uncheckedBoxs.each(function(idx, uncheckedBox) {
|
|
|
$(uncheckedBox).removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
});
|
|
|
} else {
|
|
|
$checkedBoxs.each(function(idx, checkedBox) {
|
|
|
$(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
});
|
|
|
}
|
|
|
window.history.go(0);
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
goodInfo.goods_type = type;
|
|
|
goodInfo.selected = isSelected ? 'N' : 'Y';
|
|
|
|
|
|
$goods.each(function(idx, good) {
|
|
|
$good = $(good);
|
|
|
|
|
|
goodInfo.product_sku = $(good).data('id');
|
|
|
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
|
|
|
|
|
|
goodsList.push(new GoodInfo(goodInfo));
|
|
|
});
|
|
|
|
|
|
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);
|
|
|
|
|
|
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
|
|
|
});
|
|
|
|
|
|
$('.down').on('touchend', function() {
|
|
|
chosePanel.show();
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/cart/order-info", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 订单信息读取
|
|
|
* @author: bikai<kai.bi@yoho.cn>
|
|
|
* @date: 2015/12/14
|
|
|
*/
|
|
|
var $ = require("jquery");
|
|
|
var info = window.cookie('order-info');
|
|
|
|
|
|
function init() {
|
|
|
info = {
|
|
|
uid: window.getUid(),
|
|
|
deliveryId: 1,
|
|
|
deliveryTimeId: 1,
|
|
|
paymentTypeId: 1,
|
|
|
yohoCoin: $('.coin').data('yoho-coin') || 0,
|
|
|
addressId: null,
|
|
|
couponCode: null,
|
|
|
couponName: null,
|
|
|
invoice: null,
|
|
|
invoiceText: null,
|
|
|
invoiceType: null,
|
|
|
msg: null,
|
|
|
cartType: 'ordinary'
|
|
|
};
|
|
|
window.setCookie('order-info', JSON.stringify(info));
|
|
|
}
|
|
|
|
|
|
// info 必须是 JSON 字符串
|
|
|
try {
|
|
|
info = JSON.parse(info);
|
|
|
} catch (e) {
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
exports.init = init;
|
|
|
|
|
|
exports.orderInfo = function(key, value) {
|
|
|
if (value === undefined) {
|
|
|
return info[key];
|
|
|
}
|
|
|
info[key] = value;
|
|
|
window.setCookie('order-info', JSON.stringify(info));
|
|
|
};
|
|
|
|
|
|
});
|
|
|
define("js/cart/gift-advance", ["jquery","lazyload"], function(require, exports, module){
|
|
|
/**
|
|
|
* 赠品/加价购
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/23
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
lazyLoad = require("lazyload"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
loading = require("js/plugin/loading"),
|
|
|
chosePanel = require("js/cart/chose-panel");
|
|
|
|
|
|
var $page = $('.gift-advance-page'),
|
|
|
queryString = $.queryString();
|
|
|
|
|
|
lazyLoad($('.lazy'));
|
|
|
|
|
|
function getProductInfo(skn, promotionId) {
|
|
|
loading.showLoadingMask();
|
|
|
$.get('/cart/index/giftinfo', {
|
|
|
skn: skn,
|
|
|
promotionId: promotionId
|
|
|
}).then(function(html) {
|
|
|
if (!html) {
|
|
|
tip.show('网络错误');
|
|
|
return;
|
|
|
}
|
|
|
chosePanel.show(html, function() {
|
|
|
window.location.href = '/cart/index/index?cartType=' + queryString.cartType;
|
|
|
});
|
|
|
}, function() {
|
|
|
tip.show('网络错误');
|
|
|
}).always(function() {
|
|
|
loading.hideLoadingMask();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$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){
|
|
|
/**
|
|
|
* 订单确认
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/11/12
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
lazyLoad = require("lazyload"),
|
|
|
Hammer = require("hammer"),
|
|
|
Handlebars = require("handlebars"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
loading = require("js/plugin/loading"),
|
|
|
order = require("js/cart/order-info");
|
|
|
|
|
|
var dispatchModeHammer,
|
|
|
dispatchTimeHammer,
|
|
|
$invoice = $('.invoice'),
|
|
|
$price = $('.price-cal'),
|
|
|
$couponUse = $('.coupon-use.used'),
|
|
|
$addressWrap = $('.address-wrap'),
|
|
|
payType,
|
|
|
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
|
|
|
queryString = $.queryString(),
|
|
|
orderInfo = order.orderInfo;
|
|
|
|
|
|
lazyLoad();
|
|
|
|
|
|
if (window.getUid() !== orderInfo('uid')) {
|
|
|
order.init();
|
|
|
window.location.reload();
|
|
|
}
|
|
|
|
|
|
if ($couponUse.data('name') !== orderInfo('couponName')) {
|
|
|
orderInfo('couponCode', null);
|
|
|
orderInfo('couponName', null);
|
|
|
}
|
|
|
|
|
|
orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
|
|
|
|
|
|
function dispacthTapEvt(e) {
|
|
|
var $cur = $(e.target).closest('li');
|
|
|
|
|
|
if ($cur.length === 0 || $cur.hasClass('chosed')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$cur.siblings('li.chosed').removeClass('chosed');
|
|
|
$cur.addClass('chosed');
|
|
|
}
|
|
|
|
|
|
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
|
|
|
dispatchModeHammer.on('tap', dispacthTapEvt);
|
|
|
|
|
|
dispatchTimeHammer = new Hammer(document.getElementsByClassName('dispatch-time')[0]);
|
|
|
dispatchTimeHammer.on('tap', dispacthTapEvt);
|
|
|
|
|
|
$('.checkbox').on('touchstart', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
return;
|
|
|
}
|
|
|
if ($this.hasClass('icon-checkbox')) {
|
|
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.invoice').on('touchend', '.checkbox', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
$('.invoice').addClass('focus');
|
|
|
}
|
|
|
if ($this.hasClass('icon-checkbox')) {
|
|
|
$('.invoice').removeClass('focus');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function orderCompute() {
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/orderCompute',
|
|
|
data: {
|
|
|
cartType: orderInfo('cartType') || 'ordinary',
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
couponCode: orderInfo('couponCode'),
|
|
|
yohoCoin: orderInfo('yohoCoin')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var priceHtml;
|
|
|
|
|
|
if (!res) {
|
|
|
tip.show('网络出错');
|
|
|
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);
|
|
|
}
|
|
|
priceHtml = priceTmpl({
|
|
|
cartPayData: res.promotion_formula_list,
|
|
|
price: res.last_order_amount
|
|
|
});
|
|
|
|
|
|
$price.html(priceHtml);
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出错');
|
|
|
window.location.reload();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function submitOrder() {
|
|
|
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
|
|
|
msg = $('#msg').find('input').val() || orderInfo('msg');
|
|
|
|
|
|
if (orderInfo('invoice')) {
|
|
|
if (!invoiceText) {
|
|
|
tip.show('请输入发票抬头');
|
|
|
return;
|
|
|
}
|
|
|
if (invoiceText.length > 30) {
|
|
|
tip.show('发票抬头不得超过30个汉字');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (msg) {
|
|
|
if (msg.length > 40) {
|
|
|
tip.show('留言不得超过40个汉字');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/orderSub',
|
|
|
data: {
|
|
|
addressId: orderInfo('addressId'),
|
|
|
cartType: orderInfo('cartType') || 'ordinary',
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
deliveryTimeId: orderInfo('deliveryTimeId'),
|
|
|
invoiceText: orderInfo('invoice') ? invoiceText : null,
|
|
|
invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() ||
|
|
|
orderInfo('invoiceType')) : null,
|
|
|
msg: msg,
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
paymentType: orderInfo('paymentType'), //支付方式
|
|
|
couponCode: orderInfo('couponCode'),
|
|
|
yohoCoin: orderInfo('yohoCoin')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var url;
|
|
|
|
|
|
if (!res) {
|
|
|
loading.hideLoadingMask();
|
|
|
tip.show('网络出错');
|
|
|
return;
|
|
|
}
|
|
|
if (res.code === 200) {
|
|
|
if (payType === 2) {
|
|
|
|
|
|
// 货到付款的进入订单页面
|
|
|
url = '/home/orderDetail?order_code=' + res.data.order_code;
|
|
|
} else {
|
|
|
url = '/home/pay?order_code=' + res.data.order_code;
|
|
|
}
|
|
|
window.setCookie('order-info', '');
|
|
|
window.location.href = url;
|
|
|
} else {
|
|
|
loading.hideLoadingMask();
|
|
|
tip.show(res.message || '网络出错');
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
loading.hideLoadingMask();
|
|
|
tip.show('网络出错');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 界面点击,状态存 cookie
|
|
|
if (!orderInfo('addressId')) {
|
|
|
orderInfo('addressId', $addressWrap.data('id'));
|
|
|
}
|
|
|
|
|
|
$('.dispatch-mode').on('touchstart', 'li', function() {
|
|
|
var $defaultMode = $('.dispatch-mode [data-id="1"]');
|
|
|
|
|
|
if (!$addressWrap.data('support') && $(this).data('id') === 2) {
|
|
|
dispacthTapEvt({
|
|
|
target: $defaultMode
|
|
|
});
|
|
|
tip.show('当前地址不支持顺丰快递');
|
|
|
} else {
|
|
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
orderCompute();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.dispatch-time').on('touchend', 'li', function() {
|
|
|
orderInfo('deliveryTimeId', $(this).data('id'));
|
|
|
});
|
|
|
|
|
|
$('.coin').on('touchend', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
|
|
|
orderInfo('yohoCoin', $this.data('yoho-coin'));
|
|
|
$this.find('.coin-check em').show();
|
|
|
} else {
|
|
|
orderInfo('yohoCoin', 0);
|
|
|
$this.find('.coin-check em').hide();
|
|
|
}
|
|
|
orderCompute();
|
|
|
});
|
|
|
|
|
|
$invoice.on('touchend', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked'));
|
|
|
});
|
|
|
|
|
|
$invoice.find('[name="invoice-title"]').on('blur', function() {
|
|
|
orderInfo('invoiceText', $(this).val());
|
|
|
}).end().find('.invoice-type').on('change', function() {
|
|
|
orderInfo('invoiceType', $(this).val());
|
|
|
});
|
|
|
|
|
|
$('#msg').find('textarea').on('blur', function() {
|
|
|
orderInfo('msg', $(this).val());
|
|
|
});
|
|
|
|
|
|
$('.pay-mode').on('click', 'li', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
orderInfo('paymentTypeId', $this.data('pay-id'));
|
|
|
orderInfo('paymentType', $this.data('pay-type'));
|
|
|
payType = $this.data('pay-type');
|
|
|
submitOrder();
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/cart/select-coupon", ["jquery","handlebars","source-map","mlellipsis"], function(require, exports, module){
|
|
|
/**
|
|
|
* 优惠券选择
|
|
|
* @author: bikai<kai.bi@yoho.cn>
|
|
|
* @date: 2015/12/10
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
Handlebars = require("handlebars"),
|
|
|
ellipsis = require("mlellipsis"),
|
|
|
loading = require("js/plugin/loading"),
|
|
|
tip = require("js/plugin/tip"),
|
|
|
orderInfo = require("js/cart/order-info").orderInfo;
|
|
|
|
|
|
var page = 1,
|
|
|
canGetCoupon = true,
|
|
|
isGetData;
|
|
|
|
|
|
var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
|
|
|
$newCoupon = $('#new-coupon');
|
|
|
|
|
|
// conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
$newCoupon.on('submit', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if (!$this.find('[name="couponCode"]').val()) {
|
|
|
tip.show('请输入优惠券码');
|
|
|
return false;
|
|
|
}
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/couponSearch',
|
|
|
data: $this.serialize()
|
|
|
}).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
tip.show('优惠券可用');
|
|
|
orderInfo('couponCode', res.data.coupon_code);
|
|
|
orderInfo('couponName', res.data.coupon_title);
|
|
|
window.location.href = '/cart/index/orderEnsure';
|
|
|
} else {
|
|
|
tip.show(res.message || '网络错误');
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络错误');
|
|
|
});
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$('#coupon-list').on('touchend', '.employ-main', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
orderInfo('couponCode', $this.data('coupon-code'));
|
|
|
orderInfo('couponName', $this.data('coupon-name'));
|
|
|
});
|
|
|
|
|
|
$('body').on('touchend', '.not-use', function() {
|
|
|
orderInfo('couponCode', null);
|
|
|
orderInfo('couponName', null);
|
|
|
});
|
|
|
|
|
|
|
|
|
$newCoupon.find('input').on('input', function() {
|
|
|
if ($(this).val() !== '') {
|
|
|
$newCoupon.find('.submit').css('background', '#444');
|
|
|
} else {
|
|
|
$newCoupon.find('.submit').css('background', '#b0b0b0');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function getCouponHandle(coupons) {
|
|
|
var notAvailableCoupons = [];
|
|
|
|
|
|
// 后端需要返回一个 coupons 列表,如下
|
|
|
// notAvailable 表示不可用的优惠券
|
|
|
// coupons = [{
|
|
|
// money: '99',
|
|
|
// coupon_name: '满XX-减去吴悠右腿有益于有2222',
|
|
|
// couponValidity: '20150129-20150430',
|
|
|
// coupon_id: '22222'
|
|
|
// }, {
|
|
|
// money: '99',
|
|
|
// coupon_name: '满XX-减去吴悠右腿有益于有2222',
|
|
|
// couponValidity: '20150129-20150430',
|
|
|
// coupon_id: '2222233'
|
|
|
// }, {
|
|
|
// money: '99',
|
|
|
// coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222',
|
|
|
// couponValidity: '20150129-20150430',
|
|
|
// coupon_id: '2222233',
|
|
|
// notAvailable: 1
|
|
|
// }];
|
|
|
|
|
|
// coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算
|
|
|
if (!$.isArray(coupons)) {
|
|
|
page--;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 每页10张,当不足10张时,说明已经加载完
|
|
|
if (coupons.length < 10) {
|
|
|
canGetCoupon = false;
|
|
|
}
|
|
|
|
|
|
// 第一页张数为 0 ,显示优惠券为空
|
|
|
if (!coupons.length && page === 2) {
|
|
|
$('.coupin-wrap').html($('#tmpl-no-coupon').html());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 把不可用的优惠券分离出来
|
|
|
$.each(coupons, function(i, coupon) {
|
|
|
if (coupon.notAvailable) {
|
|
|
notAvailableCoupons.push(coupon);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('#coupon-list').append(conponTmpl({
|
|
|
coupons: coupons
|
|
|
}));
|
|
|
|
|
|
// 产品说,暂时不做不可使用的优惠券
|
|
|
// if (notAvailableCoupons.length) {
|
|
|
// $('.not-avaliable-coupon-line').show();
|
|
|
// }
|
|
|
// $('#coupon-list-not').append(conponNotAvaliableTmpl({
|
|
|
// notAvailableCoupons: notAvailableCoupons
|
|
|
// }));
|
|
|
window.rePosFooter();
|
|
|
}
|
|
|
|
|
|
function getCouponDate() {
|
|
|
if (!canGetCoupon) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (isGetData) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
page += 1;
|
|
|
isGetData = true;
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/cart/index/couponList',
|
|
|
dataType: 'json',
|
|
|
data: {
|
|
|
page: page
|
|
|
}
|
|
|
}).then(getCouponHandle).fail(function() {
|
|
|
page -= 1;
|
|
|
tip.show('加载优惠券失败');
|
|
|
}).always(function() {
|
|
|
isGetData = false;
|
|
|
loading.hideLoadingMask();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getCouponDate();
|
|
|
|
|
|
$(window).scroll(function() {
|
|
|
if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
|
|
|
getCouponDate();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/cart/select-address", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 购物车 地址选择
|
|
|
* @author: bikai<kai.bi@yoho.cn>
|
|
|
* @date: 2015/12/14
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
orderInfo = require("js/cart/order-info").orderInfo;
|
|
|
|
|
|
var $confim = $('.confim-mask'),
|
|
|
deleteId;
|
|
|
|
|
|
$('.address-item').on('touchend', function() {
|
|
|
orderInfo('addressId', $(this).data('address-id'));
|
|
|
}).on('touchend', '.edit', function() {
|
|
|
window.location.href = $(this).data('href');
|
|
|
return false;
|
|
|
}).on('touchend', '.del', function() {
|
|
|
deleteId = $(this).data('address-id');
|
|
|
});
|
|
|
|
|
|
$confim.on('touchend', '.confim', function() {
|
|
|
if (orderInfo('addressId') === deleteId) {
|
|
|
orderInfo('addressId', null);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}); |
...
|
...
|
|