Back.php
5.86 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use Passport\PassportModel;
use Plugin\Helpers;
use LibModels\Wap\Passport\BackData;
use Plugin\AuthCode;
class BackController extends WebAction
{
/**
* 找回密码
*/
public function indexAction()
{
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'backPage' => true,
'back' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countryCode' => '86',
'countryName' => '中国',
'countryList' => RegData::getAreasData(),
)
);
$this->_view->display('index', $data);
}
public function authcodeAction()
{
echo $this->echoJson(array('code'=> 200));
}
/**
*
*/
public function emailAction()
{
$phoneNum = $this->post('phoneNum','');
$area = $this->post('area','86');
$captcha = $this->post('captcha','');
if(Helpers::verifyEmail($phoneNum)){ //验证邮箱
$email = $phoneNum;
$data = BackData::sendCodeToEmail($email);
$this->setSession('phoneNum', $phoneNum);
if($data['code'] == 200) {
$this->redirect('sendemail');
}
else {
$this->redirect('index');
}
} else if(Helpers::verifyMobile($phoneNum)) {//验证手机号
$mobile = $phoneNum;
$data = BackData::sendCodeToMobile($mobile);
$this->setSession('phoneNum', $phoneNum);
$this->setSession('area', $area);
if($data['code'] == 200) {
$this->redirect('verification');
}
else {
$this->redirect('index');
}
}
}
/**
* 发送邮件
*/
public function sendemailAction() {
$phoneNum = $this->getSession('phoneNum');
if(empty($phoneNum)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$simpleHeader = array(
'logo' => array(
'img' => 'http://static.yohobuy.com/newheader/img/logo_e.png',
'url' => 'http://www.yohobuy.com'
),
'tool' => array(
'user' => '2586703@qq.com',
'userCenter' => '',
'loginHref' => '',
'logoutHref' => '',
'registerHref' => '',
'favoriteHref' => '',
'couponHref' => '',
'orderHref' => '',
'helpHref' => ''
)
);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'sendEmail' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
)
);
$this->_view->display('send-email', $data);
}
/**
* 重置密码
*/
public function backcodeAction() {
$code = $this->get('code');
$info = $this->checkCode($code);
if(empty($info)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'resetPage' => true,
'resetPwd' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
)
);
$this->_view->display('reset-pwd', $data);
}
/**
* 更新密码
*
*/
public function updateAction()
{
$code = $this->post('code');
$password = $this->post('pwd');
$info = $this->checkCode($code);
if(Helpers::verifyPassword($password) && !empty($info)) {
$uid = $info['uid'];
//修改密码
}
}
/**
* 重置密码成功
*/
public function resetSuccessAction() {
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'resetSuccess' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
)
);
$this->_view->display('reset-success', $data);
}
/**
* 手机验证
*/
public function verificationAction() {
$phoneNum = $this->getSession('phoneNum');
$area = $this->getSession('area');
// if(empty($phoneNum)) {
// $this->redirect('index');
// }
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'vertificationPage' => true,
'verification' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'phoneNum' => $phoneNum,
'area' => $area,
'countrys' => array()
)
);
$this->_view->display('verification', $data);
}
/**
* 检查code
*
* @param string $code
* @return boolean
*/
private function checkCode($code)
{
$key = '_+@#$%^';
$code = base64_decode($code);
$info = json_decode(AuthCode::decode($code, $key), true);
if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
return array();
}
return $info;
}
}