resource.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. console.log(111);
  125. },
  126. // 精品慕课下拉刷新
  127. purepulling() {
  128. this.putrigger = true
  129. // this.isrepulling = true
  130. setTimeout(() => {
  131. this.putrigger = false;
  132. }, 1000);
  133. // 精品课程
  134. this.classList2= []
  135. this.teaLoading= 0 //0默认值 1加载中 2没有更多了
  136. this.teacurrentPage= 1
  137. this.getteaList()
  138. console.log(111);
  139. },
  140. // 获取资源库
  141. getreList() {
  142. let data = {
  143. openid: uni.getStorageSync('oId'),
  144. ty: 0,
  145. page: this.recurrentPage,
  146. lim: 15
  147. }
  148. this.$request('/selectResource', "POST", data).then(res => {
  149. console.log('获取资源库', res);
  150. if (!res[0].length) {
  151. this.reLoading = 2
  152. } else {
  153. this.reLoading = 0
  154. }
  155. this.classList = [...this.classList, ...res[0]]
  156. // this.classList2 = res[1]
  157. })
  158. },
  159. // 获取精品慕课
  160. getteaList() {
  161. let data = {
  162. openid: uni.getStorageSync('oId'),
  163. ty: 1,
  164. page: this.teacurrentPage,
  165. lim: 15
  166. }
  167. this.$request('/selectResource', "POST", data).then(res => {
  168. console.log('获取资源库', res);
  169. if (!res[0].length) {
  170. this.teaLoading = 2
  171. } else {
  172. this.teaLoading = 0
  173. }
  174. this.classList2 = [...this.classList2, ...res[0]]
  175. // this.classList2 = res[1]
  176. })
  177. },
  178. // 资源库触底
  179. relower() {
  180. console.log('没触底?');
  181. if (this.reLoading == 2) return
  182. this.reLoading = 1
  183. this.recurrentPage++
  184. setTimeout(this.getreList, 1000)
  185. },
  186. // 精品慕课触底
  187. tealower() {
  188. console.log('没触底?');
  189. if (this.teaLoading == 2) return
  190. this.teaLoading = 1
  191. this.teacurrentPage++
  192. setTimeout(this.getteaList, 1000)
  193. },
  194. swipeIndex(index) {
  195. this.current = index.detail.current;
  196. },
  197. // 区域滑动
  198. phoneLogin() {
  199. this.current = 0;
  200. },
  201. accountLogin() {
  202. this.current = 1;
  203. },
  204. costClass() {
  205. this.current = 2;
  206. }
  207. },
  208. onLoad() {
  209. // this.classList: []
  210. // 精品课程
  211. // this.classList2: []
  212. // this.reLoading: 0 //0默认值 1加载中 2没有更多了
  213. // this.recurrentPage: 1 //页数
  214. // this.teaLoading: 0 //0默认值 1加载中 2没有更多了
  215. // this.teacurrentPage: 1
  216. },
  217. onShow() {
  218. // 精品课程
  219. this.classList2= []
  220. this.teaLoading= 0 //0默认值 1加载中 2没有更多了
  221. this.teacurrentPage= 1
  222. // 资源库
  223. this.classList= []
  224. this.reLoading= 0 //0默认值 1加载中 2没有更多了
  225. this.recurrentPage= 1 //页数
  226. this.getreList()
  227. this.getteaList()
  228. this.getAllMessage() // 调用app.js中的方法
  229. // 获取收藏
  230. this.$refs.reso.getdata()
  231. this.$refs.tech.getdata()
  232. }
  233. // onShow() {
  234. // // 资源库
  235. // this.getAllMessage() // 调用app.js中的方法
  236. // this.getreList()
  237. // this.getteaList()
  238. // // 获取收藏
  239. // this.$refs.reso.getdata()
  240. // this.$refs.tech.getdata()
  241. // },
  242. };
  243. </script>
  244. <style lang="scss" scoped>
  245. .btntop {
  246. width: 100%;
  247. }
  248. .resource {
  249. display: flex;
  250. flex-direction: column;
  251. height: 100vh;
  252. .search {
  253. background-color: #ffffff;
  254. position: relative;
  255. display: flex;
  256. width: 750rpx;
  257. height: 88rpx;
  258. justify-content: center;
  259. align-items: center;
  260. }
  261. .top {
  262. width: 100%;
  263. display: flex;
  264. justify-content: space-between;
  265. margin: auto;
  266. background-color: #ffffff;
  267. padding: 10px 60rpx;
  268. height: 98rpx;
  269. .info1 {
  270. font-weight: bold !important;
  271. position: relative;
  272. color: rgba(0, 0, 0, 0.8);
  273. font-size: 34rpx;
  274. line-height: 48rpx;
  275. width: 136rpx;
  276. height: 48rpx;
  277. text-align: center;
  278. .yun {
  279. width: 134rpx;
  280. height: 32rpx;
  281. position: absolute;
  282. left: 0;
  283. bottom: -10rpx;
  284. image {
  285. width: 100%;
  286. height: 100%;
  287. }
  288. }
  289. }
  290. .info2 {
  291. color: rgba(0, 0, 0, 0.6);
  292. font-size: 34rpx;
  293. font-weight: 400;
  294. line-height: 48rpx;
  295. width: 136rpx;
  296. height: 48rpx;
  297. text-align: center;
  298. font-family: 微软雅黑;
  299. }
  300. }
  301. .scroll-view-height {
  302. flex: 1;
  303. width: 100%;
  304. display: flex;
  305. flex-wrap: wrap;
  306. justify-content: space-between;
  307. }
  308. }
  309. </style>