This commit is contained in:
parent
6e3394a681
commit
467601a859
|
|
@ -25,7 +25,7 @@ class Base extends Controller{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查变量是否是一个只有数字的一维数组
|
// 检查变量是否是一个只有数字的一维数组
|
||||||
function isNumericArray($array = [1,2,3]) {
|
function is_num_array($array = [1,2,3]) {
|
||||||
if (!is_array($array)) {
|
if (!is_array($array)) {
|
||||||
return false; // 变量不是数组
|
return false; // 变量不是数组
|
||||||
}
|
}
|
||||||
|
|
@ -35,8 +35,11 @@ class Base extends Controller{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// $result = Db::table('app_card_data')->where(['is_del'=>1])->cache(true,3600)->column('id');//查询结果缓存3600秒
|
// $result = Db::table('app_card_data')->where(['is_del'=>1])->cache(true,3600)->column('id');//查询结果缓存3600秒
|
||||||
$result = Db::table('app_card_data')->where(['is_del'=>0])->cache(true,3600)->select();//查询结果缓存3600秒
|
$result = Db::table('app_card_data')->where(['is_del'=>0])->cache(true,3600)->select();//查询结果缓存3600秒
|
||||||
|
dump($result);
|
||||||
|
die;
|
||||||
// dump(array_column($result, 'id'));
|
// dump(array_column($result, 'id'));
|
||||||
// die;
|
// die;
|
||||||
if(empty(array_diff($array, array_column($result, 'id')))){
|
if(empty(array_diff($array, array_column($result, 'id')))){
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ class Index extends Base{
|
||||||
// $result = Db::table('admin_user')->select();
|
// $result = Db::table('admin_user')->select();
|
||||||
// dump($result);
|
// dump($result);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 创建用户
|
// 创建用户
|
||||||
public function create_user_data(){
|
public function create_user_data($data = ['aan_id'=>66,'nickname'=>'王小二','birthday'=>'2019-01-01','gender'=>1,'grade'=>'二年级']){
|
||||||
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
|
}
|
||||||
$verify_result = $this->verify_parameters($data,'register');
|
$verify_result = $this->verify_parameters($data,'register');
|
||||||
if(!is_array($verify_result)){
|
if(!is_array($verify_result)){
|
||||||
return $this->msg(10002,$verify_result);
|
return $this->msg(10002,$verify_result);
|
||||||
|
|
@ -47,23 +47,29 @@ class Index extends Base{
|
||||||
|
|
||||||
// 获取账号下用户列表
|
// 获取账号下用户列表
|
||||||
// $type 1获取列表,2获取详细信息
|
// $type 1获取列表,2获取详细信息
|
||||||
public function user_card_list($aan_id,$type=1){
|
public function get_user_card_list($data = ['aan_id'=>66,'type'=>1]){
|
||||||
$result = Db::table('app_user_data')->where(['aan_id'=>$aan_id])->select();
|
if(count(input()) > 0){
|
||||||
|
$data = input();
|
||||||
|
}
|
||||||
|
$result = Db::table('app_user_data')->where(['aan_id'=>$data['aan_id']])->select();
|
||||||
// $result = Db::table('app_user_data')->where(['aan_id'=>$aan_id])->field('id,nickname')->select();
|
// $result = Db::table('app_user_data')->where(['aan_id'=>$aan_id])->field('id,nickname')->select();
|
||||||
$data = [];
|
$temporary_data = [];
|
||||||
if($type == 1){
|
if($data['type'] == 1){
|
||||||
for ($i=0; $i < count($result); $i++) {
|
for ($i=0; $i < count($result); $i++) {
|
||||||
array_push($data,['id'=>$result[$i]['id'],'nickname'=>$result[$i]['nickname']]);
|
array_push($temporary_data,['id'=>$result[$i]['id'],'nickname'=>$result[$i]['nickname']]);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$data = $result;
|
$temporary_data = $result;
|
||||||
}
|
}
|
||||||
return $this->msg(0,'success',$data);
|
return $this->msg(0,'success',$temporary_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取指定用户详细信息
|
// 获取指定用户详细信息
|
||||||
public function user_data_information($id=11){
|
public function get_user_data_information($data = ['aud_id'=>11]){
|
||||||
$result = Db::table('app_user_data')->where(['id'=>$id])->field('id,aan_id,nickname,birthday,gender,card_order')->find();
|
if(count(input()) > 0){
|
||||||
|
$data = input();
|
||||||
|
}
|
||||||
|
$result = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,aan_id,nickname,birthday,gender,card_order')->find();
|
||||||
unset($result['ROW_NUMBER']);
|
unset($result['ROW_NUMBER']);
|
||||||
if($result['card_order'] === ''){
|
if($result['card_order'] === ''){
|
||||||
$result['age'] = $this->calculate_age($result['birthday']);
|
$result['age'] = $this->calculate_age($result['birthday']);
|
||||||
|
|
@ -77,8 +83,11 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有卡片列表信息
|
// 获取所有卡片列表信息
|
||||||
public function get_card_all_list($id = 11){
|
public function get_card_all_list($data = ['aud_id'=>11]){
|
||||||
$user_card_list = Db::table('app_user_data')->where(['id'=>$id])->field('id,card_order')->find();
|
if(count(input()) > 0){
|
||||||
|
$data = input();
|
||||||
|
}
|
||||||
|
$user_card_list = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,card_order')->find();
|
||||||
unset($user_card_list['ROW_NUMBER']);
|
unset($user_card_list['ROW_NUMBER']);
|
||||||
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
|
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
|
||||||
$all_card_list = Db::table('app_card_data')->field('id,name')->select();
|
$all_card_list = Db::table('app_card_data')->field('id,name')->select();
|
||||||
|
|
@ -97,38 +106,33 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存用户的卡片排序
|
// 保存用户的卡片排序
|
||||||
public function save_user_card_order($data=['id'=>11,'card_order'=>[2,8]]){
|
public function save_user_card_order($data=['aud_id'=>11,'card_order'=>'2,8']){
|
||||||
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
if(!array_key_exists('order_list', $data) || !array_key_exists('user_token', $data)){
|
|
||||||
return $this->msg(10001,'数据格式错误');
|
|
||||||
}
|
}
|
||||||
if(!$this->isNumericArray($data['order_list'])){
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('card_order', $data)){
|
||||||
|
return $this->msg(10001,'数据参数错误');
|
||||||
|
}
|
||||||
|
// dump($data['card_order']);
|
||||||
|
// dump(explode(',',$data['card_order']));
|
||||||
|
// die;
|
||||||
|
dump($this->is_num_array(explode(',',$data['card_order'])));
|
||||||
|
die;
|
||||||
|
if(!$this->is_num_array(explode(',',$data['card_order']))){
|
||||||
return $this->msg(10002,'数据内参数格式或值错误');
|
return $this->msg(10002,'数据内参数格式或值错误');
|
||||||
}
|
}
|
||||||
$data['card_order'] = json_encode($data['card_order']);
|
|
||||||
$result = Db::table('app_user_data')->where(['id'=>$data['id']])->update(['card_order'=>implode(',',$data['card_order'])]);
|
|
||||||
return $this->msg(0,'success');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 存储卡片顺序
|
$data['card_order'] = json_encode($data['card_order']);
|
||||||
// $data = ['id'=>'xxxxxxxxxxxxxxx','card_order'=>[1,2,3,4,5]]
|
$result = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->update(['card_order'=>$data['card_order']]);
|
||||||
public function save_card_order(){
|
|
||||||
$data = input();
|
|
||||||
if(!array_key_exists('order_list', $data) || !array_key_exists('user_token', $data)){
|
|
||||||
return $this->msg(10001,'数据格式错误');
|
|
||||||
}
|
|
||||||
if(!$this->isNumericArray($data['order_list'])){
|
|
||||||
return $this->msg(10002,'数据内参数格式或值错误');
|
|
||||||
}
|
|
||||||
$data['order_list'] = json_encode($data['order_list']);
|
|
||||||
$result = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->update(['card_order'=>$data['order_list']]);
|
|
||||||
if($result){
|
if($result){
|
||||||
return $this->msg(0,'success');
|
return $this->msg(0,'success');
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10003,'修改失败');
|
return $this->msg(10003,'保存失败或未发生改变');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
################################获取账号下信息操作################################
|
################################获取账号下信息操作################################
|
||||||
// 获取账号下首页卡片的基础数据
|
// 获取账号下首页卡片的基础数据
|
||||||
public function get_user_card_data_list($data,$aud_id){
|
public function get_user_card_data_list($data,$aud_id){
|
||||||
|
|
@ -194,14 +198,16 @@ class Index extends Base{
|
||||||
$parameter['create_time'] = date('Y-m-d H:i:s');
|
$parameter['create_time'] = date('Y-m-d H:i:s');
|
||||||
$parameter['last_update_time'] = date('Y-m-d H:i:s');
|
$parameter['last_update_time'] = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
$result = Db::table('app_user_data')->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id']])->count();
|
||||||
|
if($result>0){
|
||||||
|
return '该成员已存在';
|
||||||
|
}
|
||||||
|
|
||||||
return $parameter;
|
return $parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function msg($code,$msg='',$data=[]){
|
|
||||||
return json(['code'=>$code,'msg'=>$msg,'data'=>$data]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -18,11 +18,11 @@ class Login extends Base{
|
||||||
################################################################个人资料卡################################################################
|
################################################################个人资料卡################################################################
|
||||||
|
|
||||||
// 注册
|
// 注册
|
||||||
public function register_action($data = ['tel'=>18866668889,'password'=>'ceshi','code'=>'123456']){
|
public function register_action($data = ['data'=>15588885555,'password'=>'ceshi','code'=>'123456']){
|
||||||
|
|
||||||
// dump('123');
|
// dump('123');
|
||||||
phpinfo();
|
// phpinfo();
|
||||||
die;
|
// die;
|
||||||
if(count(input()) > 0){
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +30,8 @@ class Login extends Base{
|
||||||
if(!is_array($verify_result)){
|
if(!is_array($verify_result)){
|
||||||
return $this->msg(10001,$verify_result);
|
return $this->msg(10001,$verify_result);
|
||||||
}
|
}
|
||||||
// dump('321');
|
// dump($verify_result);
|
||||||
|
// die;
|
||||||
// 记录
|
// 记录
|
||||||
$result = Db::table('app_account_number')->insert($verify_result);
|
$result = Db::table('app_account_number')->insert($verify_result);
|
||||||
if($result){
|
if($result){
|
||||||
|
|
@ -47,7 +48,7 @@ class Login extends Base{
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!array_key_exists('data', $data) || !array_key_exists('validate_data', $data) || !array_key_exists('type', $data) || !array_key_exists('validate_type', $data)){
|
if(!array_key_exists('data', $data) || !array_key_exists('validate_data', $data) || !array_key_exists('validate_type', $data)){
|
||||||
return $this->msg(10001,'参数缺失');
|
return $this->msg(10001,'参数缺失');
|
||||||
}
|
}
|
||||||
// 检测是否为手机
|
// 检测是否为手机
|
||||||
|
|
@ -60,19 +61,24 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
// 检测校验途径
|
// 检测校验途径
|
||||||
if($data['validate_type'] == 'code'){
|
if($data['validate_type'] == 'code'){
|
||||||
$code_name = $data['data']."_".$road."_".$data['type'];
|
$code_name = $data['data'];
|
||||||
// dump(cache($code_name));
|
// dump(cache($code_name));
|
||||||
// die;
|
// die;
|
||||||
if(cache($code_name) == $data['validate_data']){
|
if(cache($code_name) == $data['validate_data']){
|
||||||
return $this->msg(0,'success',$data);
|
$result = Db::table('app_account_number')->where(['tel'=>$verify_result['tel']])->find();
|
||||||
|
if($result){
|
||||||
|
return $this->msg(0,'success',$result['id']);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002,'登录失败,无效账号');
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10001,'登录失败,验证码错误或失效');
|
return $this->msg(10001,'登录失败,验证码错误或失效');
|
||||||
}
|
}
|
||||||
}else if($data['validate_type'] == 'password'){
|
}else if($data['validate_type'] == 'password'){
|
||||||
$verify_result['password'] = $data['validate_data'];
|
$verify_result['password'] = $data['validate_data'];
|
||||||
$result = Db::table('app_account_number')->where($verify_result)->count();
|
$result = Db::table('app_account_number')->where($verify_result)->find();
|
||||||
if($result){
|
if($result){
|
||||||
return $this->msg(0,'success');
|
return $this->msg(0,'success',$result['id']);
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10001,'登录失败,账号/密码错误');
|
return $this->msg(10001,'登录失败,账号/密码错误');
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +111,7 @@ class Login extends Base{
|
||||||
$road = 'email';
|
$road = 'email';
|
||||||
}
|
}
|
||||||
if(is_array($result) && $result['code'] == 0){
|
if(is_array($result) && $result['code'] == 0){
|
||||||
cache($data['data']."_".$road."_".$data['type'], $num, 60);
|
cache($data['data'], $num, 60);
|
||||||
// dump($data['data']."_".$data['road']."_".$data['type']);
|
// dump($data['data']."_".$data['road']."_".$data['type']);
|
||||||
return $this->msg(0,'success',$num);
|
return $this->msg(0,'success',$num);
|
||||||
// return true;
|
// return true;
|
||||||
|
|
@ -230,17 +236,15 @@ class Login extends Base{
|
||||||
public function verify_parameters($data,$type){
|
public function verify_parameters($data,$type){
|
||||||
// 设置验证
|
// 设置验证
|
||||||
$rule = [
|
$rule = [
|
||||||
'tel' => 'number|length:11',
|
'data' => 'require',
|
||||||
'password' => 'require',
|
'password' => 'require',
|
||||||
'email' => 'email',
|
'code' => 'require|number',
|
||||||
'code' => 'number',
|
|
||||||
];
|
];
|
||||||
$msg = [
|
$msg = [
|
||||||
'password.require' => '密码必须',
|
'password.require' => '密码必须',
|
||||||
'tel.number' => '手机必须是数字',
|
'data.require' => '手机或邮箱必须',
|
||||||
'code.number' => '验证码必须是数字',
|
'code.number' => '验证码必须是数字',
|
||||||
'tel.length' => '手机必须是11位',
|
'code.number' => '验证码必须',
|
||||||
'email' => '邮箱格式错误',
|
|
||||||
];
|
];
|
||||||
$validate = new Validate($rule,$msg);
|
$validate = new Validate($rule,$msg);
|
||||||
$result = $validate->check($data);
|
$result = $validate->check($data);
|
||||||
|
|
@ -249,31 +253,30 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
// dump('3211');
|
// dump('3211');
|
||||||
// 判断参数
|
// 判断参数
|
||||||
if(array_key_exists('tel', $data)){
|
if(preg_match('/^\d{11}$/', $data['data'])){
|
||||||
$parameter['tel'] = $data['tel'];
|
$parameter['tel'] = $data['data'];
|
||||||
$parameter['password'] = $data['password'];
|
|
||||||
$montage_data = 'tel';
|
$montage_data = 'tel';
|
||||||
}else if(array_key_exists('email', $data)){
|
|
||||||
$parameter['email'] = $data['email'];
|
|
||||||
$parameter['password'] = $data['password'];
|
|
||||||
$montage_data = 'email';
|
|
||||||
}else{
|
}else{
|
||||||
return '手机/邮箱必须';
|
$parameter['email'] = $data['data'];
|
||||||
|
$montage_data = 'email';
|
||||||
}
|
}
|
||||||
|
$parameter['password'] = $data['password'];
|
||||||
|
|
||||||
dump($montage_data);
|
// dump($montage_data);
|
||||||
|
// dump( $parameter);
|
||||||
// 检验是否注册过
|
// 检验是否注册过
|
||||||
if($montage_data == 'tel'){
|
if($montage_data == 'tel'){
|
||||||
// $inspect_repeat = Db::table('app_account_number')->where(['tel'=>$parameter['tel'],'password'=>$parameter['password']])->count();
|
$inspect_repeat = Db::table('app_account_number')->where(['tel'=>$parameter['tel']])->count();
|
||||||
$inspect_repeat = Db::query("select count(*) from app_account_number where tel='".$parameter['tel']."'and password='".$parameter['password']);
|
// $inspect_repeat = Db::query("select count(*) from app_account_number where tel='".$parameter['tel']."'and password='".$parameter['password']);
|
||||||
}else{
|
}else{
|
||||||
$inspect_repeat = Db::table('app_account_number')->where(['email'=>$parameter['email'],'password'=>$parameter['password']])->count();
|
$inspect_repeat = Db::table('app_account_number')->where(['email'=>$parameter['email']])->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dump( $inspect_repeat);
|
||||||
dump($inspect_repeat);
|
// die;
|
||||||
|
// dump($inspect_repeat);
|
||||||
// dump('3212');
|
// dump('3212');
|
||||||
if($inspect_repeat){
|
if($inspect_repeat>0){
|
||||||
return '注册失败,账号已存在';
|
return '注册失败,账号已存在';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,10 +284,10 @@ class Login extends Base{
|
||||||
if($type == 'register'){
|
if($type == 'register'){
|
||||||
if(array_key_exists('code', $data)){
|
if(array_key_exists('code', $data)){
|
||||||
// dump($parameter[$montage_data]."_".$montage_data."_register".'='.cache($parameter[$montage_data]."_".$montage_data."_register"));
|
// dump($parameter[$montage_data]."_".$montage_data."_register".'='.cache($parameter[$montage_data]."_".$montage_data."_register"));
|
||||||
if(cache($parameter[$montage_data]."_".$montage_data."_register") == false){
|
if(cache($parameter[$montage_data]) == false){
|
||||||
return '验证码过期';
|
return '验证码过期';
|
||||||
}else{
|
}else{
|
||||||
if($data['code'] != cache($parameter[$montage_data]."_".$montage_data."_register")){
|
if($data['code'] != cache($parameter[$montage_data])){
|
||||||
return '验证码错误';
|
return '验证码错误';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ Route::any('/send_phone_email_code', 'app/login/send_phone_email_code');
|
||||||
// 创建用户
|
// 创建用户
|
||||||
Route::any('/create_user_data', 'app/index/create_user_data');
|
Route::any('/create_user_data', 'app/index/create_user_data');
|
||||||
// 获取账号下用户列表
|
// 获取账号下用户列表
|
||||||
Route::any('/user_card_list', 'app/index/user_card_list');
|
Route::any('/get_user_card_list', 'app/index/get_user_card_list');
|
||||||
// 获取指定用户详细信息
|
// 获取指定用户详细信息
|
||||||
Route::any('/user_data_information', 'app/index/user_data_information');
|
Route::any('/get_user_data_information', 'app/index/get_user_data_information');
|
||||||
// 获取所有卡片列表信息
|
// 获取所有卡片列表信息
|
||||||
Route::any('/get_card_all_list', 'app/index/get_card_all_list');
|
Route::any('/get_card_all_list', 'app/index/get_card_all_list');
|
||||||
// 保存用户的卡片排序
|
// 保存用户的卡片排序
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue