9月7日问题汇总修改

This commit is contained in:
tiansf 2024-09-09 03:35:17 +08:00
parent eac1e75b8f
commit 53b1af4377
4 changed files with 73 additions and 53 deletions

View File

@ -105,6 +105,7 @@ class Base extends Controller{
}
// 秒转化格式00:00:00
public function handle_hour_branch_second($data = '2000'){
$data = abs($data);
$hours = intval($data / 3600);
$minutes = intval(($data % 3600) / 60);
$remainingSeconds = $data % 60;

View File

@ -274,13 +274,13 @@ class Index extends Base{
return $this->msg(20001);
}
unset($data['token']);
$user_card_list = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,card_order')->find();
$user_card_list = Db::table('app_user_data')->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,card_order')->find();
if(!$user_card_list){
return $this->msg(10003);
}
unset($user_card_list['ROW_NUMBER']);
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
$all_card_list = Db::table('app_card_data')->field('id,name,pic')->select();
$all_card_list = Db::table('app_card_data')->where(['is_del'=>0])->field('id,name,pic')->select();
// dump($user_card_list);
// dump($all_card_list);
$result = ['user'=>[],'all'=>[]];
@ -480,7 +480,7 @@ class Index extends Base{
// 设置验证
$rule = [
'aan_id' => 'require|number',
'nickname' => 'require|chsAlpha',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
'grade' => 'require',
@ -499,7 +499,7 @@ class Index extends Base{
// 'identity.require' => '身份缺失',
'aan_id.number' => '账号信息格式错误',
'nickname.chsAlpha' => '昵称只能是只能是汉字、字母',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',

View File

@ -20,30 +20,35 @@ class Login extends Base{
// 注册
public function register_action($data = ['data'=>18530934717,'password'=>'ceshi','code'=>'746119']){
// 验证是否前段发送过来的数据
if(count(input('post.')) > 0){
$data = input('post.');
}
// 验证数据项是否完整
if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('code', $data)){
return $this->msg(10001);
}
// 验证数据值是否合规
if(!$data['data'] || !$data['password'] || !$data['code']){
return $this->msg(10006);
}
$set_data = [];
// 验证是手机还是邮箱
$montage_data = $this->is_tel_email($data['data']);
if($montage_data == false){
return $this->msg(10005);
}
// 查询账号是否已经注册
$inspect_repeat = Db::table('app_account_number')->where([$montage_data=>$data['data'],'is_del'=>0])->count();
if($inspect_repeat >= 0){
return $this->msg(10002,'注册失败,账号已存在');
}
// 检查验证码
$code_result = $this->check_code($data['data'],$data['code']);
if($code_result !== true){
return $this->msg(10002,$code_result);
}
// 验证完之后
$set_data = [];
if($montage_data == 'tel'){
$set_data['tel'] = $data['data'];
}else{
@ -64,19 +69,22 @@ class Login extends Base{
}
// 重置密码
public function reset_password($data = ['data'=>'18530934717','password'=>'ceshi1','c_password'=>'ceshi1','code'=>'491661']){
// 验证是否前段发送过来的数据
if(count(input('post.')) > 0){
$data = input('post.');
}
// 验证数据项是否完整
if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('c_password', $data) || !array_key_exists('code', $data)){
return $this->msg(10001);
}
// 验证数据值是否合规
if($data['password'] != $data['c_password']){
return $this->msg(10003,'两次密码不一致');
}
if($data['password'] == ''){
return $this->msg(10003,'密码不能为空');
}
// 检查验证码
$code_result = $this->check_code($data['data'],$data['code']);
if($code_result !== true){
return $this->msg(10003,$code_result);
@ -85,7 +93,8 @@ class Login extends Base{
if($t_y === false){
return $this->msg(10003,'账号格式错误');
}
$find_data = Db::table('app_account_number')->where([$t_y=>$data['data']])->field('id,token')->find();
// 检查账号是否存在
$find_data = Db::table('app_account_number')->where([$t_y=>$data['data'],'is_del'=>0])->field('id,token')->find();
if(!$find_data){
return $this->msg(10003);
}
@ -205,7 +214,9 @@ class Login extends Base{
* $type验证类型是注册用还是其他用途 字符串 默认register注册register、login、reset_password
* $road是手机还是邮箱还是其他 字符串 默认tel或email
*/
public function send_phone_email_code($data = ['data'=>'tsf3920322@126.com','type'=>'login']){
public function send_phone_email_code($data = ['data'=>'18530934717']){
// dump(cache('linshi'));
// die;
// $data = input('post.');
if(count(input('post.')) > 0){
$data = input('post.');
@ -228,6 +239,7 @@ class Login extends Base{
$road = 'email';
}
// dump($result);
// dump($road);
// die;
if(is_array($result) && $result['code'] == 0){
cache($data['data'], $num, $this->code_time);
@ -236,12 +248,57 @@ class Login extends Base{
return $this->msg([]);
// return true;
}else{
return $this->msg(10002);
return $this->msg(10010,'验证码发送失败');
// return false;
}
}
################################内部调用################################
/* 接口说明(发手机短信)
*/
public function send_tel_code($tel,$code){
// 初始化cURL会话
$ch = curl_init();
$headers = [
'Accept: application/json',
'Content-Type: application/json',
];
// 设置头部信息
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// 设置请求的URL
$url = "http://sms.ybhdmob.com/Message/Send?token=ybhdmob";
curl_setopt($ch, CURLOPT_URL, $url);
// 设置为POST请求
curl_setopt($ch, CURLOPT_POST, 1);
// 设置POST数据
$postData = array(
'phone' => $tel,
// 'content' => '您好欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码三分钟内有效,若非本人操作,请忽略!'
'content' => '测试验证码为:'.$code
);
$postData = json_encode($postData);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// 设置返回结果不直接输出,而是返回到变量中
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 发送请求并获取响应
$response = curl_exec($ch);
// 检查是否有错误发生
if (curl_errno($ch)) {
$error_message = curl_error($ch);
return "请求错误: " . $error_message;
}
// 关闭cURL会话
curl_close($ch);
// 处理响应
// dump($response);
cache('linshi', $response);
if ($response) {
return json_decode($response,true);
} else {
echo "未收到响应";
}
}
/* 接口说明(发邮件)
* $address收件人的邮箱地址 数组 格式: ['460834639@qq.com','460834639@qq.com'.......]
* $content邮件的主题数据信息 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123']
@ -390,49 +447,11 @@ class Login extends Base{
}
}
public function send_tel_code($tel,$code){
// 初始化cURL会话
$ch = curl_init();
$headers = [
'Accept: application/json',
'Content-Type: application/json',
];
// 设置头部信息
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// 设置请求的URL
$url = "http://sms.ybhdmob.com/Message/Send?token=ybhdmob";
curl_setopt($ch, CURLOPT_URL, $url);
// 设置为POST请求
curl_setopt($ch, CURLOPT_POST, 1);
// 设置POST数据
$postData = array(
'phone' => $tel,
'content' => '您好欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码三分钟内有效,若非本人操作,请忽略!'
);
$postData = json_encode($postData);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// 设置返回结果不直接输出,而是返回到变量中
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 发送请求并获取响应
$response = curl_exec($ch);
// 检查是否有错误发生
if (curl_errno($ch)) {
$error_message = curl_error($ch);
return "请求错误: " . $error_message;
}
// 关闭cURL会话
curl_close($ch);
// 处理响应
if ($response) {
return json_decode($response,true);
} else {
echo "未收到响应";
}
}
public function check_code($data = 18530934717 , $code = 123456){
// 默认验证码正确
return true;
// // 默认验证码正确
// return true;
// dump($data);
// dump(cache($data));
// die;

View File

@ -75,7 +75,7 @@ class Pagingcontrast extends Base{
return $this->jump_transfer_interface_detailed($data);
}
// 数据对比(包含身体、跳绳、肺活量)
public function get_all_card_data_contrast($data = ['before_id'=>'11','after_id'=>'10','type'=>'8','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function get_all_card_data_contrast($data = ['before_id'=>'837','after_id'=>'836','type'=>'6','token'=>'caadd1be045a65f30b92aa805f1de54a']){
if(count(input('post.')) > 0){
$data = input('post.');
}
@ -514,7 +514,7 @@ class Pagingcontrast extends Base{
'diffval'=>bcsub($after_arr,$before_arr,2)
];
if($key=='jump_time'){
$temporary_arr['diffval'] = $temporary_arr['diffval'] >= 0?implode(':',$this->handle_hour_branch_second($before_arr)):'-'.implode(':',$this->handle_hour_branch_second($before_arr));
$temporary_arr['diffval'] = $temporary_arr['diffval'] >= 0?implode(':',$this->handle_hour_branch_second($temporary_arr['diffval'])):'-'.implode(':',$this->handle_hour_branch_second($temporary_arr['diffval']));
}
array_push($return_data['list'], $temporary_arr);