resource.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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" v-show="!searchText">
  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" v-show="!searchText">
  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. if (val === '') {
  140. this.classList = []
  141. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  142. this.recurrentPage = 1 //页数
  143. this.getreList()
  144. this.classList2 = []
  145. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  146. this.teacurrentPage = 1
  147. this.getteaList()
  148. return
  149. }
  150. this.selectSearchdata()
  151. }
  152. },
  153. methods: {
  154. selectSearchdata() {
  155. if (this.current === 2) return
  156. let data = {
  157. openid: uni.getStorageSync('oId'),
  158. txt: encodeURIComponent(this.searchText),
  159. ty: this.current,
  160. }
  161. this.$request('/selectActSearch', "get", data).then(res => {
  162. if (this.current == 0) {
  163. this.classList = res[0]
  164. } else if (this.current == 1) {
  165. this.classList2 = res[0]
  166. }
  167. })
  168. },
  169. // 资源库下拉刷新
  170. repulling() {
  171. this.bansearchData = true
  172. this.trigger = true
  173. // this.isrepulling = true
  174. // setTimeout(() => {
  175. // this.trigger = false;
  176. // }, 1000);
  177. // 资源库
  178. // this.classList = []
  179. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  180. this.recurrentPage = 1 //页数
  181. if (this.searchText !== '') {
  182. this.classList2 = []
  183. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  184. this.teacurrentPage = 1
  185. this.searchText = ''
  186. this.getteaList()
  187. }
  188. this.getreList()
  189. },
  190. // 精品慕课下拉刷新
  191. purepulling() {
  192. this.bansearchData = true
  193. this.putrigger = true
  194. // this.isrepulling = true
  195. // setTimeout(() => {
  196. // this.putrigger = false;
  197. // }, 1000);
  198. // 精品课程
  199. // this.classList2 = []
  200. this.teaLoading = 0 //0默认值 1加载中 2没有更多了
  201. this.teacurrentPage = 1
  202. if (this.searchText !== '') {
  203. this.classList = []
  204. this.reLoading = 0 //0默认值 1加载中 2没有更多了
  205. this.recurrentPage = 1 //页数
  206. this.searchText = ''
  207. this.getreList()
  208. }
  209. this.getteaList()
  210. },
  211. // 获取资源库
  212. getreList() {
  213. let data = {
  214. openid: uni.getStorageSync('oId'),
  215. ty: 0,
  216. page: this.recurrentPage,
  217. lim: 30
  218. }
  219. this.$request('/selectResource', "POST", data).then(res => {
  220. // console.log('获取资源库', res);
  221. if (!res[0].length) {
  222. this.reLoading = 2
  223. } else {
  224. this.reLoading = 0
  225. }
  226. if(this.recurrentPage==1){
  227. this.classList=[]
  228. }
  229. this.classList = [...this.classList, ...res[0]]
  230. this.bansearchData = false
  231. setTimeout(() => {
  232. this.trigger = false;
  233. }, 1000);
  234. })
  235. },
  236. // 获取精品慕课
  237. getteaList() {
  238. let data = {
  239. openid: uni.getStorageSync('oId'),
  240. ty: 1,
  241. page: this.teacurrentPage,
  242. lim: 30
  243. }
  244. this.$request('/selectResource', "POST", data).then(res => {
  245. // console.log('获取精品慕课', res);
  246. if (!res[0].length) {
  247. this.teaLoading = 2
  248. } else {
  249. this.teaLoading = 0
  250. }
  251. if(this.teacurrentPage==1){
  252. this.classList2=[]
  253. }
  254. this.classList2 = [...this.classList2, ...res[0]]
  255. this.bansearchData = false
  256. setTimeout(() => {
  257. this.putrigger = false;
  258. }, 1000);
  259. })
  260. },
  261. // 资源库触底
  262. relower() {
  263. if (this.searchText !== '') return console.log('禁止触底');
  264. console.log('没触底?');
  265. if (this.reLoading == 2) return
  266. this.reLoading = 1
  267. this.recurrentPage++
  268. setTimeout(this.getreList, 1000)
  269. },
  270. // 精品慕课触底
  271. tealower() {
  272. if (this.searchText !== '') return console.log('禁止触底');
  273. console.log('没触底?');
  274. if (this.teaLoading == 2) return
  275. this.teaLoading = 1
  276. this.teacurrentPage++
  277. setTimeout(this.getteaList, 1000)
  278. },
  279. swipeIndex(index) {
  280. this.current = index.detail.current;
  281. if (this.searchText !== '') {
  282. this.selectSearchdata()
  283. }
  284. },
  285. // 区域滑动
  286. phoneLogin() {
  287. this.current = 0;
  288. },
  289. accountLogin() {
  290. this.current = 1;
  291. },
  292. costClass() {
  293. this.current = 2;
  294. }
  295. },
  296. onLoad() {
  297. },
  298. onShow() {
  299. this.recurrentPage=1
  300. this.teacurrentPage=1
  301. if (this.searchText !== '') {
  302. this.selectSearchdata()
  303. }else{
  304. this.getreList()
  305. this.getteaList()
  306. }
  307. this.getAllMessage() // 调用app.js中的方法
  308. // 获取收藏
  309. this.$refs.reso.getdata()
  310. this.$refs.tech.getdata()
  311. }
  312. };
  313. </script>
  314. <style lang="scss" scoped>
  315. .btntop {
  316. width: 100%;
  317. }
  318. .searchPagedata {
  319. width: 750rpx;
  320. height: 40%;
  321. display: flex;
  322. justify-content: center;
  323. align-items: center;
  324. }
  325. .resource {
  326. display: flex;
  327. flex-direction: column;
  328. height: 100vh;
  329. .search {
  330. background-color: #ffffff;
  331. position: relative;
  332. display: flex;
  333. width: 750rpx;
  334. height: 88rpx;
  335. justify-content: center;
  336. align-items: center;
  337. }
  338. .top {
  339. width: 100%;
  340. display: flex;
  341. justify-content: space-around;
  342. margin: auto;
  343. background-color: #ffffff;
  344. padding: 10px 60rpx;
  345. height: 98rpx;
  346. .info1 {
  347. font-weight: bold !important;
  348. position: relative;
  349. color: rgba(0, 0, 0, 0.8);
  350. font-size: 34rpx;
  351. line-height: 48rpx;
  352. width: 136rpx;
  353. height: 48rpx;
  354. text-align: center;
  355. .yun {
  356. width: 134rpx;
  357. height: 32rpx;
  358. position: absolute;
  359. left: 0;
  360. bottom: -10rpx;
  361. image {
  362. width: 100%;
  363. height: 100%;
  364. }
  365. }
  366. }
  367. .info2 {
  368. color: rgba(0, 0, 0, 0.6);
  369. font-size: 34rpx;
  370. font-weight: 400;
  371. line-height: 48rpx;
  372. width: 136rpx;
  373. height: 48rpx;
  374. text-align: center;
  375. // font-family: 微软雅黑;
  376. }
  377. }
  378. .scroll-view-height {
  379. flex: 1;
  380. width: 100%;
  381. display: flex;
  382. flex-wrap: wrap;
  383. justify-content: space-between;
  384. }
  385. }
  386. </style>