MainController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace pt\controllers;
  3. use common\components\util;
  4. use Yii;
  5. use common\services\xhWxOpenAdminService;
  6. class MainController extends PlatformController
  7. {
  8. public $guestAccess = ['login', 'logout', 'check-login', 'index'];
  9. public function actionIndex()
  10. {
  11. $host = Yii::$app->request->getHostInfo();
  12. $name = '花掌柜';
  13. $bei = '闽ICP备15017325号-1';
  14. if (strstr($host, 'hzghd') !== false) {
  15. $name = '花掌柜';
  16. $bei = '闽ICP备15017325号-1';
  17. }
  18. if (strstr($host, 'theflorist') !== false) {
  19. $name = '花掌柜';
  20. $bei = '闽ICP备15017325号-2';
  21. }
  22. if (strstr($host, 'huaml') !== false) {
  23. $name = '花美利';
  24. $bei = '闽ICP备15017325号-3';
  25. }
  26. if (strstr($host, 'zhhinc') !== false) {
  27. $name = '中花汇';
  28. $bei = '闽ICP备15017325号-4';
  29. }
  30. if (strstr($host, 'huahb.com') !== false) {
  31. $name = '花掌柜';
  32. $bei = '闽ICP备15017325号-5';
  33. }
  34. if (strstr($host, 'huahb.cn') !== false) {
  35. $name = '花掌柜';
  36. $bei = '闽ICP备15017325号-6';
  37. }
  38. $this->layout = false;
  39. return $this->render('index', ['name' => $name, 'bei' => $bei]);
  40. }
  41. public function actionLogout()
  42. {
  43. xhWxOpenAdminService::logout();//不注销所有的 用户会话数据
  44. $this->redirect(['main/login']);
  45. }
  46. public function actionCheckLogin()
  47. {
  48. $request = Yii::$app->request;
  49. $mobile = $request->post('mobile');
  50. $password = $request->post('password');
  51. $return = xhWxOpenAdminService::loginByMobile($mobile, $password, true);//true 自动登陆
  52. if ($return) {
  53. util::complete('success');
  54. }
  55. util::fail('帐号或密码错误');
  56. }
  57. public function actionRunning()
  58. {
  59. return $this->render('running');
  60. }
  61. public function actionBook()
  62. {
  63. return $this->render('book');
  64. }
  65. }