Index.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\api\controller;
  4. use app\api\service\msg\WechatMsg;
  5. use think\annotation\route\Get;
  6. use think\annotation\route\Group;
  7. use think\annotation\route\Post;
  8. /**
  9. * 测试控制器,实际开发请删除全部方法
  10. */
  11. class Index extends Api
  12. {
  13. protected $noNeedLogin = ['*'];
  14. public function testget()
  15. {
  16. sleep(1);
  17. $data=$this->request->get();
  18. $this->success('返回消息',$data);
  19. }
  20. public function testpost()
  21. {
  22. sleep(1);
  23. $data=$this->request->post();
  24. $this->success('返回消息',$data);
  25. }
  26. public function list()
  27. {
  28. $page=$this->request->get('page/d');
  29. //假装有29条数据
  30. $limit=0;
  31. if($page==1 || $page==2){
  32. $limit=10;
  33. }
  34. if($page==3){
  35. $limit=9;
  36. }
  37. if($page>3){
  38. $limit=0;
  39. }
  40. $res=[];
  41. for ($i=0;$i<$limit;$i++){
  42. $id=($page-1)*10+1+$i;
  43. $res[]=array(
  44. 'id'=>$id,
  45. 'title'=>'标题'.$id,
  46. 'content'=>'内容'.$id
  47. );
  48. }
  49. $this->success('',$res);
  50. }
  51. public function mpconfig()
  52. {
  53. $result=[
  54. 'url'=>$this->request->domain().'/api/mpapp/connect',
  55. 'token'=>site_config("uniapp.mpapp_token"),
  56. 'encodingaeskey'=>site_config("uniapp.mpapp_aeskey"),
  57. ];
  58. $this->success('',$result);
  59. }
  60. public function sendtempmsg()
  61. {
  62. WechatMsg::testMsg($this->auth->id);
  63. $this->success('创建消息成功,等待消息推送');
  64. }
  65. }