Index.php 1.4 KB

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