diff --git a/application/admin/controller/Index - 副本 (3).php b/application/admin/controller/Card.php similarity index 72% rename from application/admin/controller/Index - 副本 (3).php rename to application/admin/controller/Card.php index 26ea69a..90ec5bf 100644 --- a/application/admin/controller/Index - 副本 (3).php +++ b/application/admin/controller/Card.php @@ -1,6 +1,6 @@ =',$data['s_time']]; + } + if($data['e_time']){ + $parameter['create_time'] = ['<=',$data['e_time']]; + } + } + $num = Db::table('app_account_number')->where($parameter)->count(); + $member_list = Db::table('app_account_number')->where($parameter)->page("$page,10")->order('is_del,id desc')->select(); + if(!$pd){ + $result['num'] = $num; + $result['data'] = $member_list; + return $this->msg(0,'success',$result); + } + $this->assign([ + 'result' => $member_list, + 'num' => $num, + ]); + return $this->fetch(); + } + + // 用户账号停用 + public function member_is_del(){ + $data = input(); + if(is_array($data['id'])){ + $data['id'] = implode(',',$data['id']); + $result = Db::table('app_account_number')->where("id in (".$data['id'].")")->update(['is_del'=>$data['is_del']]); + }else{ + $result = Db::table('app_account_number')->where(['id'=>$data['id']])->update(['is_del'=>$data['is_del']]); + } + + if($result){ + return $this->msg(0,'success'); + }else{ + return $this->msg(10001,'success'); + } + } + + ################################################################角色################################################################ + ################################################################角色################################################################ + ################################################################角色################################################################ + + // 角色列表 + public function user_list($page = 1){ + $data = input(); + $pd = true; + $parameter = []; + if(array_key_exists('tt', $data)){ + $status = ['0', '1', '2']; + $page = $data['page_num']; + unset($data['page_num']); + unset($data['tt']); + $pd = false; + if(in_array($data['status_num'], $status)){ + $parameter['is_del'] = $data['status_num']; + } + if($data['aan_id']){ + $parameter['aan_id'] = $data['aan_id']; + } + if($data['nickname']){ + $parameter['nickname'] = $data['nickname']; + } + if(in_array($data['gender'], $status)){ + $parameter['gender'] = $data['gender']; + } + // if($data['s_time']){ + // $parameter['create_time'] = ['>=',$data['s_time']]; + // } + // if($data['e_time']){ + // $parameter['create_time'] = ['<=',$data['e_time']]; + // } + } + // dump($parameter); + // die; + $num = Db::table('app_user_data')->where($parameter)->count(); + $member_list = Db::table('app_user_data')->where($parameter)->page("$page,10")->order('is_del,id desc')->select(); + if(!$pd){ + $result['num'] = $num; + $result['data'] = $member_list; + return $this->msg(0,'success',$result); + } + $this->assign([ + 'result' => $member_list, + 'num' => $num, + ]); + return $this->fetch(); + } + + // 角色停用 + public function user_is_del(){ + $data = input(); + if(is_array($data['id'])){ + // dump($data['id']); + $data['id'] = implode(',',$data['id']); + // dump($data['id']); + // die; + $result = Db::table('app_user_data')->where("id in (".$data['id'].")")->update(['is_del'=>$data['is_del']]); + }else{ + $result = Db::table('app_user_data')->where(['id'=>$data['id']])->update(['is_del'=>$data['is_del']]); + } + + if($result){ + return $this->msg(0,'success'); + }else{ + return $this->msg(10001,'success'); + } + } + + + ################################################################other################################################################ + ################################################################other################################################################ + ################################################################other################################################################ + + public function msg($code,$msg='',$data=[]){ + return json(['code'=>$code,'msg'=>$msg,'data'=>$data]); + } + +} \ No newline at end of file diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index ab01978..ef9c521 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -12,11 +12,6 @@ - - \ No newline at end of file diff --git a/application/admin/view/index/welcome.html b/application/admin/view/index/welcome.html index 47bc410..f362ddd 100644 --- a/application/admin/view/index/welcome.html +++ b/application/admin/view/index/welcome.html @@ -215,14 +215,5 @@ // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); - \ No newline at end of file diff --git a/application/admin/view/member/member_list.html b/application/admin/view/member/member_list.html new file mode 100644 index 0000000..6dd9d20 --- /dev/null +++ b/application/admin/view/member/member_list.html @@ -0,0 +1,359 @@ + + + + + 欢迎页面-X-admin2.2 + + + + + + + + + + +
+ + 首页 + 演示 + + 导航元素 + + + +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ + +
+
+ + + + + + + + + + + + + + + {volist name="result" id="vo"} + + + + + + + + + + + {/volist} + +
ID唯一token手机邮箱创建时间状态
{$vo.id}{$vo.token}{$vo.tel}{$vo.email}{$vo.create_time} + {if condition="$vo.is_del == 1"} + 已停用 + {else /} + 已启用 + {/if} + +
+
+
+
+
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/application/admin/view/member/user_list.html b/application/admin/view/member/user_list.html new file mode 100644 index 0000000..4532186 --- /dev/null +++ b/application/admin/view/member/user_list.html @@ -0,0 +1,372 @@ + + + + + 欢迎页面-X-admin2.2 + + + + + + + + + + +
+ + 首页 + 演示 + + 导航元素 + + + +
+
+
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + {volist name="result" id="vo"} + + + + + + + {if condition="$vo.gender == 1"} + + {elseif condition="$vo.gender == 2"/} + + {else /} + + {/if} + + + + + {/volist} + +
IDAan_ID昵称生日性别创建时间最后修改时间状态
{$vo.id}{$vo.aan_id}{$vo.nickname}{$vo.birthday}未知{$vo.create_time}{$vo.last_update_time} + {if condition="$vo.is_del == 1"} + 已停用 + {else /} + 已启用 + {/if} +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/application/app/controller/Card.php b/application/app/controller/Card.php index 25b949c..a6ea9d9 100644 --- a/application/app/controller/Card.php +++ b/application/app/controller/Card.php @@ -11,46 +11,52 @@ use \think\Validate; class Card extends Controller{ - ################################################################个人资料卡################################################################ - ################################################################个人资料卡################################################################ - ################################################################个人资料卡################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ - // 获取默认卡片信息 - // $type 1获取列表,2获取详细信息 - public function get_card_msg($type=1){ - $result = Db::table('app_card_data')->select(); - $data = []; - if($type == 1){ - for ($i=0; $i < count($result); $i++) { - array_push($data,['id'=>$result[$i]['id'],'name'=>$result[$i]['name']]); - } - }else{ - // 如果需要详细信息再从中编辑信息 - $data = $result; + // 存储卡片顺序 + // $data = ['user_token'=>'xxxxxxxxxxxxxxx','order_list'=>[1,2,3,4,5]] + public function save_card_order(){ + $data = input(); + if(!array_key_exists('order_list', $data) || !array_key_exists('user_token', $data)){ + return $this->msg(10001,'数据格式错误'); } - return $this->msg(0,'success',$data); - } - - // 获取默认卡片规则 - // $type 1获取列表,2获取详细信息 - public function get_card_rule(){ - $result = Db::table('app_card_data')->select(); - $data = []; - if($type == 1){ - for ($i=0; $i < count($result); $i++) { - array_push($data,['id'=>$result[$i]['id'],'name'=>$result[$i]['name']]); - } - }else{ - // 如果需要详细信息再从中编辑信息 - $data = $result; + 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['user_token']])->update(['card_order'=>$data['order_list']]); + if($result){ + return $this->msg(0,'success'); + }else{ + return $this->msg(10003,'修改失败'); } - return $this->msg(0,'success',$data); } - // 新建卡片 - public function create_card(){ - + // 添加卡片规则 + // $data = ['user_token'=>'xxxxxxxxxxxxxxx','order_list'=>[1,2,3,4,5]] + public function add_card_rule(){ + $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['user_token']])->update(['card_order'=>$data['order_list']]); + if($result){ + return $this->msg(0,'success'); + }else{ + return $this->msg(10003,'修改失败'); + } } + + + + + @@ -60,42 +66,25 @@ class Card extends Controller{ ################################################################other################################################################ ################################################################other################################################################ - public function verify_parameters($data,$type){ - // 设置验证 - $rule = [ - 'aan_id' => 'require|number', - 'nickname' => 'require|chsAlpha', - 'birthday' => 'require|date', - 'gender' => 'require|number|in:0,1,2', - ]; - $msg = [ - 'aan_id.require' => '账号信息缺失', - 'nickname.require' => '昵称缺失', - 'birthday.require' => '生日缺失', - 'gender.require' => '性别缺失', - - 'aan_id.number' => '账号信息格式错误', - 'nickname.chsAlpha' => '昵称只能是只能是汉字、字母', - 'birthday.date' => '生日信息格式错误', - 'gender.number' => '性别格式错误', - 'gender.in' => '性别信息错误', - ]; - $validate = new Validate($rule,$msg); - $result = $validate->check($data); - if(!$result){ - return $validate->getError(); + // 检查变量是否是一个只有数字的一维数组 + function isNumericArray($array) { + if (!is_array($array)) { + return false; // 变量不是数组 } - - $parameter['aan_id'] = $data['aan_id']; - $parameter['nickname'] = $data['nickname']; - $parameter['birthday'] = $data['birthday']; - $parameter['gender'] = $data['gender']; - $parameter['create_time'] = date('Y-m-d H:i:s'); - $parameter['last_update_time'] = date('Y-m-d H:i:s'); + foreach ($array as $value) { + if (!is_numeric($value)) { + return false; // 数组中包含非数字元素 + } + } + $result = Db::table('app_card_data')->where(['is_del'=>1])->cache(true,3600)->column('id');//查询结果缓存3600秒 + if(empty(array_diff($array, $result))){ + return true;// 数组是一维的且只包含数字,且已经跟数据库比对过,每个数值都是有效 + }else{ + return false;//跟数据库比对过,存在无效数值 + } + + } - - return $parameter; - } public function msg($code,$msg='',$data=[]){ return json(['code'=>$code,'msg'=>$msg,'data'=>$data]); diff --git a/application/app/controller/Index.php b/application/app/controller/Index.php index 2f72b35..347dd25 100644 --- a/application/app/controller/Index.php +++ b/application/app/controller/Index.php @@ -26,7 +26,7 @@ class Index extends Controller{ // 创建用户卡片 public function create_user_data(){ $data = input(); - + $verify_result = $this->verify_parameters($data,'register'); $result = Db::table('app_user_data')->insert($verify_result); if($result){ return $this->msg(0,'success'); @@ -136,12 +136,14 @@ class Index extends Controller{ 'nickname' => 'require|chsAlpha', 'birthday' => 'require|date', 'gender' => 'require|number|in:0,1,2', + 'grade' => 'require', ]; $msg = [ 'aan_id.require' => '账号信息缺失', 'nickname.require' => '昵称缺失', 'birthday.require' => '生日缺失', 'gender.require' => '性别缺失', + 'grade.require' => '年级缺失', 'aan_id.number' => '账号信息格式错误', 'nickname.chsAlpha' => '昵称只能是只能是汉字、字母', @@ -159,12 +161,15 @@ class Index extends Controller{ $parameter['nickname'] = $data['nickname']; $parameter['birthday'] = $data['birthday']; $parameter['gender'] = $data['gender']; + $parameter['grade'] = $data['grade']; $parameter['create_time'] = date('Y-m-d H:i:s'); $parameter['last_update_time'] = date('Y-m-d H:i:s'); return $parameter; } + + public function msg($code,$msg='',$data=[]){ return json(['code'=>$code,'msg'=>$msg,'data'=>$data]); diff --git a/application/app/controller/Login.php b/application/app/controller/Login.php index 0f1a0f2..b7ee57c 100644 --- a/application/app/controller/Login.php +++ b/application/app/controller/Login.php @@ -43,8 +43,8 @@ class Login extends Controller{ return $this->msg(10001,$verify_result); } $result = Db::table('app_register')->where($verify_result)->field('id')->find(); - dump($result); - die; + // dump($result); + // die; if($result){ $user_data = Db::table('app_user_data')->where(['aan_id'=>$result['id']])->field('id,nickname')->select(); return $this->msg(0,'success'); @@ -66,13 +66,14 @@ class Login extends Controller{ } $num = $this->rand_int(); if($data['road'] == 'tel'){ - $result = $this->send_tel_code($data['tel'],$num); + $result = $this->send_tel_code($data['data'],$num); }else if($data['road'] == 'email'){ - + $result = $this->send_email_code($data['data'],['title'=>'体测APP验证码','from_user_name'=>'体测APP','content'=>$num]); } if(is_array($result) && $result['code'] == 0){ - cache($data['data']."_".$data['road']."_".$data['type'], $num, 20); + cache($data['data']."_".$data['road']."_".$data['type'], $num, 60); + // dump($data['data']."_".$data['road']."_".$data['type']); return $this->msg(0,'success'); }else{ return $this->msg(10001,'error'); @@ -232,6 +233,7 @@ class Login extends Controller{ if($type == 'register'){ if(array_key_exists('code', $data)){ + // dump($parameter[$montage_data]."_".$montage_data."_register".'='.cache($parameter[$montage_data]."_".$montage_data."_register")); if(cache($parameter[$montage_data]."_".$montage_data."_register") == false){ return '验证码过期'; }else{ @@ -243,11 +245,23 @@ class Login extends Controller{ return '验证码必须'; } $parameter['create_time'] = date('Y-m-d H:i:s'); + $parameter['token'] = md5($parameter['tel'].$this->create_random_string(12).time()); } return $parameter; } + public function create_random_string($length = 12) + { + //创建随机字符 + $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + $str = ""; + for ($i = 0; $i < $length; $i++) { + $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); + } + return $str; + } + public function msg($code,$msg='',$data=[]){ return json(['code'=>$code,'msg'=>$msg,'data'=>$data]); }