index.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. use common\helpers\Html;
  3. use common\helpers\Url;
  4. use common\enums\StatusEnum;
  5. use common\enums\AccessTokenGroupEnum;
  6. $this->title = '第三方授权';
  7. ?>
  8. <div class="callout callout-dark">
  9. <h5><i class="iconfont iconbaocuo help"></i> 操作提示</h5>
  10. 如果是绑定微信,需要先安装微信公众号插件,否则会导致绑定不成功。<br>
  11. </div>
  12. <div class="row">
  13. <div class="col-lg-12">
  14. <div class="box">
  15. <div class="box-header with-border">
  16. <h3 class="box-title">第三方授权</h3>
  17. </div>
  18. <div class="box-body">
  19. <table class="table table-hover" style="margin-top: 10px">
  20. <thead>
  21. <tr>
  22. <th>绑定类型</th>
  23. <th>绑定账号</th>
  24. <th>绑定状态</th>
  25. <th>操作</th>
  26. </tr>
  27. </thead>
  28. <tbody>
  29. <?php foreach ($thirdParty as $item) { ?>
  30. <tr>
  31. <td><?= $item['title'];?> </td>
  32. <td><?= Html::encode($item['client']) ?></td>
  33. <td>
  34. <?php if($item['status'] == StatusEnum::DISABLED) { ?>
  35. <span class="label label-outline-danger">未绑定</span>
  36. <?php } else { ?>
  37. <span class="label label-outline-success">已绑定</span>
  38. <?php } ?>
  39. </td>
  40. <td>
  41. <?php if($item['status'] == StatusEnum::DISABLED) { ?>
  42. <?= Html::a('立即绑定', ['binding-wechat', 'member_id' => $memberId, 'type' => AccessTokenGroupEnum::WECHAT_MP], [
  43. 'class' => 'cyan wechat-binding',
  44. 'data-member_id' => $memberId,
  45. 'data-oauth_client' => AccessTokenGroupEnum::WECHAT_MP,
  46. 'data-fancybox' => 'gallery',
  47. ])?>
  48. <?php } else { ?>
  49. <?= Html::a('解绑', ['un-bind', 'member_id' => $memberId, 'type' => AccessTokenGroupEnum::WECHAT_MP], [
  50. 'class' => 'red'
  51. ])?>
  52. <?php } ?>
  53. </td>
  54. </tr>
  55. <?php } ?>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <script>
  63. var timer;
  64. var member_id;
  65. var type;
  66. $('.wechat-binding').click(function () {
  67. if (timer) {
  68. clearInterval(timer);
  69. }
  70. member_id = $(this).data('member_id');
  71. type = $(this).data('oauth_client');
  72. timer = setInterval(binding, 1000);
  73. })
  74. function binding() {
  75. // 判断登录
  76. $.ajax({
  77. type: "get",
  78. url: "<?= Url::to(['oauth-status'])?>",
  79. dataType: "json",
  80. data: {member_id: member_id, type: type},
  81. success: function (data) {
  82. if (parseInt(data.code) === 200) {
  83. window.location.reload();
  84. }
  85. }
  86. });
  87. }
  88. </script>
粤ICP备19079148号