resource.vue 10.0 KB

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