Authored by 毕凯

修改输入优惠券号码直接使用

@@ -16,17 +16,17 @@ ellipsis.init(); @@ -16,17 +16,17 @@ ellipsis.init();
16 $('#search-coupon').on('submit', function() { 16 $('#search-coupon').on('submit', function() {
17 $.ajax({ 17 $.ajax({
18 method: 'POST', 18 method: 'POST',
19 - url: '', 19 + url: '/shoppingCart/coupon',
20 data: $(this).serialize() 20 data: $(this).serialize()
21 }).then(function(res) { 21 }).then(function(res) {
22 - if (res.avaliable) {  
23 - $('#coupon-list').html(conponTmpl({  
24 - coupons: res.coupons  
25 - }));  
26 - $('#coupon-list-not').html(''); 22 + if (res.code === 200) {
  23 + tip.show('优惠券可用');
  24 + window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code;
27 } else { 25 } else {
28 tip.show(res.msg); 26 tip.show(res.msg);
29 } 27 }
  28 + }).fail(function() {
  29 + tip.show('网络错误');
30 }); 30 });
31 return false; 31 return false;
32 }); 32 });
@@ -36,23 +36,23 @@ function getCouponHandle(coupons) { @@ -36,23 +36,23 @@ function getCouponHandle(coupons) {
36 36
37 // 后端需要返回一个 coupons 列表,如下 37 // 后端需要返回一个 coupons 列表,如下
38 // notAvailable 表示不可用的优惠券 38 // notAvailable 表示不可用的优惠券
39 - coupons = [{  
40 - money: '99',  
41 - coupon_name: '满XX-减去吴悠右腿有益于有2222',  
42 - couponValidity: '20150129-20150430',  
43 - coupon_id: '22222'  
44 - }, {  
45 - money: '99',  
46 - coupon_name: '满XX-减去吴悠右腿有益于有2222',  
47 - couponValidity: '20150129-20150430',  
48 - coupon_id: '2222233'  
49 - }, {  
50 - money: '99',  
51 - coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222',  
52 - couponValidity: '20150129-20150430',  
53 - coupon_id: '2222233',  
54 - notAvailable: 1  
55 - }]; 39 + // coupons = [{
  40 + // money: '99',
  41 + // coupon_name: '满XX-减去吴悠右腿有益于有2222',
  42 + // couponValidity: '20150129-20150430',
  43 + // coupon_id: '22222'
  44 + // }, {
  45 + // money: '99',
  46 + // coupon_name: '满XX-减去吴悠右腿有益于有2222',
  47 + // couponValidity: '20150129-20150430',
  48 + // coupon_id: '2222233'
  49 + // }, {
  50 + // money: '99',
  51 + // coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222',
  52 + // couponValidity: '20150129-20150430',
  53 + // coupon_id: '2222233',
  54 + // notAvailable: 1
  55 + // }];
56 56
57 // coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算 57 // coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算
58 if (!$.isArray(coupons)) { 58 if (!$.isArray(coupons)) {
@@ -106,9 +106,8 @@ function getCouponDate() { @@ -106,9 +106,8 @@ function getCouponDate() {
106 $.ajax({ 106 $.ajax({
107 type: 'POST', 107 type: 'POST',
108 url: '/home/couponData', 108 url: '/home/couponData',
109 - dataType: 'html', 109 + dataType: 'json',
110 data: { 110 data: {
111 - statuss: status,  
112 page: page 111 page: page
113 } 112 }
114 }).then(getCouponHandle).fail(function() { 113 }).then(getCouponHandle).fail(function() {
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="yoho-page select-coupon-page my-coupon-page"> 2 <div class="yoho-page select-coupon-page my-coupon-page">
3 <form id="search-coupon" method="POST" action=""> 3 <form id="search-coupon" method="POST" action="">
4 - <input type="text" name="coupon-code" value="" placeholder="输入优惠券码"> 4 + <input type="text" name="couponCode" value="" placeholder="输入优惠券码">
5 <button type="submit" class="submit">确定</button> 5 <button type="submit" class="submit">确定</button>
6 </form> 6 </form>
7 <div id="coupon-list" class="coupon-list"></div> 7 <div id="coupon-list" class="coupon-list"></div>
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <script id="tmpl-coupon" type="text/tmpl"> 11 <script id="tmpl-coupon" type="text/tmpl">
12 \{{#coupons}} 12 \{{#coupons}}
13 \{{^ notAvailable}} 13 \{{^ notAvailable}}
14 - <a class="employ-main" href="/shoppingCart/orderEnsure?coupon_id={{ coupon_id}}"> 14 + <a class="employ-main" href="/shoppingCart/orderEnsure?coupon_code={{ coupon_code}}">
15 <span>\{{ money}}</span> 15 <span>\{{ money}}</span>
16 <p class="coupon-name">\{{ coupon_name}}</p> 16 <p class="coupon-name">\{{ coupon_name}}</p>
17 <p>有效期:\{{ couponValidity}}</p> 17 <p>有效期:\{{ couponValidity}}</p>
@@ -33,7 +33,7 @@ class ShoppingCartController extends AbstractAction @@ -33,7 +33,7 @@ class ShoppingCartController extends AbstractAction
33 33
34 /** 34 /**
35 * 加入购物车 35 * 加入购物车
36 - * 36 + *
37 * @param string productSku 商品的SKU 37 * @param string productSku 商品的SKU
38 * @param int buyNumber 购买数量 38 * @param int buyNumber 购买数量
39 * @param int promotionId 促销ID, 加价购有关 39 * @param int promotionId 促销ID, 加价购有关
@@ -53,10 +53,10 @@ class ShoppingCartController extends AbstractAction @@ -53,10 +53,10 @@ class ShoppingCartController extends AbstractAction
53 $promotionId = $this->post('promotionId', 0); 53 $promotionId = $this->post('promotionId', 0);
54 $isEdit = $this->post('isEdit', 0); 54 $isEdit = $this->post('isEdit', 0);
55 $uid = $this->getUid(true); 55 $uid = $this->getUid(true);
56 - 56 +
57 // 执行加入购物车操作 57 // 执行加入购物车操作
58 $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey); 58 $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
59 - 59 +
60 // 设置加入购物车凭证到客户端浏览器 60 // 设置加入购物车凭证到客户端浏览器
61 if (isset($result['data']['shopping_key'])) { 61 if (isset($result['data']['shopping_key'])) {
62 $this->setCookie('_spk', $shoppingKey); 62 $this->setCookie('_spk', $shoppingKey);