Authored by xiaowei

格式js

... ... @@ -9,8 +9,11 @@ var address = require('./address');
var dialog = require('../common/dialog');
var accMul = function (arg1, arg2){
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
var accMul = function(arg1, arg2) {
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length
} catch (e) {
... ... @@ -61,13 +64,13 @@ var Order = {
$hasEnvelopes: $('.has-envelopes span'),
$useEnvelopesInput: $('.use-envelopes').find('input')
},
init: function () {
init: function() {
var e = this.e,
d = Order.Data,
c = Order.Common;
//初始化产品价格(表格中的价格)
e.$tbody.find('tr').each(function (index) {
e.$tbody.find('tr').each(function(index) {
var td = $(this).find('td');
var len = e.$tbody.find('tr').length;
... ... @@ -93,7 +96,7 @@ var Order = {
});
// 使用优惠券、使用yoho币点击展开
e.$pan.find('dt').click(function () {
e.$pan.find('dt').click(function() {
var pan = $(this).parent('dl.pan');
... ... @@ -110,7 +113,7 @@ var Order = {
});
//请填写并核对一下信息
e.$orderSelectionSave.click(function () {
e.$orderSelectionSave.click(function() {
var i = 0,
$addressLi = $('.exist-address-list li'),
liLen = $addressLi.length,
... ... @@ -166,7 +169,7 @@ var Order = {
//支付及送货时间
e.$switchPayModify.click(function () {
e.$switchPayModify.click(function() {
if (e.$payTimeModify.hasClass('hide')) {
e.$payTimeModify.removeClass('hide');
... ... @@ -183,13 +186,13 @@ var Order = {
}
});
e.$spanPayTypeLegend.click(function () {
e.$spanPayTypeLegend.click(function() {
$(this).toggleClass('active');
e.$supportType.toggleClass('hide');
});
$(document).on('click', '.exist-address-list li', function () {
$(document).on('click', '.exist-address-list li', function() {
$('.exist-address-list li').removeClass('active');
... ... @@ -210,7 +213,7 @@ var Order = {
});
},
//渲染价格明细
render: function (data, tips) {
render: function(data, tips) {
// 下面这段是在服务端算价格
var e = this.e,
... ... @@ -255,7 +258,7 @@ var Order = {
e.$toPay.html((data.last_order_amount).toFixed(2));
//有货币清零状态更新
$('#biprice').val(accMul(100,data.use_yoho_coin));
$('#biprice').val(accMul(100, data.use_yoho_coin));
if (~~data.use_yoho_coin === 0) {
$('.errbitip').text('');
} else {
... ... @@ -278,7 +281,7 @@ var Order = {
},
/*公共方法*/
Common: {
enterNUM: function (str1, str2) {
enterNUM: function(str1, str2) {
str1 = str1.replace(/[^\d]/g, '');
if (str1 && str2) {
str1 = parseInt(str1);
... ... @@ -289,34 +292,34 @@ var Order = {
}
return str1;
},
calucate: function () {
calucate: function() {
var p = Order.Data;
$.each(Order.Data, function (key, index) {
$.each(Order.Data, function(key, index) {
p[key] = parseFloat(Order.Data[key]);
});
return p.product - p.activity + p.carriage - p.juan - p.yohocoin;
},
winShow: function (pan) {
winShow: function(pan) {
pan.find('dt').show();
pan.find('dd').show();
if (pan.attr('class').match(/(-bi-)|(-juan-)/g)) {
pan.find('dt').hide();
}
},
winHide: function (pan) {
winHide: function(pan) {
pan.find('dt').show();
pan.find('dd').hide();
/*if (pan.hasClass('play-juan-pan') && $('.juan-modify').length > 0) {
pan.find('dt').hide();
}
if (pan.hasClass('play-bi-pan') && $('.bi-modify').length > 0) {
pan.find('dt').hide();
}*/
},
strFixed: function (str) {
strFixed: function(str) {
return parseFloat(str).toFixed(2);
}
},
... ... @@ -336,7 +339,7 @@ var Order = {
$redEnvelopes: $('.red-envelopes'),
$loading: $('.loading')
},
init: function () {
init: function() {
var e = this.e,
u = Order.UI,
options,
... ... @@ -361,7 +364,7 @@ var Order = {
couponCode: codeVal,
yohoCoin: biVal
//redEnvelopes: e.$useEnvelopesInput.length > 0 ? ~~e.$hasEnvelopes.text().substring(1) : '0'
//redEnvelopes: e.$useEnvelopesInput.length > 0 ? ~~e.$hasEnvelopes.text().substring(1) : '0'
};
if (!!redEnvelopes) {
... ... @@ -373,13 +376,13 @@ var Order = {
}
// 选择快递
e.$selectExpress.click(function () {
e.$selectExpress.click(function() {
var expressId = $(this).val();
e.$loading.show();
getSelectData(function (d) {
getSelectData(function(d) {
d.deliveryWay = expressId;
... ... @@ -387,7 +390,7 @@ var Order = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function (data) {
success: function(data) {
e.$loading.hide();
if (data.code === 200) {
... ... @@ -410,7 +413,7 @@ var Order = {
});
//点击 优惠卷支付 确认按钮
e.$juanok.click(function () {
e.$juanok.click(function() {
var pan = $(this).parents('dl.pan');
... ... @@ -418,7 +421,7 @@ var Order = {
$('.play-juan').addClass('is-select');
getSelectData(function (d) {
getSelectData(function(d) {
var code = d.couponCode;
... ... @@ -435,7 +438,7 @@ var Order = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function (data) {
success: function(data) {
e.$loading.hide();
... ... @@ -465,7 +468,7 @@ var Order = {
});
// 优惠券修改
$(document).on('click', '.juan-modify', function () {
$(document).on('click', '.juan-modify', function() {
var $pan = $('.play-juan-pan');
... ... @@ -473,14 +476,14 @@ var Order = {
c.winShow($pan);
});
e.$biok.click(function () {
e.$biok.click(function() {
var pan = $(this).parents('dl.pan');
var juanText;
$('#biprice').addClass('is-select');
getSelectData(function (d) {
getSelectData(function(d) {
if (!!d.couponCode) {
juanText = $('.play-juan input[value="' + d.couponCode + '"]').next().text();
... ... @@ -503,7 +506,7 @@ var Order = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function (data) {
success: function(data) {
e.$loading.hide();
... ... @@ -528,7 +531,7 @@ var Order = {
});
// 修改yoho币
$(document).on('click', '.bi-modify', function () {
$(document).on('click', '.bi-modify', function() {
var $pan = $('.play-bi-pan');
... ... @@ -536,7 +539,7 @@ var Order = {
c.winShow($pan);
});
e.$bp.keyup(function () {
e.$bp.keyup(function() {
var val = $(this).val();
... ... @@ -551,7 +554,7 @@ var Order = {
});
// 取消yoho 币
$('.cancel-bi').click(function () {
$('.cancel-bi').click(function() {
var $pan = $('.play-bi-pan');
... ... @@ -563,7 +566,7 @@ var Order = {
e.$loading.show();
getSelectData(function (d) {
getSelectData(function(d) {
d.yohoCoin = 0;
... ... @@ -575,7 +578,7 @@ var Order = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function (data) {
success: function(data) {
e.$loading.hide();
... ... @@ -610,7 +613,7 @@ var Order = {
});
// 取消优惠券
$('.cancel-code').click(function () {
$('.cancel-code').click(function() {
var $pan = $('.play-juan-pan');
... ... @@ -618,7 +621,7 @@ var Order = {
e.$loading.show();
getSelectData(function (d) {
getSelectData(function(d) {
d.couponCode = '';
... ... @@ -626,7 +629,7 @@ var Order = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function (data) {
success: function(data) {
e.$loading.hide();
... ... @@ -659,7 +662,7 @@ var Order = {
// 红包
envelopesVal = e.$useEnvelopesInput.data('all') - e.$useEnvelopesInput.data('use'); // 剩余的红包
e.$hasEnvelopes.text('¥' + envelopesVal.toFixed(2));
e.$useEnvelopes.find('input').click(function () {
e.$useEnvelopes.find('input').click(function() {
var $this = $(this),
juanText;
... ... @@ -668,7 +671,7 @@ var Order = {
$this.attr('disabled', 'disabled');
getSelectData(function (d) {
getSelectData(function(d) {
if (!!$this.attr('checked')) {
... ... @@ -686,7 +689,7 @@ var Order = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function (data) {
success: function(data) {
e.$loading.hide();
if (data.code === 200) {
... ... @@ -719,7 +722,7 @@ var Order = {
var $this = $obj;
$this.keyup(function () {
$this.keyup(function() {
if ($this.val().length > len) {
... ... @@ -750,15 +753,15 @@ address.saveAddress();
//不同订单包裹提示
$('.why').click(function () {
$('.why').click(function() {
$('#differentBag').show();
return false;
});
$('#differentBag').click(function () {
$('#differentBag').click(function() {
return false;
});
$(document).click(function () {
$(document).click(function() {
$('#differentBag').hide();
});
... ... @@ -770,7 +773,7 @@ function lunBo($pre, $next, $ul, $iWidth) {
var iSpeed = 0,
isMoving = false;
$pre.click(function () {
$pre.click(function() {
if (isMoving) {
return;
}
... ... @@ -784,11 +787,11 @@ function lunBo($pre, $next, $ul, $iWidth) {
}
$ul.stop().animate({
left: iSpeed
}, 300, function () {
}, 300, function() {
isMoving = false;
});
});
$next.click(function () {
$next.click(function() {
var $largeLeft = $ul.parent().width() - $ul.width() + 'px';
if (isMoving) {
... ... @@ -804,7 +807,7 @@ function lunBo($pre, $next, $ul, $iWidth) {
$ul.stop().animate({
left: iSpeed
}, 300, function () {
}, 300, function() {
isMoving = false;
});
});
... ... @@ -813,7 +816,7 @@ function lunBo($pre, $next, $ul, $iWidth) {
//订单分类
$('.bag').find('ul').each(function () {
$('.bag').find('ul').each(function() {
var $pre = $(this).parent().parent().find('.pre');
var $next = $(this).parent().parent().find('.next');
... ...