catalogueN.nvue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="es content es-bc-white" style="position: relative; flex-direction: column" @touchmove.stop>
  3. <view class="pBox es-bc-white es-br-20 flex" style="padding: 20rpx 0; box-sizing: border-box">
  4. <view class="es-view-w-x">
  5. <view class="es es-h-60">
  6. <view class="es es-ac es-h-44 es-mt-5">
  7. <image class="es-w-27 es-h-29" src="../../static/images/other/course/icon-6.png"></image>
  8. <text class="es-ml-20 es-fs-28 es-fw-600 es-f1">目录</text>
  9. <text class="es-ml-1 es-fs-30 es-c-99">({{ totalNum }})</text>
  10. </view>
  11. <image @tap="closePopup()" style="position: absolute; right: 10rpx; top: 0rpx" class="es-w-40 es-h-40" src="../../static/images/close40.png"></image>
  12. </view>
  13. <view class="es-f1 es-bc-f7 es-h-74 es-br es es-ac flex" style="box-sizing: border-box; margin-bottom: 24rpx">
  14. <image class="es-icon-26 es-ml-27" src="../../static/images/other/search/search.png"></image>
  15. <view class="es-f1 es-ipt es-ml-10 es-bc-f7 es-br-10 flex">
  16. <input v-model="searchText" placeholder="请输入关键字搜索" @input="onKeyInput" class="es-h-76 es-fs-28" placeholder-class="es-c-b4" />
  17. </view>
  18. <view @tap="doSearch()" class="es-w-108 es-h-54 es-br es-bc es-mr-10 es es-ac es-pc es-fw-500 es-fs-26">
  19. <text class="es-c-white es-fs-26">搜索</text>
  20. </view>
  21. </view>
  22. <!-- 下面是目录列表 -->
  23. <list loadmoreoffset="100" @loadmore="loadmore" :style="{ height: listHei + 'px' }">
  24. <refresh @pullingdown="onpullingdown" @refresh="onrefresh" :display="refreshing ? 'show' : 'hide'" class="refresh x-c">
  25. <loading-indicator style="width: 22px; height: 22px; color: #999"></loading-indicator>
  26. <text class="es-fs-32 es-ml-8">{{ refreshText }}</text>
  27. </refresh>
  28. <cell v-for="(item, index) in dataList" :key="index">
  29. <view @click="pickCatalogAction(Number(item.courseSort) - 1)"
  30. :class="Number(item.courseSort) - 1 == pickCatalogIdx ?'cateitem cate-bg1': 'cateitem cate-bg2'">
  31. <!-- <image class="bgImg" :src="Number(item.courseSort) - 1 == pickCatalogIdx ? '../../static/images/other/course/cate-bg1.png'
  32. : '../../static/images/other/course/cate-bg2.png'"></image> -->
  33. <view class="es-f1 flex">
  34. <view class="es es-ac flex">
  35. <text class="es-fs-30 es-fw-600 cateitem-title">第{{ item.courseSort }}讲</text>
  36. <image src="../../static/images/other/course/play-loading.png" class="es-w-60 es-h-31 es-ml-10"
  37. v-if="Number(item.courseSort) - 1 == pickCatalogIdx"></image>
  38. </view>
  39. <text class="es-fs-26 es-mt-4 cateitem-sub">{{ item.title }}</text>
  40. </view>
  41. <view
  42. :class="item.courseSort>2 && canShowVip(item) ? 'freeflag freeflag-member':'freeflag freeflag-free'">
  43. <text class="es-fs-22 es-fw-500" style="color: #fff;">
  44. {{ item.courseSort>2 && canShowVip(item) ? '限时特惠' : '免费'}}
  45. </text>
  46. </view>
  47. <!-- <view class="vip es-icon-auto es-w-87 es-h-42 es es-ac es-fs-22 es es-ac es-pc" v-if="Number(item.courseSort) - 1 != pickCatalogIdx">
  48. <image class="bgImg" src="../../static/images/other/course/cate-bg3.png"></image>
  49. <image v-if="item.courseSort > 2 && canShowVip(item)" class="es-icon-22" src="../../static/images/other/course/vip.png"></image>
  50. <text class="es-ml-4 es-fs-22">{{ item.courseSort > 2 && canShowVip(item) ? '限时特惠' : '免费' }}</text>
  51. </view> -->
  52. </view>
  53. </cell>
  54. <cell v-if="showLoadMore || dataList.length > 4">
  55. <view class="loading-more">
  56. <text class="loading-more-text">{{ loadMoreText }}</text>
  57. </view>
  58. </cell>
  59. <cell>
  60. <view v-if="totalNum == 0 && reqDataCode != 0" class="y-f" style="height: 300px; padding-top: 200rpx">
  61. <image @tap="refreshPage()" class="es-w-124 es-h-80" style="width: 187rpx; height: 120rpx" src="../../static/image/nodata.png"></image>
  62. <text @tap="refreshPage()" class="es-c-33">{{ reqDataCode == 1 ? '暂无数据' : '请求超时' }}</text>
  63. </view>
  64. </cell>
  65. </list>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import { getCourseById, getCourseVideoList, addDuration } from '@/api/course';
  72. import { isEmpty } from '@/utils/common';
  73. export default {
  74. data() {
  75. return {
  76. dataList: [],
  77. pickCatalog: { videoUrl: '', thumbnail: '', duration: 0, videoId: 0, seconds: 0 },
  78. pickCatalogIdx: 0,
  79. searchText: '',
  80. videoContext: null,
  81. video: {
  82. percent: 10 //进度百分比
  83. },
  84. courseId: null,
  85. data: {
  86. courseId: null,
  87. imgUrl: '',
  88. talentAvatar: '',
  89. price: '',
  90. remark: '',
  91. noteNum: 0,
  92. courseName: '',
  93. description: '',
  94. cataIndex: 0,
  95. isFast: false,
  96. isAutoPlay: false
  97. },
  98. danmuList: [],
  99. tempStudyTimes: 0,
  100. studyTimes: 0,
  101. audioContext: null,
  102. audioPlayIng: false,
  103. showFullScreenBtn: true,
  104. isLearning: false,
  105. myVideo: null,
  106. showProgress: true,
  107. videoUrl: 'https://1319721001.vod-qcloud.com/3525603bvodcq1319721001/2b3e76ac1253642698811158287/Hmod7JMfAowA.mp4',
  108. poster: '',
  109. videoId: null,
  110. isAutoPlay: false,
  111. loadMoreText: '加载中...',
  112. showLoadMore: false,
  113. isLastPage: false,
  114. refreshing: false,
  115. refreshText: '下拉刷新',
  116. pageNum: 1,
  117. listHei: 0,
  118. totalNum: 0,
  119. reqDataCode: 0, //1:正常加载 -1 请求超时
  120. myUserInfo: {}
  121. };
  122. },
  123. mounted() {
  124. try {
  125. let that = this;
  126. this.subNVue = uni.getSubNVueById('catalogueN');
  127. uni.$on('catalogue', (data) => {
  128. console.log('qxj catalogue ondata:' + JSON.stringify(data));
  129. that.courseId = data.courseId;
  130. that.videoId = data.videoId;
  131. that.pickCatalogIdx = data.pickCatalogIdx;
  132. if (that.reqDataCode == 1) {
  133. return;
  134. }
  135. that.getCourseInfo();
  136. that.upCallback();
  137. });
  138. uni.$on('pickCatalogIdx', (data) => {
  139. that.pickCatalogIdx = data.pickCatalogIdx;
  140. if (data.type == 'catalogueN') {
  141. that.closePopup();
  142. }
  143. });
  144. const res = uni.getSystemInfoSync();
  145. // this.listHei=res.windowHeight*1.05;
  146. this.listHei = res.windowHeight * 0.85 - uni.upx2px(200);
  147. if (!this.$isLogin()) {
  148. let useInfo = uni.getStorageSync('userInfo');
  149. if (!!useInfo && useInfo != null) {
  150. this.myUserInfo = JSON.parse(useInfo);
  151. }
  152. }
  153. } catch (e) {}
  154. },
  155. onUnload() {
  156. // 注销全局配置监听
  157. uni.$off('catalogue');
  158. uni.$off('pickCatalogIdx');
  159. },
  160. methods: {
  161. getCourseInfo() {
  162. getCourseById(this.courseId).then(
  163. (res) => {
  164. if (res.code == 200) {
  165. this.courseData = res.data;
  166. }
  167. },
  168. (rej) => {}
  169. );
  170. },
  171. onpullingdown(e) {
  172. if (this.refreshing) return;
  173. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  174. this.refreshText = '下拉更新';
  175. } else {
  176. this.refreshText = '释放更新';
  177. }
  178. },
  179. onrefresh(e) {
  180. console.log('onRefreshing...');
  181. this.refreshing = true;
  182. this.pageNum = 1;
  183. this.upCallback();
  184. if (this.refreshing) return;
  185. },
  186. loadmore() {
  187. if (this.isLastPage) {
  188. return;
  189. }
  190. console.log('loadmore');
  191. this.pageNum++;
  192. this.showLoadMore = true;
  193. setTimeout(() => {
  194. this.upCallback();
  195. }, 300);
  196. },
  197. pickCatalogAction(index) {
  198. const data = {
  199. index: index,
  200. type: 'catalogueN'
  201. };
  202. uni.$emit('pickCatalogAction', data);
  203. },
  204. /*下拉刷新的回调 */
  205. upCallback() {
  206. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  207. if (this.courseId == null) {
  208. this.courseId = 7;
  209. }
  210. const params = { courseId: this.courseId, keyword: this.searchText };
  211. uni.showLoading({ title: '' });
  212. getCourseVideoList(params, this.pageNum).then((res) => {
  213. uni.hideLoading();
  214. if (res.code == 200) {
  215. setTimeout(() => {
  216. if (this.pageNum == 1) this.dataList = []; //如果是第一页需手动制空列表
  217. this.dataList = this.dataList.concat(res.data.list); //追加新数据
  218. this.totalNum = res.data.total;
  219. this.reqDataCode = 1;
  220. this.refreshing = false;
  221. this.isLastPage = res.data.isLastPage;
  222. if (this.isLastPage) {
  223. this.refreshText = '加载完成';
  224. }
  225. if (res.data.isLastPage) {
  226. this.loadMoreText = '没有更多数据了!';
  227. this.showLoadMore = false;
  228. } else {
  229. this.loadMoreText = '加载中...';
  230. }
  231. }, 200);
  232. } else {
  233. this.refreshing = false;
  234. this.refreshText = '加载完成';
  235. this.reqDataCode = -1;
  236. }
  237. },
  238. (rej) => {}
  239. ).catch(() => {
  240. //联网失败, 结束加载
  241. this.refreshing = false;
  242. this.refreshText = '加载完成';
  243. this.reqDataCode = -1;
  244. });
  245. },
  246. closePopup() {
  247. const subNVue = uni.getSubNVueById('catalogueN');
  248. subNVue.hide('slide-out-bottom');
  249. },
  250. doSearch() {
  251. this.pageNum = 1;
  252. this.upCallback();
  253. },
  254. refreshPage() {
  255. this.pageNum = 1;
  256. this.upCallback();
  257. },
  258. onKeyInput: function (event) {
  259. this.refreshPage();
  260. },
  261. canShowVip(item) {
  262. return true;
  263. if (this.myUserInfo.isVip) {
  264. return false;
  265. }
  266. return item.isVip == 1 && item.isBuy == 0;
  267. }
  268. }
  269. };
  270. </script>
  271. <style scoped lang="scss">
  272. page {
  273. background-color: white;
  274. }
  275. .cateitem {
  276. /* es es-ac es-icon-auto es-view-w-x es-pt-15 es-pb-15 es-mb-16 */
  277. padding: 20rpx;
  278. margin-bottom: 20rpx;
  279. border-radius: 16rpx 16rpx 16rpx 16rpx;
  280. }
  281. .cate-bg1 {
  282. background-color: #eef5fd;
  283. .cateitem-title {
  284. color: #2583EB !important;
  285. }
  286. .cateitem-sub {
  287. color: #2583EB !important;
  288. }
  289. }
  290. .cate-bg2 {
  291. background-color: #F5F7FA;
  292. .cateitem-sub {
  293. color: #757575
  294. }
  295. }
  296. .freeflag {
  297. min-width: 68rpx;
  298. // height: 32rpx;
  299. padding: 4rpx 12rpx;
  300. text-align: center;
  301. line-height: 32rpx;
  302. position: absolute;
  303. right: 0;
  304. top: 0;
  305. border-radius: 0 16rpx 0 16rpx;
  306. &-free {
  307. // background: url('@/static/image/hall/free_lable_bg.png') no-repeat right / 100% 32rpx;
  308. background-color: #2583EB;
  309. }
  310. &-member {
  311. // background: url('@/static/image/hall/member_label_bg.png') no-repeat right / 100% 32rpx;
  312. background-color: #FFB205;
  313. }
  314. }
  315. .fl-row {
  316. display: flex;
  317. flex-direction: row;
  318. }
  319. .pBox {
  320. background-color: #171a1d;
  321. box-sizing: border-box;
  322. }
  323. .es-icon-course-icon-6 {
  324. background-image: url(../../static/images/other/course/icon-6.png);
  325. }
  326. .es-icon-course-close {
  327. background-image: url(../../static/images/other/course/close.png);
  328. }
  329. .es-icon-course-cate-bg1 {
  330. background-image: url(../../static/images/other/course/cate-bg1.png);
  331. }
  332. .es-icon-course-cate-bg2 {
  333. background-image: url(../../static/images/other/course/cate-bg2.png);
  334. }
  335. .es-icon-course-cate-bg3 {
  336. background-image: url(../../static/images/other/course/cate-bg3.png);
  337. }
  338. .es-icon-course-play-loading {
  339. background-image: url(../../static/images/other/course/play-loading.png);
  340. }
  341. .es-icon-course-cate-vip {
  342. background-image: url(../../static/images/other/course/vip.png);
  343. }
  344. .es-icon-search-search {
  345. background-image: url(../../static/images/other/search/search.png);
  346. }
  347. .bgImg {
  348. position: absolute;
  349. left: 0;
  350. right: 0;
  351. top: 0;
  352. bottom: 0;
  353. }
  354. .vip {
  355. position: absolute;
  356. right: 0;
  357. top: 0;
  358. }
  359. .video {
  360. height: 380rpx;
  361. position: relative;
  362. display: flex;
  363. }
  364. .video .cover {
  365. position: absolute;
  366. left: 0;
  367. top: 0;
  368. width: 100%;
  369. height: 100%;
  370. border-radius: 20rpx;
  371. }
  372. .video .playIcon {
  373. position: absolute;
  374. width: 44rpx;
  375. height: 44rpx;
  376. z-index: 10;
  377. right: 26rpx;
  378. bottom: 50rpx;
  379. }
  380. .video video {
  381. width: 100%;
  382. height: 100%;
  383. border-radius: 20rpx;
  384. }
  385. .video .video-1,
  386. .video .video-2,
  387. .video .video-3,
  388. .video .video-4 {
  389. position: absolute;
  390. width: 20rpx;
  391. height: 20rpx;
  392. z-index: 1;
  393. }
  394. .video .video-1 {
  395. left: 0;
  396. top: 0;
  397. }
  398. .video .video-2 {
  399. right: 0;
  400. top: 0;
  401. }
  402. .video .video-3 {
  403. left: 0;
  404. bottom: 0;
  405. }
  406. .video .video-4 {
  407. right: 0;
  408. bottom: 0;
  409. }
  410. .refresh {
  411. display: flex;
  412. flex-direction: row;
  413. justify-content: center;
  414. height: 50px;
  415. }
  416. .loading-more {
  417. align-items: center;
  418. justify-content: center;
  419. padding-top: 14px;
  420. padding-bottom: 14px;
  421. text-align: center;
  422. }
  423. .loading-more-text {
  424. font-size: 28rpx;
  425. color: #999;
  426. }
  427. </style>