123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2017/3/17 0017
- * Time: 上午 10:52
- */
- use yii\helpers\Url;
- use yii\widgets\LinkPager;
- ?>
- <style>
- .color{
- color: red;
- }
- </style>
- <div class="row">
- <div class="col-sm-12">
- <div class="ibox float-e-margins">
- <div class="ibox-content">
- <div class="row">
- <div class="col-sm-5 m-b-xs">
- <a class="btn btn-sm btn-primary addhotsearch" href="<?=Url::toRoute(['webconfig/addadvert'])?>"> 新建广告</a>
- </div>
- </div>
- <div class="table-responsive">
- <table class="table table-striped">
- <thead>
- <tr>
- <th>ID</th>
- <th>图片名称</th>
- <!-- <th>所属房子</th>-->
- <th>图片</th>
- <th>链接地址</th>
- <th>轮播顺序</th>
- <th>是否显示</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- <form id="checkForm" method="post">
- <?php if(!empty($datas)):?>
- <?php $i=0; foreach($datas as $data):?>
- <tr class="hotsearch_<?=$data->id?>">
- <td><?php $i++;echo $i;?></td>
- <td class="keyword"><?= $data->name?></td>
- <!-- <td class="keyword">--><?//= $data->uid?><!--</td>-->
- <td><img src="<?=Yii::getAlias('@imgdomain').'/'.$data->imgurl; ?>" style=" width: 50px;"></td>
- <td class="keyword"><?= $data->link?></td>
- <td class="keyword"><?= $data->orderby?></td>
- <td>
- <a>
- <?php if($data->status==\common\models\advert::ADVERT_STATE_SHOW):?>
- <i class="fa fa-check text-navy" data="<?=$data->id?>"></i>
- <?php else:?>
- <i class="fa fa-close text-danger" data="<?=$data->id?>"></i>
- <?php endif;?>
- </a>
- </td>
- <td>
- <a href="<?=Url::toRoute(['webconfig/addadvert','id'=>$data->id])?>" class="btn btn-sm btn-primary edit_advert">修改</a>
- <a class="btn btn-sm btn-danger del_advert"data="<?= $data->id?>">删除</a>
- </td>
- </tr>
- <?php endforeach;?>
- <?php endif?>
- <input type="hidden" name="_csrf-backend" value="<?=Yii::$app->request->csrfToken;?>" />
- <input type="hidden" value="" name="key" class="shelves-key">
- </form>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- $('.table-responsive').on('click','.fa',function(){
- var advertid = $(this).attr('data');
- var text = $(this);
- if($(this).hasClass('text-navy')){
- var title = '确定将该图片不显示?';
- }else{
- var title = '确定将该图片显示?';
- }
- swal({
- title: title,
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- closeOnConfirm: true,
- closeOnCancel: true },
- function(isConfirm){
- if (isConfirm) {
- $.ajax({
- url:'<?=Url::toRoute(['webconfig/show']);?>',
- type:'POST',
- dataType:'json',
- data:{id:advertid,'_csrf-backend':'<?=Yii::$app->request->csrfToken;?>'},
- success:function(data){
- if(data.sign==1){
- if(text.hasClass('text-navy')){
- text.addClass('text-danger');
- text.addClass('fa-close');
- text.removeClass('text-navy');
- text.removeClass('fa-check');
- }else{
- text.addClass('text-navy');
- text.addClass('fa-check');
- text.removeClass('text-danger');
- text.removeClass('fa-close');
- }
- }else{
- swal("", data.msg, "error");
- }
- }
- })
- }
- });
- });
- $('.table-responsive').on('click','.del_advert',function(){
- var id = $(this).attr('data');
- var text = $(this);
- swal({
- title: "确定删除该轮播图?",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- closeOnConfirm: true,
- closeOnCancel: true },
- function(isConfirm){
- if (isConfirm) {
- $.ajax({
- url:'<?=Url::toRoute(['webconfig/del_advert']);?>',
- type:'POST',
- dataType:'json',
- data:{id:id,'_csrf-backend':'<?=Yii::$app->request->csrfToken;?>'},
- success:function(data){
- if(data.sign==1){
- text.parents('tr').remove();
- }else{
- swal("", data.msg, "error");
- }
- }
- })
- }
- });
- })
- </script>
|