111 lines
3.8 KiB
PHP
111 lines
3.8 KiB
PHP
<?php
|
||
namespace app\controller;
|
||
|
||
use app\v1\model\AppToken;
|
||
use think\facade\Db;
|
||
|
||
class Sign
|
||
{
|
||
public function password(){
|
||
if(empty($GLOBALS['data']['data']['mobile'])){
|
||
return show("手机号不能为空!");
|
||
}
|
||
if(empty($GLOBALS['data']['data']['password'])){
|
||
return show("密码不能为空!");
|
||
}
|
||
$password = md5($GLOBALS['data']['data']['password']);
|
||
$info = Db::name("student")->where("mobile",$GLOBALS['data']['data']['mobile'])->find();
|
||
if(empty($info)){
|
||
return show("找不到家长信息!");
|
||
}
|
||
if($info['password']!=$password){
|
||
return show("密码不正确,请重试!");
|
||
}
|
||
|
||
$tokenData = ['userid' => $info['id'],'loginTime' => time(),'rankStr' => strRand(5)];
|
||
$tk = authcode(json_encode($tokenData), 'ENCODE');
|
||
unset($info['password']);
|
||
$res = [
|
||
'TK' => $tk,
|
||
'user' => [
|
||
"userid"=>$info['id'],
|
||
"identifier"=>$info['identifier'],
|
||
"nickname"=>$info['nickname'],
|
||
"mobile"=>$info['mobile'],
|
||
"avatar"=> env("ADMIN_PANNEL_ADDRESS") . $info['avatar'],
|
||
"gender"=>$info['gender'],
|
||
"birthday"=>$info['birthday'],
|
||
"age"=>$info['age'],
|
||
"createtime"=>$info['createtime'],
|
||
"is_disabled"=>$info['disabled'],
|
||
"type"=>$info["type"],
|
||
"hot"=>$info['hot']
|
||
]
|
||
];
|
||
return show("验证成功!",SUCCESS_CODE,$res);
|
||
}
|
||
public function getuser(){
|
||
if(empty($GLOBALS['data']['userid'])){
|
||
return show("请上传TOKEN!");
|
||
}
|
||
|
||
$info = Db::name("student")->where("id",$GLOBALS['data']['userid'])->find();
|
||
if(empty($info)){
|
||
return show("找不到家长信息!");
|
||
}
|
||
$res = [
|
||
'user' => [
|
||
"userid"=>$info['id'],
|
||
"identifier"=>$info['identifier'],
|
||
"nickname"=>$info['nickname'],
|
||
"mobile"=>$info['mobile'],
|
||
"avatar"=> env("ADMIN_PANNEL_ADDRESS") . $info['avatar'],
|
||
"gender"=>$info['gender'],
|
||
"birthday"=>$info['birthday'],
|
||
"age"=>$info['age'],
|
||
"createtime"=>$info['createtime'],
|
||
"is_disabled"=>$info['disabled'],
|
||
"type"=>$info["type"],
|
||
"hot"=>$info['hot']
|
||
]
|
||
];
|
||
return show("操作成功!",SUCCESS_CODE,$res);
|
||
}
|
||
|
||
public function repass(){
|
||
if(empty($GLOBALS['data']['data']['mobile'])){
|
||
return show("手机号不能为空!");
|
||
}
|
||
$mobile = $GLOBALS['data']['data']['mobile'];
|
||
$info = Db::name("student")->where("mobile",$mobile)->find();
|
||
if(empty($info)){
|
||
return show("找不到用户信息!");
|
||
}
|
||
|
||
|
||
if(empty($GLOBALS['data']['data']['code'])){
|
||
return show("验证码不能为空!");
|
||
}
|
||
$code = $GLOBALS['data']['data']['code'];
|
||
|
||
if(empty($GLOBALS['data']['data']['password'])){
|
||
return show("请输入密码!");
|
||
}
|
||
$password = $GLOBALS['data']['data']['password'];
|
||
$code = Db::name("app_sms")->order("id desc")->where("mobile", $mobile)->find();
|
||
if(empty($code)){
|
||
return show("请发送短信后再试!");
|
||
}
|
||
Db::name("app_sms")->where("id",$code['id'])->inc("count",1)->update();
|
||
if((time() - $code['create_time'])>15*60){
|
||
return show("短信已经失效,请重新发送!");
|
||
}
|
||
|
||
|
||
|
||
Db::name("student")->where("id",$info['id'])->update([
|
||
"password" => md5($password)
|
||
]);
|
||
return show(SUCCESS_MESSAGE,SUCCESS_CODE,[]);
|
||
}
|
||
} |