...
|
...
|
@@ -11,24 +11,28 @@ use Plugin\Partner\Factory; |
|
|
*/
|
|
|
class LoginController extends AbstractAction
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* 登录页
|
|
|
*/
|
|
|
public function indexAction()
|
|
|
{
|
|
|
$this->setTitle('登录');
|
|
|
|
|
|
|
|
|
$data = array(
|
|
|
'loginIndex' => true,
|
|
|
'backUrl' => '/',
|
|
|
'showHeaderImg' => true,
|
|
|
'isPassportPage' => true,
|
|
|
'registerUrl' => '/reg.html',
|
|
|
'interationalUrl' => '/login.html',
|
|
|
'phoneRetriveUrl' => '',
|
|
|
'emailRetriveUrl' => '',
|
|
|
'loginIndex' => true, // 模板中使用JS的标识
|
|
|
'backUrl' => '/', // 返回的URL链接
|
|
|
'showHeaderImg' => true, // 控制显示头部图片
|
|
|
'isPassportPage' => true, // 模板中模块标识
|
|
|
'registerUrl' => '/reg.html', // 注册的URL链接
|
|
|
'interationalUrl' => '/login.html', // 国际号登录的URL链接
|
|
|
'phoneRetriveUrl' => '/phoneback.html', // 通过手机号找回密码的URL链接
|
|
|
'emailRetriveUrl' => '/emailback.html', // 通过邮箱找回密码的URL链接
|
|
|
);
|
|
|
|
|
|
// 生成HTML(signin.html)
|
|
|
$this->_view->html('signin');
|
|
|
// 渲染模板
|
|
|
$this->_view->display('index', $data);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -38,41 +42,21 @@ class LoginController extends AbstractAction |
|
|
public function interationalAction()
|
|
|
{
|
|
|
$this->setTitle('国际账号登录');
|
|
|
|
|
|
$data = array();
|
|
|
$data['loginInterational'] = true;
|
|
|
$data['backUrl'] = '/';
|
|
|
$data['headerText'] = '登录';
|
|
|
$data['isPassportPage'] = true;
|
|
|
$data['areaCode'] = '+86';
|
|
|
|
|
|
// 获取地区数据列表
|
|
|
$area = RegData::getAreasData();
|
|
|
// 有数据
|
|
|
if (!empty($area['data'])) {
|
|
|
$build = array();
|
|
|
foreach ($area['data'] as $value) {
|
|
|
$build = array();
|
|
|
$build['areaCode'] = '+' . $value['area'];
|
|
|
$build['selected'] = $value['area'] === '86';
|
|
|
$build['name'] = $value['name'];
|
|
|
$data['countrys'][] = $build;
|
|
|
}
|
|
|
}
|
|
|
// 没数据
|
|
|
else {
|
|
|
$data['countrys'][0] = array();
|
|
|
$data['countrys'][0]['areaCode'] = '+86';
|
|
|
$data['countrys'][0]['selected'] = true;
|
|
|
$data['countrys'][0]['name'] = '中国';
|
|
|
}
|
|
|
|
|
|
$this->_view->display('interational', $data);
|
|
|
|
|
|
$data = array();
|
|
|
$area = array();
|
|
|
$data['loginInterational'] = true; // 模板中使用JS的标识
|
|
|
$data['backUrl'] = '/'; // 返回的URL链接
|
|
|
$data['headerText'] = '登录'; // 头部信息
|
|
|
$data['isPassportPage'] = true; // 模板中模块标识
|
|
|
$data['areaCode'] = '+86'; // 默认区号
|
|
|
$data['countrys'] = RegData::getAreasData(); // 地区信息列表
|
|
|
//
|
|
|
// 生成HTML(login.html)
|
|
|
$this->_view->html('login');
|
|
|
// 渲染模板
|
|
|
$this->_view->display('interational', $data);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 登录操作
|
|
|
*
|
...
|
...
|
@@ -84,13 +68,13 @@ class LoginController extends AbstractAction |
|
|
public function authAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '账号或密码不正确', 'data' => '');
|
|
|
|
|
|
|
|
|
do {
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax()) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 判断参数是否传递 */
|
|
|
$area = $this->post('areaCode', '86');
|
|
|
$profile = $this->post('account');
|
...
|
...
|
@@ -98,23 +82,22 @@ class LoginController extends AbstractAction |
|
|
if (!is_numeric($area) || empty($profile) || empty($password)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 判断参数是否有效 */
|
|
|
$verifyEmail = Helpers::verifyEmail($profile);
|
|
|
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile)
|
|
|
: Helpers::verifyAreaMobile($profile);
|
|
|
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile);
|
|
|
if (!$verifyEmail && !$verifyMobile) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 调用登录接口进行登录 */
|
|
|
$data = LoginData::signin($area, $profile, $password);
|
|
|
if ($data['code'] == 200) {
|
|
|
$data['data'] = '/'; // @todo
|
|
|
}
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
}
|
|
|
while (false);
|
|
|
|
|
|
$this->echoJson($data);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -124,8 +107,7 @@ class LoginController extends AbstractAction |
|
|
public function alipayAction()
|
|
|
{
|
|
|
$redirect = $this->_request->getServer('HTTP_REFERER', '');
|
|
|
if($redirect != '')
|
|
|
{
|
|
|
if ($redirect != '') {
|
|
|
$this->setCookie('alipay_redirect', $redirect);
|
|
|
}
|
|
|
Factory::create('alipay')->getAuthorizeUrl();
|
...
|
...
|
@@ -133,15 +115,13 @@ class LoginController extends AbstractAction |
|
|
exit();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* QQ账号登录:授权页面
|
|
|
*/
|
|
|
public function qqAction()
|
|
|
{
|
|
|
$redirect = $this->_request->getServer('HTTP_REFERER', '');
|
|
|
if($redirect != '')
|
|
|
{
|
|
|
if ($redirect != '') {
|
|
|
$this->setCookie('qq_redirect', $redirect);
|
|
|
}
|
|
|
Factory::create('qqconnect')->getAuthorizeUrl();
|
...
|
...
|
@@ -149,15 +129,13 @@ class LoginController extends AbstractAction |
|
|
exit();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 新浪微博账号登录:授权页面
|
|
|
*/
|
|
|
public function sinaAction()
|
|
|
{
|
|
|
$redirect = $this->_request->getServer('HTTP_REFERER', '');
|
|
|
if($redirect != '')
|
|
|
{
|
|
|
if ($redirect != '') {
|
|
|
$this->setCookie('sina_redirect', $redirect);
|
|
|
}
|
|
|
header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl());
|
...
|
...
|
@@ -174,19 +152,16 @@ class LoginController extends AbstractAction |
|
|
$alipay = Factory::create('alipay');
|
|
|
$access = $alipay->getAccessToken();
|
|
|
|
|
|
if (!isset($_GET['real_name']))
|
|
|
{
|
|
|
if (!isset($_GET['real_name'])) {
|
|
|
/* 获取支付宝用户的详细信息 */
|
|
|
$userInfo = $alipay->getUserInfo($access);
|
|
|
if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name']))
|
|
|
{
|
|
|
if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name'])) {
|
|
|
$nickname = $userInfo['response']['user_info']['user_name'];
|
|
|
$alipayEmail = $userInfo['response']['user_info']['email'];
|
|
|
}
|
|
|
var_dump($userInfo);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
else {
|
|
|
$nickname = $_GET['real_name'];
|
|
|
$alipayEmail = isset($_GET['email']) ? $_GET['email'] : '';
|
|
|
}
|
...
|
...
|
@@ -194,8 +169,7 @@ class LoginController extends AbstractAction |
|
|
|
|
|
$result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq');
|
|
|
|
|
|
if($result['code'] == 200)
|
|
|
{
|
|
|
if ($result['code'] == 200) {
|
|
|
$redirect = $this->_request->getCookie('alipay_redirect');
|
|
|
$redirect && $this->redirect($redirect);
|
|
|
}
|
...
|
...
|
@@ -213,12 +187,10 @@ class LoginController extends AbstractAction |
|
|
/* 获取QQ腾讯用户的详细信息 */
|
|
|
$partnerInfo = $qqconnect->getUserInfo($access);
|
|
|
|
|
|
if ($partnerInfo && is_array($partnerInfo))
|
|
|
{
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
|
|
|
|
|
|
if($result['code'] == 200)
|
|
|
{
|
|
|
if ($result['code'] == 200) {
|
|
|
$redirect = $this->_request->getCookie('qq_redirect');
|
|
|
$redirect && $this->redirect($redirect);
|
|
|
}
|
...
|
...
|
@@ -237,17 +209,16 @@ class LoginController extends AbstractAction |
|
|
/* 获取QQ腾讯用户的详细信息 */
|
|
|
$partnerInfo = $sina->getUserInfo($access);
|
|
|
|
|
|
if ($partnerInfo && is_array($partnerInfo))
|
|
|
{
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
|
|
|
|
|
|
if($result['code'] == 200)
|
|
|
{
|
|
|
if ($result['code'] == 200) {
|
|
|
$redirect = $this->_request->getCookie('sina_redirect');
|
|
|
$redirect && $this->redirect($redirect);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->redirect('/');
|
|
|
$this->redirect('/');
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
|
|
|
|
|
} |
...
|
...
|
|