|
@@ -31,15 +31,6 @@ class User extends Api
|
|
|
parent::_initialize();
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 会员中心
|
|
|
- */
|
|
|
- public function index()
|
|
|
- {
|
|
|
- $this->success('', ['welcome' => $this->auth->nickname]);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 会员登录
|
|
|
*
|
|
@@ -49,15 +40,15 @@ class User extends Api
|
|
|
*/
|
|
|
public function login()
|
|
|
{
|
|
|
- $countrycode = input('countrycode',86,'intval');
|
|
|
+
|
|
|
$account = input('account');
|
|
|
$password = input('password');
|
|
|
|
|
|
- if (!$countrycode || !$account || !$password) {
|
|
|
+ if (!$account || !$password) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
|
|
|
- $account = $countrycode.$account;
|
|
|
+
|
|
|
$ret = $this->auth->login($account, $password);
|
|
|
if ($ret) {
|
|
|
$data = $this->userInfo('return');
|
|
@@ -77,18 +68,18 @@ class User extends Api
|
|
|
*/
|
|
|
public function mobilelogin()
|
|
|
{
|
|
|
- $countrycode = input('countrycode',86,'intval');
|
|
|
+
|
|
|
$mobile = input('mobile');
|
|
|
$captcha = input('captcha');
|
|
|
|
|
|
- if (!$countrycode || !$mobile || !$captcha) {
|
|
|
+ if (!$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
@@ -106,7 +97,7 @@ class User extends Api
|
|
|
|
|
|
} else {
|
|
|
$extend = [
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
+
|
|
|
];
|
|
|
$ret = $this->auth->register('', '', '', $mobile, $extend);
|
|
|
|
|
@@ -226,9 +217,9 @@ class User extends Api
|
|
|
} else {
|
|
|
// 取号成功, 执行登录等流程
|
|
|
// 用户登录逻辑 === 开始
|
|
|
- $countrycode = 86;
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$user = \app\common\model\User::getByMobile($mobile);
|
|
|
if ($user) {
|
|
|
if ($user->status == -1) {
|
|
@@ -244,7 +235,7 @@ class User extends Api
|
|
|
|
|
|
} else {
|
|
|
$extend = [
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
+
|
|
|
];
|
|
|
$ret = $this->auth->register('', '', '', $mobile, $extend);
|
|
|
$is_register = 1;
|
|
@@ -540,17 +531,17 @@ class User extends Api
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$oldcaptcha = $this->request->request('oldcaptcha');
|
|
|
- $countrycode = $this->request->request('countrycode',86,'intval');
|
|
|
+
|
|
|
$mobile = $this->request->request('mobile');
|
|
|
$captcha = $this->request->request('captcha');
|
|
|
- if (!$oldcaptcha || !$countrycode || !$mobile || !$captcha) {
|
|
|
+ if (!$oldcaptcha || !$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if($user->mobile == $mobile){
|
|
|
$this->error('新手机号不能与旧手机号相同');
|
|
|
}
|
|
@@ -570,7 +561,7 @@ class User extends Api
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
|
|
|
$user->mobile = $mobile;
|
|
|
- $user->simplemobile = $simplemobile;
|
|
|
+
|
|
|
$user->save();
|
|
|
|
|
|
$this->success();
|
|
@@ -585,19 +576,19 @@ class User extends Api
|
|
|
*/
|
|
|
public function applebindmobile()
|
|
|
{
|
|
|
- $countrycode = $this->request->request('countrycode',86,'intval');
|
|
|
+
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
$iosUserId = $this->request->param('ios_user_id','');
|
|
|
|
|
|
- if (!$countrycode || !$mobile || !$captcha || !$iosUserId) {
|
|
|
+ if (!$mobile || !$captcha || !$iosUserId) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
@@ -635,7 +626,7 @@ class User extends Api
|
|
|
} else {
|
|
|
$extend = [
|
|
|
'ios_user_id' => $iosUserId,
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
+
|
|
|
];
|
|
|
$ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
}
|
|
@@ -656,19 +647,19 @@ class User extends Api
|
|
|
*/
|
|
|
public function bindmobile()
|
|
|
{
|
|
|
- $countrycode = $this->request->param('countrycode',86,'intval');
|
|
|
+
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
$code = $this->request->param('code');
|
|
|
|
|
|
- if (!$countrycode || !$mobile || !$captcha || !$code) {
|
|
|
+ if (!$mobile || !$captcha || !$code) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
@@ -710,7 +701,7 @@ class User extends Api
|
|
|
} else {
|
|
|
$extend = [
|
|
|
'wechat_openid' => $wechatCode['openid'],
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
+
|
|
|
];
|
|
|
$ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
}
|
|
@@ -765,20 +756,20 @@ class User extends Api
|
|
|
{
|
|
|
//$type = input("type");
|
|
|
$type = 'mobile';
|
|
|
- $countrycode = input("countrycode",86,'intval');
|
|
|
+
|
|
|
$mobile = input("mobile");
|
|
|
// $email = input("email");
|
|
|
$newpassword = input("newpassword");
|
|
|
$captcha = input("captcha");
|
|
|
- if (!$countrycode || !$mobile || !$newpassword || !$captcha) {
|
|
|
+ if (!$mobile || !$newpassword || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+
|
|
|
if ($type == 'mobile') {
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
+ }
|
|
|
$user = \app\common\model\User::getByMobile($mobile);
|
|
|
if (!$user) {
|
|
|
$this->error(__('User not found'));
|