Weapp.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\weapp;
  12. use app\service\api\notice\NoticeService;
  13. use app\service\api\weapp\WeappAuthService;
  14. use core\base\BaseApiController;
  15. use think\Response;
  16. class Weapp extends BaseApiController
  17. {
  18. /**
  19. * 授权登录
  20. * @return Response
  21. */
  22. public function login(){
  23. $data = $this->request->params([['code', '']]);
  24. $weapp_auth_service = new WeappAuthService();
  25. return success($weapp_auth_service->login($data['code']));
  26. }
  27. /**
  28. * 注册
  29. * @return Response
  30. */
  31. public function register(){
  32. $data = $this->request->params([
  33. ['openid', ''],
  34. [ 'unionid', '' ],
  35. ['mobile_code', ''],
  36. ['mobile', ''],
  37. ]);
  38. $weapp_auth_service = new WeappAuthService();
  39. return success($weapp_auth_service->register($data['openid'], $data['mobile'], $data['mobile_code'], $data[ 'unionid' ]));
  40. }
  41. public function subscribeMessage(){
  42. $data = $this->request->params([ ['keys', ''] ]);
  43. return success((new NoticeService())->getWeappNoticeTemplateId($data['keys']));
  44. }
  45. /**
  46. * 更新openid
  47. * @return Response
  48. */
  49. public function updateOpenid()
  50. {
  51. $data = $this->request->params([ [ 'code', '' ] ]);
  52. $weapp_auth_service = new WeappAuthService();
  53. return success($weapp_auth_service->updateOpenid($data[ 'code' ]));
  54. }
  55. }