viewHistorys.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <z-paging
  3. class="content-page-wrap flex-column"
  4. ref="paging"
  5. v-model="videoList"
  6. @query="gteHistoryData"
  7. :refresher-enabled="false"
  8. >
  9. <template #top>
  10. <view
  11. class="head-title flex-left justify-between"
  12. style="padding: 32rpx 32rpx 0 32rpx"
  13. >
  14. <view style="width: 94rpx">
  15. <u-icon
  16. name="arrow-left"
  17. color="#000E08"
  18. size="42rpx"
  19. @click="goBack"
  20. bold
  21. ></u-icon>
  22. </view>
  23. <view>观看历史</view>
  24. <view style="width: 94rpx"> </view>
  25. </view>
  26. </template>
  27. <view class="flex-row flex-wrap">
  28. <view
  29. v-for="(item, index) in videoList"
  30. class="videoCardMain flex-column"
  31. @click="goPlayVideo(item)"
  32. >
  33. <view class="videoCardImgBox">
  34. <image
  35. class="videoCardImg"
  36. :src="item.videoPoster"
  37. mode="aspectFill"
  38. ></image>
  39. <text class="video-state">{{
  40. secondsToTime(item.duration)
  41. }}</text>
  42. </view>
  43. <view class="videoCardName line_1">
  44. {{ item.videoName }}
  45. </view>
  46. </view>
  47. </view>
  48. </z-paging>
  49. </template>
  50. <script>
  51. import $req from "@/service/serviceConfig";
  52. export default {
  53. data() {
  54. return {
  55. videoList: [],
  56. };
  57. },
  58. onShow() {
  59. let vm = this;
  60. vm.gteHistoryData();
  61. },
  62. methods: {
  63. // 获取历史数据
  64. gteHistoryData(pageNo = 1) {
  65. let vm = this;
  66. uni.showLoading({
  67. title: "加载中",
  68. });
  69. let query = {
  70. page: pageNo,
  71. size: 10,
  72. };
  73. $req.request({ alias: "view-records-page", query })
  74. .then((res) => {
  75. if (res.code == 0) {
  76. uni.hideLoading();
  77. vm.$refs.paging.complete(res.data.rows);
  78. }
  79. })
  80. .catch(() => {
  81. uni.hideLoading();
  82. vm.$refs.paging.complete(false);
  83. });
  84. },
  85. goPlayVideo(row) {
  86. uni.navigateTo({
  87. url: `/pages/play/play?url=${row.url}`,
  88. });
  89. },
  90. goBack() {
  91. uni.navigateBack();
  92. },
  93. // 秒转换为时分秒
  94. secondsToTime(seconds) {
  95. const hours = Math.floor(seconds / 3600)
  96. .toString()
  97. .padStart(2, "0");
  98. const minutes = Math.floor((seconds % 3600) / 60)
  99. .toString()
  100. .padStart(2, "0");
  101. const remainingSeconds = (seconds % 60).toString().padStart(2, "0");
  102. return hours + ":" + minutes + ":" + remainingSeconds;
  103. },
  104. },
  105. };
  106. </script>