do modify product detail page commentsUrl and consultsUrl named
Showing
4 changed files
with
198 additions
and
8 deletions
library/LibModels/Wap/Passport/BindData.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace LibModels\Wap\Passport; | ||
4 | + | ||
5 | +use Api\Sign; | ||
6 | +use Api\Yohobuy; | ||
7 | + | ||
8 | +/** | ||
9 | + * 绑定手机号 数据模型 | ||
10 | + * | ||
11 | + * @name BindData | ||
12 | + * @package LibModels/Wap/Passport | ||
13 | + * @copyright yoho.inc | ||
14 | + * @version 1.0 (2015-12-14 10:00:00) | ||
15 | + * @author xiaowei | ||
16 | + */ | ||
17 | +class BindData | ||
18 | +{ | ||
19 | + | ||
20 | + /** | ||
21 | + * 绑定前检查 | ||
22 | + * @param string $openId 第三方唯一识别码 | ||
23 | + * @param string $sourceType 登录方式 | ||
24 | + * @param string $clientType 所属客户端类型 | ||
25 | + * @return array 登录返回结果 | ||
26 | + */ | ||
27 | + public static function bindCheck($openId, $sourceType) | ||
28 | + { | ||
29 | + $param = Yohobuy::param(); | ||
30 | + | ||
31 | + $param['v'] = '7'; | ||
32 | + $param['method'] = 'app.passport.check'; | ||
33 | + $param['open_id'] = $openId; | ||
34 | + $param['source_type'] = $sourceType; | ||
35 | + $param['client_secret'] = Sign::getSign($param); | ||
36 | + | ||
37 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
38 | + } | ||
39 | + | ||
40 | + /** | ||
41 | + * 发送、重发送验证码 | ||
42 | + * @param string $mobile 手机号 | ||
43 | + * | ||
44 | + */ | ||
45 | + public static function sendBindMsg($mobile) | ||
46 | + { | ||
47 | + $param = Yohobuy::param(); | ||
48 | + | ||
49 | + $param['v'] = '7'; | ||
50 | + $param['method'] = 'app.passport.smsbind'; | ||
51 | + $param['mobile'] = $mobile; | ||
52 | + $param['client_secret'] = Sign::getSign($param); | ||
53 | + | ||
54 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * 验证验证码是否正确 | ||
59 | + * | ||
60 | + */ | ||
61 | + public static function checkBindCode($mobile, $code) | ||
62 | + { | ||
63 | + $param = Yohobuy::param(); | ||
64 | + | ||
65 | + $param['v'] = '7'; | ||
66 | + $param['method'] = 'app.register.validRegCode'; | ||
67 | + $param['mobile'] = $mobile; | ||
68 | + $param['code'] = $code; | ||
69 | + $param['client_secret'] = Sign::getSign($param); | ||
70 | + | ||
71 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * 第三方绑定手机号 | ||
76 | + * @param string $nickname 姓名 | ||
77 | + * @param string $openId 第三方唯一识别码 | ||
78 | + * @param string $sourceType 登录方式 | ||
79 | + * @param string $mobile 手机号 | ||
80 | + * @param string $password 密码 | ||
81 | + */ | ||
82 | + public static function bindMobile($openId, $nickname, $sourceType, $mobile, $password) | ||
83 | + { | ||
84 | + $param = Yohobuy::param(); | ||
85 | + | ||
86 | + $param['v'] = '7'; | ||
87 | + $param['method'] = 'app.passport.bind'; | ||
88 | + $param['mobile'] = $mobile; | ||
89 | + $param['passport'] = $password; | ||
90 | + $param['open_id'] = $openId; | ||
91 | + $param['nickname'] = $nickname; | ||
92 | + $param['source_type'] = $sourceType; | ||
93 | + | ||
94 | + $param['client_secret'] = Sign::getSign($param); | ||
95 | + | ||
96 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
97 | + } | ||
98 | + | ||
99 | +} |
@@ -66,7 +66,7 @@ class LoginData | @@ -66,7 +66,7 @@ class LoginData | ||
66 | // 构建必传参数 | 66 | // 构建必传参数 |
67 | $param = Yohobuy::param(); | 67 | $param = Yohobuy::param(); |
68 | 68 | ||
69 | - $param['v'] = '4'; // 只有早期的V4版本才有直接生成UID | 69 | + $param['v'] = '7'; // 只有早期的V4版本才有直接生成UID |
70 | $param['method'] = 'app.passport.signinByOpenID'; | 70 | $param['method'] = 'app.passport.signinByOpenID'; |
71 | $param['openId'] = $openId; | 71 | $param['openId'] = $openId; |
72 | $param['source_type'] = $sourceType; | 72 | $param['source_type'] = $sourceType; |
1 | +<?php | ||
2 | + | ||
3 | +use Action\AbstractAction; | ||
4 | +use LibModels\Wap\Passport\LoginData; | ||
5 | +use LibModels\Wap\Passport\RegData; | ||
6 | +use Plugin\Helpers; | ||
7 | +use Plugin\Partner\Factory; | ||
8 | + | ||
9 | +/** | ||
10 | + * 登录的控制器 | ||
11 | + */ | ||
12 | +class BindController extends AbstractAction | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * 登录到bind页面 | ||
17 | + */ | ||
18 | + public function indexAction() | ||
19 | + { | ||
20 | + | ||
21 | + $this->setTitle('绑定手机号'); | ||
22 | + | ||
23 | + $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链接 | ||
35 | + ); | ||
36 | + | ||
37 | + // 渲染模板 | ||
38 | + $this->_view->display('index', $data); | ||
39 | + } | ||
40 | + | ||
41 | + | ||
42 | + | ||
43 | + | ||
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 | +// } | ||
74 | + | ||
75 | + | ||
76 | + | ||
77 | +} |
@@ -206,27 +206,41 @@ class LoginController extends AbstractAction | @@ -206,27 +206,41 @@ class LoginController extends AbstractAction | ||
206 | public function qqcallbackAction() | 206 | public function qqcallbackAction() |
207 | { | 207 | { |
208 | $qqconnect = Factory::create('qqconnect'); | 208 | $qqconnect = Factory::create('qqconnect'); |
209 | - $access = $qqconnect->getAccessToken(); | 209 | + $access = $qqconnect->getAccessToken(); |
210 | /* 获取QQ腾讯用户的详细信息 */ | 210 | /* 获取QQ腾讯用户的详细信息 */ |
211 | $partnerInfo = $qqconnect->getUserInfo($access); | 211 | $partnerInfo = $qqconnect->getUserInfo($access); |
212 | $result = array(); | 212 | $result = array(); |
213 | - if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) { | 213 | + if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) |
214 | + { | ||
214 | $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq'); | 215 | $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq'); |
215 | } | 216 | } |
216 | 217 | ||
218 | + //判定是否需要绑定手机号 | ||
219 | + $isBind = $result['data']['is_bind']; | ||
220 | + if ($isBind == 'N') | ||
221 | + { | ||
222 | + $this->go(Helpers::url('/passport/bind/index')); | ||
223 | + } | ||
224 | + | ||
217 | $refer = $this->getCookie('refer'); | 225 | $refer = $this->getCookie('refer'); |
218 | - if (empty($refer)) { | 226 | + if (empty($refer)) |
227 | + { | ||
219 | $refer = SITE_MAIN . '/?go=1'; | 228 | $refer = SITE_MAIN . '/?go=1'; |
220 | - } else { | 229 | + } |
230 | + else | ||
231 | + { | ||
221 | $refer = rawurldecode($refer); | 232 | $refer = rawurldecode($refer); |
222 | } | 233 | } |
223 | 234 | ||
224 | - if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) { | 235 | + if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) |
236 | + { | ||
225 | $token = Helpers::makeToken($result['data']['uid']); | 237 | $token = Helpers::makeToken($result['data']['uid']); |
226 | $this->setCookie('_TOKEN', $token); | 238 | $this->setCookie('_TOKEN', $token); |
227 | $this->setSession('_TOKEN', $token); | 239 | $this->setSession('_TOKEN', $token); |
228 | $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); | 240 | $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); |
229 | - } else { | 241 | + } |
242 | + else | ||
243 | + { | ||
230 | $this->go($refer); | 244 | $this->go($refer); |
231 | } | 245 | } |
232 | } | 246 | } |
@@ -262,5 +276,5 @@ class LoginController extends AbstractAction | @@ -262,5 +276,5 @@ class LoginController extends AbstractAction | ||
262 | $this->go($refer); | 276 | $this->go($refer); |
263 | } | 277 | } |
264 | } | 278 | } |
265 | - | 279 | + |
266 | } | 280 | } |
-
Please register or login to post a comment