qrcode-login.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\bootstrap\ActiveForm;
  4. /* @var $this yii\web\View */
  5. /* @var $form yii\bootstrap\ActiveForm */
  6. /* @var $model \common\models\LoginForm */
  7. $this->title = '微信登录';
  8. $cssString = "html{
  9. background: url('" . Yii::$app->config->get('site_login_bg') . "');
  10. background-size: cover !important;
  11. background-attachment: fixed !important;
  12. }
  13. .login-page, .register-page{background: transparent;}
  14. ";
  15. $this->registerCss($cssString);
  16. ?>
  17. <div class="login-box">
  18. <div class="login-logo">
  19. <a href="#"><b style="color: #fff;"><?= Yii::$app->config->get('name') ?></b></a>
  20. </div>
  21. <!-- /.login-logo -->
  22. <div class="login-box-body">
  23. <a href="login">
  24. <img src="/assets/images/password.png"
  25. style="height: 40px; margin-left: 250px; cursor: pointer; position: absolute;" title="密码登录">
  26. </a>
  27. <h4 class="login-box-msg" style="padding-bottom: 30px">微信登录</h4>
  28. <?php if ($errcode == 0): ?>
  29. <div class="row">
  30. <div class="col-xs-12" style="text-align: center">
  31. <img style="width: 150px" src="<?= $media['url'] ?>">
  32. </div>
  33. </div>
  34. <div class="row" style="padding-top: 10px">
  35. <div class="col-xs-12 js-footer" style="text-align: center">
  36. <i class="fa fa-fw fa-wechat"></i>
  37. <span class="js-tips">打开微信扫一扫登录</span>
  38. </div>
  39. </div>
  40. <?php else: ?>
  41. <div class="row" style="padding-top: 10px">
  42. <div class="col-xs-12" style="text-align: center">
  43. <i class="fa fa-fw fa-wechat"></i>
  44. <span class=""><?= $errmsg ?></span>
  45. </div>
  46. </div>
  47. <?php endif; ?>
  48. </div>
  49. <!-- /.login-box-body -->
  50. </div><!-- /.login-box -->
  51. <?php
  52. $js = <<<JS
  53. $(document).ready(function() {
  54. setInterval( () => {
  55. $.post(location.href, {
  56. access_token:"{$access_token}",
  57. qrcode_hash:"{$media['name']}",
  58. }, (res) => {
  59. if (res.status == 1) {
  60. location.href = res.returnUrl;
  61. } else {
  62. $('.js-tips').text(res.message);
  63. if (res.errors.qrcode_hash) {
  64. $('.js-footer').css('color', '#19be6b');
  65. } else {
  66. $('.js-footer').css('color', '#ed3f14');
  67. }
  68. }
  69. });
  70. }, 1000);
  71. });
  72. JS;
  73. $this->registerJs($js);
  74. ?>