index.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. use yii\widgets\LinkPager;
  3. use common\helpers\Url;
  4. use common\helpers\Html;
  5. use common\helpers\Auth;
  6. use common\enums\StatusEnum;
  7. use addons\Wechat\common\enums\MenuTypeEnum;
  8. use addons\Wechat\common\enums\MenuClientPlatformTypeEnum;
  9. $this->title = MenuTypeEnum::getValue($type);
  10. $this->params['breadcrumbs'][] = ['label' => $this->title];
  11. ?>
  12. <div class="row">
  13. <div class="col-sm-12">
  14. <div class="nav-tabs-custom">
  15. <ul class="nav nav-tabs">
  16. <?php foreach ($types as $key => $value) { ?>
  17. <li <?php if ($key == $type){ ?>class="active"<?php } ?>><a href="<?= Url::to(['index', 'type' => $key]) ?>"> <?= $value ?></a></li>
  18. <?php } ?>
  19. <li class="pull-right">
  20. <div class="row">
  21. <div class="col-lg-12 normalPaddingTop">
  22. <!-- 权限校验判断 -->
  23. <?php if (Auth::verify('/wechat/menu/sync')) { ?>
  24. <a class="btn btn-primary btn-sm" id="getNewMenu">
  25. <i class="fa fa-cloud-download"></i> 同步
  26. </a>
  27. <?php } ?>
  28. <?= Html::create(['edit', 'type' => $type]) ?>
  29. </div>
  30. </div>
  31. </li>
  32. </ul>
  33. <div class="tab-content">
  34. <div class="active tab-pane">
  35. <table class="table table-hover">
  36. <thead>
  37. <tr>
  38. <th>#</th>
  39. <th>标题</th>
  40. <th>显示对象</th>
  41. <th>是否在微信生效</th>
  42. <th>创建时间</th>
  43. <th>操作</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. <?php foreach ($models as $model) { ?>
  48. <tr>
  49. <td><?= $model->id ?></td>
  50. <td><?= $model->title ?></td>
  51. <td>
  52. <?php if ($model->type == MenuTypeEnum::CUSTOM) { ?>
  53. 全部粉丝
  54. <?php } else { ?>
  55. 标签: <?= empty($model->tag_id) ? '全部粉丝' : Yii::$app->wechatService->fansTags->findById($model->tag_id)['name']; ?> <br>
  56. 手机系统: <?= MenuClientPlatformTypeEnum::getValue($model->client_platform_type); ?>
  57. <?php } ?>
  58. </td>
  59. <td>
  60. <?php if ($model->status == StatusEnum::ENABLED || $model->type == MenuTypeEnum::INDIVIDUATION) { ?>
  61. <span class="text-success">菜单生效中</span>
  62. <?php } else { ?>
  63. <a href="<?= Url::to(['save', 'id' => $model->id]) ?>" class="color-default">生效并置顶</a>
  64. <?php } ?>
  65. </td>
  66. <td><?= Yii::$app->formatter->asDatetime($model->created_at) ?></td>
  67. <td>
  68. <?= Html::edit(['edit', 'id' => $model->id, 'type' => $model->type],
  69. $model->type == 2 ? '查看' : '编辑'); ?>
  70. <?php if ($model->status == 0 || $model->type == 2) { ?>
  71. <?= Html::delete(['delete', 'id' => $model->id, 'type' => $model->type]); ?>
  72. <?php } ?>
  73. </td>
  74. </tr>
  75. <?php } ?>
  76. </tbody>
  77. </table>
  78. <div class="row">
  79. <div class="col-sm-12">
  80. <?= LinkPager::widget([
  81. 'pagination' => $pages,
  82. ]); ?>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <script type="application/javascript">
  91. // 获取资源
  92. $("#getNewMenu").click(function () {
  93. rfAffirm('同步中,请不要关闭当前页面');
  94. sync();
  95. });
  96. // 同步菜单
  97. function sync() {
  98. $.ajax({
  99. type: "get",
  100. url: "<?= Url::to(['sync'])?>",
  101. dataType: "json",
  102. success: function (data) {
  103. if (data.code == 200) {
  104. rfAffirm(data.message);
  105. window.location.reload();
  106. } else {
  107. rfAffirm(data.message);
  108. }
  109. }
  110. });
  111. }
  112. </script>
粤ICP备19079148号