Girlday.php
2.72 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
108
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2016/3/2
* Time: 10:48
*/
use Action\HuodongWebAction;
use Cuxiao\GirldayModel;
use WebPlugin\Helpers;
/**
* 女生节活动领券-第二波
* @author Administrator
*/
class GirldayController extends HuodongWebAction
{
// const STATIC_FILE = 'http://localhost:2222/1.0.3';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016xinshili-2-web/1.0.3';
/**
* 检测登录状态
*
* @return int
*/
private function getLoggedUid()
{
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
}
return $uid;
}
/**
* 判断是否登录
*/
private function checkLogin()
{
$url = Helpers::url('/cuxiao/girlday/index');
$uid = $this->getLoggedUid();
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $url), 'default'));
}
}
/**
* 根据环境来获取活动ID
*
* @return int
*/
private function getActivityId()
{
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 528;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 528; //490;
}
}
/**
* 领券接口
*/
public function sendCouponAction()
{
$result = array('code' => 201);
do {
if (!$this->isAjax()) {
break;
}
$activityId = $this->getActivityId();
$uid = $this->getLoggedUid();
$result = GirldayModel::getGirldayCoupon($uid, $activityId);
} while (false);
$this->echoJson($result);
}
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/10/10/020ea7cb1f9c2f26b14e08107f778485ff.jpg',
'url' => 'http://www.yohobuy.com/special_14548_0310PCHOME.html',
),
'selectUrl' => 'http://www.yohobuy.com/home/coupons',
));
}
}