publicCourse.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="content">
  3. <view class="content-list">
  4. <view class="content-list-item" v-for="(item, index) in videoList" :key="index" @click="clickVideo(item)">
  5. <view class="content-list-item-image">
  6. <u-image class="image" width="100%" height="224rpx" :src="item.coverUrl" />
  7. <view class="play-btn">
  8. <u-image width="70rpx" height="70rpx" src="/static/img/play-video-icon.svg" />
  9. </view>
  10. </view>
  11. <view class="content-list-item-title">
  12. <text>{{ item.chapterName }}</text>
  13. </view>
  14. <view class="content-list-item-subtitle">
  15. <text>{{ '颂军魂' }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <u-loadmore :status="status" />
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. status: 'loadmore',
  27. videoList: [],
  28. page: {
  29. num: 1,
  30. size: 10,
  31. total: 0
  32. }
  33. };
  34. },
  35. onLoad(options) {
  36. uni.setNavigationBarTitle({
  37. title: '颂军魂'
  38. });
  39. this.getDict();
  40. },
  41. onPullDownRefresh() {
  42. Object.assign(this, {
  43. status: 'loadmore',
  44. videoList: [],
  45. page: {
  46. num: 1,
  47. size: 10,
  48. total: 0
  49. }
  50. });
  51. setTimeout(() => {
  52. this.handleVideoList();
  53. uni.stopPullDownRefresh(); //停止刷新
  54. }, 1000);
  55. },
  56. onReachBottom() {
  57. if (this.page.num >= this.page.total) return;
  58. this.status = 'loading';
  59. this.page.num = ++this.page.num;
  60. setTimeout(() => {
  61. this.handleVideoList();
  62. }, 1500);
  63. },
  64. methods: {
  65. async handleVideoList() {
  66. const { num, size } = this.page
  67. const { code, data } = await this.$u.api.publicClasses.getPublicClassesListApi({ id: 1, pageNum: num, pageSize: size });
  68. if (code === 200) {
  69. this.videoList = this.videoList.concat(data?.rows ?? [])
  70. this.page.total = Number(data?.pages ?? 0);
  71. if (this.page.num >= this.page.total) this.status = 'nomore';
  72. else this.status = 'loading';
  73. }
  74. },
  75. async getDict() {
  76. const { code, data } = await this.$u.api.getDictdataUrl({
  77. key: 'site_type'
  78. })
  79. if (code === 200) {
  80. const type = this.iswap();
  81. const { text } = data.find((item) => item.label === type);
  82. if (!location.href.includes(text)) {
  83. location.href = text;
  84. return
  85. }
  86. this.handleVideoList()
  87. }
  88. },
  89. clickVideo(item) {
  90. this.$u.route({
  91. url: '/pages/publicCourse/videoDetails/videoDetails',
  92. params: {
  93. chapterName: item.chapterName,
  94. videoUrl: item.videoUrl
  95. }
  96. });
  97. },
  98. iswap() {
  99. var uA = navigator.userAgent.toLowerCase();
  100. var ipad = uA.match(/ipad/i) == "ipad";
  101. var iphone = uA.match(/iphone os/i) == "iphone os";
  102. var midp = uA.match(/midp/i) == "midp";
  103. var uc7 = uA.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
  104. var uc = uA.match(/ucweb/i) == "ucweb";
  105. var android = uA.match(/android/i) == "android";
  106. var windowsce = uA.match(/windows ce/i) == "windows ce";
  107. var windowsmd = uA.match(/windows mobile/i) == "windows mobile";
  108. if (
  109. !(
  110. ipad ||
  111. iphone ||
  112. midp ||
  113. uc7 ||
  114. uc ||
  115. android ||
  116. windowsce ||
  117. windowsmd
  118. )
  119. ) {
  120. // PC 端
  121. return "Pc";
  122. } else {
  123. // 移动端
  124. return "Mobile";
  125. }
  126. },
  127. }
  128. };
  129. </script>
  130. <style lang="scss" scoped>
  131. @import './publicCourse.scss';
  132. </style>