Gift.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
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use Home\UserModel;
use LibModels\Web\Home\UserData;
use Passport\PassportModel;
use Home\CurrencyModel;
/**
* 个人中心 礼品卡兑换
*/
class GiftController extends WebAction
{
/**
* 礼品卡页面
*/
public function indexAction()
{
//判断是否登录
$uid = $this->auditJumpLogin();
//头部导航
$channel = Helpers::getChannelNameByCookie();
$this->setWebNavHeader($channel);
//面包屑-左侧导航
$path = UserModel::getCenterCrumb('兑换礼品卡');
$leftNav = UserModel::getCenterLeftNav('兑换礼品卡', $uid);
$type = $this->get('type', '');
$data = array(
'path' => $path,
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => $leftNav,
);
if ($type) {
//yohocoin信息
$yohoCoinInfo = CurrencyModel::currencyTotal($uid);
$yohoCoin = isset($yohoCoinInfo['data']['yohocoin_num']) ? $yohoCoinInfo['data']['yohocoin_num'] : 0;
$success = ($type == 1) ? true : false;
$data['resultInfo'] = array('success' => $success, 'yohoCoin' => $yohoCoin);
}
else {
$data['resultInfo'] = false;
}
$this->_view->display('gift', array(
'gift' => $data,
'meGiftPage' => true
));
}
/**
* 个人中心-兑换礼品卡提交返回信息
*/
public function exchangeAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$uid = $this->auditJumpLogin();
$giftCardCode1 = trim($this->post('giftCardCode1', ''));
$giftCardCode2 = trim($this->post('giftCardCode2', ''));
$giftCardCode3 = trim($this->post('giftCardCode3', ''));
$captchaCode = strtolower(trim($this->post('verifyCode', '')));
if (!PassportModel::verifyCode($captchaCode)) {
$data['code'] = 400;
$data['message'] = '图形验证码不正确';
break;
}
$data = UserData::exchangeGift($uid, $giftCardCode1, $giftCardCode2, $giftCardCode3, $captchaCode);
if (!isset($data['code'])) {
break;
}
}
while (false);
$this->echoJson($data);
}
}