Authored by 郭成尧

领券DEMO

... ... @@ -2,6 +2,7 @@
<head>
<meta charset="UTF-8">
<title>领券楼层</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div>
... ... @@ -13,10 +14,27 @@
<div><a href=""><img src="{{picUrl}}" alt=""></a></div>
<div>
<div>状态:{{status}} 剩余数量:{{num}}</div>
<button onclick="receiveCoupon()">领券</button>
<div><a href="{{go}}">去逛逛</a></div>
</div>
</div>
{{/ coupons}}
</div>
<script type="application/javascript">
function receiveCoupon() {
$.ajax({
url:'http://m.dev.yohobuy.com/coupon/receiveCoupon',
method:'GET',
data:{id:12},
dataType:'html',
success:function (data) {
alert(data);
},
error:function (error) {
alert(error);
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...
<div>ID:{{id}}</div>
<div>状态:{{status}}</div>
<div>信息:{{message}}</div>
\ No newline at end of file
... ...
... ... @@ -29,26 +29,46 @@ class CouponController extends AbstractAction
'showTitle' => 1,
'coupons' => [
[
'id' => 1,
'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
'status' => 1,
'num' => '123',
'go'=>'http://m.dev.yohobuy.com/boys',
'couponIds' =>[8024,2564,3587]
],
[
'id' => 1,
'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
'status' => 2,
'num' => '0',
'go'=>'http://m.dev.yohobuy.com/boys',
'couponIds' =>[8024,2564,3587]
],
[
'id' => 1,
'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200',
'status' => 3,
'num'=>'456',
'go'=>'http://m.dev.yohobuy.com/boys',
'couponIds' =>[8024,2564,3587]
],
]
];
$this->_view->display('index', $data);
}
public function receiveCouponAction()
{
$receiveData = filter_input_array(INPUT_GET,array(
'id' => FILTER_DEFAULT
));
$returnData = [
'id' => $receiveData['id'],
'status' => 1,
'message' => '您已经领过券了!'
];
$this->_view->display('receive-coupon',$returnData);
}
}
\ No newline at end of file
... ...