Authored by 毕凯

修改优惠券使用方式

/**
* 订单信息读取
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var info = window.cookie('order-info'),
orderInfo;
// info 必须是 JSON 字符串
try {
info = JSON.parse(orderInfo);
} catch (e) {
info = {};
}
orderInfo = function(key, value) {
if (value === undefined) {
return info[key];
}
info[key] = value;
window.setCookie('order-info', JSON.stringify(info));
};
module.export = orderInfo;
... ...
/**
* 优惠券选择
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/10
*/
var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
ellipsis = require('mlellipsis'),
loading = require('../plugin/loading'),
tip = require('../plugin/tip');
tip = require('../plugin/tip'),
orderInfo = require('./order-info');
var page = 1,
canGetCoupon = true,
... ... @@ -21,9 +28,10 @@ $('#search-coupon').on('submit', function() {
}).then(function(res) {
if (res.code === 200) {
tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code;
} else {
tip.show(res.msg);
tip.show(res.message);
}
}).fail(function() {
tip.show('网络错误');
... ... @@ -31,6 +39,10 @@ $('#search-coupon').on('submit', function() {
return false;
});
$('#coupon-list').on('touchend', 'employ-main', function() {
orderInfo('couponCode', $(this).data('coupon-code'));
});
function getCouponHandle(coupons) {
var notAvailableCoupons = [];
... ...
... ... @@ -11,7 +11,7 @@
<script id="tmpl-coupon" type="text/tmpl">
\{{#coupons}}
\{{^ notAvailable}}
<a class="employ-main" href="/shoppingCart/orderEnsure?coupon_code={{ coupon_code}}">
<a class="employ-main" data-coupon-code="{{ coupon_code}}" href="/shoppingCart/orderEnsure?coupon_code={{ coupon_code}}">
<span>\{{ money}}</span>
<p class="coupon-name">\{{ coupon_name}}</p>
<p>有效期:\{{ couponValidity}}</p>
... ...