resource.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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.trim="searchText" bgColor="#f0f2f5" class="btntop" placeholder="搜索"
  8. cancelButton="none" 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" @transition='cutS' @animationfinish='ani'
  34. :current="current" :duration="300">
  35. <swiper-item>
  36. <scroll-view scroll-y="true" :refresher-enabled='refevent' :refresher-triggered="trigger"
  37. @refresherrefresh='repulling' @scrolltolower="relower" style="height: 100%;">
  38. <view class="searchPagedata" v-if="!classList.length">暂无数据</view>
  39. <view class="">
  40. <teaching-case ref="reso" :acList='classList'></teaching-case>
  41. </view>
  42. <view class="loading">
  43. <view v-if="reLoading==1">数据加载中...</view>
  44. <view v-if="reLoading==2">没有更多了~~</view>
  45. </view>
  46. </scroll-view>
  47. </swiper-item>
  48. <swiper-item>
  49. <scroll-view scroll-y="true" :refresher-enabled='refevent' :refresher-triggered="putrigger"
  50. @refresherrefresh='purepulling' @scrolltolower="tealower" style="height: 100%;">
  51. <view class="searchPagedata" v-if="!classList2.length">暂无数据</view>
  52. <view class="">
  53. <teaching-case ref="tech" :acList='classList2'></teaching-case>
  54. </view>
  55. <view class="loading">
  56. <view v-if="teaLoading==1">数据加载中...</view>
  57. <view v-if="teaLoading==2">没有更多了~~</view>
  58. </view>
  59. </scroll-view>
  60. </swiper-item>
  61. <!-- <swiper-item>
  62. <scroll-view scroll-y="true" style="height: 100%;">
  63. <view class=""
  64. style="height: 100%; width: 750rpx;display: flex;justify-content: center;align-items: center;">
  65. <image src="../../static/Frame.png" style="width: 400rpx;height: 400rpx;" mode=""></image>
  66. </view>
  67. </scroll-view>
  68. </swiper-item> -->
  69. </swiper>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. navBarData: {
  77. title: "课程",
  78. btn: 0,
  79. },
  80. indexId: 1,
  81. current: 0, //页面切换
  82. info1: "info1", //类名
  83. info2: "info2",
  84. // swiper: 0,
  85. searchText: "", // 搜索文本
  86. pic_coll: 'https://teacherapi.cocorobo.cn/teaching-file/static/Stara.png',
  87. pic_coll2: 'https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png',
  88. // 资源库
  89. classList: [],
  90. // 精品课程
  91. classList2: [],
  92. refevent: true,
  93. reLoading: 0, //0默认值 1加载中 2没有更多了
  94. recurrentPage: 1, //页数
  95. teaLoading: 0, //0默认值 1加载中 2没有更多了
  96. teacurrentPage: 1,
  97. // 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  98. trigger: false, //专题
  99. putrigger: false, //常规
  100. // 在搜索框有文字的时候下拉刷新禁止触发watch,防止数据叠加
  101. bansearchData: false
  102. };
  103. },
  104. watch: {
  105. searchText(val) {
  106. if (this.bansearchData) return
  107. // console.log('巴尔纳广播in而哦啊办呢日内');
  108. // console.log('searchText', val);
  109. if (val === '') {
  110. // 资源库
  111. // if (this.current == 0) {
  112. this.classList = []
  113. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  114. this.recurrentPage = 1 //页数
  115. this.getreList()
  116. // console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
  117. // }
  118. // if (this.current == 1) {
  119. this.classList2 = []
  120. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  121. this.teacurrentPage = 1
  122. this.getteaList()
  123. // }
  124. // console.log(1111);
  125. // 精品课程
  126. return
  127. }
  128. // console.log(888888);
  129. // if(val===''){
  130. // this.pu
  131. // }
  132. this.selectSearchdata()
  133. }
  134. },
  135. methods: {
  136. ani() {
  137. this.refevent = true
  138. },
  139. cutS(event) {
  140. // console.log(event.detail);
  141. this.refevent = false
  142. },
  143. selectSearchdata() {
  144. if (this.current === 2) return
  145. let data = {
  146. openid: uni.getStorageSync('oId'),
  147. txt: this.searchText,
  148. ty: this.current,
  149. // page: this.Searchpage,
  150. // lim: 15
  151. }
  152. // return console.log(data);
  153. this.$request('/selectActSearch', "get", data).then(res => {
  154. console.log('常规', res);
  155. if (this.current == 0) {
  156. this.classList = res[0]
  157. } else if (this.current == 1) {
  158. this.classList2 = res[0]
  159. }
  160. })
  161. },
  162. // 资源库下拉刷新
  163. repulling() {
  164. this.bansearchData = true
  165. this.trigger = true
  166. // this.isrepulling = true
  167. setTimeout(() => {
  168. this.trigger = false;
  169. }, 1000);
  170. // 资源库
  171. this.classList = []
  172. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  173. this.recurrentPage = 1 //页数
  174. if (this.searchText !== '') {
  175. this.classList2 = []
  176. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  177. this.teacurrentPage = 1
  178. this.getteaList()
  179. }
  180. this.searchText = ''
  181. this.getreList()
  182. },
  183. // 精品慕课下拉刷新
  184. purepulling() {
  185. this.bansearchData = true
  186. this.putrigger = true
  187. // this.isrepulling = true
  188. setTimeout(() => {
  189. this.putrigger = false;
  190. }, 1000);
  191. // 精品课程
  192. this.classList2 = []
  193. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  194. this.teacurrentPage = 1
  195. if (this.searchText !== '') {
  196. this.classList = []
  197. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  198. this.recurrentPage = 1 //页数
  199. this.getreList()
  200. }
  201. this.searchText = ''
  202. this.getteaList()
  203. },
  204. // 获取资源库
  205. getreList() {
  206. let data = {
  207. openid: uni.getStorageSync('oId'),
  208. ty: 0,
  209. page: this.recurrentPage,
  210. lim: 15
  211. }
  212. this.$request('/selectResource', "POST", data).then(res => {
  213. console.log('获取资源库', res);
  214. if (!res[0].length) {
  215. this.reLoading = 2
  216. } else {
  217. this.reLoading = 0
  218. }
  219. this.classList = [...this.classList, ...res[0]]
  220. this.bansearchData = false
  221. // this.classList2 = res[1]
  222. })
  223. },
  224. // 获取精品慕课
  225. getteaList() {
  226. let data = {
  227. openid: uni.getStorageSync('oId'),
  228. ty: 1,
  229. page: this.teacurrentPage,
  230. lim: 15
  231. }
  232. this.$request('/selectResource', "POST", data).then(res => {
  233. console.log('获取精品慕课', res);
  234. if (!res[0].length) {
  235. this.teaLoading = 2
  236. } else {
  237. this.teaLoading = 0
  238. }
  239. // console.log('前',this.classList2);
  240. this.classList2 = [...this.classList2, ...res[0]]
  241. this.bansearchData = false
  242. // console.log('后',this.classList2);
  243. // this.classList2 = res[1]
  244. })
  245. },
  246. // 资源库触底
  247. relower() {
  248. if (this.searchText !== '') return console.log('禁止触底');
  249. console.log('没触底?');
  250. if (this.reLoading == 2) return
  251. this.reLoading = 1
  252. this.recurrentPage++
  253. setTimeout(this.getreList, 1000)
  254. },
  255. // 精品慕课触底
  256. tealower() {
  257. if (this.searchText !== '') return console.log('禁止触底');
  258. console.log('没触底?');
  259. if (this.teaLoading == 2) return
  260. this.teaLoading = 1
  261. this.teacurrentPage++
  262. setTimeout(this.getteaList, 1000)
  263. },
  264. swipeIndex(index) {
  265. this.current = index.detail.current;
  266. if (this.searchText !== '') {
  267. this.selectSearchdata()
  268. }
  269. },
  270. // 区域滑动
  271. phoneLogin() {
  272. this.current = 0;
  273. },
  274. accountLogin() {
  275. this.current = 1;
  276. },
  277. costClass() {
  278. this.current = 2;
  279. }
  280. },
  281. onLoad() {
  282. this.getreList()
  283. this.getteaList()
  284. },
  285. onShow() {
  286. this.getAllMessage() // 调用app.js中的方法
  287. // 获取收藏
  288. this.$refs.reso.getdata()
  289. this.$refs.tech.getdata()
  290. }
  291. };
  292. </script>
  293. <style lang="scss" scoped>
  294. .btntop {
  295. width: 100%;
  296. }
  297. .searchPagedata {
  298. width: 750rpx;
  299. height: 40%;
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. }
  304. .resource {
  305. display: flex;
  306. flex-direction: column;
  307. height: 100vh;
  308. .search {
  309. background-color: #ffffff;
  310. position: relative;
  311. display: flex;
  312. width: 750rpx;
  313. height: 88rpx;
  314. justify-content: center;
  315. align-items: center;
  316. }
  317. .top {
  318. width: 100%;
  319. display: flex;
  320. justify-content: space-around;
  321. margin: auto;
  322. background-color: #ffffff;
  323. padding: 10px 60rpx;
  324. height: 98rpx;
  325. .info1 {
  326. font-weight: bold !important;
  327. position: relative;
  328. color: rgba(0, 0, 0, 0.8);
  329. font-size: 34rpx;
  330. line-height: 48rpx;
  331. width: 136rpx;
  332. height: 48rpx;
  333. text-align: center;
  334. .yun {
  335. width: 134rpx;
  336. height: 32rpx;
  337. position: absolute;
  338. left: 0;
  339. bottom: -10rpx;
  340. image {
  341. width: 100%;
  342. height: 100%;
  343. }
  344. }
  345. }
  346. .info2 {
  347. color: rgba(0, 0, 0, 0.6);
  348. font-size: 34rpx;
  349. font-weight: 400;
  350. line-height: 48rpx;
  351. width: 136rpx;
  352. height: 48rpx;
  353. text-align: center;
  354. font-family: 微软雅黑;
  355. }
  356. }
  357. .scroll-view-height {
  358. flex: 1;
  359. width: 100%;
  360. display: flex;
  361. flex-wrap: wrap;
  362. justify-content: space-between;
  363. }
  364. }
  365. </style>