dlClassList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="content">
  3. <view class="topBox">
  4. <u-tabs
  5. lineWidth="100"
  6. :is-scroll="true"
  7. :list="cate_list"
  8. keyName="name"
  9. :current="current"
  10. :itemStyle="{ fontSize: '28rpx', height: '100rpx'}"
  11. :activeStyle="{ color: '#87C477',borderBottom:'2px solid #87C477' }"
  12. lineHeight="0"
  13. sticky
  14. @click="topHandle"
  15. ></u-tabs>
  16. </view>
  17. <view class="top-input dfsb">
  18. <u-search :showAction="false" placeholder="输入关键词搜索课程" @input="search()" v-model="keyword"></u-search>
  19. </view>
  20. <view class="swiper"><u-swiper :autoplay="false" :list="banner" keyName="img" height="120" border-radius="20" @click="bannerClick"></u-swiper></view>
  21. <view class="conwarp">
  22. <view class="fl-five"><course-list :flag="2" :list="list"></course-list></view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import courseList from './components/knowVidList.vue';
  28. import videoList from './video/componets/list.vue';
  29. export default {
  30. components: {
  31. courseList,
  32. videoList
  33. },
  34. data() {
  35. return {
  36. cate_list:[], //独立分类
  37. keyword: '',
  38. banner: [],
  39. flag: '', // 1 视频 2.其他
  40. cat_id:0,
  41. nav_id: '',
  42. subject_id: '',
  43. grade_id: '',
  44. list: [
  45. // { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
  46. ],
  47. status: 'loadmore',
  48. page: 1,
  49. pagenum: 6
  50. };
  51. },
  52. onPullDownRefresh() {
  53. this.page = 1;
  54. this.list = [];
  55. this.getInfoList();
  56. setTimeout(res => {
  57. uni.stopPullDownRefresh();
  58. }, 1000);
  59. },
  60. onReachBottom() {
  61. if (this.status == 'nomore') return;
  62. this.status = 'loading';
  63. this.page = ++this.page;
  64. this.getInfoList();
  65. },
  66. //url: `/pages/index/knowledgeList?flag=${val}&subject_id=${val}&grade_id=${this.grade_id}&title=${item.name}`
  67. onLoad(opt) {
  68. // this.flag = opt.flag || '1'; // 1 视频 2.其他
  69. this.keyword = opt.keyword || ''; //关键词
  70. this.nav_id = opt.nav_id || ''; //独立导航ID
  71. uni.setNavigationBarTitle({
  72. title: opt.title
  73. });
  74. this.dl_cate();
  75. if (!this.keyword) return this.getInfoList();
  76. },
  77. methods: {
  78. // 顶部按钮被点击
  79. topHandle(e) {
  80. console.log('top: ',e);
  81. this.cat_id = e.id;
  82. this.page = 1;
  83. this.list = [];
  84. this.getInfoList();
  85. // this.onload();
  86. },
  87. search() {
  88. if(this.keyword)
  89. {
  90. this.page = 1;
  91. this.list = [];
  92. this.getInfoList();
  93. }
  94. },
  95. //获取独立分类
  96. dl_cate() {
  97. this.$api
  98. .request('index/getDlCate', {
  99. dl_nav_id: this.nav_id || 0,
  100. })
  101. .then(data => {
  102. console.log(data);
  103. if (data.code == 200) {
  104. this.cate_list = data.data;
  105. // this.cat_id = data.data[0].id;
  106. console.log(this.cat_id);
  107. // this.getInfoList();
  108. } else {
  109. this.$api.toast(data.msg);
  110. }
  111. });
  112. },
  113. getInfoList() {
  114. this.status = 'loadmore';
  115. this.$api
  116. .request('index/getDlClassList', {
  117. keyword: this.keyword || '',
  118. dl_cate:this.cat_id||0,
  119. dl_nav:this.nav_id||'',
  120. page: this.page,
  121. limit: this.pagenum
  122. })
  123. .then(data => {
  124. console.log(data);
  125. if (data.code == 200) {
  126. this.banner = data.data.banner;
  127. this.list = this.list.concat(data.data.list);
  128. if (data.data.list.length < this.pagnum) {
  129. this.status = 'nomore';
  130. }
  131. } else {
  132. this.$api.toast(data.msg);
  133. }
  134. });
  135. },
  136. toNext(url) {
  137. uni.navigateTo({
  138. url: url
  139. });
  140. },
  141. bannerClick(e) {
  142. console.log(e);
  143. let item = this.banner[e];
  144. if (item.goods_id != 0) {
  145. if (item.type == 1) {
  146. uni.navigateTo({
  147. url: '/pages/index/video/videoInfo?id=' + item.goods_id
  148. });
  149. } else {
  150. uni.navigateTo({
  151. url: '/pages/index/navInfo?id=' + item.goods_id
  152. });
  153. }
  154. }
  155. }
  156. }
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .content {
  161. .topBox {
  162. width: auto;
  163. background-color: #fff;
  164. }
  165. /deep/ .u-tabs{
  166. width: 100vw;
  167. }
  168. .top-input {
  169. padding: 20rpx 30rpx;
  170. .sel {
  171. color: #f89638;
  172. padding: 12rpx 20rpx;
  173. font-size: $font-sm;
  174. background-color: rgba(#f89638, 0.1);
  175. border-radius: 30rpx;
  176. margin-right: 36rpx;
  177. }
  178. }
  179. .swiper {
  180. margin: 20rpx 30rpx;
  181. }
  182. .conwarp {
  183. background-color: #fff;
  184. padding: 32rpx 30rpx 30rpx;
  185. border-radius: 16rpx;
  186. margin-bottom: 20rpx;
  187. .gdHead {
  188. line-height: 58rpx;
  189. margin-bottom: 16rpx;
  190. .head {
  191. font-size: 34rpx;
  192. font-family: PingFangSC-Medium, PingFang SC;
  193. font-weight: 600;
  194. color: #333333;
  195. line-height: 48rpx;
  196. }
  197. }
  198. }
  199. }
  200. </style>