video.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="pageCon">
  3. <view class="top bb scrollx ">
  4. <view @click="sectionChange(item, 1)" :class="[cat == item.id ? 'sel' : '', 'li']"
  5. v-for="(item, index) in vedio_cats" :key="index">{{ item.name }}</view>
  6. </view>
  7. <view class="top scrollx ">
  8. <view @click="sectionChange(item, 2)" :class="[two_cat == item.id ? 'sel' : '', 'li']"
  9. v-for="(item, index) in vedio_two_cats" :key="index">{{ item.name }}</view>
  10. </view>
  11. <view class="conwarp">
  12. <list :flag="1" :list="video_list"></list>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import list from './componets/list.vue';
  18. export default {
  19. components: {
  20. list
  21. },
  22. data() {
  23. return {
  24. cat: '',
  25. two_cat: 0, //二级分类
  26. keyword: '',
  27. nav_id: 0,
  28. vedio_cats: [],
  29. vedio_two_cats: [],
  30. video_list: [
  31. // { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
  32. ],
  33. page: 1,
  34. pagnum: 10
  35. };
  36. },
  37. onPullDownRefresh() {
  38. this.page = 1;
  39. this.video_list = [];
  40. this.getInfoList();
  41. setTimeout(res => {
  42. uni.stopPullDownRefresh();
  43. }, 1000);
  44. },
  45. onReachBottom() {
  46. if (this.status == 'nomore') return;
  47. this.status = 'loading';
  48. this.page = ++this.page;
  49. this.getInfoList();
  50. },
  51. onLoad(opt) {
  52. this.nav_id = opt.nav_id || '';
  53. this.keyword = opt.keyword || '';
  54. this.cat = opt.cat || '';
  55. this.getInfoList();
  56. },
  57. methods: {
  58. sectionChange(item, key) {
  59. if (key == 2) {
  60. this.two_cat = item.id;
  61. this.page = 1;
  62. this.video_list = [];
  63. this.getInfoList();
  64. } else if (key == 1) {
  65. this.two_cat = 0;
  66. this.cat = item.id;
  67. this.page = 1;
  68. this.video_list = [];
  69. this.getInfoList();
  70. uni.setNavigationBarTitle({
  71. title: item.name
  72. });
  73. }
  74. },
  75. getInfoList() {
  76. this.status = 'loadmore';
  77. this.$api
  78. .request('index/getVideoList', {
  79. is_top: 0,
  80. keyword: this.keyword || '',
  81. nav_id: this.nav_id,
  82. cat: this.cat,
  83. two_cat: this.two_cat || '',
  84. page: this.page,
  85. limit: this.pagnum
  86. })
  87. .then(data => {
  88. console.log(data);
  89. if (data.code == 200) {
  90. this.vedio_cats = data.data.vedio_cats;
  91. if (!this.cat) {
  92. this.cat = this.vedio_cats[0].id;
  93. uni.setNavigationBarTitle({
  94. title: this.vedio_cats[0].name
  95. });
  96. }
  97. // 没有二级分类 调取
  98. // if (!this.two_cat) {
  99. // return;
  100. // }
  101. this.getTwoList();
  102. this.video_list = this.video_list.concat(data.data.video_list);
  103. if (data.data.video_list.length < this.pagnum) {
  104. this.status = 'nomore';
  105. }
  106. } else {
  107. this.$api.toast(data.msg);
  108. }
  109. });
  110. },
  111. getTwoList() {
  112. this.$api
  113. .request('index/getTwoCate', {
  114. id: this.cat
  115. })
  116. .then(data => {
  117. console.log(data);
  118. if (data.code == 200) {
  119. this.vedio_two_cats = data.data;
  120. console.log(this.vedio_two_cats, data.data);
  121. if (!this.two_cat) {
  122. this.two_cat = this.vedio_two_cats[0].id || '0';
  123. }
  124. // 调取列表
  125. // this.page = 1;
  126. // this.video_list = [];
  127. // this.getInfoList();
  128. } else {
  129. this.$api.toast(data.msg);
  130. }
  131. });
  132. },
  133. toNext(url) {
  134. uni.navigateTo({
  135. url: url
  136. });
  137. }
  138. }
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .pageCon {
  143. .top {
  144. padding: 22rpx 10rpx 20rpx;
  145. background-color: #fff;
  146. .li {
  147. padding: 8rpx 15rpx;
  148. background-color: #f2f2f2;
  149. margin-right: 20rpx;
  150. color: #999;
  151. border-radius: 20rpx;
  152. font-size: 22rpx;
  153. }
  154. .sel {
  155. border: 1px solid #025b58;
  156. background: rgba(2, 91, 88, 0.1);
  157. color: #025b58;
  158. }
  159. }
  160. .conwarp {
  161. background: #ffffff;
  162. margin-top: 20rpx;
  163. padding: 0 30rpx;
  164. }
  165. }
  166. </style>