1
0

Index.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\index\controller;
  3. use Symfony\Component\HttpFoundation\RedirectResponse;
  4. use think\Controller;
  5. use think\Db;
  6. use think\Request;
  7. class Index extends Controller
  8. {
  9. public function login(Request $request)
  10. {
  11. $code = $request->param("code");
  12. $openid = (new AccessToken())->getOpenid($code);
  13. return json(["result"=>1,"openid"=>$openid]);
  14. }
  15. public function getGongMessage()
  16. {
  17. $data = Db::name("gonginfo")->select();
  18. return json(['result'=>1,'content'=>$data]);
  19. }
  20. public function identify(Request $request)
  21. {
  22. $password = $request->param("password");
  23. $list = Db::name("gonginfo")->where("password",$password)->select();
  24. return json(['result'=>1,"content"=>$list]);
  25. }
  26. public function admin(Request $request)
  27. {
  28. $id = $request->param("id");
  29. $formid = $request->param("formid");
  30. $openid = $request->param("openid");
  31. $sql = "Update gonginfo set fromid = $formid,openid=$openid where id = $id";
  32. $result = Db::query($sql);
  33. if($result){
  34. return json(['result'=>1,'msg'=>'更改成功']);
  35. }else{
  36. return json(['result'=>0,'msg'=>'更改失败']);
  37. }
  38. }
  39. }