list.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. use yii\widgets\LinkPager;
  3. use common\components\stringUtil;
  4. ?>
  5. <div class="page-title">
  6. <div class="title-env">
  7. <h1 class="title">文章管理</h1>
  8. </div>
  9. <div class="breadcrumb-env">
  10. <ol class="breadcrumb bc-1">
  11. <li>
  12. <a href="/"><i class="fa-home"></i>Home</a>
  13. </li>
  14. <li>
  15. <a href="javascript:void(0)">商城管理</a>
  16. </li>
  17. <li class="active">
  18. <strong>文章管理</strong>
  19. </li>
  20. </ol>
  21. </div>
  22. </div>
  23. <div class="panel panel-default">
  24. <div class="panel-body">
  25. <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  26. <div class="row">
  27. <form action="" method="GET">
  28. <div class="col-xs-6" style="width:90%;">
  29. <div class="dataTables_length">
  30. <label>标题:<input type="search" class="form-control" name="title" placeholder="" aria-controls="example-1"></label>
  31. <input class="btn btn-secondary btn-single" type="submit" value="搜索" />
  32. <a href="/article/add" class="btn btn-secondary btn-single" style="margin-right:15px;">添加文章</a>
  33. </div>
  34. </div>
  35. </form>
  36. </div>
  37. <div name="xhQrTip" style="position:absolute;border-color: #8dc63f;width:110px;height:122px;z-index:9999;display:none;background:white;border:1px solid #ccc;">
  38. <div style="background:red;">
  39. <a href="javascript:void(0)" style="color:#68b828;float:right;z-index:9999;" <i="" class="fa-times"></a>
  40. </div>
  41. <div></div>
  42. </div>
  43. <div class="table-responsive">
  44. <table class="table table-bordered table-striped" >
  45. <thead>
  46. <tr class="active">
  47. <th class="no-sorting"><input type="checkbox"></th>
  48. <th>ID</th>
  49. <th>封面</th>
  50. <th>标题</th>
  51. <th>阅读</th>
  52. <th>转发</th>
  53. <th>创建日期</th>
  54. <th>操作</th>
  55. </tr>
  56. </thead>
  57. <tbody class="middle-align">
  58. <?php foreach($models as $key => $val){?>
  59. <tr>
  60. <td><input type="checkbox"></td>
  61. <td><?= $val['id'] ?></td>
  62. <td><?php if(!empty($val['cover'])){ ?><img src="<?= Yii::$app->params['imgUrl'].$val['cover'] ?>" width="20" /><?php }else{ ?><img src="/images/nopicture.png" width="20" /><?php } ?></td>
  63. <td>
  64. <?= stringUtil::subStringUtf8($val['title'],10,'…')?>&nbsp;
  65. <a data-urlqrcode="<?= $val['urlQrCode'] ?>" data-id="<?= $val['id'] ?>" name="qrShow" href="javascript:void(0)" style="color:#68b828;"><i class="fa-qrcode"></i></a>
  66. </td>
  67. <td><?= stringUtil::calcAdd($val['viewNum'], $val['viewAddNum']) ?></td>
  68. <td><?= $val['relayNum'] ?></td>
  69. <td><?= $val['createTime'] ?></td>
  70. <td>
  71. <a href="/article/edit?id=<?= $val['id'] ?>" class="btn btn-secondary btn-sm btn-icon icon-left">修改 </a>
  72. <a href="javascript:void(0)" class="btn btn-secondary btn-sm btn-icon icon-left">删除 </a>
  73. </td>
  74. </tr>
  75. <?php } ?>
  76. </tbody>
  77. </table>
  78. </div>
  79. <div class="row">
  80. <div>
  81. <!--
  82. <div style="display:inline-block;margin-left:15px;">
  83. <label><select name="example-1_length"
  84. aria-controls="example-1" class="form-control">
  85. <option value="0">批量操作</option>
  86. <option value="1">批量下架</option>
  87. <option value="2">批量删除</option>
  88. </select>
  89. </label>
  90. <input class="btn btn-secondary btn-single" type="submit" name="" value="确认" />
  91. </div>
  92. -->
  93. <div class="dataTables_paginate paging_simple_numbers" style="float:right;padding-top:0px;margin-right:15px;">
  94. <?= LinkPager::widget(['pagination' => $pages]); ?>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- footer -->
  102. <?php
  103. use backend\widgets\FooterWidget;
  104. ?>
  105. <?= FooterWidget::widget()?>
  106. <!-- footer -->
  107. <script>
  108. $("a[name=qrShow]").click(function(){
  109. var left = $(this).position().left;
  110. var top = $(this).position().top;
  111. var id = $(this).attr('data-id');
  112. var urlqrcode = $(this).attr('data-urlqrcode');
  113. var object = $(this);
  114. $("div[name=xhQrTip]").children('div').eq(1).html('<img src="/images/loading.gif" style="margin:47px 0 0 47px;" />');
  115. $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css('display','block');
  116. if(urlqrcode.length > 0){
  117. $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>'+urlqrcode+'" />');
  118. $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css("padding","2px").fadeIn();
  119. }else{
  120. $.ajax({type:"get",url:'/article/show-article-qrcode?id='+id,async:true,dataType:'json',success:function(data){
  121. if(data.code == 'A0001'){
  122. var imgUrl = data.data.url;
  123. object.attr('data-urlqrcode',imgUrl);
  124. $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>'+imgUrl+'" />');
  125. $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css("padding","2px").fadeIn();
  126. }
  127. }});
  128. }
  129. });
  130. $("div[name=xhQrTip]").click(function(){
  131. $(this).css("display","none");
  132. });
  133. </script>