resource.vue 8.2 KB

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