Authored by whb

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -229,6 +229,7 @@ @@ -229,6 +229,7 @@
229 .icon { 229 .icon {
230 margin-right: pxToRem(10px); 230 margin-right: pxToRem(10px);
231 font-size: pxToRem(50px); 231 font-size: pxToRem(50px);
  232 + vertical-align: top;
232 } 233 }
233 234
234 .num { 235 .num {
  1 +{{> layout/simple-header}}
  2 +<div class="passport-page yoho-page clearfix">
  3 + {{# passport}}
  4 + {{> passport/cover}}
  5 + <div class="content">
  6 + {{> passport/register}}
  7 + </div>
  8 + {{/ passport}}
  9 +
  10 + <div class="page-tip clearfix">为了给您更好的购物体验, 建议您创建YOHO!Family账号</div>
  11 +
  12 +</div>
  13 +{{> layout/footer}}
@@ -22,6 +22,8 @@ class PassportModel @@ -22,6 +22,8 @@ class PassportModel
22 22
23 const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064';//注册左边的banner 23 const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064';//注册左边的banner
24 const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner 24 const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
  25 + const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
  26 + const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
25 27
26 //简单头部 28 //简单头部
27 public static function getSimpleHeader($isLogin, $username = '') 29 public static function getSimpleHeader($isLogin, $username = '')
1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 -use LibModels\Web\Passport\RegData;  
5 use LibModels\Web\Passport\LoginData; 4 use LibModels\Web\Passport\LoginData;
6 -use LibModels\Web\Home\IndexData;  
7 use Passport\PassportModel as PassportModel; 5 use Passport\PassportModel as PassportModel;
8 use Plugin\Helpers; 6 use Plugin\Helpers;
9 -use Plugin\Images;  
10 use Plugin\Partner\Factory; 7 use Plugin\Partner\Factory;
11 8
12 class AutosignController extends AbstractAction 9 class AutosignController extends AbstractAction
@@ -67,6 +64,14 @@ class AutosignController extends AbstractAction @@ -67,6 +64,14 @@ class AutosignController extends AbstractAction
67 } 64 }
68 65
69 /** 66 /**
  67 + * 微信网站授权入口
  68 + */
  69 + public function wechatAction(){
  70 + $url = QINWechat_Sdk_Open::getCode('http://www.yohobuy.com/passport/autosign/wechatback');
  71 + $this->helpGo($url);
  72 + }
  73 +
  74 + /**
70 * 支付宝账号登录:回调方法 75 * 支付宝账号登录:回调方法
71 */ 76 */
72 public function alipaycallbackAction() 77 public function alipaycallbackAction()
@@ -269,4 +274,51 @@ class AutosignController extends AbstractAction @@ -269,4 +274,51 @@ class AutosignController extends AbstractAction
269 } 274 }
270 } 275 }
271 276
  277 +
  278 + /**
  279 + * 微信网站授权获取用户信息并登录
  280 + * @param string code
  281 + */
  282 + public function wechatbackAction(){
  283 + $code = $this->helpGquery('code');
  284 + $accessToken = QINWechat_Sdk_Open::getAccessToken($code);
  285 + $userInfo = array();
  286 + if(empty($accessToken)){
  287 + $this->helpGo('/signin.html');
  288 + }
  289 + if(!isset($accessToken['access_token']) || !isset($accessToken['unionid']) || empty($accessToken['access_token']) || empty($accessToken['unionid'])){
  290 + $this->helpGo('/signin.html');
  291 + }
  292 + $userInfo = QINWechat_Sdk_Open::getUserInfo($accessToken['access_token'], $accessToken['unionid']);
  293 + if(empty($userInfo)){
  294 + $this->helpGo('/signin.html');
  295 + }
  296 + $this->wechatlogin($userInfo);
  297 + }
  298 +
  299 + /**
  300 + * 微信登录
  301 + * @param array $userInfo
  302 + */
  303 + public function wechatlogin($userInfo){
  304 + if(empty($userInfo)){
  305 + $this->helpGo('/signin.html');
  306 + }
  307 + try {
  308 + $oauthUserInfo = QINAuth_User_Utils::check('wechat', $userInfo['unionid'], $userInfo['nickname'], null, $userInfo);
  309 + $auth = QINAuth_Factory::profile('wechat');
  310 + $res=$auth->associate($oauthUserInfo['email'], array(
  311 + 'password' => QINAuth_User_Utils::$defaultPassword,
  312 + 'open_id' => $userInfo['unionid'],
  313 + 'nick_name' => $userInfo['nickname']
  314 + ));
  315 + } catch (Exception $e) {
  316 + $this->helpSession('passport_space')->__set('error_message', 'wechat' . $e->getMessage());
  317 + $this->helpGo('/signin.html');
  318 + }
  319 + //跳转到
  320 + $url = $this->authInfo($res, 'wechat' , $oauthUserInfo['email']);
  321 + $this->helpGo($url);
  322 + }
  323 +
272 } 324 }
@@ -2,12 +2,9 @@ @@ -2,12 +2,9 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Web\Passport\RegData; 4 use LibModels\Web\Passport\RegData;
5 -use LibModels\Web\Passport\LoginData;  
6 -use LibModels\Web\Home\IndexData; 5 +use LibModels\Wap\Passport\BindData;
7 use Passport\PassportModel as PassportModel; 6 use Passport\PassportModel as PassportModel;
8 use Plugin\Helpers; 7 use Plugin\Helpers;
9 -use Plugin\Images;  
10 -use Plugin\Partner\Factory;  
11 8
12 class AutouserinfoController extends AbstractAction 9 class AutouserinfoController extends AbstractAction
13 { 10 {
@@ -19,9 +16,9 @@ class AutouserinfoController extends AbstractAction @@ -19,9 +16,9 @@ class AutouserinfoController extends AbstractAction
19 public function indexAction() 16 public function indexAction()
20 { 17 {
21 $this->setTitle('联合登录补全信息'); 18 $this->setTitle('联合登录补全信息');
22 - $nickname = $this->get('nickname');  
23 - $openId = $this->get('openId');  
24 - $sourceType = $this->get('sourceType'); 19 +// $nickname = $this->get('nickname');
  20 + $openId = trim($this->get('openId'));
  21 + $sourceType = trim($this->get('sourceType'));
25 22
26 //登录后跳转页面 23 //登录后跳转页面
27 $refer = $this->getCookie('refer'); 24 $refer = $this->getCookie('refer');
@@ -43,15 +40,26 @@ class AutouserinfoController extends AbstractAction @@ -43,15 +40,26 @@ class AutouserinfoController extends AbstractAction
43 $username = $this->_uname; 40 $username = $this->_uname;
44 } 41 }
45 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username); 42 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
  43 + $cover = PassportModel::getLeftBanner(PassportModel::AUTOUSERINFO_LEFT_BANNER_CODE);
46 44
47 //整合 45 //整合
48 $data = array( 46 $data = array(
49 - 'loginPage' => true, 47 + 'registerPage' => true,
50 'simpleHeader' => $simpleHeader, 48 'simpleHeader' => $simpleHeader,
51 'passport' => array( 49 'passport' => array(
52 - 'coverHref' => '',  
53 - 'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',  
54 - ), 50 + 'actionUrl' => Helpers::url('/autouserinfo/bind'),
  51 + 'region' => RegData::getAreasData(),
  52 + 'location' => '+86',
  53 + 'captchaUrl' => Helpers::url('/passport/images?t=' . time()),
  54 + 'itemUrl' => Helpers::url('/help/?category_id=9'),
  55 + 'referUrl' => $refer,
  56 + 'skipUrl' => SITE_MAIN,
  57 + 'coverHref' => $cover['url'],
  58 + 'coverImg' => !empty($cover['img']) ? $cover['img'] : 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
  59 + 'regBtnText' => '完善信息',
  60 + 'openId' => $openId,
  61 + 'sourceType' => $sourceType
  62 + )
55 ); 63 );
56 64
57 $this->_view->display('index', $data); 65 $this->_view->display('index', $data);
@@ -77,12 +85,13 @@ class AutouserinfoController extends AbstractAction @@ -77,12 +85,13 @@ class AutouserinfoController extends AbstractAction
77 $username = $this->_uname; 85 $username = $this->_uname;
78 } 86 }
79 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username); 87 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
  88 + $cover = PassportModel::getLeftBanner(PassportModel::AUTOUSERINFO_LEFT_BANNER_CODE);
80 //整合 89 //整合
81 $data = array( 90 $data = array(
82 'simpleHeader' => $simpleHeader, 91 'simpleHeader' => $simpleHeader,
83 'passport' => array( 92 'passport' => array(
84 - 'coverHref' => '',  
85 - 'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190', 93 + 'coverHref' => $cover['url'],
  94 + 'coverImg' => !empty($cover['img']) ? $cover['img'] : 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
86 'goShoppingUrl' => SITE_MAIN, 95 'goShoppingUrl' => SITE_MAIN,
87 'completeInfoUrl' => Helpers::url('/passport/autouserinfo/index', array('openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname)), 96 'completeInfoUrl' => Helpers::url('/passport/autouserinfo/index', array('openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname)),
88 ), 97 ),
@@ -91,19 +100,197 @@ class AutouserinfoController extends AbstractAction @@ -91,19 +100,197 @@ class AutouserinfoController extends AbstractAction
91 $this->_view->display('userinfo', $data); 100 $this->_view->display('userinfo', $data);
92 } 101 }
93 102
94 - /*  
95 - * 发送绑定验证吗 103 + /**
  104 + * 绑定前手机号校验
96 */ 105 */
  106 + public function bindCheckAction()
  107 + {
  108 + $data = array('code' => 400, 'message' => '', 'data' => '');
97 109
98 - /*  
99 - * 验证图形验证码 110 + do {
  111 + /* 判断是不是AJAX请求 */
  112 + if (!$this->isAjax()) {
  113 + break;
  114 + }
  115 +
  116 + $phoneNum = trim($this->post('phoneNum'));
  117 + $openId = trim($this->post('openId'));
  118 + $areaCode = trim($this->post('areaCode', '86'));
  119 + $sourceType = trim($this->post('sourceType'));
  120 +
  121 +
  122 + if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) {
  123 + break;
  124 + }
  125 +
  126 + $res = BindData::bindCheck($phoneNum, $openId, $sourceType, $areaCode);
  127 + if (!isset($res['code'])) {
  128 + break;
  129 + }
  130 + if ($res['code'] == 200) {
  131 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register']));
  132 + }
  133 + else {
  134 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
  135 + }
  136 + }
  137 + while (false);
  138 +
  139 + $this->echoJson($data);
  140 + }
  141 +
  142 + /**
  143 + * 发送验证码
100 */ 144 */
  145 + public function sendBindMsgAction()
  146 + {
  147 + $data = array('code' => 400, 'message' => '', 'data' => '');
  148 +
  149 + do {
  150 + /* 判断是不是AJAX请求 */
  151 + if (!$this->isAjax()) {
  152 + break;
  153 + }
  154 +
  155 + $phoneNum = trim($this->post('phoneNum'));
  156 + $areaCode = trim($this->post('areaCode'));
  157 + $verifyCode = trim($this->post('verifyCode'));
  158 +
  159 + //校验手机号格式
  160 + if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
  161 + $data['code'] = 401;
  162 + $data['message'] = '手机号码格式不正确';
  163 + break;
  164 + }
  165 +
  166 + //检测验证码不正确
  167 + if (!PassportModel::verifyCode($verifyCode)) {
  168 + $data['code'] = 402;
  169 + $data['message'] = '图形验证码不正确';
  170 + break;
  171 + }
  172 +
  173 + $data = BindData::sendBindMsg($areaCode, $phoneNum);
  174 + if (!isset($data['code'])) {
  175 + break;
  176 + }
  177 + }
  178 + while (false);
  179 +
  180 + $this->echoJson($data);
  181 + }
101 182
102 /* 183 /*
103 - * 验证短信验证码 184 + * 校验图形验证码
104 */ 185 */
105 186
106 - /* 187 + public function checkPicCodeAction()
  188 + {
  189 + $data = array('code' => 400, 'message' => '', 'data' => '');
  190 +
  191 + do {
  192 + /* 判断是不是AJAX请求 */
  193 + if (!$this->isAjax()) {
  194 + break;
  195 + }
  196 + $verifyCode = $phoneNum = trim($this->post('verifyCode'));
  197 + $picFlag = PassportModel::verifyCode($verifyCode);
  198 + if ($picFlag) {
  199 + $data = array('code' => 200, 'message' => '验证码正确', 'data' => '');
  200 + }
  201 + else {
  202 + $data = array('code' => 400, 'message' => '验证码错误', 'data' => '');
  203 + }
  204 + }
  205 + while (false);
  206 +
  207 + $this->echoJson($data);
  208 + }
  209 +
  210 + /**
  211 + * 校验短信验证码
  212 + */
  213 + public function checkBindMsgAction()
  214 + {
  215 + $data = array('code' => 400, 'message' => '', 'data' => '');
  216 +
  217 + do {
  218 + /* 判断是不是AJAX请求 */
  219 + if (!$this->isAjax()) {
  220 + break;
  221 + }
  222 +
  223 + $phoneNum = trim($this->post('phoneNum'));
  224 + $areaCode = trim($this->post('areaCode'));
  225 + $code = trim($this->post('code')); //短信验证码
  226 + //校验手机号格式
  227 + if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
  228 + $data['code'] = 401;
  229 + $data['message'] = '手机号码格式不正确';
  230 + break;
  231 + }
  232 +
  233 + $data = BindData::checkBindCode($areaCode, $phoneNum, $code);
  234 + if (!isset($data['code'])) {
  235 + break;
  236 + }
  237 + }
  238 + while (false);
  239 +
  240 + $this->echoJson($data);
  241 + }
  242 +
  243 + /**
107 * 绑定手机号 244 * 绑定手机号
108 */ 245 */
  246 + public function bindMobileAction()
  247 + {
  248 + $data = array('code' => 400, 'message' => '', 'data' => '');
  249 +
  250 + do {
  251 + /* 判断是不是AJAX请求 */
  252 + if (!$this->isAjax()) {
  253 + break;
  254 + }
  255 +
  256 + $phoneNum = trim($this->post('phoneNum'));
  257 + $areaCode = trim($this->post('areaCode', '86'));
  258 + $openId = trim($this->post('openId'));
  259 + $sourceType = trim($this->post('sourceType'));
  260 + $code = trim($this->post('code')); //短信验证码
  261 + $verifyCode = trim($this->post('verifyCode')); //图形验证码
  262 +// $nickname = trim($this->post('nickname'));//nickname不同步信息
  263 + $password = trim($this->post('password'));
  264 + $password = empty($password) ? '' : $password;
  265 +
  266 + //校验手机号格式
  267 + if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
  268 + $data['code'] = 401;
  269 + $data['message'] = '手机号码格式不正确';
  270 + break;
  271 + }
  272 + $picFlag = PassportModel::verifyCode($verifyCode);
  273 + if (!$picFlag) {
  274 + $data['code'] = 402;
  275 + $data['message'] = '图形验证码不正确';
  276 + break;
  277 + }
  278 + $bindMsgFlag = BindData::checkBindCode($areaCode, $phoneNum, $code);
  279 + if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) {
  280 + $data['code'] = 403;
  281 + $data['message'] = '短信验证码不正确';
  282 + break;
  283 + }
  284 +
  285 + $res = BindData::bindMobile($openId, $sourceType, $phoneNum, $areaCode, $password);
  286 + if (!isset($res['code'])) {
  287 + break;
  288 + }
  289 + $data = array('code' => $res['code'], 'message' => $res['message']);
  290 + }
  291 + while (false);
  292 +
  293 + $this->echoJson($data);
  294 + }
  295 +
109 } 296 }
@@ -3,11 +3,8 @@ @@ -3,11 +3,8 @@
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Web\Passport\RegData; 4 use LibModels\Web\Passport\RegData;
5 use LibModels\Web\Passport\LoginData; 5 use LibModels\Web\Passport\LoginData;
6 -use LibModels\Web\Home\IndexData;  
7 use Passport\PassportModel as PassportModel; 6 use Passport\PassportModel as PassportModel;
8 use Plugin\Helpers; 7 use Plugin\Helpers;
9 -use Plugin\Images;  
10 -use Plugin\Partner\Factory;  
11 8
12 class LoginController extends AbstractAction 9 class LoginController extends AbstractAction
13 { 10 {
@@ -42,26 +39,20 @@ class LoginController extends AbstractAction @@ -42,26 +39,20 @@ class LoginController extends AbstractAction
42 } 39 }
43 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username); 40 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
44 //获取登陆页左侧资源 41 //获取登陆页左侧资源
45 - $adInfo = IndexData::getResourceData('db350894e01e90eac55cd3a13ad77331');  
46 - $coverHref = '';  
47 - $coverImg = '';  
48 - if (isset($adInfo['data'][0]['data']) && $adInfo['data'][0]['data']) {  
49 - $coverHref = $adInfo['data'][0]['data'][0]['url'];  
50 - $coverImg = Images::getImageUrl($adInfo['data'][0]['data'][0]['src'], 252, 190);  
51 - } 42 + $cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE);
52 //整合 43 //整合
53 $data = array( 44 $data = array(
54 'loginPage' => true, 45 'loginPage' => true,
55 'simpleHeader' => $simpleHeader, 46 'simpleHeader' => $simpleHeader,
56 'passport' => array( 47 'passport' => array(
57 - 'coverHref' => $coverHref,  
58 - 'coverImg' => !empty($coverImg)?$coverImg:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190', 48 + 'coverHref' => $cover['url'],
  49 + 'coverImg' => !empty($cover['img'])?$cover['img']:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
59 'countryCode' => '+86', 50 'countryCode' => '+86',
60 'countryName' => '中国', 51 'countryName' => '中国',
61 'countryList' => RegData::getAreasData(), 52 'countryList' => RegData::getAreasData(),
62 'forgetPwd' => Helpers::url('/passport/back/index'), 53 'forgetPwd' => Helpers::url('/passport/back/index'),
63 'fastReg' => Helpers::url('/reg.html'), 54 'fastReg' => Helpers::url('/reg.html'),
64 - 'weixinLogin' => Helpers::url('/passport/autosign/weixin'), 55 + 'weixinLogin' => Helpers::url('/passport/autosign/wechat'),
65 'qqLogin' => Helpers::url('/passport/autosign/qq'), 56 'qqLogin' => Helpers::url('/passport/autosign/qq'),
66 'weiboLogin' => Helpers::url('/passport/autosign/sina'), 57 'weiboLogin' => Helpers::url('/passport/autosign/sina'),
67 'alipayLogin' => Helpers::url('/passport/autosign/alipay'), 58 'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
@@ -92,9 +83,9 @@ class LoginController extends AbstractAction @@ -92,9 +83,9 @@ class LoginController extends AbstractAction
92 } 83 }
93 84
94 /* 判断参数是否传递 */ 85 /* 判断参数是否传递 */
95 - $area = $this->post('areaCode', '86');  
96 - $profile = $this->post('account');  
97 - $password = $this->post('password'); 86 + $area = trim($this->post('areaCode', '86'));
  87 + $profile = trim($this->post('account'));
  88 + $password = trim($this->post('password'));
98 if (!is_numeric($area) || empty($profile) || empty($password)) { 89 if (!is_numeric($area) || empty($profile) || empty($password)) {
99 break; 90 break;
100 } 91 }
@@ -36,33 +36,6 @@ class RegisterController extends WebAction @@ -36,33 +36,6 @@ class RegisterController extends WebAction
36 36
37 37
38 /** 38 /**
39 - * 第三方登录  
40 - */  
41 - public function thirdAction()  
42 - {  
43 - $refer = $this->get('refer', SITE_MAIN);  
44 - $cover = PassportModel::getLeftBanner(PassportModel::REGISTER_LEFT_BANNER_CODE);  
45 - $this->setSession('effective_time', time() + 1800);  
46 - $data = array(  
47 - 'registerPage' => true,  
48 - 'passport' => array(  
49 - 'actionUrl' => '/passport/register/mobileregister',  
50 - 'region' => RegData::getAreasData(),  
51 - 'location' => '+86',  
52 - 'captchaUrl' => '/passport/images?t=1449799445',  
53 - 'itemUrl' => '##',  
54 - 'referUrl' => $refer,  
55 - 'skipUrl' => '/signin.html?refer='.$refer,  
56 - 'coverHref' => $cover['url'],  
57 - 'coverImg' => $cover['img'],  
58 - 'regBtnText' => '完善信息'  
59 - )  
60 - );  
61 - $this->setCookie('refer', $refer);  
62 - $this->_view->display('third-register', $data);  
63 - }  
64 -  
65 - /**  
66 * 检测手机号 39 * 检测手机号
67 * 40 *
68 * @return json 41 * @return json