publish_tab_download.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. // 获取应用ID
  3. $id = bees_decrypt(SafeRequest("id", "get"));
  4. $row = db('appid')->where('in_uid', $this->userid)->where('in_id', $id)->find();
  5. // 获取日期参数
  6. $start_date = SafeRequest("start_date", "get");
  7. $end_date = SafeRequest("end_date", "get");
  8. $starttime = $start_date . ' 00:00:00';
  9. $endtime = $end_date . ' 23:59:59';
  10. $specified = '';
  11. if (!empty($start_date) && !empty($end_date)) {
  12. $specified = "addtime>'" . $starttime . "' and addtime<'" . $endtime . "' ";
  13. }
  14. // 查询下载记录 - 使用 paginate 方法
  15. $page = SafeRequest("page", "get");
  16. $result = db('downhistory')->where($specified)->where('appid', $id)->where('uid', $this->userid)->order('addtime desc')->paginate(["page" => $page, 'list_rows' => 5]);
  17. $render = $result->render();
  18. $count = $result->total();
  19. $sid = bees_encrypt($row['in_id']);
  20. ?>
  21. <div class="download-details">
  22. <div class="d-top clearfix">
  23. <div class="date date1">
  24. <input class="form-control" type="text" id="datetimepicker1" value="<?php if (empty($start_date)) { echo date("Y/m/d", strtotime(date("Y/m/d") . '-1 week')); } else { echo $start_date; } ?>">
  25. <span class="iconfont icon-date"></span>
  26. </div>
  27. <div class="fl line">
  28. _
  29. </div>
  30. <div class="date date2">
  31. <input class="form-control" type="text" id="datetimepicker2" value="<?php if (empty($end_date)) { echo date("Y/m/d"); } else { echo $end_date; } ?>">
  32. <span class="iconfont icon-date"></span>
  33. </div>
  34. <button type="button" class="ms-btn ms-btn-secondary fl query">查询</button>
  35. <span class="fl num">累计总下载 <i>
  36. <?php echo $row['in_downloads'];?>
  37. </i> 次</span>
  38. <button type="button" class="ms-btn ms-btn-secondary fr cleanUp"
  39. data-app-id="<?php echo bees_encrypt($row['in_id']);?>">清空统计数据
  40. </button>
  41. </div>
  42. <div class="table-responsive">
  43. <table class="table">
  44. <tbody>
  45. <tr>
  46. <th>时间</th>
  47. <th>应用名称</th>
  48. <th>版本</th>
  49. <th>大小</th>
  50. <th>浏览次数</th>
  51. <th>下载次数</th>
  52. </tr>
  53. <?php
  54. foreach ($result as $key => $value) {
  55. ?>
  56. <tr>
  57. <td><?php echo $value['addtime'];?></td>
  58. <td><?php echo $value['appname'];?></td>
  59. <td><?php echo $value['appversion'];?></td>
  60. <td><?php echo formatsize($value['appsize']);?></td>
  61. <td><?php echo $value['liulan'];?></td>
  62. <td><?php echo $value['down'];?></td>
  63. </tr>
  64. <?php
  65. }
  66. ?>
  67. </tbody>
  68. <tfoot>
  69. <tr>
  70. <td colspan="6"><?php echo getRender($result, $page); ?></td>
  71. </tr>
  72. </tfoot>
  73. </table>
  74. <?php
  75. if ($count == 0) {
  76. ?>
  77. <div class="text-center no-content">
  78. <img src="/static/index/image/invoice-1.png" alt="">
  79. <p class="color-333 mt10">
  80. 暂无任何数据
  81. </p>
  82. </div>
  83. <?php
  84. }
  85. ?>
  86. </div>
  87. </div>
  88. <script>
  89. $(function () {
  90. // 初始化日期选择器
  91. $('#datetimepicker1, #datetimepicker2').datetimepicker({
  92. format: 'Y/m/d',
  93. timepicker: false,
  94. datepicker: true
  95. });
  96. // 查询按钮点击事件
  97. $(".download-details div:first").on('click', '.query', function () {
  98. var start_date = $(this).parent().find("input:first").val();
  99. var end_date = $(this).parent().find("input:last").val();
  100. window.location.href = "/index/publish_detail?id=<?php echo bees_encrypt($row['in_id']);?>&tab=download&start_date=" + start_date + "&end_date=" + end_date + "&page=1";
  101. });
  102. // 清空统计数据按钮点击事件
  103. $(".download-details div:first").on('click', '.cleanUp', function () {
  104. var appId = $(this).data('app-id');
  105. alert('确认清空统计数据吗?', function () {
  106. $.post('/index/ajax_profile/cleanStatistics', { appId: appId }, function (data) {
  107. if (data.code == 200) {
  108. window.location.reload();
  109. } else {
  110. alert(data.msg);
  111. }
  112. }, 'json')
  113. }, function () {
  114. }, 'center', '确定', '取消');
  115. });
  116. });
  117. </script>