|
|
@ -835,11 +835,47 @@ class ApiController extends \yii\web\Controller |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 短信验证码 |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function actionSmsVerifyCode(){ |
|
|
|
|
|
|
|
header("Access-Control-Allow-Origin: *"); |
|
|
|
|
|
|
|
header("Access-Control-Allow-Methods: POST"); |
|
|
|
|
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
|
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
|
|
|
|
$params = Yii::$app->request->post(); |
|
|
|
|
|
|
|
if (!isset($params['mobile']) || $params['mobile'] == '') { |
|
|
|
|
|
|
|
$result['success'] = false; |
|
|
|
|
|
|
|
$result['msg'] = '手机号无效'; |
|
|
|
|
|
|
|
return $result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$code = MyLib::randomStr(6,true); |
|
|
|
|
|
|
|
$url = 'http://user.banmacar.com/api/sms/single-send'; |
|
|
|
|
|
|
|
$params['token'] = 'b0909511a91119876a0957ab95fe8c7c'; |
|
|
|
|
|
|
|
$params['content'] = "【汇盈帮手】验证码是{$code}。如非本人操作,请忽略本短信"; |
|
|
|
|
|
|
|
$ret = MyLib::Post(http_build_query($params), $url); |
|
|
|
|
|
|
|
$ret = json_decode($ret, true); |
|
|
|
|
|
|
|
if (isset($ret['code']) && $ret['code'] == 200) { |
|
|
|
|
|
|
|
$result['code'] = -1; |
|
|
|
|
|
|
|
$result['msg'] = '短信发送成功'; |
|
|
|
|
|
|
|
$session = Yii::$app->session; |
|
|
|
|
|
|
|
$session->set('hy_vcode_'.$params['mobile'], $code); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$result['success'] = false; |
|
|
|
|
|
|
|
$result['msg'] = $ret['msg']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 游客注册接口 |
|
|
|
* 游客注册接口 |
|
|
|
* @return array |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionRegister(){ |
|
|
|
public function actionRegister(){ |
|
|
|
|
|
|
|
header("Access-Control-Allow-Origin: *"); |
|
|
|
|
|
|
|
header("Access-Control-Allow-Methods: POST"); |
|
|
|
|
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
$request = Yii::$app->request; |
|
|
|
$request = Yii::$app->request; |
|
|
|
$result = array( |
|
|
|
$result = array( |
|
|
@ -847,6 +883,7 @@ class ApiController extends \yii\web\Controller |
|
|
|
'msg' => '请求成功', |
|
|
|
'msg' => '请求成功', |
|
|
|
); |
|
|
|
); |
|
|
|
$name = trim($request->post('name','')); |
|
|
|
$name = trim($request->post('name','')); |
|
|
|
|
|
|
|
$code = trim($request->post('code','')); |
|
|
|
$mobile = trim($request->post('mobile','')); |
|
|
|
$mobile = trim($request->post('mobile','')); |
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
if($name == '' || !preg_match('/^1[345789]\d{9}$/', $mobile)){ |
|
|
|
if($name == '' || !preg_match('/^1[345789]\d{9}$/', $mobile)){ |
|
|
@ -854,6 +891,11 @@ class ApiController extends \yii\web\Controller |
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if($code == '' || Yii::$app->session->get('hy_vcode_'.$mobile) != $code){ |
|
|
|
|
|
|
|
$result['code'] = -1; |
|
|
|
|
|
|
|
$result['msg'] = '验证码错误'; |
|
|
|
|
|
|
|
return $result; |
|
|
|
|
|
|
|
} |
|
|
|
if($user) { |
|
|
|
if($user) { |
|
|
|
$user->password = MyLib::hashPwd('123456',$user->salt); |
|
|
|
$user->password = MyLib::hashPwd('123456',$user->salt); |
|
|
|
if(!$user->save()){ |
|
|
|
if(!$user->save()){ |
|
|
@ -913,6 +955,7 @@ class ApiController extends \yii\web\Controller |
|
|
|
$result['code'] = -1; |
|
|
|
$result['code'] = -1; |
|
|
|
$result['msg'] = $e->getMessage(); |
|
|
|
$result['msg'] = $e->getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Yii::$app->session->remove('hy_vcode_'.$mobile); |
|
|
|
} |
|
|
|
} |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|