Authored by whb

修改

<?php
namespace LibModels\Web\Home;
use Api\Yohobuy;
use Api\Sign;
use Plugin\Helpers;
class UserData extends \LibModels\Wap\Home\UserData
{
/**
* 根据手机号获取用户信息[TODO +cache]
*
* @param string $area
* @param string $mobile
* @return array
*/
public static function getUserInfoByMobile($area, $mobile)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.userlist';
$param['mobile'] = Helpers::makeMobile($area, $mobile);
$param['debug'] = 'Y';
$param['screen_size'] = '320x568';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 根据email获取用户信息
*
* @param string $email
* @return array
*/
public static function getUserInfoByEmail($email)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.userlist';
$param['email'] = $email;
$param['debug'] = 'Y';
$param['screen_size'] = '320x568';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
<?php
namespace LibModels\Web\Passport;
use Api\Yohobuy;
use Api\Sign;
use Plugin\Helpers;
class RegData extends \LibModels\Wap\Passport\RegData
{
/**
* 根据手机号获取用户信息[TODO +cache]
*
* @param string $area
* @param string $mobile
* @return string
*/
public static function getUserInfoByMobile($area, $mobile)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.userlist';
$param['mobile'] = Helpers::makeMobile($area, $mobile);
$param['debug'] = 'Y';
$param['screen_size'] = '320x568';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ namespace Passport;
use Plugin\Helpers;
use LibModels\Web\Home\IndexData;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Home\UserData;
use Plugin\Images;
use Plugin\Captcha;
... ... @@ -113,7 +113,7 @@ class PassportModel
*/
public static function getUserInfoByMobile($area, $mobile) {
$ret = array();
$data = RegData::getUserInfoByMobile($area, $mobile);
$data = UserData::getUserInfoByMobile($area, $mobile);
if($data['code'] == 200) {
if(!empty($data['data'])) {
$ret = current($data['data']);
... ... @@ -122,4 +122,20 @@ class PassportModel
return $ret;
}
/**
* 根据邮箱获取用户信息
*
* @param string $email
* @return array
*/
public static function getUserInfoByEmail($email) {
$ret = array();
$data = UserData::getUserInfoByEmail($email);
if($data['code'] == 200) {
if(!empty($data['data'])) {
$ret = current($data['data']);
}
}
return $ret;
}
}
... ...
... ... @@ -30,15 +30,27 @@ class BackController extends WebAction {
/**
* 校验验证码
*/
public function authcodeAction() {
$phoneNum = $this->post ('phoneNum', '');
$area = intval ($this->post( 'area', '86' ));
$verifyCode = $this->post ('verifyCode', '');
$data = array('code' => 400, 'message' =>'验证失败');
if ((Helpers::verifyEmail($phoneNum) || Helpers::verifyMobile($phoneNum))
&& PassportModel::verifyCode($verifyCode)) {
$data['code'] = 200;
$data['message'] = '验证成功';
public function authcodeAction()
{
$phoneNum = $this->post('phoneNum', '');
$area = intval($this->post('area', '86'));
$verifyCode = $this->post('verifyCode', '');
$data = array(
'code' => 200,
'message' => '验证成功'
);
if (PassportModel::verifyCode($verifyCode)) {
if (Helpers::verifyEmail($phoneNum)) {
if (empty(PassportModel::getUserInfoByEmail($phoneNum))) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
}
} else if (Helpers::verifyMobile($phoneNum)) {
if (empty(PassportModel::getUserInfoByMobile($phoneNum, $area))) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
}
}
}
echo $this->echoJson($data);
}
... ...