Authored by xiaowei

PC重构 登录

{{> layout/simple-header}}
<div class="passport-page yoho-page clearfix">
{{# passport}}
{{> passport/cover}}
<div class="content">
{{> passport/register}}
</div>
{{/ passport}}
<div class="page-tip clearfix">为了给您更好的购物体验, 建议您创建YOHO!Family账号</div>
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -22,6 +22,8 @@ class PassportModel
const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064';//注册左边的banner
const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
//简单头部
public static function getSimpleHeader($isLogin, $username = '')
... ...
<?php
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class AutosignController extends AbstractAction
... ... @@ -67,6 +64,14 @@ class AutosignController extends AbstractAction
}
/**
* 微信网站授权入口
*/
public function wechatAction(){
$url = QINWechat_Sdk_Open::getCode('http://www.yohobuy.com/passport/autosign/wechatback');
$this->helpGo($url);
}
/**
* 支付宝账号登录:回调方法
*/
public function alipaycallbackAction()
... ... @@ -269,4 +274,51 @@ class AutosignController extends AbstractAction
}
}
/**
* 微信网站授权获取用户信息并登录
* @param string code
*/
public function wechatbackAction(){
$code = $this->helpGquery('code');
$accessToken = QINWechat_Sdk_Open::getAccessToken($code);
$userInfo = array();
if(empty($accessToken)){
$this->helpGo('/signin.html');
}
if(!isset($accessToken['access_token']) || !isset($accessToken['unionid']) || empty($accessToken['access_token']) || empty($accessToken['unionid'])){
$this->helpGo('/signin.html');
}
$userInfo = QINWechat_Sdk_Open::getUserInfo($accessToken['access_token'], $accessToken['unionid']);
if(empty($userInfo)){
$this->helpGo('/signin.html');
}
$this->wechatlogin($userInfo);
}
/**
* 微信登录
* @param array $userInfo
*/
public function wechatlogin($userInfo){
if(empty($userInfo)){
$this->helpGo('/signin.html');
}
try {
$oauthUserInfo = QINAuth_User_Utils::check('wechat', $userInfo['unionid'], $userInfo['nickname'], null, $userInfo);
$auth = QINAuth_Factory::profile('wechat');
$res=$auth->associate($oauthUserInfo['email'], array(
'password' => QINAuth_User_Utils::$defaultPassword,
'open_id' => $userInfo['unionid'],
'nick_name' => $userInfo['nickname']
));
} catch (Exception $e) {
$this->helpSession('passport_space')->__set('error_message', 'wechat' . $e->getMessage());
$this->helpGo('/signin.html');
}
//跳转到
$url = $this->authInfo($res, 'wechat' , $oauthUserInfo['email']);
$this->helpGo($url);
}
}
... ...
... ... @@ -2,12 +2,9 @@
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use LibModels\Wap\Passport\BindData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class AutouserinfoController extends AbstractAction
{
... ... @@ -19,9 +16,9 @@ class AutouserinfoController extends AbstractAction
public function indexAction()
{
$this->setTitle('联合登录补全信息');
$nickname = $this->get('nickname');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
// $nickname = $this->get('nickname');
$openId = trim($this->get('openId'));
$sourceType = trim($this->get('sourceType'));
//登录后跳转页面
$refer = $this->getCookie('refer');
... ... @@ -43,15 +40,26 @@ class AutouserinfoController extends AbstractAction
$username = $this->_uname;
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
$cover = PassportModel::getLeftBanner(PassportModel::AUTOUSERINFO_LEFT_BANNER_CODE);
//整合
$data = array(
'loginPage' => true,
'registerPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => '',
'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
),
'actionUrl' => Helpers::url('/autouserinfo/bind'),
'region' => RegData::getAreasData(),
'location' => '+86',
'captchaUrl' => Helpers::url('/passport/images?t=' . time()),
'itemUrl' => Helpers::url('/help/?category_id=9'),
'referUrl' => $refer,
'skipUrl' => SITE_MAIN,
'coverHref' => $cover['url'],
'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',
'regBtnText' => '完善信息',
'openId' => $openId,
'sourceType' => $sourceType
)
);
$this->_view->display('index', $data);
... ... @@ -77,12 +85,13 @@ class AutouserinfoController extends AbstractAction
$username = $this->_uname;
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
$cover = PassportModel::getLeftBanner(PassportModel::AUTOUSERINFO_LEFT_BANNER_CODE);
//整合
$data = array(
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => '',
'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'coverHref' => $cover['url'],
'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',
'goShoppingUrl' => SITE_MAIN,
'completeInfoUrl' => Helpers::url('/passport/autouserinfo/index', array('openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname)),
),
... ... @@ -91,19 +100,197 @@ class AutouserinfoController extends AbstractAction
$this->_view->display('userinfo', $data);
}
/*
* 发送绑定验证吗
/**
* 绑定前手机号校验
*/
public function bindCheckAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
/*
* 验证图形验证码
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$phoneNum = trim($this->post('phoneNum'));
$openId = trim($this->post('openId'));
$areaCode = trim($this->post('areaCode', '86'));
$sourceType = trim($this->post('sourceType'));
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) {
break;
}
$res = BindData::bindCheck($phoneNum, $openId, $sourceType, $areaCode);
if (!isset($res['code'])) {
break;
}
if ($res['code'] == 200) {
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register']));
}
else {
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
}
}
while (false);
$this->echoJson($data);
}
/**
* 发送验证码
*/
public function sendBindMsgAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$phoneNum = trim($this->post('phoneNum'));
$areaCode = trim($this->post('areaCode'));
$verifyCode = trim($this->post('verifyCode'));
//校验手机号格式
if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
$data['code'] = 401;
$data['message'] = '手机号码格式不正确';
break;
}
//检测验证码不正确
if (!PassportModel::verifyCode($verifyCode)) {
$data['code'] = 402;
$data['message'] = '图形验证码不正确';
break;
}
$data = BindData::sendBindMsg($areaCode, $phoneNum);
if (!isset($data['code'])) {
break;
}
}
while (false);
$this->echoJson($data);
}
/*
* 验证短信验证码
* 校验图形验证码
*/
/*
public function checkPicCodeAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$verifyCode = $phoneNum = trim($this->post('verifyCode'));
$picFlag = PassportModel::verifyCode($verifyCode);
if ($picFlag) {
$data = array('code' => 200, 'message' => '验证码正确', 'data' => '');
}
else {
$data = array('code' => 400, 'message' => '验证码错误', 'data' => '');
}
}
while (false);
$this->echoJson($data);
}
/**
* 校验短信验证码
*/
public function checkBindMsgAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$phoneNum = trim($this->post('phoneNum'));
$areaCode = trim($this->post('areaCode'));
$code = trim($this->post('code')); //短信验证码
//校验手机号格式
if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
$data['code'] = 401;
$data['message'] = '手机号码格式不正确';
break;
}
$data = BindData::checkBindCode($areaCode, $phoneNum, $code);
if (!isset($data['code'])) {
break;
}
}
while (false);
$this->echoJson($data);
}
/**
* 绑定手机号
*/
public function bindMobileAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$phoneNum = trim($this->post('phoneNum'));
$areaCode = trim($this->post('areaCode', '86'));
$openId = trim($this->post('openId'));
$sourceType = trim($this->post('sourceType'));
$code = trim($this->post('code')); //短信验证码
$verifyCode = trim($this->post('verifyCode')); //图形验证码
// $nickname = trim($this->post('nickname'));//nickname不同步信息
$password = trim($this->post('password'));
$password = empty($password) ? '' : $password;
//校验手机号格式
if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
$data['code'] = 401;
$data['message'] = '手机号码格式不正确';
break;
}
$picFlag = PassportModel::verifyCode($verifyCode);
if (!$picFlag) {
$data['code'] = 402;
$data['message'] = '图形验证码不正确';
break;
}
$bindMsgFlag = BindData::checkBindCode($areaCode, $phoneNum, $code);
if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) {
$data['code'] = 403;
$data['message'] = '短信验证码不正确';
break;
}
$res = BindData::bindMobile($openId, $sourceType, $phoneNum, $areaCode, $password);
if (!isset($res['code'])) {
break;
}
$data = array('code' => $res['code'], 'message' => $res['message']);
}
while (false);
$this->echoJson($data);
}
}
... ...
... ... @@ -3,11 +3,8 @@
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class LoginController extends AbstractAction
{
... ... @@ -42,26 +39,20 @@ class LoginController extends AbstractAction
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//获取登陆页左侧资源
$adInfo = IndexData::getResourceData('db350894e01e90eac55cd3a13ad77331');
$coverHref = '';
$coverImg = '';
if (isset($adInfo['data'][0]['data']) && $adInfo['data'][0]['data']) {
$coverHref = $adInfo['data'][0]['data'][0]['url'];
$coverImg = Images::getImageUrl($adInfo['data'][0]['data'][0]['src'], 252, 190);
}
$cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE);
//整合
$data = array(
'loginPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => $coverHref,
'coverImg' => !empty($coverImg)?$coverImg:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'coverHref' => $cover['url'],
'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',
'countryCode' => '+86',
'countryName' => '中国',
'countryList' => RegData::getAreasData(),
'forgetPwd' => Helpers::url('/passport/back/index'),
'fastReg' => Helpers::url('/reg.html'),
'weixinLogin' => Helpers::url('/passport/autosign/weixin'),
'weixinLogin' => Helpers::url('/passport/autosign/wechat'),
'qqLogin' => Helpers::url('/passport/autosign/qq'),
'weiboLogin' => Helpers::url('/passport/autosign/sina'),
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
... ... @@ -92,9 +83,9 @@ class LoginController extends AbstractAction
}
/* 判断参数是否传递 */
$area = $this->post('areaCode', '86');
$profile = $this->post('account');
$password = $this->post('password');
$area = trim($this->post('areaCode', '86'));
$profile = trim($this->post('account'));
$password = trim($this->post('password'));
if (!is_numeric($area) || empty($profile) || empty($password)) {
break;
}
... ...
... ... @@ -35,33 +35,6 @@ class RegisterController extends WebAction
/**
* 第三方登录
*/
public function thirdAction()
{
$refer = $this->get('refer', SITE_MAIN);
$cover = PassportModel::getLeftBanner(PassportModel::REGISTER_LEFT_BANNER_CODE);
$this->setSession('effective_time', time() + 1800);
$data = array(
'registerPage' => true,
'passport' => array(
'actionUrl' => '/passport/register/mobileregister',
'region' => RegData::getAreasData(),
'location' => '+86',
'captchaUrl' => '/passport/images?t=1449799445',
'itemUrl' => '##',
'referUrl' => $refer,
'skipUrl' => '/signin.html?refer='.$refer,
'coverHref' => $cover['url'],
'coverImg' => $cover['img'],
'regBtnText' => '完善信息'
)
);
$this->setCookie('refer', $refer);
$this->_view->display('third-register', $data);
}
/**
* 检测手机号
*
* @return json
... ...