resource.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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" :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. onShareTimeline() {
  105. uni.share({
  106. provider: "weixin",
  107. scene: "WXSceneTimeline",
  108. type: 0,
  109. href: "http://uniapp.dcloud.io/",
  110. title: "uni-app分享",
  111. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  112. imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
  113. success: function(res) {
  114. console.log("success:" + JSON.stringify(res));
  115. },
  116. fail: function(err) {
  117. console.log("fail:" + JSON.stringify(err));
  118. }
  119. });
  120. },
  121. // 分享
  122. onShareAppMessage() {
  123. uni.share({
  124. provider: "weixin",
  125. scene: "WXSceneSession",
  126. type: 1,
  127. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  128. success: function(res) {
  129. console.log("success:" + JSON.stringify(res));
  130. },
  131. fail: function(err) {
  132. console.log("fail:" + JSON.stringify(err));
  133. }
  134. });
  135. },
  136. watch: {
  137. searchText(val) {
  138. if (this.bansearchData) return
  139. // console.log('巴尔纳广播in而哦啊办呢日内');
  140. // console.log('searchText', val);
  141. if (val === '') {
  142. // 资源库
  143. // if (this.current == 0) {
  144. this.classList = []
  145. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  146. this.recurrentPage = 1 //页数
  147. this.getreList()
  148. // console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
  149. // }
  150. // if (this.current == 1) {
  151. this.classList2 = []
  152. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  153. this.teacurrentPage = 1
  154. this.getteaList()
  155. // }
  156. // console.log(1111);
  157. // 精品课程
  158. return
  159. }
  160. // console.log(888888);
  161. // if(val===''){
  162. // this.pu
  163. // }
  164. this.selectSearchdata()
  165. }
  166. },
  167. methods: {
  168. ani() {
  169. this.refevent = true
  170. },
  171. cutS(event) {
  172. // console.log(event.detail);
  173. this.refevent = false
  174. },
  175. selectSearchdata() {
  176. if (this.current === 2) return
  177. let data = {
  178. openid: uni.getStorageSync('oId'),
  179. txt: encodeURIComponent(this.searchText),
  180. ty: this.current,
  181. // page: this.Searchpage,
  182. // lim: 15
  183. }
  184. // return console.log(data);
  185. this.$request('/selectActSearch', "get", data).then(res => {
  186. // console.log('常规', res);
  187. if (this.current == 0) {
  188. this.classList = res[0]
  189. } else if (this.current == 1) {
  190. this.classList2 = res[0]
  191. }
  192. })
  193. },
  194. // 资源库下拉刷新
  195. repulling() {
  196. this.bansearchData = true
  197. this.trigger = true
  198. // this.isrepulling = true
  199. setTimeout(() => {
  200. this.trigger = false;
  201. }, 1000);
  202. // 资源库
  203. this.classList = []
  204. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  205. this.recurrentPage = 1 //页数
  206. if (this.searchText !== '') {
  207. this.classList2 = []
  208. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  209. this.teacurrentPage = 1
  210. this.searchText = ''
  211. this.getteaList()
  212. }
  213. this.getreList()
  214. },
  215. // 精品慕课下拉刷新
  216. purepulling() {
  217. this.bansearchData = true
  218. this.putrigger = true
  219. // this.isrepulling = true
  220. setTimeout(() => {
  221. this.putrigger = false;
  222. }, 1000);
  223. // 精品课程
  224. this.classList2 = []
  225. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  226. this.teacurrentPage = 1
  227. if (this.searchText !== '') {
  228. this.classList = []
  229. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  230. this.recurrentPage = 1 //页数
  231. this.searchText = ''
  232. this.getreList()
  233. }
  234. this.getteaList()
  235. },
  236. // 获取资源库
  237. getreList() {
  238. let data = {
  239. openid: uni.getStorageSync('oId'),
  240. ty: 0,
  241. page: this.recurrentPage,
  242. lim: 30
  243. }
  244. this.$request('/selectResource', "POST", data).then(res => {
  245. // console.log('获取资源库', res);
  246. if (!res[0].length) {
  247. this.reLoading = 2
  248. } else {
  249. this.reLoading = 0
  250. }
  251. this.classList = [...this.classList, ...res[0]]
  252. this.bansearchData = false
  253. // this.classList2 = res[1]
  254. })
  255. },
  256. // 获取精品慕课
  257. getteaList() {
  258. let data = {
  259. openid: uni.getStorageSync('oId'),
  260. ty: 1,
  261. page: this.teacurrentPage,
  262. lim: 30
  263. }
  264. this.$request('/selectResource', "POST", data).then(res => {
  265. // console.log('获取精品慕课', res);
  266. if (!res[0].length) {
  267. this.teaLoading = 2
  268. } else {
  269. this.teaLoading = 0
  270. }
  271. // console.log('前',this.classList2);
  272. this.classList2 = [...this.classList2, ...res[0]]
  273. this.bansearchData = false
  274. // console.log('后',this.classList2);
  275. // this.classList2 = res[1]
  276. })
  277. },
  278. // 资源库触底
  279. relower() {
  280. if (this.searchText !== '') return console.log('禁止触底');
  281. console.log('没触底?');
  282. if (this.reLoading == 2) return
  283. this.reLoading = 1
  284. this.recurrentPage++
  285. setTimeout(this.getreList, 1000)
  286. },
  287. // 精品慕课触底
  288. tealower() {
  289. if (this.searchText !== '') return console.log('禁止触底');
  290. console.log('没触底?');
  291. if (this.teaLoading == 2) return
  292. this.teaLoading = 1
  293. this.teacurrentPage++
  294. setTimeout(this.getteaList, 1000)
  295. },
  296. swipeIndex(index) {
  297. this.current = index.detail.current;
  298. if (this.searchText !== '') {
  299. this.selectSearchdata()
  300. }
  301. },
  302. // 区域滑动
  303. phoneLogin() {
  304. this.current = 0;
  305. },
  306. accountLogin() {
  307. this.current = 1;
  308. },
  309. costClass() {
  310. this.current = 2;
  311. }
  312. },
  313. onLoad() {
  314. this.getreList()
  315. this.getteaList()
  316. },
  317. onShow() {
  318. this.getAllMessage() // 调用app.js中的方法
  319. // 获取收藏
  320. this.$refs.reso.getdata()
  321. this.$refs.tech.getdata()
  322. }
  323. };
  324. </script>
  325. <style lang="scss" scoped>
  326. .btntop {
  327. width: 100%;
  328. }
  329. .searchPagedata {
  330. width: 750rpx;
  331. height: 40%;
  332. display: flex;
  333. justify-content: center;
  334. align-items: center;
  335. }
  336. .resource {
  337. display: flex;
  338. flex-direction: column;
  339. height: 100vh;
  340. .search {
  341. background-color: #ffffff;
  342. position: relative;
  343. display: flex;
  344. width: 750rpx;
  345. height: 88rpx;
  346. justify-content: center;
  347. align-items: center;
  348. }
  349. .top {
  350. width: 100%;
  351. display: flex;
  352. justify-content: space-around;
  353. margin: auto;
  354. background-color: #ffffff;
  355. padding: 10px 60rpx;
  356. height: 98rpx;
  357. .info1 {
  358. font-weight: bold !important;
  359. position: relative;
  360. color: rgba(0, 0, 0, 0.8);
  361. font-size: 34rpx;
  362. line-height: 48rpx;
  363. width: 136rpx;
  364. height: 48rpx;
  365. text-align: center;
  366. .yun {
  367. width: 134rpx;
  368. height: 32rpx;
  369. position: absolute;
  370. left: 0;
  371. bottom: -10rpx;
  372. image {
  373. width: 100%;
  374. height: 100%;
  375. }
  376. }
  377. }
  378. .info2 {
  379. color: rgba(0, 0, 0, 0.6);
  380. font-size: 34rpx;
  381. font-weight: 400;
  382. line-height: 48rpx;
  383. width: 136rpx;
  384. height: 48rpx;
  385. text-align: center;
  386. // font-family: 微软雅黑;
  387. }
  388. }
  389. .scroll-view-height {
  390. flex: 1;
  391. width: 100%;
  392. display: flex;
  393. flex-wrap: wrap;
  394. justify-content: space-between;
  395. }
  396. }
  397. </style>