MainController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. $newUrl = 'http://m.huaml.com/#/pay/index?account=12358&shopId=15680';
  33. $arr = array(
  34. 1 => array('id'=>'1','parentid'=>0,'name'=>'一级栏目一'),
  35. 2 => array('id'=>'2','parentid'=>0,'name'=>'一级栏目二'),
  36. 3 => array('id'=>'3','parentid'=>1,'name'=>'二级栏目一'),
  37. 4 => array('id'=>'4','parentid'=>1,'name'=>'二级栏目二'),
  38. 5 => array('id'=>'5','parentid'=>2,'name'=>'二级栏目三'),
  39. 6 => array('id'=>'6','parentid'=>3,'name'=>'三级栏目一'),
  40. 7 => array('id'=>'7','parentid'=>3,'name'=>'三级栏目二')
  41. );
  42. $data = array(
  43. array(
  44. 'id'=>1,
  45. 'name'=>'book',
  46. 'parent_id'=>0
  47. ),
  48. array(
  49. 'id'=>2,
  50. 'name'=>'music',
  51. 'parent_id'=>0
  52. ),
  53. array(
  54. 'id'=>3,
  55. 'name'=>'book1',
  56. 'parent_id'=>1
  57. ),
  58. array(
  59. 'id'=>4,
  60. 'name'=>'book2',
  61. 'parent_id'=>3
  62. )
  63. );
  64. $r = tree::makeTree($data);
  65. echo '<pre>';
  66. print_r($r);die;
  67. // echo jwt::create(1,12536630);
  68. }
  69. }