|
|
<?php
|
|
|
|
|
|
use Action\AbstractAction;
|
|
|
use LibModels\Wap\Passport\LoginData;
|
|
|
use LibModels\Wap\Passport\RegData;
|
|
|
use LibModels\Wap\Passport\BindData;
|
|
|
use Plugin\Helpers;
|
|
|
use Plugin\Partner\Factory;
|
|
|
|
|
|
/**
|
|
|
* 登录的控制器
|
...
|
...
|
@@ -17,61 +15,233 @@ class BindController extends AbstractAction |
|
|
*/
|
|
|
public function indexAction()
|
|
|
{
|
|
|
|
|
|
$this->setTitle('绑定手机号');
|
|
|
|
|
|
$openId = $this->get('openId');
|
|
|
$sourceType = $this->get('sourceType');
|
|
|
$nickName = $this->get('nickName');
|
|
|
$data = array(
|
|
|
'loginIndex' => true, // 模板中使用JS的标识
|
|
|
'backUrl' => '/', // 返回的URL链接
|
|
|
'showHeaderImg' => true, // 控制显示头部图片
|
|
|
'isPassportPage' => true, // 模板中模块标识
|
|
|
'registerUrl' => '/reg.html', // 注册的URL链接
|
|
|
'aliLoginUrl' => '/passport/login/alipay', // 支付宝快捷登录的URL链接
|
|
|
'weiboLoginUrl' => '/passport/login/sina', // 微博登录的URL链接
|
|
|
'qqLoginUrl' => '/passport/login/qq', // 腾讯QQ登录的URL链接
|
|
|
'internationalUrl' => '/login.html', // 国际号登录的URL链接
|
|
|
'phoneRetriveUrl' => '/passport/back/mobile', // 通过手机号找回密码的URL链接
|
|
|
'emailRetriveUrl' => '/passport/back/email', // 通过邮箱找回密码的URL链接
|
|
|
'sourceType' => $sourceType, // 第三方登录来源
|
|
|
'openId' => $openId, // openId
|
|
|
'nickname' => $nickName, //昵称
|
|
|
);
|
|
|
|
|
|
// 渲染模板
|
|
|
$this->_view->display('index', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 手机验证码页面
|
|
|
*/
|
|
|
public function codeAction()
|
|
|
{
|
|
|
|
|
|
$this->setTitle('验证手机');
|
|
|
$openId = $this->get('openId');
|
|
|
$sourceType = $this->get('sourceType');
|
|
|
$nickName = $this->get('nickName');
|
|
|
$area = $this->get('areaCode', '86');
|
|
|
$isReg = $this->get('isReg');
|
|
|
|
|
|
$data = array(
|
|
|
'sourceType' => $sourceType, // 第三方登录来源
|
|
|
'openId' => $openId, // openId
|
|
|
'nickname' => $nickName, //昵称
|
|
|
'isReg' => $isReg, //是否是已注册过的手机号
|
|
|
'area' => $area //国别码
|
|
|
);
|
|
|
|
|
|
// 渲染模板
|
|
|
$this->_view->display('code', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置登录密码页面
|
|
|
*/
|
|
|
public function passwordAction()
|
|
|
{
|
|
|
|
|
|
$this->setTitle('重新设置登录密码');
|
|
|
$openId = $this->get('openId');
|
|
|
$sourceType = $this->get('sourceType');
|
|
|
$nickName = $this->get('nickName');
|
|
|
$area = $this->get('areaCode', '86');
|
|
|
$data = array(
|
|
|
'sourceType' => $sourceType, // 第三方登录来源
|
|
|
'openId' => $openId, // openId
|
|
|
'nickname' => $nickName, //昵称
|
|
|
'area' => $area //国别码
|
|
|
);
|
|
|
|
|
|
// 渲染模板
|
|
|
$this->_view->display('password', $data);
|
|
|
}
|
|
|
|
|
|
//绑定前手机号校验
|
|
|
public function bindCheckAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
|
|
|
do
|
|
|
{
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax())
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$mobile = $this->post('mobile');
|
|
|
$openId = $this->post('openId');
|
|
|
$area = $this->post('areaCode', '86');
|
|
|
$sourceType = $this->post('sourceType');
|
|
|
$nickName = $this->post('nickName');
|
|
|
|
|
|
|
|
|
if (!is_numeric($mobile) || !$openId || !$area || !$sourceType)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$res = BindData::bindCheck($mobile, $openId, $sourceType);
|
|
|
if (!isset($res['code']))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
if ($res['code'] == 200)
|
|
|
{
|
|
|
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickName' => $nickName, 'areaCode' => $area, 'mobile' => $mobile));
|
|
|
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('is_register' => $res['data']['is_register'], 'next' => $next));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
$data = array('code' => 500, 'message' => $res['message'], 'data' => $res['data']);
|
|
|
}
|
|
|
}
|
|
|
while (false);
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
// * 支付宝账号登录:回调方法
|
|
|
// */
|
|
|
// public function alipaycallbackAction()
|
|
|
// {
|
|
|
// $realName = $this->_request->get('real_name');
|
|
|
// $email = $this->_request->get('email');
|
|
|
// $userId = $this->_request->get('user_id');
|
|
|
//
|
|
|
// $result = array();
|
|
|
// if (isset($realName, $email, $userId)) {
|
|
|
// $result = LoginData::signinByOpenID($realName, $userId, 'alipay');
|
|
|
// }
|
|
|
//
|
|
|
// $refer = $this->getCookie('refer');
|
|
|
// if (empty($refer)) {
|
|
|
// $refer = SITE_MAIN . '/?go=1';
|
|
|
// } else {
|
|
|
// $refer = rawurldecode($refer);
|
|
|
// }
|
|
|
//
|
|
|
// if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
// $token = Helpers::makeToken($result['data']['uid']);
|
|
|
// $this->setCookie('_TOKEN', $token);
|
|
|
// $this->setSession('_TOKEN', $token);
|
|
|
// $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
// } else {
|
|
|
// $this->go($refer);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
$this->echoJson($data);
|
|
|
}
|
|
|
|
|
|
//发送验证码
|
|
|
public function sendBindMsgAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
|
|
|
do
|
|
|
{
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax())
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$mobile = $this->post('mobile');
|
|
|
|
|
|
if (!is_numeric($mobile))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$data = BindData::sendBindMsg($mobile);
|
|
|
if (!isset($data['code']))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
while (false);
|
|
|
|
|
|
$this->echoJson($data);
|
|
|
}
|
|
|
|
|
|
//校验短信验证码
|
|
|
public function checkBindMsgAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '', 'data' => '');
|
|
|
|
|
|
do
|
|
|
{
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax())
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$mobile = $this->post('mobile');
|
|
|
$msgCode = $this->post('msgCode');
|
|
|
|
|
|
if (!is_numeric($mobile) || !$msgCode)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$data = BindData::checkBindCode($mobile, $msgCode);
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
$mobile = $this->post('mobile');
|
|
|
$openId = $this->post('openId');
|
|
|
$area = $this->post('areaCode', '86');
|
|
|
$sourceType = $this->post('sourceType');
|
|
|
$nickName = $this->post('nickName');
|
|
|
$password = $this->post('password');
|
|
|
|
|
|
if (!is_numeric($mobile) || !$openId || !$sourceType || !$area)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$res = BindData::bindMobile($openId, $nickName, $sourceType, $mobile, $area, $password);
|
|
|
if (!isset($res['code']))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//绑定成功,跳转页面
|
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer))
|
|
|
{
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
|
|
|
if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid']))
|
|
|
{
|
|
|
$token = Helpers::makeToken($res['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$refer = Helpers::syncUserSession($data['data']['uid'], $refer);
|
|
|
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
|
|
|
}
|
|
|
}
|
|
|
while (false);
|
|
|
|
|
|
$this->echoJson($data);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|