Index.php 702 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\newhome\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use app\user\model\User;
  6. class Index extends Controller {
  7. private $userModel;
  8. public function _initialize(){
  9. $this->userModel = new User();
  10. }
  11. public function index()
  12. {
  13. $data = Db::name('config')->select();
  14. return json(["l"=>$data]);
  15. }
  16. public function robot(){
  17. $data = decode($this->request->post());
  18. $this->userModel->addAndSave(['id'=>$data['u'], 'robot'=>1]);
  19. return json(['error'=>0]);
  20. }
  21. public function number(){
  22. $data = decode($this->request->post());
  23. $res = $this->userModel->getRobotId($data['n']);
  24. return json(['l'=>$res]);
  25. }
  26. }