添加手机登录的功能

master
zhengyongxing 4 years ago
parent 114e51ebe2
commit 288f121955

@ -81,7 +81,7 @@ class PublicController extends \Think\Controller
$this->error('验证码错误');
}
$member = M('ucenter_member ucenter')
->field("uid,nickname,last_login_time,status")
->field("uid,nickname,ucenter.last_login_time,member.status")
->join("left join sys_member member on ucenter.id=member.uid")
->where(['mobile' => $mobile])->find();
@ -94,8 +94,39 @@ class PublicController extends \Think\Controller
if ($member) {
/* 记录登录SESSION和COOKIES */
$Member = D('Member');
$Member->autoLogin($member);
/* 更新登录信息 */
$data = array(
'uid' => $member['uid'],
'login' => array('exp', '`login`+1'),
'last_login_time' => NOW_TIME,
'last_login_ip' => get_client_ip(1),
);
$Member->save($data);
$adminData = getAdminData($member['uid']);
$groupId = getGameGroup($member['uid']);
/* 记录登录SESSION和COOKIES */
$auth = array(
'uid' => $member['uid'],
'username' => $member['nickname'],
'last_login_time' => $member['last_login_time'],
'data_empower_type'=>$adminData['data_empower_type'],
'data_president'=>$adminData['data_president'],
'show_data'=>$adminData['show_data'],
);
//登录有效时间改为6小时
$expireTime = 3600;
ini_set('session.gc_maxlifetime', $expireTime);
ini_set('session.cookie_lifetime', $expireTime);
session('user_group_id',$groupId);
session('user_auth', $auth);
session('user_auth_sign', data_auth_sign($auth));
session('user_auth_expire', time());
session_regenerate_id();
} else {
$this->error('登录失败');
}
// else {
// $partner = M('partner', 'tab_')->where(['link_phone' => $mobile,])->find();

@ -284,9 +284,16 @@ class UserController extends AdminController
if (!empty($emailUser)) {
$this->error('邮箱已存在!');
}
$moblieUser = M('UcenterMember', 'sys_')->field('id')->where(['mobile' => $_POST['mobile']])->find();
if (!empty($moblieUser)) {
$this->error('手机号码已存在!');
}
/* 调用注册接口注册用户 */
$User = new UserApi;
$uid = $User->register($username, $password, $email, $second_pwd);
$uid = $User->register($username, $password, $email, $second_pwd, $_POST['mobile']);
if (0 < $uid) { //注册成功
$user = array('uid' => $uid,'real_name'=>$real_name, 'nickname' => $username, 'status' => 1,"birthday"=>date('Y-m-d',time()));
$data['uid'] = $uid;
@ -373,21 +380,21 @@ class UserController extends AdminController
if (!preg_match($pattern, $_POST['email'])) {
$this->error('邮箱格式不正确!');
}
if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
$dx = A('Phone');
$res = $dx->check_tel_code($_POST['mobile'], $_POST['code']);
switch ($res) {
case '-1':
$this->error('短信验证码无效,请重新获取');
break;
case '-2':
$this->error('时间超时,请重新获取短信验证码');
break;
case '-3':
$this->error('短信验证码不正确,请重新输入');
break;
}
}
// if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
// $dx = A('Phone');
// $res = $dx->check_tel_code($_POST['mobile'], $_POST['code']);
// switch ($res) {
// case '-1':
// $this->error('短信验证码无效,请重新获取');
// break;
// case '-2':
// $this->error('时间超时,请重新获取短信验证码');
// break;
// case '-3':
// $this->error('短信验证码不正确,请重新输入');
// break;
// }
// }
$Member = D('UcenterMember');
$mem = D('Member');
$au = D('AuthGroupAccess');

@ -66,6 +66,13 @@
<span class="notice-text">管理员邮箱,用于找回密码等安全操作</span>
</td>
</tr>
<tr>
<td class="l">手机</td>
<td class="r">
<input name="mobile" type="text" class="">
<span class="notice-text">管理员手机号码,用于找回密码等安全操作</span>
</td>
</tr>
</tbody>
</table>

@ -58,6 +58,16 @@
<span class="notice-text">管理员邮箱,用于找回密码等安全操作</span>
</td>
</tr>
<tr>
<td class="l">手机:</td>
<td class="r">
<input name="mobile" type="text" value="{$list.mobile}" class="puser">
<span class="notice-text">管理员手机号码,用于找回密码等安全操作</span>
<!-- <if condition="$list['mobile'] eq ''">-->
<!-- <span class="notice-text"><a href="javascript:;" class="pop-code smcode sendvcode">获取验证码</a></span>-->
<!-- </if>-->
</td>
</tr>
<if condition="is_administrator() and I('get.id') eq C('USER_ADMINISTRATOR')">
<tr>
<td class="l">手机:</td>

@ -111,7 +111,7 @@ class UcenterMemberModel extends Model{
'email' => $email,
'mobile' => $mobile,
);
//验证手机
if(empty($data['mobile'])) unset($data['mobile']);
/* 添加用户 */
@ -120,6 +120,8 @@ class UcenterMemberModel extends Model{
$data['email'] = $email;
$data['password'] = think_ucenter_md5($password, UC_AUTH_KEY);
$data['second_pwd'] = think_ucenter_md5($second_pwd, UC_AUTH_KEY);
$data['mobile'] = $mobile;
// dump($data);die();
try {
$status = M('UcenterMember', 'sys_')->add($data);
} catch (\Throwable $th) {

Loading…
Cancel
Save