Blogger Information
Blog 42
fans 0
comment 0
visits 15636
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0907安装axios,获取管理员接口数据,增加管理员接口
小言
Original
695 people have browsed it

安装axios

在vue目录内执行以下命令安装axios

  1. npm i axios -S

获取管理员接口数据

  1. public function UserLists (){
  2. $user = Db::table('yj_admin')->select()->toArray();
  3. if (!empty($user)){
  4. foreach ($user as &$user_v){
  5. if ($user_v['status'] == 1){
  6. $user_v['status_s'] = '开启';
  7. }else{
  8. $user_v['status_s'] = '关闭';
  9. }
  10. $user_v['add_time'] = date('Y-m-d',$user_v['add_time']);
  11. $user_v['last_time'] = date('Y-m-d',$user_v['last_time']);
  12. }
  13. }
  14. $json = json_encode($user);
  15. echo $json;
  16. }

增加管理员接口

  1. public function UserSave(){
  2. $post = input('post.');
  3. //print_r($post);
  4. $data = [
  5. 'account' => $post['account'],
  6. 'password' => md5($post['password']),
  7. 'name' => $post['name'],
  8. 'phone' => $post['phone'],
  9. 'status' => $post['status'],
  10. 'add_time' => time()
  11. ];
  12. $insert = Db::table('yj_admin')->insert($data);
  13. if(empty($insert)){
  14. $arr = [
  15. 'code' => 1,
  16. 'msg' => '失败'
  17. ];
  18. }else{
  19. $arr = [
  20. 'code' => 0,
  21. 'msg' => '成功'
  22. ];
  23. }
  24. echo json_encode($arr);
  25. }

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!