MainController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. if (strstr($host, 'zhiguanhua.cn') !== false) {
  39. $name = '花掌柜';
  40. $bei = '闽ICP备15017325号-7';
  41. }
  42. if (strstr($host, 'huadianbao.net') !== false) {
  43. $name = '花掌柜';
  44. $bei = '闽ICP备15017325号-8';
  45. }
  46. $this->layout = false;
  47. return $this->render('index', ['name' => $name, 'bei' => $bei]);
  48. }
  49. public function actionLogout()
  50. {
  51. xhWxOpenAdminService::logout();//不注销所有的 用户会话数据
  52. $this->redirect(['main/login']);
  53. }
  54. public function actionCheckLogin()
  55. {
  56. $request = Yii::$app->request;
  57. $mobile = $request->post('mobile');
  58. $password = $request->post('password');
  59. $return = xhWxOpenAdminService::loginByMobile($mobile, $password, true);//true 自动登陆
  60. if ($return) {
  61. util::complete('success');
  62. }
  63. util::fail('帐号或密码错误');
  64. }
  65. public function actionRunning()
  66. {
  67. return $this->render('running');
  68. }
  69. public function actionBook()
  70. {
  71. return $this->render('book');
  72. }
  73. }