Authored by xiaowei

手机号码绑定

... ... @@ -42,12 +42,13 @@ class BindData
* @param string $mobile 手机号
*
*/
public static function sendBindMsg($mobile)
public static function sendBindMsg($area,$mobile)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.smsbind';
$param['mobile'] = $mobile;
$param['area'] = $area;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
... ... @@ -57,13 +58,14 @@ class BindData
* 验证验证码是否正确
*
*/
public static function checkBindCode($mobile, $code)
public static function checkBindCode($area,$mobile, $code)
{
$param = Yohobuy::param();
$param['method'] = 'app.register.validRegCode';
$param['mobile'] = $mobile;
$param['code'] = $code;
$param['area'] = $area;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
... ...
... ... @@ -2,6 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Passport\BindData;
use LibModels\Wap\Passport\RegData;
use Plugin\Helpers;
/**
... ... @@ -15,14 +16,28 @@ class BindController extends AbstractAction
*/
public function indexAction()
{
$refer = $this->get('refer');
if (!empty($refer))
{
$this->setCookie('refer', $refer);
}
$this->setTitle('绑定手机号');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
$nickName = $this->get('nickName');
$nickname = $this->get('nickname');
$data = array(
'bindIndex'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'sourceType' => $sourceType, // 第三方登录来源
'platform'=>$sourceType,
'openId' => $openId, // openId
'nickname' => $nickName, //昵称
'areaCode'=>'+86',//默认区号
'countrys'=>RegData::getAreasData(),//国别码
'nickname' => $nickname, //昵称
);
// 渲染模板
... ... @@ -38,16 +53,22 @@ class BindController extends AbstractAction
$this->setTitle('验证手机');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
$nickName = $this->get('nickName');
$area = $this->get('areaCode', '86');
$nickname = $this->get('nickname');
$areaCode = $this->get('areaCode', '86');
$isReg = $this->get('isReg');
$mobile=$this->get('mobile');
$data = array(
'bindIndex'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'sourceType' => $sourceType, // 第三方登录来源
'openId' => $openId, // openId
'nickname' => $nickName, //昵称
'nickname' => $nickname, //昵称
'isReg' => $isReg, //是否是已注册过的手机号
'area' => $area //国别码
'areaCode' => $areaCode, //国别码
'phoneNum'=>$mobile,//手机号码
);
// 渲染模板
... ... @@ -63,13 +84,17 @@ class BindController extends AbstractAction
$this->setTitle('重新设置登录密码');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
$nickName = $this->get('nickName');
$area = $this->get('areaCode', '86');
$nickname = $this->get('nickname');
$areaCode = $this->get('areaCode', '86');
$data = array(
'bindIndex'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'sourceType' => $sourceType, // 第三方登录来源
'openId' => $openId, // openId
'nickname' => $nickName, //昵称
'area' => $area //国别码
'nickname' => $nickname, //昵称
'areaCode' => $areaCode //国别码
);
// 渲染模板
... ... @@ -91,12 +116,12 @@ class BindController extends AbstractAction
$mobile = $this->post('mobile');
$openId = $this->post('openId');
$area = $this->post('areaCode', '86');
$areaCode = $this->post('areaCode', '86');
$sourceType = $this->post('sourceType');
$nickName = $this->post('nickName');
$nickname = $this->post('nickname');
if (!is_numeric($mobile) || !$openId || !$area || !$sourceType)
if (!is_numeric($mobile) || !$openId || !$areaCode || !$sourceType)
{
break;
}
... ... @@ -108,7 +133,7 @@ class BindController extends AbstractAction
}
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));
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'mobile' => $mobile));
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('is_register' => $res['data']['is_register'], 'next' => $next));
}
else
... ... @@ -135,13 +160,14 @@ class BindController extends AbstractAction
}
$mobile = $this->post('mobile');
$areaCode = $this->post('areaCode');
if (!is_numeric($mobile))
{
break;
}
$data = BindData::sendBindMsg($mobile);
$data = BindData::sendBindMsg($areaCode,$mobile);
if (!isset($data['code']))
{
break;
... ... @@ -167,13 +193,14 @@ class BindController extends AbstractAction
$mobile = $this->post('mobile');
$msgCode = $this->post('msgCode');
$areaCode = $this->post('areaCode');
if (!is_numeric($mobile) || !$msgCode)
{
break;
}
$data = BindData::checkBindCode($mobile, $msgCode);
$data = BindData::checkBindCode($areaCode,$mobile, $msgCode);
if (!isset($data['code']))
{
break;
... ... @@ -199,17 +226,17 @@ class BindController extends AbstractAction
$mobile = $this->post('mobile');
$openId = $this->post('openId');
$area = $this->post('areaCode', '86');
$areaCode = $this->post('areaCode', '86');
$sourceType = $this->post('sourceType');
$nickName = $this->post('nickName');
$nickname = $this->post('nickname');
$password = $this->post('password');
if (!is_numeric($mobile) || !$openId || !$sourceType || !$area)
if (!is_numeric($mobile) || !$openId || !$sourceType || !$areaCode)
{
break;
}
$res = BindData::bindMobile($openId, $nickName, $sourceType, $mobile, $area, $password);
$res = BindData::bindMobile($openId, $nickname, $sourceType, $mobile, $areaCode, $password);
if (!isset($res['code']))
{
break;
... ...