Authored by 刘传洋

Merge branch 'feature/shoppingCart' of http://git.yoho.cn/fe/yohobuy-node into feature/shoppingCart

... ... @@ -33,41 +33,6 @@ const index = (req, res, next) => {
}).catch(next);
};
// 获取地址列表
const addressList = (req, res, next) => {
oeModel.addressList(req.user.uid).then(data => {
res.send(data);
}).catch(next);
};
// 获取区域列表
const getAreaList = (req, res, next) => {
oeModel.areaList(req.query.id).then(data => {
res.send(data);
}).catch(next);
};
// 地址删除
const delAddress = (req, res, next) => {
oeModel.delAddress(req.user.uid, req.body.id).then(data => {
res.send(data);
}).catch(next);
};
// 地址/更新新增
const saveAddress = (req, res, next) => {
oeModel.saveAddress(req.user.uid, req.body).then(data => {
res.send(data);
}).catch(next);
};
// 设置默认地址
const setDefault = (req, res, next) => {
oeModel.setDefault(req.user.uid, req.body.id).then(data => {
res.send(data);
}).catch(next);
};
// 获取优惠券列表
const getCoupons = (req, res, next) => {
oeModel.getCoupons(req.user.uid).then(data => {
... ... @@ -77,9 +42,10 @@ const getCoupons = (req, res, next) => {
// 订单金额计算
const compute = (req, res, next) => {
let cartType = req.query.cartType === '2' ? 'advance' : 'ordinary';
let params = req.body;
let cartType = params.cartType === '2' ? 'advance' : 'ordinary';
oeModel.compute(req.user.uid, cartType, req.query).then(data => {
oeModel.compute(req.user.uid, cartType, params).then(data => {
res.send(data);
}).catch(next);
};
... ... @@ -103,11 +69,6 @@ const submit = (req, res, next) => {
module.exports = {
index,
addressList,
getAreaList,
delAddress,
saveAddress,
setDefault,
getCoupons,
compute,
submit
... ...
... ... @@ -7,6 +7,12 @@
const api = global.yoho.API;
/**
* 购物车结算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
* @param yohoCoinMode [number] 是否使用yoho币,1使用,0不使用
*/
const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', {
method: 'app.Shopping.payment',
cart_type: cartType,
... ... @@ -15,6 +21,15 @@ const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', {
});
/**
* 获取用户优惠券信息API
* @param uid [number] uid
*/
const getUesrCouponAsync = (uid) => api.get('', {
method: 'app.Shopping.listCoupon',
uid: uid
});
/**
* 订单计算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
... ... @@ -93,7 +108,8 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p
delivery_way: deliveryWay,
payment_type: paymentType,
payment_id: paymentId,
is_print_price: printPrice
is_print_price: printPrice,
is_continue_buy: other.continueBuy ? 'Y' : 'N'
};
// 发票
... ... @@ -139,6 +155,7 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p
module.exports = {
getOrderPaymentAsync,
getUesrCouponAsync,
getOrderComputeAsync,
orderSubmitAsync
};
... ...
... ... @@ -38,36 +38,7 @@ const index = (uid, cartType) => {
};
// 获取优惠券列表
// const getCoupons = (uid) => api.get('', {
// method: 'app.Shopping.listCoupon',
// uid: uid
// }).then(result => {
// if (result.code === 200) {
// let unuse = [];
// let use = [];
// _.forEach(result.data.unusable_coupons, i => {
// unuse.push({
// code: i.coupon_code,
// name: i.coupon_name,
// value: i.coupon_value,
// canuse: false
// });
// });
// _.forEach(result.data.usable_coupons, i => {
// use.push({
// code: i.coupon_code,
// name: i.coupon_name,
// value: i.coupon_value
// });
// });
// result.data = _.concat(use, unuse);
// }
// return result;
// });
const getCoupons = (uid) => ensureApi.getUesrCouponAsync(uid);
// 订单计算
const compute = (uid, cartType, pa) => {
... ... @@ -110,8 +81,7 @@ const submit = (uid, cartType, p) => {
module.exports = {
index,
// getCoupons,
getCoupons,
compute,
submit
};
... ...
... ... @@ -24,6 +24,8 @@ router.post('/address/save', address.saveAddress); // 新增地址/更新地址
router.post('/address/setdefault', address.setDefault); // 设置默认地址
router.get('/ensure', ensure.index); // 限购商品快捷结算页
router.get('/ensure/coupons', ensure.getCoupons); // 限购商品快捷结算页
router.post('/ensure/compute', ensure.compute); // 价格重新计算
router.get('/easypay', easypay.index); // 限购商品快捷结算页
router.post('/easypay/compute', easypay.compute); // 价格重新计算
... ...
... ... @@ -120,19 +120,83 @@
<label id="modify-invoice">修改</label>
</div>
</div>
{{# shoppingCartData}}
<div class="extra-wrap">
<dl>
<dt>使用YOHO币</dt>
<dd></dd>
<dt>使用红包</dt>
<dd></dd>
<dt>添加备注信息</dt>
<dd></dd>
<dt id="use-coupons" class="use-coupons">
<span class="iconfont locker-switch">&#xe645;</span>使用优惠券/优惠码
<div class="tip-box right">
<p>优惠码不可与优惠券同时使用</p>
<p class="coupon-err-tip"></p>
</div>
</dt>
<dd>
<div class="coupon-opt-title">
<label class="radio-btn on">使用优惠券</label>
<label class="radio-btn code">使用优惠码</label>
<span class="ticket-use-tip hide">
已成功使用<em class="red num">1</em>张优惠券,<em class="red price"></em>
<b class="cancel-use-ticket">取消使用</b>
</span>
<div class="opt-area right">
<input type="text" class="coupon-code">
<label class="sure-use-code">直接使用</label>
<label class="sure-use-ticket">确定</label>
</div>
</div>
<div class="coupon-list-wrap"></div>
</dd>
<dt><span class="iconfont locker-switch">&#xe645;</span>使用YOHO币</dt>
<dd id="yoho-coin-box" class="yoho-coin-box" data-coin="{{usedCoinNum}}" data-max={{canUseCoinNum}}>
<div class="outer-view">
<p class="coin-err-tip">{{coinErrorTip}}</p>
<p>有货币满<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p>
<i class="iconfont help-icon">&#xe628;</i>
<div class="coin-tip-help">
<p>有货币使用提示:</p>
<p>
1.订单金额大于20元(含20元)<br>
2.有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个) <br>
3.有货币支付上限为每笔订单应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}}
</p>
<p class="rs-text">备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p>
</div>
</div>
<div class="coin-main-view">
<p>本次使用有货币<span class="red">{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥{{yoho_coin}}</span></p>
<p class="grey">您当前共有有货币 <span class="red">{{total_yoho_coin_num}}</span> 个,可用 <span class="red">{{canUseCoinNum}}</span></p>
<label class="coin-cancel-btn">取消使用</label>
<label class="coin-use-btn">确定</label>
</div>
</dd>
{{#if red_envelopes}}
<dt><span class="iconfont locker-switch">&#xe645;</span>使用红包</dt>
<dd id="red-packet-box" class="red-packet-box">
<div>
<label class="radio-btn"></label>
使用红包支付(当前账户红包金额:<em class="red">¥ {{red_envelopes}}</em>
<label class="sure-btn" data-num="{{red_envelopes}}">确定</label>
</div>
</dd>
{{/if}}
<dt><span class="iconfont locker-switch">&#xe645;</span>添加备注信息</dt>
<dd id="remark-box" class="remark-box">
<div class="note-text-box">
<p class="tip-text">声明:备注中有关收货人信息、支付方式、配送方式、发票信息等购买要求一律以上面的选择为准,备注无效。</p>
<textarea class="note-text"></textarea>
</div>
<p class="pp-area">是否打印价格:
<label class="radio-btn on"></label>
<label class="radio-btn unprint"></label>
<span>(如:送朋友的商品可不打印价格哦!)</span>
</p>
</dd>
</dl>
</div>
{{# shoppingCartData}}
<div class="balance-wrap">
<ul class="balance-detail">
<ul id="balance-detail" class="balance-detail">
{{#each promotion_formula_list}}
<li class="promotion-item">
{{#if @first}}
... ... @@ -149,7 +213,7 @@
</div>
<div class="sum-wrap">
应付金额:<span class="price">¥ {{last_order_amount}}</span>
应付金额:<span id="order-price" class="price">¥ {{round last_order_amount 2}}</span>
<button id="order-submit">提交订单</button>
</div>
{{/ shoppingCartData}}
... ...
<script id="address-tpl" type="text/html">
<div class="title">\{{title}}</div>
<p class="prompt">\{{title}}、电话为选填项,其他均为必填项</p>
... ... @@ -138,3 +136,70 @@
</ul>
</div>
</script>
<script id="coupons-tpl" type="text/html">
\{{#if usable_coupons}}
<ul class="usable-list">
<li class="useable-title">可用优惠券</li>
\{{#each usable_coupons}}
<li>
<span class="title">\{{coupon_name}}</span>
<span class="time">\{{coupon_validity}}</span>
<span class="money">¥ \{{round coupon_value 2}}</span>
<span class="coupon-radio" data-id="\{{coupon_code}}" data-price="\{{round coupon_value 2}}"></span>
</li>
\{{/each}}
</ul>
\{{^}}
<p class="empty-tip">暂无可用优惠券~</p>
\{{/if}}
\{{#if unusable_coupons}}
<ul class="unusable-list">
<li class="unuseable-title">未满足使用条件的优惠券</li>
\{{#each unusable_coupons}}
<li>
<span class="title">\{{coupon_name}}</span>
<span class="time">\{{coupon_validity}}</span>
<span class="money">¥ \{{round coupon_value 2}}</span>
</li>
\{{/each}}
</ul>
\{{/if}}
</script>
<script id="yoho-coin-tpl" type="text/html">
<div class="outer-view">
<p class="coin-err-tip">\{{coinErrorTip}}</p>
<p>有货币满<span class="red">\{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="red">\{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p>
<i class="iconfont help-icon">&#xe628;</i>
<div class="coin-tip-help">
<p>有货币使用提示:</p>
<p>
1.订单金额大于20元(含20元)<br>
2.有货币数量大于\{{yoho_coin_pay_rule.num_limit}}个(含\{{yoho_coin_pay_rule.num_limit}}个) <br>
3.有货币支付上限为每笔订单应付金额的\{{yoho_coin_pay_rule.max_pay_rate_desc}}
</p>
<p class="rs-text">备注:使用有货币数量为\{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p>
</div>
</div>
<div class="coin-main-view">
<p>本次使用有货币<span class="red">\{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥\{{yoho_coin}}</span></p>
<p class="grey">您当前共有有货币 <span class="red">\{{total_yoho_coin_num}}</span> 个,可用 <span class="red">\{{canUseCoinNum}}</span> 个</p>
<label class="coin-cancel-btn">取消使用</label>
<label class="coin-use-btn">确定</label>
</div>
</script>
<script id="promotion-list-tpl" type="text/html">
\{{#each promotion_formula_list}}
<li class="promotion-item">
\{{#if @first}}
<a class="gain-coin-tip" href="/help/?category_id=87" target="_blank"></a>
<span class="back-coin">共返YOHO币:\{{../gain_yoho_coin}}个</span>
<span class="total-num"><i>\{{../selected_goods_count}}</i>件商品</span>
\{{/if}}
<span class="promotion-name">\{{promotion}}:</span>
<em class="promotion-val">\{{promotion_amount}}</em>
</li>
\{{/each}}
</script>
... ...
No preview for this file type
... ... @@ -2,7 +2,11 @@
<!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>
<<<<<<< HEAD
Created by FontForge 20120731 at Fri Dec 30 17:59:57 2016
=======
Created by FontForge 20120731 at Fri Jan 6 16:35:29 2017
>>>>>>> 01504b9ffb57840ea020ad6141c7b32753e14078
By admin
</metadata>
<defs>
... ... @@ -239,11 +243,14 @@ d="M512 832q-91 0 -174 -35.5t-143 -95.5t-95 -143t-35 -174t35 -174t95 -142.5t143
<glyph glyph-name="jia" unicode="&#xe645;"
d="M512 832q-91 0 -174 -35.5t-143 -95.5t-95.5 -142.5t-35.5 -173.5t35.5 -173.5t95.5 -142.5t143 -95.5t174 -35.5t174 35.5t143 95.5t95.5 142.5t35.5 173.5t-35.5 173.5t-95.5 142.5t-143 95.5t-174 35.5v0zM753 351h-207v-207h-68v207h-207v68h207v207h68v-207h207v-68
v0zM753 351z" />
<<<<<<< HEAD
=======
<glyph glyph-name="focus" unicode="&#xe68e;" horiz-adv-x="1122"
d="M793 798q92 0 150.5 -65t58.5 -161q0 -82 -54 -145l-398 -413l-399 413q-53 63 -53 145q0 96 58 161t150 65q43 0 90 -22t79 -52t53.5 -58.5t21.5 -42.5q0 14 21 42.5t53.5 58.5t79 52t89.5 22zM793 896q-63 0 -127 -30t-116 -78q-53 48 -117 78t-127 30
q-131 0 -218.5 -92.5t-87.5 -231.5q0 -118 76 -208l3 -3l2 -2l398 -413l71 -73l70 73l398 413l3 2l2 3q76 90 76 208q0 139 -87.5 231.5t-218.5 92.5v0z" />
<glyph glyph-name="focused" unicode="&#xe68f;" horiz-adv-x="1122"
d="M793 896q-63 0 -127 -30t-116 -78q-53 48 -117 78t-127 30q-131 0 -218.5 -92.5t-87.5 -231.5q0 -118 76 -208l3 -3l2 -2l398 -413l71 -73l70 73l398 413l3 2l2 3q76 90 76 208q0 139 -87.5 231.5t-218.5 92.5v0z" />
>>>>>>> 01504b9ffb57840ea020ad6141c7b32753e14078
<glyph glyph-name="wenhao1" unicode="&#xe628;"
d="M512 886q-102 0 -195 -39.5t-160.5 -107t-107 -160.5t-39.5 -195t39.5 -195t107 -160.5t160.5 -107t195 -39.5t195 39.5t160.5 107t107 160.5t39.5 195t-39.5 195t-107 160.5t-160.5 107t-195 39.5zM521 -15q-34 0 -58.5 24t-24.5 58.5t24.5 58.5t58.5 24t58 -24t24 -58
q1 -34 -23.5 -58.5t-58.5 -24.5zM738 477q-17 -34 -67 -83q-45 -43 -60 -61q-12 -16 -17 -35q-6 -22 -6 -61l1 -31h-142v30q0 56 9 90q11 38 30 64q17 23 62 71q43 44 52 60q8 13 8 44q0 28 -20 51q-20 21 -61 21q-29 0 -48.5 -9.5t-28.5 -27.5t-12.5 -36t-3.5 -43v-30h-142
... ... @@ -266,6 +273,8 @@ d="M947 179q31 0 54 -23t23 -53.5t-23 -53.5t-54 -23h-51q31 0 54 -23t23 -54t-23 -5
q0 -136 -26 -205h256q31 0 54 -23t23 -53.5t-23 -53.5t-54 -23h51q31 0 54 -23t23 -54t-23 -54t-54 -23zM102.5 -128q-42.5 0 -72.5 30t-30 72v410q0 42 30 72t72.5 30t72.5 -30t30 -72v-410q0 -42 -30 -72t-72.5 -30z" />
<glyph glyph-name="juxingkaobei" unicode="&#xe6bc;"
d="M186 2l391 382l-391 382l131 130l521 -512l-521 -512z" />
<<<<<<< HEAD
=======
<glyph glyph-name="shang" unicode="&#xe6c0;"
d="M958 179q0 -15 -10.5 -25.5t-25.5 -10.5t-26 10l-384 384l-384 -384q-11 -10 -26 -10t-25.5 10.5t-10.5 25.5t11 26l409 410q11 10 26 10t26 -10l409 -410q11 -11 11 -26z" />
<glyph glyph-name="xia" unicode="&#xe6c1;"
... ... @@ -301,5 +310,6 @@ q-42 -57 -105.5 -93.5t-135.5 -46.5q-72 -9 -141 9t-126 61q-19 14 -44 10.5t-39 -23
<glyph glyph-name="yz" unicode="&#xe6d2;"
d="M255 743q113 85 252.5 96.5t262.5 -51.5l83 83q25 25 63 12q18 0 28.5 -15t10.5 -36v-248q0 -24 -17 -40.5t-41 -16.5h-254q-38 0 -57 38q-12 48 12 64l70 70q-79 35 -174 22t-169 -73q-78 -59 -115.5 -148.5t-26 -186t71.5 -174.5q43 -57 106.5 -93.5t135.5 -46.5
q71 -9 140 9t127 61q19 14 43.5 10.5t39 -23t10.5 -44t-23 -38.5q-133 -102 -293 -102q-44 0 -63 6q-97 15 -179.5 62t-139.5 123q-78 106 -92.5 235t35.5 248t153 197z" />
>>>>>>> 01504b9ffb57840ea020ad6141c7b32753e14078
</font>
</defs></svg>
... ...
No preview for this file type
No preview for this file type

2.96 KB | W: | H:

283 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

3.03 KB | W: | H:

360 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

47.4 KB | W: | H:

48.1 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -5,14 +5,105 @@
*/
var $ = require('yoho-jquery');
var Hbs = require('yoho-handlebars');
var order = {};
var $balanceDetail = $('#balance-detail'),
$orderPrice = $('#order-price');
var order = {
printPrice: 'Y'
},
iconCode = {
on: '&#xe643;',
off: '&#xe645;'
};
var payWay,
deliveryWay;
deliveryWay,
coupon,
yohoCoin;
var address = require('./order-new/address'),
invoice = require('./order-new/invoice');
var coinTpl = Hbs.compile($('#yoho-coin-tpl').html());
var promotionTpl = Hbs.compile($('#promotion-list-tpl').html());
require('../common');
order.cartType = window.queryString().type || 1;
// FE Helper
Hbs.registerHelper('round', function(num, precision) {
precision = parseFloat('0' + precision, 10) || 2;
return (+num).toFixed(precision);
});
// 订单计算
// 传有货币数量则使用有货币,否者不使用,更改订单总价有货币使用数量重置为0
function compute(coin) {
var reqData = {
cartType: order.cartType,
coin: coin ? coin : 0
};
require('./order-new/address');
require('./order-new/invoice');
order.coin = reqData.coin;
// 支付方式
if (order.paymentType) {
reqData.paymentType = order.paymentType;
}
// 配送方式
if (order.deliveryWay) {
reqData.deliveryWay = order.deliveryWay;
}
// 优惠券
if (order.couponCode) {
reqData.couponCode = order.couponCode;
}
// 红包
if (order.redEnvelopes) {
reqData.redEnvelopes = order.redEnvelopes;
}
$.ajax({
type: 'POST',
url: '/cart/ensure/compute',
data: reqData
}).then(function(data) {
var res;
if (data.code === 200) {
res = data.data;
// update yoho coin max use num
yohoCoin.maxCoin = res.canUseCoinNum;
// update yoho coin using
yohoCoin.$el.html(coinTpl(res));
if (!reqData.coin) {
yohoCoin.$el.removeClass('used');
}
// update last order amount
$orderPrice.html('¥ ' + res.last_order_amount);
// update promotion formula list
$balanceDetail.html(promotionTpl(res));
} else if (data.code === 317) {
if (coupon.$errorTip) {
coupon.$errorTip.text(data.message);
if (order.couponCode) {
delete order.couponCode;
}
}
}
});
}
// 支付方式
payWay = {
... ... @@ -53,6 +144,9 @@ payWay = {
// 更新订单支付数据
that.updateOrder($this.data());
// 重新计算订单价格
compute();
});
},
updateOrder: function(info) {
... ... @@ -116,6 +210,9 @@ deliveryWay = {
// 更新订单配送方式数据
that.updateOrder({way: $this.data('id')});
// 重新计算订单价格
compute();
});
this.$deliveryTime.click(function() {
... ... @@ -146,5 +243,239 @@ deliveryWay = {
}
};
coupon = {
$el: $('#use-coupons'),
init: function() {
if (!this.$el.length) {
return;
}
this.$couponWrap = this.$el.next();
this.$errorTip = $('.coupon-err-tip', this.$el);
this.$ticketUseTip = $('.ticket-use-tip', this.$couponWrap);
this.$couponCode = $('.coupon-code', this.$couponWrap);
this.$couponList = $('.coupon-list-wrap', this.$couponWrap);
this.couponsTpl = Hbs.compile($('#coupons-tpl').html());
this.getList();
this.eventBind();
},
getList: function() {
var that = this;
$.ajax({
type: 'GET',
url: '/cart/ensure/coupons'
}).then(function(data) {
if (data.code === 200) {
$('.coupon-list-wrap', that.$couponWrap).html(that.couponsTpl(data.data));
that.$radios = that.$couponWrap.find('.coupon-radio');
}
});
},
eventBind: function() {
var that = this;
this.$couponWrap.on('click', '.radio-btn', function() {
var $this = $(this);
if ($this.hasClass('on')) {
return;
}
$this.siblings('.radio-btn.on').removeClass('on');
$this.addClass('on').parent().toggleClass('using-code');
if ($this.hasClass('code')) {
that.cancelTicketUse();
that.$couponList.slideUp();
} else {
that.cancelCodeUse();
that.$couponList.slideDown();
}
}).on('click', '.cancel-use-ticket', function() {
that.cancelTicketUse();
}).on('change', '.coupon-code', function() {
that.$errorTip.empty();
}).on('click', '.opt-area > label', function() {
var $this = $(this);
var couponId, data;
if ($this.hasClass('sure-use-ticket')) {
data = that.$radios.filter('.on').data();
if (data) {
that.$ticketUseTip.find('.price').text('- ¥' + data.price);
that.$ticketUseTip.removeClass('hide');
couponId = data.id;
}
} else {
couponId = $this.siblings('.coupon-code').val();
}
if (couponId) {
order.couponCode = couponId;
// 重新计算订单价格
compute();
}
}).on('click', '.coupon-radio', function() {
var $this = $(this);
if ($this.hasClass('on')) {
return;
}
if (that.$radios) {
that.$radios.filter('.on').removeClass('on');
}
$this.addClass('on');
});
},
cancelTicketUse: function() {
if (order.couponCode) {
this.$ticketUseTip.addClass('hide');
this.$radios.filter('.on').removeClass('on');
delete order.couponCode;
compute(); // 重新计算订单价格
}
},
cancelCodeUse: function() {
this.$errorTip.empty();
this.$couponCode.val('');
if (order.couponCode) {
delete order.couponCode;
compute(); // 重新计算订单价格
}
}
};
yohoCoin = {
$el: $('#yoho-coin-box'),
init: function() {
var data;
if (!this.$el.length) {
return;
}
data = this.$el.data();
if (data) {
order.coin = data.coin || 0;
this.maxCoin = data.max;
}
this.eventBind();
},
eventBind: function() {
var that = this;
this.$el.on('click', '.coin-use-btn', function() {
if (order.coin * 1 === this.maxCoin * 1) {
return;
}
compute(that.maxCoin);
}).on('click', '.coin-cancel-btn', function() {
if (order.coin * 1 === 0) {
return;
}
compute();
});
}
};
$('.locker-switch').click(function() {
var $this = $(this),
$par = $this.parent();
$par.toggleClass('open');
if ($par.hasClass('open')) {
$this.html(iconCode.on);
} else {
$this.html(iconCode.off);
}
});
$('#red-packet-box').on('click', '.radio-btn', function() {
$(this).toggleClass('on');
}).on('click', '.sure-btn', function() {
var $this = $(this),
num = $this.data('num');
if (!num) {
return;
}
if ($this.siblings('.on').length) {
order.redEnvelopes = num;
} else if (order.redEnvelopes) {
delete order.redEnvelopes;
}
compute(); // 重新计算订单价格
});
$('#remark-box').on('keyup', '.note-text', function() {
var $this = $(this);
var val = $.trim($this.val());
if (val) {
$this.addClass('has-text');
if (val.length > 100) {
val = val.substring(0, 99);
$this.val(val);
}
order.remark = val;
} else {
$this.removeClass('has-text');
}
}).on('click', '.radio-btn', function() {
var $this = $(this);
if ($this.hasClass('on')) {
return;
}
if ($this.hasClass('unprint')) {
order.printPrice = 'N';
} else {
order.printPrice = 'Y';
}
$this.siblings('.on').removeClass('on');
$this.addClass('on');
});
$('#order-submit').click(function() {
var invoiceInfo = invoice.getInvoice();
order.addressId = address.getAddress();
// 发票信息
if (invoiceInfo) {
$.extend(order, invoiceInfo);
}
$.ajax({
type: 'POST',
url: '/cart/ensure/submit',
data: order
}).then(function(data) {
if (data.code === 200) {
location.href = data.data.url;
}
});
});
payWay.init();
deliveryWay.init();
coupon.init();
yohoCoin.init();
... ...
... ... @@ -22,6 +22,8 @@ var addressTpl = hbs.compile($('#address-tpl').html()),
var addrList = {},
addrDefault = '';
var addrSelect;
$('.addr-item').each(function() {
var data = $(this).data();
... ... @@ -168,6 +170,7 @@ function setShowDeliveryAddr(data) {
}
if (data) {
addrSelect = data.id;
_h = '寄送至:' + data.area + '&nbsp;&nbsp;&nbsp;&nbsp;' + data.address +
'<br>收货人:' + data.consignee + '&nbsp;&nbsp;&nbsp;&nbsp;' + data.mobile;
}
... ... @@ -377,3 +380,8 @@ $('.addr-opt').on('click', 'span', function() {
});
setShowDeliveryAddr();
// 获取地址信息
exports.getAddress = function() {
return addrSelect;
};
... ...
/**
* 订单结算页
* 订单结算页-发票
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/12/29
*/
... ...
... ... @@ -483,11 +483,351 @@
border: 1px solid $borderColor;
border-bottom-color: #fff;
dt {
line-height: 40px;
> .iconfont {
font-size: 18px;
margin-right: 10px;
vertical-align: top;
cursor: pointer;
}
}
dd {
display: none;
}
.open + dd {
display: block;
}
}
.use-coupons {
.tip-box {
width: 60%;
color: $red;
position: relative;
text-align: right;
display: none;
}
.coupon-err-tip {
width: 100%;
background-color: #fff;
position: absolute;
top: 0;
}
&.open > .tip-box {
display: block;
}
}
.coupon-opt-title {
height: 50px;
line-height: 50px;
padding: 0 30px;
background-color: #f0f0f0;
.ticket-use-tip {
margin-left: 20px;
.red {
color: $red;
}
.cancel-use-ticket {
color: #1987cf;
margin-left: 20px;
cursor: pointer;
}
}
.opt-area {
line-height: 1;
margin-top: 13px;
border: 1px solid #000;
background-color: #fff;
> input {
width: 174px;
line-height: 24px;
border: none;
padding: 0 10px;
font-size: 14px;
display: none;
}
> label {
color: #fff;
background-color: #000;
width: 78px;
height: 24px;
line-height: 24px;
text-align: center;
cursor: pointer;
display: none;
}
.sure-use-code {
float: right;
}
.sure-use-ticket {
display: inline-block;
}
}
&.using-code .opt-area {
> * {
display: inline-block;
}
.sure-use-ticket {
display: none;
}
}
}
.coupon-list-wrap {
padding: 0 30px;
border: 1px solid #e8e8e8;
line-height: 18px;
.empty-tip {
line-height: 24px;
padding-top: 10px;
}
li {
padding: 6px 0;
}
.unusable-list {
color: #999;
border-top: 1px solid #e8e8e8;
margin: 10px 0;
}
.useable-title,
.unuseable-title {
color: #444;
line-height: 30px;
margin-top: 6px;
}
.title {
width: 340px;
display: inline-block;
}
.time {
width: 340px;
display: inline-block;
}
.money {
width: 170px;
display: inline-block;
}
.coupon-radio {
display: inline-block;
width: 15px;
height: 15px;
margin-right: 6px;
background-image: url(/cart/radio-off.png);
display: inline-block;
vertical-align: middle;
position: relative;
top: -1px;
cursor: pointer;
&.on {
background-image: url(/cart/radio-check.png);
}
}
}
.yoho-coin-box {
line-height: 24px;
padding: 10px 30px;
background-color: #f0f0f0;
position: relative;
.grey {
color: #a9a9a9;
}
.red {
color: $red;
}
.outer-view {
width: 70%;
position: absolute;
right: 0;
top: -32px;
padding-right: 20px;
text-align: right;
.help-icon {
position: absolute;
right: 0;
top: 0;
cursor: pointer;
&:hover + .coin-tip-help {
display: block;
}
}
}
.help-icon {
position: absolute;
right: 0;
top: 0;
cursor: pointer;
&:hover + .coin-tip-help {
display: block;
}
}
.coin-tip-help {
width: 304px;
padding: 6px 10px;
line-height: 2;
border: 1px solid #000;
background-color: #fff;
text-align: left;
position: absolute;
top: 28px;
right: -8px;
display: none;
&:before {
content: '';
width: 12px;
height: 6px;
background-image: url('/cart/row.png');
display: block;
position: absolute;
top: -6px;
right: 10px;
}
> p:first-child {
font-weight: 700;
}
.rs-text {
color: #999;
}
}
.coin-main-view {
> * {
display: inline-block;
}
> label {
width: 76px;
height: 22px;
line-height: 22px;
display: inline-block;
border: 1px solid #000;
background-color: #fff;
text-align: center;
cursor: pointer;
float: right;
}
p:first-child {
margin-right: 40px;
}
.coin-cancel-btn {
color: #fff;
background-color: #000;
margin-left: 18px;
> span {
display: none;
}
}
}
}
.red-packet-box {
padding: 10px 10px;
background-color: #f0f0f0;
line-height: 24px;
.radio-btn {
margin-right: 0;
}
.sure-btn {
width: 78px;
float: right;
background-color: #000;
color: #fff;
text-align: center;
margin-right: 20px;
cursor: pointer;
}
}
.remark-box {
padding: 30px 20px 0;
background-color: #f0f0f0;
.note-text-box {
border: 1px solid #e0e0e0;
background-color: #fff;
overflow: hidden;
.tip-text {
padding: 10px;
color: #a9a9a9;
}
}
.note-text {
width: 888px;
height: 84px;
padding: 8px 10px;
font-size: 14px;
line-height: 1.5;
border: none;
resize: none;
background: none;
margin-top: -34px;
}
.has-text {
background-color: #fff;
}
.pp-area {
line-height: 50px;
padding-bottom: 4px;
> span {
color: #a9a9a9;
}
}
}
.balance-wrap {
font-size: 13px;
line-height: 2;
... ... @@ -645,17 +985,6 @@
position: absolute;
padding-left: 94px;
line-height: 1.5;
/* &:before {
content: '';
width: 16px;
height: 16px;
margin-right: 6px;
background: url('/cart/error-ico.png');
display: inline-block;
position: relative;
top: 4px;
}*/
}
.area-box {
... ...