Authored by xiaowei

YW-1678 返回bug

... ... @@ -42,7 +42,7 @@ class BindData
* @param string $mobile 手机号
*
*/
public static function sendBindMsg($area,$mobile)
public static function sendBindMsg($area, $mobile)
{
$param = Yohobuy::param();
... ... @@ -58,7 +58,7 @@ class BindData
* 验证验证码是否正确
*
*/
public static function checkBindCode($area,$mobile, $code)
public static function checkBindCode($area, $mobile, $code)
{
$param = Yohobuy::param();
... ... @@ -100,4 +100,47 @@ class BindData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 换绑手机检验
* @param string $mobile 手机号
* @param string $area 国别码
*/
public static function changeCheck($mobile, $area)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.changeCheck';
$param['mobile'] = $mobile;
$param['area'] = $area;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 换绑手机
* @param string $uid 用户Id
* @param string $code 验证码
* @param string $mobile 手机号
* @param string $area 国别码
*/
public static function changeMobile($uid, $mobile, $area, $code)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.changeMobile';
$param['mobile'] = $mobile;
$param['uid'] = $uid;
$param['code'] = $code;
$param['area'] = $area;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
<div class="header">
{{#backUrl}}
<a class="go-back" href="javascript:history.go(-1);"></a>
{{/backUrl}}
<a class="go-back" href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}"></a>
{{#showHeaderImg}}
<div class="img-header"></div>
<div class="img-header"></div>
{{/showHeaderImg}}
{{#headerText}}
<p class="title">{{.}}</p>
<p class="title">{{.}}</p>
{{/headerText}}
</div>
\ No newline at end of file
... ...
... ... @@ -17,7 +17,8 @@ class BindController extends AbstractAction
public function indexAction()
{
$refer = $this->get('refer');
if (!empty($refer)) {
if (!empty($refer))
{
$this->setCookie('refer', $refer);
}
... ... @@ -105,9 +106,11 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
... ... @@ -118,21 +121,27 @@ class BindController extends AbstractAction
$nickname = $this->post('nickname');
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) {
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType)
{
break;
}
$res = BindData::bindCheck($phoneNum, $openId, $sourceType);
if (!isset($res['code'])) {
if (!isset($res['code']))
{
break;
}
if ($res['code'] == 200) {
if ($res['code'] == 200)
{
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum));
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next));
} else {
}
else
{
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
}
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -142,24 +151,29 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum)) {
if (!is_numeric($phoneNum) || !$areaCode)
{
break;
}
$data = BindData::sendBindMsg($areaCode, $phoneNum);
if (!isset($data['code'])) {
if (!isset($data['code']))
{
break;
}
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -169,9 +183,11 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
... ... @@ -179,15 +195,18 @@ class BindController extends AbstractAction
$code = $this->post('code');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum) || !$code) {
if (!is_numeric($phoneNum) || !$code || !$areaCode)
{
break;
}
$data = BindData::checkBindCode($areaCode, $phoneNum, $code);
if (!isset($data['code'])) {
if (!isset($data['code']))
{
break;
}
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -197,9 +216,11 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
... ... @@ -210,33 +231,107 @@ class BindController extends AbstractAction
$nickname = $this->post('nickname');
$password = $this->post('password');
if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode) {
if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode)
{
break;
}
$res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password);
if (!isset($res['code'])) {
if (!isset($res['code']))
{
break;
}
//绑定成功,跳转页面
$refer = $this->getCookie('refer');
if (empty($refer)) {
if (empty($refer))
{
$refer = SITE_MAIN . '/?go=1';
} else {
}
else
{
$refer = rawurldecode($refer);
}
if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid'])) {
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($res['data']['uid'], $refer);
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
} else {
}
else
{
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
}
} while (false);
}
while (false);
$this->echoJson($data);
}
//换绑check
public function changeCheckAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
break;
}
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum) || !$areaCode)
{
break;
}
$data = BindData::changeCheck($phoneNum, $areaCode);
if (!isset($data['code']))
{
break;
}
}
while (false);
$this->echoJson($data);
}
//换绑mobile
public function changeMobileAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
break;
}
$uid = $this->getUid(true);
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
$code = $this->post('code');
if (!is_numeric($phoneNum) || !$areaCode || !$code || !$uid)
{
break;
}
$data = BindData::changeMobile($uid, $phoneNum, $areaCode, $code);
if (!isset($data['code']))
{
break;
}
}
while (false);
$this->echoJson($data);
}
... ...