Authored by xiaowei

第三方手机号绑定流程

@@ -87,18 +87,14 @@ class AutosignController extends WebAction @@ -87,18 +87,14 @@ class AutosignController extends WebAction
87 } 87 }
88 88
89 //判定是否需要绑定手机号 89 //判定是否需要绑定手机号
90 - if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {  
91 - $token = Helpers::makeToken($result['data']['uid']);  
92 - $this->setSession('_TOKEN', $token);  
93 - $this->setSession('_LOGIN_UID', $result['data']['uid']);  
94 - $this->setCookie('_TOKEN', $token);  
95 - $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));  
96 - $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf)); 90 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  91 + $fillHerf = Helpers::url('/passport/thirdlogin/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName));
  92 + $this->go($fillHerf);
97 } 93 }
98 94
99 $refer = $this->getCookie('refer'); 95 $refer = $this->getCookie('refer');
100 if (empty($refer)) { 96 if (empty($refer)) {
101 - $refer = SITE_MAIN . '/?go=1'; 97 + $refer = SITE_MAIN;
102 } 98 }
103 else { 99 else {
104 $refer = rawurldecode($refer); 100 $refer = rawurldecode($refer);
@@ -174,18 +170,14 @@ class AutosignController extends WebAction @@ -174,18 +170,14 @@ class AutosignController extends WebAction
174 } 170 }
175 171
176 //判定是否需要绑定手机号 172 //判定是否需要绑定手机号
177 - if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {  
178 - $token = Helpers::makeToken($result['data']['uid']);  
179 - $this->setSession('_TOKEN', $token);  
180 - $this->setSession('_LOGIN_UID', $result['data']['uid']);  
181 - $this->setCookie('_TOKEN', $token);  
182 - $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));  
183 - $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf)); 173 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  174 + $fillHerf = Helpers::url('/passport/thirdlogin/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name']));
  175 + $this->go($fillHerf);
184 } 176 }
185 177
186 $refer = $this->getCookie('refer'); 178 $refer = $this->getCookie('refer');
187 if (empty($refer)) { 179 if (empty($refer)) {
188 - $refer = SITE_MAIN . '/?go=1'; 180 + $refer = SITE_MAIN;
189 } 181 }
190 else { 182 else {
191 $refer = rawurldecode($refer); 183 $refer = rawurldecode($refer);
@@ -218,6 +210,10 @@ class AutosignController extends WebAction @@ -218,6 +210,10 @@ class AutosignController extends WebAction
218 } 210 }
219 211
220 //判定是否需要绑定手机号 212 //判定是否需要绑定手机号
  213 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  214 + $fillHerf = Helpers::url('/passport/thirdlogin/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name']));
  215 + $this->go($fillHerf);
  216 + }
221 if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') { 217 if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
222 $token = Helpers::makeToken($result['data']['uid']); 218 $token = Helpers::makeToken($result['data']['uid']);
223 $this->setSession('_TOKEN', $token); 219 $this->setSession('_TOKEN', $token);
@@ -229,7 +225,7 @@ class AutosignController extends WebAction @@ -229,7 +225,7 @@ class AutosignController extends WebAction
229 225
230 $refer = $this->getCookie('refer'); 226 $refer = $this->getCookie('refer');
231 if (empty($refer)) { 227 if (empty($refer)) {
232 - $refer = SITE_MAIN . '/?go=1'; 228 + $refer = SITE_MAIN;
233 } 229 }
234 else { 230 else {
235 $refer = rawurldecode($refer); 231 $refer = rawurldecode($refer);
@@ -264,18 +260,13 @@ class AutosignController extends WebAction @@ -264,18 +260,13 @@ class AutosignController extends WebAction
264 } 260 }
265 261
266 //判定是否需要绑定手机号 262 //判定是否需要绑定手机号
267 - if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {  
268 - $token = Helpers::makeToken($result['data']['uid']);  
269 - $this->setSession('_TOKEN', $token);  
270 - $this->setSession('_LOGIN_UID', $result['data']['uid']);  
271 - $this->setCookie('_TOKEN', $token);  
272 - $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['douban_user_id'], 'sourceType' => 'douban', 'nickname' => $partnerInfo['name'])));  
273 - $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf)); 263 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  264 + $fillHerf = Helpers::url('/passport/thirdlogin/index', array('openId' => $access['douban_user_id'], 'sourceType' => 'douban', 'nickname' => $partnerInfo['name']));
  265 + $this->go($fillHerf);
274 } 266 }
275 -  
276 $refer = $this->getCookie('refer'); 267 $refer = $this->getCookie('refer');
277 if (empty($refer)) { 268 if (empty($refer)) {
278 - $refer = SITE_MAIN . '/?go=1'; 269 + $refer = SITE_MAIN;
279 } 270 }
280 else { 271 else {
281 $refer = rawurldecode($refer); 272 $refer = rawurldecode($refer);
@@ -311,18 +302,14 @@ class AutosignController extends WebAction @@ -311,18 +302,14 @@ class AutosignController extends WebAction
311 } 302 }
312 303
313 //判定是否需要绑定手机号 304 //判定是否需要绑定手机号
314 - if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {  
315 - $token = Helpers::makeToken($result['data']['uid']);  
316 - $this->setSession('_TOKEN', $token);  
317 - $this->setSession('_LOGIN_UID', $result['data']['uid']);  
318 - $this->setCookie('_TOKEN', $token);  
319 - $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $partnerInfo['openid'], 'sourceType' => 'wechat', 'nickname' => $partnerInfo['nickname'])));  
320 - $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf)); 305 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  306 + $fillHerf = Helpers::url('/passport/thirdlogin/index', array('openId' => $partnerInfo['openid'], 'sourceType' => 'wechat', 'nickname' => $partnerInfo['nickname']));
  307 + $this->go($fillHerf);
321 } 308 }
322 309
323 $refer = $this->getCookie('refer'); 310 $refer = $this->getCookie('refer');
324 if (empty($refer)) { 311 if (empty($refer)) {
325 - $refer = SITE_MAIN . '/?go=1'; 312 + $refer = SITE_MAIN;
326 } 313 }
327 else { 314 else {
328 $refer = rawurldecode($refer); 315 $refer = rawurldecode($refer);
@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 use Action\WebAction; 3 use Action\WebAction;
4 use LibModels\Web\Passport\RegData; 4 use LibModels\Web\Passport\RegData;
5 use LibModels\Wap\Passport\BindData; 5 use LibModels\Wap\Passport\BindData;
  6 +use LibModels\Web\Home\UserData;
  7 +use WebPlugin\Images;
6 use Passport\PassportModel as PassportModel; 8 use Passport\PassportModel as PassportModel;
7 use WebPlugin\Helpers; 9 use WebPlugin\Helpers;
8 10
@@ -10,7 +12,7 @@ class AutouserinfoController extends WebAction @@ -10,7 +12,7 @@ class AutouserinfoController extends WebAction
10 { 12 {
11 13
12 /** 14 /**
13 - * 第三方登录完善个人信息 15 + * 第三方登录完善个人信息(旧)
14 * 绑定手机号 16 * 绑定手机号
15 */ 17 */
16 public function indexAction() 18 public function indexAction()
@@ -29,16 +31,6 @@ class AutouserinfoController extends WebAction @@ -29,16 +31,6 @@ class AutouserinfoController extends WebAction
29 $refer = rawurldecode($refer); 31 $refer = rawurldecode($refer);
30 } 32 }
31 33
32 - //获取用户  
33 - $uid = $this->getUid(true);  
34 - if (!$uid) {  
35 - $isLogin = false;  
36 - $username = '';  
37 - }  
38 - else {  
39 - $isLogin = true;  
40 - $username = $this->_uname;  
41 - }  
42 $simpleHeader = PassportModel::getSimpleHeader(); 34 $simpleHeader = PassportModel::getSimpleHeader();
43 $cover = PassportModel::getLeftBanner(PassportModel::AUTOUSERINFO_LEFT_BANNER_CODE); 35 $cover = PassportModel::getLeftBanner(PassportModel::AUTOUSERINFO_LEFT_BANNER_CODE);
44 36
@@ -66,12 +58,10 @@ class AutouserinfoController extends WebAction @@ -66,12 +58,10 @@ class AutouserinfoController extends WebAction
66 } 58 }
67 59
68 /** 60 /**
69 - * 完善信息页面 61 + * 完善信息页面(中间跳转页-旧)
70 */ 62 */
71 public function userInfoAction() 63 public function userInfoAction()
72 { 64 {
73 - //获取用户  
74 - $uid = $this->getUid(false);  
75 $nickname = $this->get('nickname'); 65 $nickname = $this->get('nickname');
76 $openId = $this->get('openId'); 66 $openId = $this->get('openId');
77 $sourceType = $this->get('sourceType'); 67 $sourceType = $this->get('sourceType');
@@ -94,6 +84,8 @@ class AutouserinfoController extends WebAction @@ -94,6 +84,8 @@ class AutouserinfoController extends WebAction
94 84
95 /** 85 /**
96 * 绑定前手机号校验 86 * 绑定前手机号校验
  87 + * 若已注册,则查询用户头像,昵称信息
  88 + *
97 */ 89 */
98 public function bindCheckAction() 90 public function bindCheckAction()
99 { 91 {
@@ -105,22 +97,34 @@ class AutouserinfoController extends WebAction @@ -105,22 +97,34 @@ class AutouserinfoController extends WebAction
105 break; 97 break;
106 } 98 }
107 99
108 - $phoneNum = trim($this->post('mobile')); 100 + $mobile = trim($this->post('mobile'));
109 $openId = trim($this->post('openId')); 101 $openId = trim($this->post('openId'));
110 - $areaCode = trim($this->post('area', '86')); 102 + $area = trim($this->post('area', '86'));
111 $sourceType = trim($this->post('sourceType')); 103 $sourceType = trim($this->post('sourceType'));
112 104
113 105
114 - if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) { 106 + if (!is_numeric($mobile) || !$openId || !$area || !$sourceType) {
115 break; 107 break;
116 } 108 }
117 109
118 - $res = BindData::bindCheck($phoneNum, $openId, $sourceType, $areaCode); 110 + $res = BindData::bindCheck($mobile, $openId, $sourceType, $area);
119 if (!isset($res['code'])) { 111 if (!isset($res['code'])) {
120 break; 112 break;
121 } 113 }
  114 + //未注册 未绑定
122 if ($res['code'] == 200) { 115 if ($res['code'] == 200) {
123 - $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'])); 116 + $next = Helpers::url('/thirdlogin/index', array(
  117 + 'openId' => $openId,
  118 + 'sourceType' => $sourceType,
  119 + 'area' => $area,
  120 + 'mobile' => $mobile,
  121 + ));
  122 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('next' => $next));
  123 + }
  124 + //506 - 已注册 未绑定 / 505 - 已注册 已绑定
  125 + elseif ($res['code'] == 506 || $res['code'] == 505) {
  126 + $user = self::getUserInfo($area, $mobile);
  127 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('user' => $user));
124 } 128 }
125 else { 129 else {
126 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : ''); 130 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
@@ -131,6 +135,20 @@ class AutouserinfoController extends WebAction @@ -131,6 +135,20 @@ class AutouserinfoController extends WebAction
131 $this->echoJson($data); 135 $this->echoJson($data);
132 } 136 }
133 137
  138 + public static function getUserInfo($area, $mobile)
  139 + {
  140 + $userInfo = UserData::getUserInfoByMobile($area, $mobile);
  141 + $user = array('username' => '', 'headImg' => '');
  142 + $userTmp = current($userInfo['data']);
  143 + if ($userTmp) {
  144 + $user = array(
  145 + 'username' => $userTmp['profile_name'],
  146 + 'headImg' => (!empty($userTmp['head_ico'])) ? Images::getImageUrl($userTmp['head_ico'], 100, 100, 2, 'headimg') : '',
  147 + );
  148 + }
  149 + return $user;
  150 + }
  151 +
134 /** 152 /**
135 * 发送验证码 153 * 发送验证码
136 */ 154 */
@@ -146,8 +164,6 @@ class AutouserinfoController extends WebAction @@ -146,8 +164,6 @@ class AutouserinfoController extends WebAction
146 164
147 $phoneNum = trim($this->post('mobile')); 165 $phoneNum = trim($this->post('mobile'));
148 $areaCode = trim($this->post('area')); 166 $areaCode = trim($this->post('area'));
149 - $verifyCode = trim($this->post('verifyCode'));  
150 -  
151 //校验手机号格式 167 //校验手机号格式
152 if (!is_numeric($phoneNum) || !is_numeric($areaCode)) { 168 if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
153 $data['code'] = 400; 169 $data['code'] = 400;
@@ -155,13 +171,6 @@ class AutouserinfoController extends WebAction @@ -155,13 +171,6 @@ class AutouserinfoController extends WebAction
155 break; 171 break;
156 } 172 }
157 173
158 - //检测验证码不正确  
159 - if (!PassportModel::verifyCode($verifyCode)) {  
160 - $data['code'] = 400;  
161 - $data['message'] = '图形验证码不正确';  
162 - break;  
163 - }  
164 -  
165 $data = BindData::sendBindMsg($areaCode, $phoneNum); 174 $data = BindData::sendBindMsg($areaCode, $phoneNum);
166 if (!isset($data['code'])) { 175 if (!isset($data['code'])) {
167 break; 176 break;
@@ -172,32 +181,6 @@ class AutouserinfoController extends WebAction @@ -172,32 +181,6 @@ class AutouserinfoController extends WebAction
172 $this->echoJson($data); 181 $this->echoJson($data);
173 } 182 }
174 183
175 - /*  
176 - * 校验图形验证码  
177 - */  
178 - public function checkPicCodeAction()  
179 - {  
180 - $data = array('code' => 400, 'message' => '', 'data' => '');  
181 -  
182 - do {  
183 - /* 判断是不是AJAX请求 */  
184 - if (!$this->isAjax()) {  
185 - break;  
186 - }  
187 - $verifyCode = trim($this->post('verifyCode'));  
188 - $picFlag = PassportModel::verifyCode($verifyCode);  
189 - if ($picFlag) {  
190 - $data = array('code' => 200, 'message' => '验证码正确', 'data' => '');  
191 - }  
192 - else {  
193 - $data = array('code' => 400, 'message' => '验证码错误', 'data' => '');  
194 - }  
195 - }  
196 - while (false);  
197 -  
198 - $this->echoJson($data);  
199 - }  
200 -  
201 /** 184 /**
202 * 校验短信验证码 185 * 校验短信验证码
203 */ 186 */
@@ -249,8 +232,6 @@ class AutouserinfoController extends WebAction @@ -249,8 +232,6 @@ class AutouserinfoController extends WebAction
249 $openId = trim($this->post('openId')); 232 $openId = trim($this->post('openId'));
250 $sourceType = trim($this->post('sourceType')); 233 $sourceType = trim($this->post('sourceType'));
251 $code = trim($this->post('code')); //短信验证码 234 $code = trim($this->post('code')); //短信验证码
252 - $verifyCode = trim($this->post('verifyCode')); //图形验证码  
253 -// $nickname = trim($this->post('nickname'));//nickname不同步信息  
254 $password = trim($this->post('password')); 235 $password = trim($this->post('password'));
255 $password = empty($password) ? '' : $password; 236 $password = empty($password) ? '' : $password;
256 237
@@ -260,13 +241,6 @@ class AutouserinfoController extends WebAction @@ -260,13 +241,6 @@ class AutouserinfoController extends WebAction
260 $data['message'] = '手机号码格式不正确'; 241 $data['message'] = '手机号码格式不正确';
261 break; 242 break;
262 } 243 }
263 - //校验图形验证码  
264 - $picFlag = PassportModel::verifyCode($verifyCode);  
265 - if (!$picFlag) {  
266 - $data['code'] = 400;  
267 - $data['message'] = '图形验证码不正确';  
268 - break;  
269 - }  
270 //校验手机验证码 244 //校验手机验证码
271 $bindMsgFlag = BindData::checkBindCode($areaCode, $phoneNum, $code); 245 $bindMsgFlag = BindData::checkBindCode($areaCode, $phoneNum, $code);
272 if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) { 246 if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) {
@@ -8,24 +8,14 @@ class ThirdloginController extends WebAction @@ -8,24 +8,14 @@ class ThirdloginController extends WebAction
8 { 8 {
9 9
10 /** 10 /**
11 - * 第三方联合登录手机绑定流程页 11 + * 第三方联合登录手机绑定流程页1
12 */ 12 */
13 public function indexAction() 13 public function indexAction()
14 { 14 {
15 $this->setTitle('联合登录补全信息'); 15 $this->setTitle('联合登录补全信息');
16 -// $nickname = $this->get('nickname');  
17 $openId = trim($this->get('openId')); 16 $openId = trim($this->get('openId'));
18 $sourceType = trim($this->get('sourceType')); 17 $sourceType = trim($this->get('sourceType'));
19 18
20 - //登录后跳转页面  
21 - $refer = $this->getCookie('refer');  
22 - if (empty($refer)) {  
23 - $refer = SITE_MAIN;  
24 - }  
25 - else {  
26 - $refer = rawurldecode($refer);  
27 - }  
28 -  
29 $simpleHeader = PassportModel::getSimpleHeader(); 19 $simpleHeader = PassportModel::getSimpleHeader();
30 20
31 //整合 21 //整合
@@ -40,11 +30,43 @@ class ThirdloginController extends WebAction @@ -40,11 +30,43 @@ class ThirdloginController extends WebAction
40 $this->_view->display('index', $data); 30 $this->_view->display('index', $data);
41 } 31 }
42 32
  33 + /*
  34 + * 首次登录绑定流程-新会员
  35 + */
  36 +
43 public function noregistAction() 37 public function noregistAction()
44 { 38 {
45 -  
46 $mobile = trim($this->post('mobile')); 39 $mobile = trim($this->post('mobile'));
47 - $data = array('mobile' => $mobile); 40 + $sourceType = trim($this->post('sourceType'));
  41 + $openId = trim($this->post('openId'));
  42 + $area = trim($this->post('area'));
  43 +
  44 + $simpleHeader = PassportModel::getSimpleHeader();
  45 + $data = array(
  46 + 'thirdLogin' => true,
  47 + 'simpleHeader' => $simpleHeader,
  48 + 'mobile' => $mobile,
  49 + 'sourceType' => $sourceType,
  50 + 'openId' => $openId,
  51 + 'area' => $area
  52 + );
48 $this->_view->display('noregist', $data); 53 $this->_view->display('noregist', $data);
49 } 54 }
  55 +
  56 + /*
  57 + * 绑定成功
  58 + *
  59 + */
  60 + public function bindSuccessAction()
  61 + {
  62 +
  63 + $simpleHeader = PassportModel::getSimpleHeader();
  64 + $data = array(
  65 + 'thirdLogin' => true,
  66 + 'simpleHeader' => $simpleHeader,
  67 + 'goShopping' => SITE_MAIN,
  68 + );
  69 + $this->_view->display(' bindsuccess', $data);
  70 + }
  71 +
50 } 72 }