|
|
<?php
|
|
|
|
|
|
use Action\AbstractAction;
|
|
|
use LibModels\Wap\Passport\RegData;
|
|
|
use Plugin\Helpers;
|
|
|
|
|
|
/**
|
|
|
* 注册的控制器
|
|
|
*/
|
|
|
class RegController extends AbstractAction
|
|
|
{
|
|
|
/**
|
|
|
* 注册页
|
|
|
*/
|
|
|
public function indexAction()
|
|
|
{
|
|
|
$data = array(
|
|
|
'backUrl' => 'm.yohobuy.com',
|
|
|
'headerText' => '注册',
|
|
|
'isPassportPage' => true,
|
|
|
'modulePath' => 'passport/register/register',
|
|
|
'countrys' => array(
|
|
|
array(
|
|
|
'areaCode' => '+86',
|
|
|
'selected' => true,
|
|
|
'name' => '中国'
|
|
|
),
|
|
|
array(
|
|
|
'areaCode' => '+864',
|
|
|
'name' => '中国香港'
|
|
|
)
|
|
|
),
|
|
|
'countryCode' => '+86'
|
|
|
);
|
|
|
$this->setTitle('注册');
|
|
|
|
|
|
$data = array();
|
|
|
$data['backUrl'] = '/';
|
|
|
$data['headerText'] = '注册';
|
|
|
$data['isPassportPage'] = true;
|
|
|
$data['countrys'] = array();
|
|
|
|
|
|
$this->_view->assign('title', '注册');
|
|
|
$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('index', $data);
|
|
|
|
|
|
$data = array();
|
|
|
$area = array();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证码
|
|
|
*
|
|
|
* @param string area 地区编号
|
|
|
* @param string mobile 手机号
|
|
|
* @param string token 访问TOKEN凭证
|
|
|
*/
|
|
|
public function codeAction()
|
|
|
{
|
|
|
$data = array(
|
|
|
'backUrl' => 'm.yohobuy.com',
|
|
|
'headerText' => '注册',
|
|
|
'isPassportPage' => true,
|
|
|
'modulePath' => 'passport/register/code',
|
|
|
'areaCode' => '+86',
|
|
|
'phoneNum' => '15895869035'
|
|
|
);
|
|
|
$token = $this->get('token');
|
|
|
$mobile = $this->get('mobile');
|
|
|
$area = $this->get('area', '86');
|
|
|
|
|
|
// 判断是否允许访问, 不允许则跳转到错误页面
|
|
|
if (!is_string($token) || !is_numeric($mobile) || !Helpers::verifyToken($mobile, $token)) {
|
|
|
$this->error();
|
|
|
}
|
|
|
|
|
|
$this->setTitle('注册-验证码');
|
|
|
|
|
|
$data = array();
|
|
|
$data['backUrl'] = '/';
|
|
|
$data['headerText'] = '注册';
|
|
|
$data['isPassportPage'] = true;
|
|
|
$data['areaCode'] = $area;
|
|
|
$data['phoneNum'] = $mobile;
|
|
|
|
|
|
$this->_view->assign('title', '注册-验证码');
|
|
|
$this->_view->display('code', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 填写密码页面
|
|
|
*
|
|
|
* @param string area 地区编号
|
|
|
* @param string mobile 手机号
|
|
|
* @param string token 访问TOKEN凭证
|
|
|
*/
|
|
|
public function passwordAction()
|
|
|
{
|
|
|
$data = array(
|
...
|
...
|
@@ -55,4 +93,150 @@ class RegController extends AbstractAction |
|
|
$this->_view->assign('title', '注册-密码');
|
|
|
$this->_view->display('password', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证注册的手机号
|
|
|
*
|
|
|
* @param string area 地区编号,注意不需要+号
|
|
|
* @param string mobile 手机号
|
|
|
* @param string token 访问TOKEN凭证
|
|
|
* @return json
|
|
|
*/
|
|
|
public function verifymobileAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '参数不正确!', 'data' => '');
|
|
|
|
|
|
do {
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax()) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$token = $this->post('token');
|
|
|
$mobile = $this->post('mobile');
|
|
|
$area = $this->post('area', '86');
|
|
|
/* 判断参数是否合法 */
|
|
|
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断是否允许访问 */
|
|
|
if (!Helpers::verifyToken($mobile, $token)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 向手机发送注册验证码 */
|
|
|
$data = RegData::sendCodeToMobile($area, $mobile);
|
|
|
if (!isset($data['code'])) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 返回跳转到验证页面的链接*/
|
|
|
if ($data['code'] == 200) {
|
|
|
$data['data'] = '/passport/reg/code?token='.$token.'&mobile='.$mobile.'&area='.$area;
|
|
|
}
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
echo $this->echoJson($data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证注册的识别码
|
|
|
*
|
|
|
* @param string area 地区编号,注意不需要+号
|
|
|
* @param string mobile 手机号
|
|
|
* @param string token 访问TOKEN凭证
|
|
|
* @param int code 验证码, 手机上收到的
|
|
|
* @return json
|
|
|
*/
|
|
|
public function verifycodeAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '参数不正确!', 'data' => '');
|
|
|
|
|
|
do {
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax()) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$token = $this->post('token');
|
|
|
$mobile = $this->post('mobile');
|
|
|
$area = $this->post('area');
|
|
|
$code = $this->post('code');
|
|
|
/* 判断参数是否合法 */
|
|
|
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($code)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断是否允许访问 */
|
|
|
if (!Helpers::verifyToken($mobile, $token)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 验证注册的标识码是否有效 */
|
|
|
$data = RegData::validMobileCode($area, $mobile, $code);
|
|
|
if (!isset($data['code'])) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 返回跳转到设置密码的链接*/
|
|
|
if ($data['code'] == 200) {
|
|
|
$data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area;
|
|
|
}
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
echo $this->echoJson($data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置密码
|
|
|
*
|
|
|
* @param string area 地区编号,注意不需要+号
|
|
|
* @param string mobile 手机号
|
|
|
* @param string token 访问TOKEN凭证
|
|
|
* @param string password 用户设置的密码
|
|
|
* @return json
|
|
|
*/
|
|
|
public function setpasswordAction()
|
|
|
{
|
|
|
$data = array('code' => 400, 'message' => '参数不正确!', 'data' => '');
|
|
|
|
|
|
do {
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax()) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$token = $this->post('token');
|
|
|
$mobile = $this->post('mobile');
|
|
|
$area = $this->post('area');
|
|
|
$password = $this->post('password');
|
|
|
/* 判断参数是否合法 */
|
|
|
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($password)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断是否允许访问 */
|
|
|
if (!Helpers::verifyToken($mobile, $token)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 验证注册的标识码是否有效 */
|
|
|
$data = RegData::regMobile($area, $mobile, $password);
|
|
|
if (!isset($data['code'])) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 返回跳转到设置密码的链接*/
|
|
|
if ($data['code'] == 200) {
|
|
|
$data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area;
|
|
|
}
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
echo $this->echoJson($data);
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|