MainController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace mobile\controllers;
  3. use biz\user\services\UserService;
  4. use common\components\jwt;
  5. use common\components\token;
  6. use common\components\tree;
  7. use Yii;
  8. use yii\db\Exception;
  9. use yii\web\Controller;
  10. class MainController extends PublicController
  11. {
  12. public $enableCsrfValidation = false;
  13. public function actionIndex()
  14. {
  15. $host = Yii::$app->request->getHostInfo();
  16. $fullUrl = Yii::$app->request->url;
  17. $token = '';
  18. if(strpos($fullUrl, 'token')){
  19. $parse = parse_url($fullUrl);
  20. if (isset($parse['query'])) {
  21. parse_str($parse['query'], $queryArray);
  22. if (isset($queryArray['token']) && !empty($queryArray['token'])) {
  23. $token = $queryArray['token'];
  24. }
  25. }
  26. }
  27. $host = 'http://mobile.huaml.com';
  28. return $this->renderPartial('index', ['host' => $host, 'token' => $token]);
  29. }
  30. public function actionJwt()
  31. {
  32. $arr = array(
  33. 1 => array('id'=>'1','parentid'=>0,'name'=>'一级栏目一'),
  34. 2 => array('id'=>'2','parentid'=>0,'name'=>'一级栏目二'),
  35. 3 => array('id'=>'3','parentid'=>1,'name'=>'二级栏目一'),
  36. 4 => array('id'=>'4','parentid'=>1,'name'=>'二级栏目二'),
  37. 5 => array('id'=>'5','parentid'=>2,'name'=>'二级栏目三'),
  38. 6 => array('id'=>'6','parentid'=>3,'name'=>'三级栏目一'),
  39. 7 => array('id'=>'7','parentid'=>3,'name'=>'三级栏目二')
  40. );
  41. $data = array(
  42. array(
  43. 'id'=>1,
  44. 'name'=>'book',
  45. 'parent_id'=>0
  46. ),
  47. array(
  48. 'id'=>2,
  49. 'name'=>'music',
  50. 'parent_id'=>0
  51. ),
  52. array(
  53. 'id'=>3,
  54. 'name'=>'book1',
  55. 'parent_id'=>1
  56. ),
  57. array(
  58. 'id'=>4,
  59. 'name'=>'book2',
  60. 'parent_id'=>3
  61. )
  62. );
  63. $r = tree::makeTree($data);
  64. echo '<pre>';
  65. print_r($r);die;
  66. // echo jwt::create(1,12536630);
  67. }
  68. }