resource.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="resource">
  3. <statusBar :item="navBarData"></statusBar>
  4. <view class="search">
  5. <uni-search-bar v-model="searchText" bgColor="#f0f2f5" class="btntop" placeholder="搜索" cancelButton="none"
  6. clearButton="none"></uni-search-bar>
  7. </view>
  8. <view class="top">
  9. <view class="left" @click="phoneLogin" :class="current == 0 ? info1 : info2">
  10. <text class="">资源库</text>
  11. <view v-if="current == 0" class="yun">
  12. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  13. mode="aspectFill"></image>
  14. </view>
  15. </view>
  16. <view class="right" @click="accountLogin" :class="current == 1 ? info1 : info2">
  17. <text class="">精品慕课</text>
  18. <view v-if="current == 1" class="yun">
  19. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  20. mode="aspectFill"></image>
  21. </view>
  22. </view>
  23. <view class="right" @click="costClass" :class="current == 2 ? info1 : info2">
  24. <text class="">付费课程</text>
  25. <view v-if="current == 2" class="yun">
  26. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  27. mode="aspectFill"></image>
  28. </view>
  29. </view>
  30. </view>
  31. <swiper class="scroll-view-height" @change="swipeIndex" :current="current" :duration="300">
  32. <swiper-item>
  33. <scroll-view scroll-y="true" refresher-enabled='true' :refresher-triggered="trigger"
  34. @refresherrefresh='repulling' @scrolltolower="relower" style="height: 100%;">
  35. <view class="">
  36. <teaching-case ref="reso" :acList='filteredClassList'></teaching-case>
  37. </view>
  38. <view class="loading">
  39. <view v-if="reLoading==1">数据加载中...</view>
  40. <view v-if="reLoading==2">没有更多了~~</view>
  41. </view>
  42. </scroll-view>
  43. </swiper-item>
  44. <swiper-item>
  45. <scroll-view scroll-y="true" refresher-enabled='true' :refresher-triggered="putrigger"
  46. @refresherrefresh='purepulling' @scrolltolower="tealower" style="height: 100%;">
  47. <view class="">
  48. <teaching-case ref="tech" :acList='filteredClassList2'></teaching-case>
  49. </view>
  50. <view class="loading">
  51. <view v-if="teaLoading==1">数据加载中...</view>
  52. <view v-if="teaLoading==2">没有更多了~~</view>
  53. </view>
  54. </scroll-view>
  55. </swiper-item>
  56. <swiper-item>
  57. <scroll-view scroll-y="true" style="height: 100%;">
  58. <view class=""
  59. style="height: 100%; width: 750rpx;display: flex;justify-content: center;align-items: center;">
  60. <image src="../../static/Frame.png" style="width: 400rpx;height: 400rpx;" mode=""></image>
  61. </view>
  62. </scroll-view>
  63. </swiper-item>
  64. </swiper>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. navBarData: {
  72. title: "课程",
  73. btn: 0,
  74. },
  75. indexId: 1,
  76. current: 0, //登录方式切换
  77. info1: "info1", //类名
  78. info2: "info2",
  79. // swiper: 0,
  80. searchText: "", // 搜索文本
  81. pic_coll: 'https://teacherapi.cocorobo.cn/teaching-file/static/Stara.png',
  82. pic_coll2: 'https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png',
  83. // 资源库
  84. classList: [],
  85. // 精品课程
  86. classList2: [],
  87. reLoading: 0, //0默认值 1加载中 2没有更多了
  88. recurrentPage: 1, //页数
  89. teaLoading: 0, //0默认值 1加载中 2没有更多了
  90. teacurrentPage: 1,
  91. // 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  92. trigger: false, //专题
  93. putrigger: false, //常规
  94. };
  95. },
  96. // 模糊搜索
  97. computed: {
  98. filteredClassList() {
  99. const filteredList = this.classList.filter((item) =>
  100. item.ctit.includes(this.searchText)
  101. );
  102. return this.searchText ? filteredList : this.classList;
  103. },
  104. filteredClassList2() {
  105. const filterdList2 = this.classList2.filter((item) =>
  106. item.ctit.includes(this.searchText)
  107. );
  108. return this.searchText ? filterdList2 : this.classList2;
  109. },
  110. },
  111. methods: {
  112. // 资源库下拉刷新
  113. repulling() {
  114. this.trigger = true
  115. // this.isrepulling = true
  116. setTimeout(() => {
  117. this.trigger = false;
  118. }, 1000);
  119. // 资源库
  120. this.classList = []
  121. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  122. this.recurrentPage = 1 //页数
  123. this.getreList()
  124. },
  125. // 精品慕课下拉刷新
  126. purepulling() {
  127. this.putrigger = true
  128. // this.isrepulling = true
  129. setTimeout(() => {
  130. this.putrigger = false;
  131. }, 1000);
  132. // 精品课程
  133. this.classList2 = []
  134. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  135. this.teacurrentPage = 1
  136. this.getteaList()
  137. console.log(111);
  138. },
  139. // 获取资源库
  140. getreList() {
  141. let data = {
  142. openid: uni.getStorageSync('oId'),
  143. ty: 0,
  144. page: this.recurrentPage,
  145. lim: 15
  146. }
  147. this.$request('/selectResource', "POST", data).then(res => {
  148. console.log('获取资源库', res);
  149. if (!res[0].length) {
  150. this.reLoading = 2
  151. } else {
  152. this.reLoading = 0
  153. }
  154. this.classList = [...this.classList, ...res[0]]
  155. // this.classList2 = res[1]
  156. })
  157. },
  158. // 获取精品慕课
  159. getteaList() {
  160. let data = {
  161. openid: uni.getStorageSync('oId'),
  162. ty: 1,
  163. page: this.teacurrentPage,
  164. lim: 15
  165. }
  166. this.$request('/selectResource', "POST", data).then(res => {
  167. console.log('获取资源库', res);
  168. if (!res[0].length) {
  169. this.teaLoading = 2
  170. } else {
  171. this.teaLoading = 0
  172. }
  173. this.classList2 = [...this.classList2, ...res[0]]
  174. // this.classList2 = res[1]
  175. })
  176. },
  177. // 资源库触底
  178. relower() {
  179. console.log('没触底?');
  180. if (this.reLoading == 2) return
  181. this.reLoading = 1
  182. this.recurrentPage++
  183. setTimeout(this.getreList, 1000)
  184. },
  185. // 精品慕课触底
  186. tealower() {
  187. console.log('没触底?');
  188. if (this.teaLoading == 2) return
  189. this.teaLoading = 1
  190. this.teacurrentPage++
  191. setTimeout(this.getteaList, 1000)
  192. },
  193. swipeIndex(index) {
  194. this.current = index.detail.current;
  195. },
  196. // 区域滑动
  197. phoneLogin() {
  198. this.current = 0;
  199. },
  200. accountLogin() {
  201. this.current = 1;
  202. },
  203. costClass() {
  204. this.current = 2;
  205. }
  206. },
  207. onLoad() {
  208. // this.classList: []
  209. // 精品课程
  210. // this.classList2: []
  211. // this.reLoading: 0 //0默认值 1加载中 2没有更多了
  212. // this.recurrentPage: 1 //页数
  213. // this.teaLoading: 0 //0默认值 1加载中 2没有更多了
  214. // this.teacurrentPage: 1
  215. this.getreList()
  216. this.getteaList()
  217. },
  218. onShow() {
  219. // 精品课程
  220. // this.classList2= []
  221. // this.teaLoading= 0 //0默认值 1加载中 2没有更多了
  222. // this.teacurrentPage= 1
  223. // 资源库
  224. // this.classList= []
  225. // this.reLoading= 0 //0默认值 1加载中 2没有更多了
  226. // this.recurrentPage= 1 //页数
  227. this.getAllMessage() // 调用app.js中的方法
  228. // 获取收藏
  229. this.$refs.reso.getdata()
  230. this.$refs.tech.getdata()
  231. }
  232. };
  233. </script>
  234. <style lang="scss" scoped>
  235. .btntop {
  236. width: 100%;
  237. }
  238. .resource {
  239. display: flex;
  240. flex-direction: column;
  241. height: 100vh;
  242. .search {
  243. background-color: #ffffff;
  244. position: relative;
  245. display: flex;
  246. width: 750rpx;
  247. height: 88rpx;
  248. justify-content: center;
  249. align-items: center;
  250. }
  251. .top {
  252. width: 100%;
  253. display: flex;
  254. justify-content: space-between;
  255. margin: auto;
  256. background-color: #ffffff;
  257. padding: 10px 60rpx;
  258. height: 98rpx;
  259. .info1 {
  260. font-weight: bold !important;
  261. position: relative;
  262. color: rgba(0, 0, 0, 0.8);
  263. font-size: 34rpx;
  264. line-height: 48rpx;
  265. width: 136rpx;
  266. height: 48rpx;
  267. text-align: center;
  268. .yun {
  269. width: 134rpx;
  270. height: 32rpx;
  271. position: absolute;
  272. left: 0;
  273. bottom: -10rpx;
  274. image {
  275. width: 100%;
  276. height: 100%;
  277. }
  278. }
  279. }
  280. .info2 {
  281. color: rgba(0, 0, 0, 0.6);
  282. font-size: 34rpx;
  283. font-weight: 400;
  284. line-height: 48rpx;
  285. width: 136rpx;
  286. height: 48rpx;
  287. text-align: center;
  288. font-family: 微软雅黑;
  289. }
  290. }
  291. .scroll-view-height {
  292. flex: 1;
  293. width: 100%;
  294. display: flex;
  295. flex-wrap: wrap;
  296. justify-content: space-between;
  297. }
  298. }
  299. </style>