publish_tab_download.php 4.6 KB

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