Xinshili.php
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
use Action\HuodongWebAction;
use Cuxiao\XinshiliModel;
use WebPlugin\Helpers;
/**
* 新势力领券活动
*/
class XinshiliController extends HuodongWebAction
{
// const STATIC_FILE = 'http://localhost:2222/1.0.6';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016xinshili-web/1.0.6';
/**
* 检测登录状态
*
* @return int
*/
private function getLoggedUid()
{
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
}
return $uid;
}
/**
* 判断是否登录
*/
private function checkLogin()
{
$playUrl = Helpers::url('/cuxiao/xinshili/index');
$uid = $this->getLoggedUid();
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $playUrl), 'default'));
}
}
/**
* 领券活动页面控制器
*/
public function indexAction()
{
$this->checkLogin();
//获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
$myCouponUrl = Helpers::url('/home/coupons', null, 'default');
$this->_view->display('index', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'home.js'
),
'couponUrl' => $myCouponUrl, // 个人中心优惠券地址
'banner' => array(
'img' => 'http://img02.yohoboys.com/staticimg/2016/03/04/09/021a94b08418c4416785d37a47088aac58.jpg',
'url' => 'http://www.yohobuy.com/special_14444_0302PCHOME.html'
)
));
}
/**
* 领券接口
*/
public function sendCouponAction()
{
$result = array('code' => 201);
do {
if (!$this->isAjax()) {
break;
}
$activityId = $this->getActivityId();
$uid = $this->getLoggedUid();
$result = XinshiliModel::getXinshiliCoupon($uid, $activityId);
} while (false);
$this->echoJson($result);
}
/**
* 根据环境来获取活动ID
*
* @return int
*/
private function getActivityId()
{
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 506;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 506;
}
}
}