login.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /* @var $this \yii\web\View */
  3. /* @var $content string */
  4. use yii\helpers\Html;
  5. use yii\helpers\Url;
  6. use yii\web\YiiAsset;
  7. YiiAsset::register($this);
  8. ?>
  9. <?php $this->beginPage() ?>
  10. <!DOCTYPE html>
  11. <html lang="<?= Yii::$app->language ?>">
  12. <head>
  13. <meta charset="<?= Yii::$app->charset ?>">
  14. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  15. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  16. <?= Html::csrfMetaTags() ?>
  17. <title>欢迎使用X Trader</title>
  18. <?php $this->head() ?>
  19. <link href="<?= STATIC_URL ?>/ui/css/bootstrap.min.css" rel="stylesheet">
  20. <link href="<?= STATIC_URL ?>/ui/font-awesome/css/font-awesome.css" rel="stylesheet">
  21. <link href="<?= STATIC_URL ?>/ui/css/animate.css" rel="stylesheet">
  22. <link href="<?= STATIC_URL ?>/ui/css/style.css" rel="stylesheet">
  23. <link href="<?= STATIC_URL ?>/ui/css/plugins/toastr/toastr.min.css" rel="stylesheet">
  24. </head>
  25. <body class="gray-bg">
  26. <?php $this->beginBody() ?>
  27. <div class="loginColumns animated fadeInDown">
  28. <div class="row">
  29. <div class="col-md-3"></div>
  30. <div class="col-md-6">
  31. <h1 class="text-center">X Trader</h1>
  32. <hr/>
  33. </div>
  34. <div class="col-md-3"></div>
  35. </div>
  36. <div class="row">
  37. <div class="col-md-3"></div>
  38. <div class="col-md-6">
  39. <div class="ibox-title">
  40. 欢迎使用X Trader
  41. </div>
  42. <div class="ibox-content">
  43. <form id="form" class="m-t" role="form">
  44. <div class="input-group" style="margin-bottom:15px;">
  45. <span class="input-group-btn">
  46. <button type="button" class="btn btn-default">邮箱</button>
  47. </span>
  48. <input type="text" id="username" name="username" class="form-control" placeholder="您的电子邮箱" required="">
  49. </div>
  50. <div class="input-group" style="margin-bottom:15px;">
  51. <span class="input-group-btn">
  52. <button type="button" class="btn btn-default">密码</button>
  53. </span>
  54. <input type="password" id="password" name="password" class="form-control" placeholder="您的登录密码" required="">
  55. </div>
  56. <button id="login" type="button" class="btn btn-primary block full-width m-b">登录</button>
  57. <a href="<?= Url::to(['pwd?type=1']) ?>">
  58. <small>忘记密码?</small>
  59. </a>
  60. <a href="<?= Url::to(['open']) ?>" class="pull-right">
  61. <small>没有账户?</small>
  62. </a>
  63. </form>
  64. </div>
  65. <hr/>
  66. </div>
  67. <div class="col-md-3"></div>
  68. </div>
  69. <div class="row">
  70. <div class="col-md-3"></div>
  71. <div class="col-md-6 text-right">
  72. <small>©2016-2019 Vegard</small>
  73. </div>
  74. <div class="col-md-3"></div>
  75. </div>
  76. </div>
  77. <?php $this->endBody() ?>
  78. <script src="<?= STATIC_URL ?>/ui/js/bootstrap.min.js"></script>
  79. <script src="<?= STATIC_URL ?>/ui/js/plugins/toastr/toastr.min.js"></script>
  80. <script type="text/javascript">
  81. $("#login").on("click", function () {
  82. $.ajax({
  83. type: "POST",
  84. url: "<?= Url::to(['login-post']) ?>",
  85. data: $('#form').serialize(),
  86. dataType: "json",
  87. beforeSend: function () {
  88. },
  89. success: function (data) {
  90. if (data.isSuccess) {
  91. var url = "<?= Url::to(['/user/dashboard']) ?>";
  92. window.location.href = url;
  93. } else {
  94. toastr.error("用户名或密码错误", "提示");
  95. }
  96. },
  97. complete: function (XMLHttpRequest, textStatus) {
  98. },
  99. error: function () {
  100. }
  101. });
  102. });
  103. </script>
  104. </body>
  105. </html>
  106. <?php $this->endPage() ?>