index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div id="game_record_container">
  3. <div class="padding">
  4. <!-- 头部-->
  5. <div class="header text-center">
  6. <view class="padding">
  7. <text class="title">
  8. {{ total }}
  9. </text>
  10. </view>
  11. <view>
  12. <text class="sub-title">
  13. 今日累计时长
  14. </text>
  15. </view>
  16. </div>
  17. <!-- 小titles -->
  18. <div class="line_container">
  19. <div>
  20. <text class="title">设备使用记录</text>
  21. <van-divider customStyle="border:.1px solid;margin:0px;"/>
  22. </div>
  23. </div>
  24. <!-- 列表模块-->
  25. <van-cell-group>
  26. <div class="record_list">
  27. <van-cell is-link :title="item.name"
  28. :value="item.play_time"
  29. v-for="(item,index) in items"
  30. :key="index"
  31. @click="to_report(item.game_record_id)"
  32. />
  33. </div>
  34. </van-cell-group>
  35. </div>
  36. <div style="height: 2rem;"></div>
  37. <!-- 标签筛选-->
  38. <view class="cu-bar tabbar foot_nonShadow">
  39. <van-tabs v-if="show" :active="active_date" @change="change_date" class="filter_date" line-width=58px>
  40. <van-tab :title="date.name" v-for="(date,index) in dates" :key="index"></van-tab>
  41. </van-tabs>
  42. </view>
  43. </div>
  44. </template>
  45. <script>
  46. import {gameList} from "../../requests/game";
  47. import {formatSeconds} from "../../utils";
  48. var $this
  49. export default {
  50. name: "game_record_container",
  51. components: {},
  52. data() {
  53. return {
  54. show:false,
  55. items: [],
  56. total: 0,
  57. dates: [
  58. {
  59. id: 1,
  60. name: "全部"
  61. },
  62. {
  63. id: 2,
  64. name: "今日",
  65. start_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime()).getTime() / 1000),
  66. end_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime() / 1000)
  67. },
  68. {
  69. id: 3,
  70. name: "昨日",
  71. start_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() - 24 * 60 * 60 * 1000).getTime() / 1000),
  72. end_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() - 1000).getTime() / 1000)
  73. },
  74. {
  75. id: 4,
  76. name: "近七日",
  77. start_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() - 7 * 24 * 60 * 60 * 1000).getTime() / 1000),
  78. end_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime() / 1000)
  79. }
  80. ],
  81. active_date: 0
  82. }
  83. },
  84. methods: {
  85. change_date($event) {
  86. let $item = $this.dates[$event.mp.detail.index]
  87. $this.get_game_list($item)
  88. },
  89. to_report($event) {
  90. mpvue.navigateTo({
  91. url: "/pages/report/main?id=" + $event
  92. })
  93. },
  94. get_game_list($params = {}) {
  95. gameList($params).then((res) => {
  96. let $res = res.data;
  97. $this.items = $res.data.list
  98. $this.items.forEach(($val, $index) => {
  99. if ($val['play_time']) {
  100. $val['play_time'] = formatSeconds($val['play_time'])
  101. } else {
  102. $val.splice($index, 1)
  103. }
  104. })
  105. $this.total = formatSeconds($res.data.total)
  106. },
  107. (err) => {
  108. console.log(err)
  109. }
  110. )
  111. }
  112. },
  113. mounted() {
  114. $this.get_game_list()
  115. },
  116. created() {
  117. $this = this
  118. $this.show = true
  119. }
  120. }
  121. </script>
  122. <style scoped>
  123. .header {
  124. width: 100%;
  125. height: 100px;
  126. }
  127. .header .title {
  128. font-size: 24px;
  129. font-weight: 400;
  130. color: #000000;
  131. line-height: 24px;
  132. }
  133. .header .sub-title {
  134. font-size: 12px;
  135. font-weight: 400;
  136. color: #6A6A6A;
  137. line-height: 24px;
  138. }
  139. .line_container .title {
  140. font-size: 10px;
  141. font-family: PingFang SC;
  142. font-weight: 400;
  143. color: #6C6C6C;
  144. line-height: 24px;
  145. }
  146. .filter_date {
  147. position: absolute;
  148. bottom: 0;
  149. width: 100%;
  150. background-color: rgba(255, 255, 255, 0);
  151. }
  152. .foot_nonShadow{
  153. position: fixed;
  154. width: 100%;
  155. bottom: 0;
  156. z-index: 1024;
  157. }
  158. .record_list {
  159. height: 490px;
  160. overflow-y: scroll;
  161. }
  162. </style>