Authored by 郭成尧

modified-code

... ... @@ -5,7 +5,6 @@
*/
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
ellipsis = require('yoho-mlellipsis'),
loading = require('../plugin/loading'),
tip = require('../plugin/tip'),
... ... @@ -125,34 +124,30 @@ function getCouponHandle(allCoupons) {
// 渲染可用的优惠券
$couponList.append(conponTmpl({
coupons: coupons
})).find('.employ-main').each(function(i, elem) {
var employHammer = new Hammer(elem);
employHammer.on('tap', function() {
var couponCode = $(elem).data('coupon-code');
$.ajax({
method: 'POST',
url: '/cart/index/new/couponSearch',
data: {
couponCode: couponCode
}
}).then(function(res) {
if (res.code === 200) {
// tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
orderInfo('couponName', res.data.coupon_title);
// 实付金额发生变化,使用有货币为0
orderInfo('yohoCoin', 0);
window.location.href = '/cart/index/new/orderEnsure';
} else if (res.message) {
tip.show(res.message);
}
}).fail(function() {
tip.show('网络错误');
});
})).find('.employ-main').on('touchstart', function() {
var couponCode = $(this).data('coupon-code');
$.ajax({
method: 'POST',
url: '/cart/index/new/couponSearch',
data: {
couponCode: couponCode
}
}).then(function(res) {
if (res.code === 200) {
// tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
orderInfo('couponName', res.data.coupon_title);
// 实付金额发生变化,使用有货币为0
orderInfo('yohoCoin', 0);
window.location.href = '/cart/index/new/orderEnsure';
} else if (res.message) {
tip.show(res.message);
}
}).fail(function() {
tip.show('网络错误');
});
});
... ...