1
|
<?php
|
1
|
<?php
|
2
|
|
2
|
|
3
|
use Action\AbstractAction;
|
3
|
use Action\AbstractAction;
|
4
|
-use LibModels\Wap\Passport\LoginData;
|
|
|
5
|
-use LibModels\Wap\Passport\RegData;
|
4
|
+use LibModels\Wap\Passport\BindData;
|
6
|
use Plugin\Helpers;
|
5
|
use Plugin\Helpers;
|
7
|
-use Plugin\Partner\Factory;
|
|
|
8
|
|
6
|
|
9
|
/**
|
7
|
/**
|
10
|
* 登录的控制器
|
8
|
* 登录的控制器
|
|
@@ -17,61 +15,233 @@ class BindController extends AbstractAction |
|
@@ -17,61 +15,233 @@ class BindController extends AbstractAction |
17
|
*/
|
15
|
*/
|
18
|
public function indexAction()
|
16
|
public function indexAction()
|
19
|
{
|
17
|
{
|
20
|
-
|
|
|
21
|
$this->setTitle('绑定手机号');
|
18
|
$this->setTitle('绑定手机号');
|
22
|
-
|
19
|
+ $openId = $this->get('openId');
|
|
|
20
|
+ $sourceType = $this->get('sourceType');
|
|
|
21
|
+ $nickName = $this->get('nickName');
|
23
|
$data = array(
|
22
|
$data = array(
|
24
|
- 'loginIndex' => true, // 模板中使用JS的标识
|
|
|
25
|
- 'backUrl' => '/', // 返回的URL链接
|
|
|
26
|
- 'showHeaderImg' => true, // 控制显示头部图片
|
|
|
27
|
- 'isPassportPage' => true, // 模板中模块标识
|
|
|
28
|
- 'registerUrl' => '/reg.html', // 注册的URL链接
|
|
|
29
|
- 'aliLoginUrl' => '/passport/login/alipay', // 支付宝快捷登录的URL链接
|
|
|
30
|
- 'weiboLoginUrl' => '/passport/login/sina', // 微博登录的URL链接
|
|
|
31
|
- 'qqLoginUrl' => '/passport/login/qq', // 腾讯QQ登录的URL链接
|
|
|
32
|
- 'internationalUrl' => '/login.html', // 国际号登录的URL链接
|
|
|
33
|
- 'phoneRetriveUrl' => '/passport/back/mobile', // 通过手机号找回密码的URL链接
|
|
|
34
|
- 'emailRetriveUrl' => '/passport/back/email', // 通过邮箱找回密码的URL链接
|
23
|
+ 'sourceType' => $sourceType, // 第三方登录来源
|
|
|
24
|
+ 'openId' => $openId, // openId
|
|
|
25
|
+ 'nickname' => $nickName, //昵称
|
35
|
);
|
26
|
);
|
36
|
|
27
|
|
37
|
// 渲染模板
|
28
|
// 渲染模板
|
38
|
$this->_view->display('index', $data);
|
29
|
$this->_view->display('index', $data);
|
39
|
}
|
30
|
}
|
40
|
|
31
|
|
|
|
32
|
+ /**
|
|
|
33
|
+ * 手机验证码页面
|
|
|
34
|
+ */
|
|
|
35
|
+ public function codeAction()
|
|
|
36
|
+ {
|
|
|
37
|
+
|
|
|
38
|
+ $this->setTitle('验证手机');
|
|
|
39
|
+ $openId = $this->get('openId');
|
|
|
40
|
+ $sourceType = $this->get('sourceType');
|
|
|
41
|
+ $nickName = $this->get('nickName');
|
|
|
42
|
+ $area = $this->get('areaCode', '86');
|
|
|
43
|
+ $isReg = $this->get('isReg');
|
|
|
44
|
+
|
|
|
45
|
+ $data = array(
|
|
|
46
|
+ 'sourceType' => $sourceType, // 第三方登录来源
|
|
|
47
|
+ 'openId' => $openId, // openId
|
|
|
48
|
+ 'nickname' => $nickName, //昵称
|
|
|
49
|
+ 'isReg' => $isReg, //是否是已注册过的手机号
|
|
|
50
|
+ 'area' => $area //国别码
|
|
|
51
|
+ );
|
|
|
52
|
+
|
|
|
53
|
+ // 渲染模板
|
|
|
54
|
+ $this->_view->display('code', $data);
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+ /**
|
|
|
58
|
+ * 设置登录密码页面
|
|
|
59
|
+ */
|
|
|
60
|
+ public function passwordAction()
|
|
|
61
|
+ {
|
|
|
62
|
+
|
|
|
63
|
+ $this->setTitle('重新设置登录密码');
|
|
|
64
|
+ $openId = $this->get('openId');
|
|
|
65
|
+ $sourceType = $this->get('sourceType');
|
|
|
66
|
+ $nickName = $this->get('nickName');
|
|
|
67
|
+ $area = $this->get('areaCode', '86');
|
|
|
68
|
+ $data = array(
|
|
|
69
|
+ 'sourceType' => $sourceType, // 第三方登录来源
|
|
|
70
|
+ 'openId' => $openId, // openId
|
|
|
71
|
+ 'nickname' => $nickName, //昵称
|
|
|
72
|
+ 'area' => $area //国别码
|
|
|
73
|
+ );
|
|
|
74
|
+
|
|
|
75
|
+ // 渲染模板
|
|
|
76
|
+ $this->_view->display('password', $data);
|
|
|
77
|
+ }
|
|
|
78
|
+
|
|
|
79
|
+ //绑定前手机号校验
|
|
|
80
|
+ public function bindCheckAction()
|
|
|
81
|
+ {
|
|
|
82
|
+ $data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
83
|
+
|
|
|
84
|
+ do
|
|
|
85
|
+ {
|
|
|
86
|
+ /* 判断是不是AJAX请求 */
|
|
|
87
|
+ if (!$this->isAjax())
|
|
|
88
|
+ {
|
|
|
89
|
+ break;
|
|
|
90
|
+ }
|
|
|
91
|
+
|
|
|
92
|
+ $mobile = $this->post('mobile');
|
|
|
93
|
+ $openId = $this->post('openId');
|
|
|
94
|
+ $area = $this->post('areaCode', '86');
|
|
|
95
|
+ $sourceType = $this->post('sourceType');
|
|
|
96
|
+ $nickName = $this->post('nickName');
|
|
|
97
|
+
|
|
|
98
|
+
|
|
|
99
|
+ if (!is_numeric($mobile) || !$openId || !$area || !$sourceType)
|
|
|
100
|
+ {
|
|
|
101
|
+ break;
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
|
104
|
+ $res = BindData::bindCheck($mobile, $openId, $sourceType);
|
|
|
105
|
+ if (!isset($res['code']))
|
|
|
106
|
+ {
|
|
|
107
|
+ break;
|
|
|
108
|
+ }
|
|
|
109
|
+ if ($res['code'] == 200)
|
|
|
110
|
+ {
|
|
|
111
|
+ $next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickName' => $nickName, 'areaCode' => $area, 'mobile' => $mobile));
|
|
|
112
|
+ $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('is_register' => $res['data']['is_register'], 'next' => $next));
|
|
|
113
|
+ }
|
|
|
114
|
+ else
|
|
|
115
|
+ {
|
|
|
116
|
+ $data = array('code' => 500, 'message' => $res['message'], 'data' => $res['data']);
|
|
|
117
|
+ }
|
|
|
118
|
+ }
|
|
|
119
|
+ while (false);
|
|
|
120
|
+
|
|
|
121
|
+ $this->echoJson($data);
|
|
|
122
|
+ }
|
|
|
123
|
+
|
|
|
124
|
+ //发送验证码
|
|
|
125
|
+ public function sendBindMsgAction()
|
|
|
126
|
+ {
|
|
|
127
|
+ $data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
128
|
+
|
|
|
129
|
+ do
|
|
|
130
|
+ {
|
|
|
131
|
+ /* 判断是不是AJAX请求 */
|
|
|
132
|
+ if (!$this->isAjax())
|
|
|
133
|
+ {
|
|
|
134
|
+ break;
|
|
|
135
|
+ }
|
|
|
136
|
+
|
|
|
137
|
+ $mobile = $this->post('mobile');
|
|
|
138
|
+
|
|
|
139
|
+ if (!is_numeric($mobile))
|
|
|
140
|
+ {
|
|
|
141
|
+ break;
|
|
|
142
|
+ }
|
|
|
143
|
+
|
|
|
144
|
+ $data = BindData::sendBindMsg($mobile);
|
|
|
145
|
+ if (!isset($data['code']))
|
|
|
146
|
+ {
|
|
|
147
|
+ break;
|
|
|
148
|
+ }
|
|
|
149
|
+ }
|
|
|
150
|
+ while (false);
|
|
|
151
|
+
|
|
|
152
|
+ $this->echoJson($data);
|
|
|
153
|
+ }
|
|
|
154
|
+
|
|
|
155
|
+ //校验短信验证码
|
|
|
156
|
+ public function checkBindMsgAction()
|
|
|
157
|
+ {
|
|
|
158
|
+ $data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
159
|
+
|
|
|
160
|
+ do
|
|
|
161
|
+ {
|
|
|
162
|
+ /* 判断是不是AJAX请求 */
|
|
|
163
|
+ if (!$this->isAjax())
|
|
|
164
|
+ {
|
|
|
165
|
+ break;
|
|
|
166
|
+ }
|
|
|
167
|
+
|
|
|
168
|
+ $mobile = $this->post('mobile');
|
|
|
169
|
+ $msgCode = $this->post('msgCode');
|
|
|
170
|
+
|
|
|
171
|
+ if (!is_numeric($mobile) || !$msgCode)
|
|
|
172
|
+ {
|
|
|
173
|
+ break;
|
|
|
174
|
+ }
|
|
|
175
|
+
|
|
|
176
|
+ $data = BindData::checkBindCode($mobile, $msgCode);
|
|
|
177
|
+ if (!isset($data['code']))
|
|
|
178
|
+ {
|
|
|
179
|
+ break;
|
|
|
180
|
+ }
|
|
|
181
|
+ }
|
|
|
182
|
+ while (false);
|
|
|
183
|
+
|
|
|
184
|
+ $this->echoJson($data);
|
|
|
185
|
+ }
|
|
|
186
|
+
|
|
|
187
|
+ //绑定手机号
|
|
|
188
|
+ public function bindMobileAction()
|
|
|
189
|
+ {
|
|
|
190
|
+ $data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
191
|
+
|
|
|
192
|
+ do
|
|
|
193
|
+ {
|
|
|
194
|
+ /* 判断是不是AJAX请求 */
|
|
|
195
|
+ if (!$this->isAjax())
|
|
|
196
|
+ {
|
|
|
197
|
+ break;
|
|
|
198
|
+ }
|
|
|
199
|
+
|
|
|
200
|
+ $mobile = $this->post('mobile');
|
|
|
201
|
+ $openId = $this->post('openId');
|
|
|
202
|
+ $area = $this->post('areaCode', '86');
|
|
|
203
|
+ $sourceType = $this->post('sourceType');
|
|
|
204
|
+ $nickName = $this->post('nickName');
|
|
|
205
|
+ $password = $this->post('password');
|
41
|
|
206
|
|
|
|
207
|
+ if (!is_numeric($mobile) || !$openId || !$sourceType || !$area)
|
|
|
208
|
+ {
|
|
|
209
|
+ break;
|
|
|
210
|
+ }
|
42
|
|
211
|
|
|
|
212
|
+ $res = BindData::bindMobile($openId, $nickName, $sourceType, $mobile, $area, $password);
|
|
|
213
|
+ if (!isset($res['code']))
|
|
|
214
|
+ {
|
|
|
215
|
+ break;
|
|
|
216
|
+ }
|
43
|
|
217
|
|
44
|
-// /**
|
|
|
45
|
-// * 支付宝账号登录:回调方法
|
|
|
46
|
-// */
|
|
|
47
|
-// public function alipaycallbackAction()
|
|
|
48
|
-// {
|
|
|
49
|
-// $realName = $this->_request->get('real_name');
|
|
|
50
|
-// $email = $this->_request->get('email');
|
|
|
51
|
-// $userId = $this->_request->get('user_id');
|
|
|
52
|
-//
|
|
|
53
|
-// $result = array();
|
|
|
54
|
-// if (isset($realName, $email, $userId)) {
|
|
|
55
|
-// $result = LoginData::signinByOpenID($realName, $userId, 'alipay');
|
|
|
56
|
-// }
|
|
|
57
|
-//
|
|
|
58
|
-// $refer = $this->getCookie('refer');
|
|
|
59
|
-// if (empty($refer)) {
|
|
|
60
|
-// $refer = SITE_MAIN . '/?go=1';
|
|
|
61
|
-// } else {
|
|
|
62
|
-// $refer = rawurldecode($refer);
|
|
|
63
|
-// }
|
|
|
64
|
-//
|
|
|
65
|
-// if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
66
|
-// $token = Helpers::makeToken($result['data']['uid']);
|
|
|
67
|
-// $this->setCookie('_TOKEN', $token);
|
|
|
68
|
-// $this->setSession('_TOKEN', $token);
|
|
|
69
|
-// $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
70
|
-// } else {
|
|
|
71
|
-// $this->go($refer);
|
|
|
72
|
-// }
|
|
|
73
|
-// }
|
218
|
+ //绑定成功,跳转页面
|
|
|
219
|
+ $refer = $this->getCookie('refer');
|
|
|
220
|
+ if (empty($refer))
|
|
|
221
|
+ {
|
|
|
222
|
+ $refer = SITE_MAIN . '/?go=1';
|
|
|
223
|
+ }
|
|
|
224
|
+ else
|
|
|
225
|
+ {
|
|
|
226
|
+ $refer = rawurldecode($refer);
|
|
|
227
|
+ }
|
74
|
|
228
|
|
|
|
229
|
+ if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid']))
|
|
|
230
|
+ {
|
|
|
231
|
+ $token = Helpers::makeToken($res['data']['uid']);
|
|
|
232
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
233
|
+ $this->setSession('_TOKEN', $token);
|
|
|
234
|
+ $refer = Helpers::syncUserSession($data['data']['uid'], $refer);
|
|
|
235
|
+ $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
|
|
|
236
|
+ }
|
|
|
237
|
+ else
|
|
|
238
|
+ {
|
|
|
239
|
+ $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
|
|
|
240
|
+ }
|
|
|
241
|
+ }
|
|
|
242
|
+ while (false);
|
75
|
|
243
|
|
|
|
244
|
+ $this->echoJson($data);
|
|
|
245
|
+ }
|
76
|
|
246
|
|
77
|
} |
247
|
} |