BindDispatch.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\api\route\dispatch;
  3. use app\dict\member\MemberLoginTypeDict;
  4. use think\App;
  5. use think\route\dispatch\Controller;
  6. class BindDispatch extends Controller
  7. {
  8. /**
  9. * 多场景授权绑定调度类
  10. * @param App $app
  11. * @return void
  12. */
  13. public function init(App $app)
  14. {
  15. $this->app = $app;
  16. $this->doRouteAfter();
  17. $channel = $this->request->getChannel();
  18. if($this->request->param('channel', '')){
  19. $channel = $this->request->param('channel');
  20. }
  21. switch ($channel) {
  22. case MemberLoginTypeDict::WECHAT:
  23. $controller = 'wechat.Wechat';
  24. $action = 'register';
  25. break;
  26. case MemberLoginTypeDict::WEAPP:
  27. $controller = 'weapp.Weapp';
  28. $action = 'register';
  29. break;
  30. }
  31. $this->controller = $controller ?? '';
  32. $this->actionName = $action ?? '';
  33. $this->request
  34. ->setController($this->controller ?? '')
  35. ->setAction($this->actionName);
  36. }
  37. }