Authored by liangxs

Merge branch 'feature/coupon' of http://git.dev.yoho.cn/web/yohobuy into feature/coupon

# Conflicts:
#	template/m.yohobuy.com/actions/index/coupon/index.phtml
@@ -3,6 +3,15 @@ @@ -3,6 +3,15 @@
3 */ 3 */
4 var $ = require('jquery'); 4 var $ = require('jquery');
5 var $receive = $('.coupon-right-re'); 5 var $receive = $('.coupon-right-re');
  6 +var $mask = $('.coupon-mask');
  7 +var $message = $('.coupon-message');
6 $receive.on('touchend',function(){ 8 $receive.on('touchend',function(){
7 - alert('sss') 9 + $.ajax({
  10 + url:'/coupon/receiveCoupon',
  11 + success:function(){
  12 + $mask.show();
  13 + $message.show();
  14 + },
  15 + error:function(){}
  16 + });
8 }); 17 });
1 -<div>ID:{{id}}</div>  
2 -<div>状态:{{status}}</div>  
3 -<div>信息:{{message}}</div>  
  1 +<div>信息:{{message}}</div>
@@ -24,32 +24,39 @@ class CouponController extends AbstractAction @@ -24,32 +24,39 @@ class CouponController extends AbstractAction
24 */ 24 */
25 public function floorAction() 25 public function floorAction()
26 { 26 {
27 - $data =[ 27 + $data = [
28 'title' => '热门推荐', 28 'title' => '热门推荐',
29 'showTitle' => 1, 29 'showTitle' => 1,
30 'coupons' => [ 30 'coupons' => [
31 [ 31 [
32 'id' => 1, 32 'id' => 1,
33 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', 33 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
34 - 'status' => 1,  
35 - 'num' => '123',  
36 - 'go'=>'http://m.dev.yohobuy.com/boys',  
37 - 'couponIds' =>[8024,2564,3587]  
38 - ],[  
39 - 'id' => 1,  
40 - 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',  
41 - 'status' => 1,  
42 - 'num' => '123',  
43 - 'go'=>'http://m.dev.yohobuy.com/boys',  
44 - 'couponIds' =>[8024,2564,3587]  
45 - ],[  
46 - 'id' => 1,  
47 - 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',  
48 - 'status' => 1,  
49 - 'num' => '123',  
50 - 'go'=>'http://m.dev.yohobuy.com/boys',  
51 - 'couponIds' =>[8024,2564,3587]  
52 - ] 34 + 'status' => true,
  35 + 'num' => 123,
  36 + 'go' => 'http://m.dev.yohobuy.com/boys',
  37 + 'couponIds' => [8024, 2564, 3587]
  38 + ], [
  39 + 'id' => 1,
  40 + 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
  41 + 'status' => false,
  42 + 'num' => 122,
  43 + 'go' => 'http://m.dev.yohobuy.com/boys',
  44 + 'couponIds' => [8024, 2564, 3587]
  45 + ], [
  46 + 'id' => 1,
  47 + 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
  48 + 'status' => 3,
  49 + 'num' => 0,
  50 + 'go' => 'http://m.dev.yohobuy.com/boys',
  51 + 'couponIds' => [8024, 2564, 3587]
  52 + ], [
  53 + 'id' => 1,
  54 + 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
  55 + 'status' => true,
  56 + 'num' => 123,
  57 + 'go' => 'http://m.dev.yohobuy.com/boys',
  58 + 'couponIds' => [8024, 2564, 3587]
  59 + ]
53 ] 60 ]
54 ]; 61 ];
55 62
@@ -61,19 +68,54 @@ class CouponController extends AbstractAction @@ -61,19 +68,54 @@ class CouponController extends AbstractAction
61 68
62 /** 69 /**
63 * 领券操作 70 * 领券操作
  71 + *
  72 + * @author Targaryen
64 */ 73 */
65 public function receiveCouponAction() 74 public function receiveCouponAction()
66 { 75 {
67 - $receiveData = filter_input_array(INPUT_GET,array(  
68 - 'id' => FILTER_DEFAULT 76 + $receiveData = filter_input_array(INPUT_GET, array(
  77 + 'couponIds' => FILTER_DEFAULT
69 )); 78 ));
70 - $returnData = [  
71 - 'id' => $receiveData['id'],  
72 - 'status' => 1,  
73 - 'message' => '您已经领过券了!'  
74 - ]; 79 + $returnData =array();
  80 + $couponIds = explode(',', str_replace(' ', '', $receiveData['couponIds']));
  81 + switch ($this->getCoupon($couponIds)){
  82 + case 1:
  83 + $returnData = [
  84 + 'message' => '领券成功!'
  85 + ];
  86 + break;
  87 + case 2:
  88 + $returnData = [
  89 + 'message' => '领券失败!'
  90 + ];
  91 + break;
  92 + case 3:
  93 + $returnData = [
  94 + 'message' => '券已经被领光了!'
  95 + ];
  96 + break;
  97 + default:
  98 + $returnData = [
  99 + 'message' => '未知错误!'
  100 + ];
  101 + break;
  102 + }
  103 + $this->_view->display('receive-coupon', $returnData);
  104 + }
75 105
76 - $this->_view->display('receive-coupon',$returnData); 106 + /**
  107 + * 领券接口模拟
  108 + *
  109 + * @param $couponIds
  110 + * @return array
  111 + * @internal param $couponId
  112 + */
  113 + public function getCoupon($couponIds)
  114 + {
  115 + foreach ($couponIds as $key => $value) {
  116 + // 后端一些处理操作
  117 + }
  118 + return rand(1,4);
77 } 119 }
78 120
79 } 121 }