index.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2017/3/17 0017
  6. * Time: 上午 10:52
  7. */
  8. use yii\helpers\Url;
  9. use yii\widgets\LinkPager;
  10. ?>
  11. <style>
  12. .color{
  13. color: red;
  14. }
  15. </style>
  16. <div class="row">
  17. <div class="col-sm-12">
  18. <div class="ibox float-e-margins">
  19. <div class="ibox-content">
  20. <div class="row">
  21. <div class="col-sm-5 m-b-xs">
  22. <a class="btn btn-sm btn-primary addhotsearch" href="<?=Url::toRoute(['redpack/add'])?>">添加红包活动</a>
  23. </div>
  24. </div>
  25. <div class="table-responsive">
  26. <table class="table table-striped">
  27. <thead>
  28. <tr>
  29. <th>ID</th>
  30. <th>活动名称</th>
  31. <th>金额区间</th>
  32. <th>城市</th>
  33. <th>类型</th>
  34. <th>个数/工地</th>
  35. <th>创建时间</th>
  36. <th>有效期</th>
  37. <th>操作</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. <form id="checkForm" method="post">
  42. <?php $i=0; foreach($datas as $data):?>
  43. <tr class="hotsearch_<?=$data->id?>">
  44. <td><?=$data->id ?></td>
  45. <td><?=$data->title ?></td>
  46. <td class="keyword"><?=$data->price_interval ?></td>
  47. <td class="keyword"><?php echo \common\models\Area::queryCity($data->city) ?><?php echo \common\models\Area::queryCity($data->area) ?></td>
  48. <td class="keyword"><?php switch ($data->type){
  49. case \common\models\RedActivity::TYPE_NOT :
  50. echo "不限制";
  51. break;
  52. case \common\models\RedActivity::TYPE_NOTMEMBER:
  53. echo "非会员";
  54. break;
  55. case \common\models\RedActivity::TYPE_MEMBER:
  56. echo "会员";
  57. break;
  58. } ?></td>
  59. <td class="keyword"><?=$data->number ?></td>
  60. <td>
  61. <?=empty($data->created_at)?'':date("Y-m-d",$data->created_at)?>
  62. </td>
  63. <td class="keyword">
  64. <?=empty($data->valid_at)?'':date("Y-m-d",$data->valid_at)?>
  65. </td>
  66. <td>
  67. <a href="<?=Url::toRoute(['redpack/edit','id'=>$data->id])?>" class="btn btn-sm btn-primary edit_advert">修改</a>
  68. <a href="<?=Url::toRoute(['redpack/receive','id'=>$data->id])?>" class="btn btn-sm btn-primary edit_advert">红包记录</a>
  69. <a class="btn btn-sm btn-danger del_manage"data="<?= $data->id?>">删除</a>
  70. </td>
  71. </tr>
  72. <?php endforeach;?>
  73. <input type="hidden" name="_csrf-backend" value="<?=Yii::$app->request->csrfToken;?>" />
  74. <input type="hidden" value="" name="key" class="shelves-key">
  75. </form>
  76. </tbody>
  77. </table>
  78. <?= LinkPager::widget(['pagination' => $pages]); ?>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <script>
  85. $('.table-responsive').on('click','.del_manage',function(){
  86. var id = $(this).attr('data');
  87. var text = $(this);
  88. swal({
  89. title: "确定删除该活动?",
  90. type: "warning",
  91. showCancelButton: true,
  92. confirmButtonColor: "#DD6B55",
  93. confirmButtonText: "确定",
  94. cancelButtonText: "取消",
  95. closeOnConfirm: true,
  96. closeOnCancel: true },
  97. function(isConfirm){
  98. if (isConfirm) {
  99. $.ajax({
  100. url:'<?=Url::toRoute(['redpack/delete']);?>',
  101. type:'POST',
  102. dataType:'json',
  103. data:{id:id,'_csrf-backend':'<?=Yii::$app->request->csrfToken;?>'},
  104. success:function(data){
  105. if(data.sign==1){
  106. text.parents('tr').remove();
  107. }else{
  108. swal("", data.msg, "error");
  109. }
  110. }
  111. })
  112. }
  113. });
  114. });
  115. </script>