catalogueN.nvue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. console.log('qxj catalogueN reqDataCode:' + this.reqDataCode);
  126. let that = this;
  127. this.subNVue = uni.getSubNVueById('catalogueN');
  128. uni.$on('catalogue', (data) => {
  129. console.log('qxj catalogue ondata:' + JSON.stringify(data));
  130. that.courseId = data.courseId;
  131. that.videoId = data.videoId;
  132. that.pickCatalogIdx = data.pickCatalogIdx;
  133. if (that.reqDataCode == 1) {
  134. return;
  135. }
  136. that.getCourseInfo();
  137. that.upCallback();
  138. });
  139. uni.$on('pickCatalogIdx', (data) => {
  140. that.pickCatalogIdx = data.pickCatalogIdx;
  141. if (data.type == 'catalogueN') {
  142. that.closePopup();
  143. }
  144. });
  145. const res = uni.getSystemInfoSync();
  146. // this.listHei=res.windowHeight*1.05;
  147. this.listHei = res.windowHeight * 0.85 - uni.upx2px(200);
  148. if (!this.$isLogin()) {
  149. let useInfo = uni.getStorageSync('userInfo');
  150. if (!!useInfo && useInfo != null) {
  151. this.myUserInfo = JSON.parse(useInfo);
  152. }
  153. }
  154. } catch (e) {}
  155. },
  156. onUnload() {
  157. // 注销全局配置监听
  158. uni.$off('catalogue');
  159. uni.$off('pickCatalogIdx');
  160. },
  161. methods: {
  162. getCourseInfo() {
  163. getCourseById(this.courseId).then(
  164. (res) => {
  165. if (res.code == 200) {
  166. this.courseData = res.data;
  167. }
  168. },
  169. (rej) => {}
  170. );
  171. },
  172. onpullingdown(e) {
  173. if (this.refreshing) return;
  174. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  175. this.refreshText = '下拉更新';
  176. } else {
  177. this.refreshText = '释放更新';
  178. }
  179. },
  180. onrefresh(e) {
  181. console.log('onRefreshing...');
  182. this.refreshing = true;
  183. this.pageNum = 1;
  184. this.upCallback();
  185. if (this.refreshing) return;
  186. },
  187. loadmore() {
  188. if (this.isLastPage) {
  189. return;
  190. }
  191. console.log('loadmore');
  192. this.pageNum++;
  193. this.showLoadMore = true;
  194. setTimeout(() => {
  195. this.upCallback();
  196. }, 300);
  197. },
  198. pickCatalogAction(index) {
  199. const data = {
  200. index: index,
  201. type: 'catalogueN'
  202. };
  203. uni.$emit('pickCatalogAction', data);
  204. },
  205. /*下拉刷新的回调 */
  206. upCallback() {
  207. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  208. if (this.courseId == null) {
  209. this.courseId = 7;
  210. }
  211. const params = { courseId: this.courseId, keyword: this.searchText };
  212. uni.showLoading({ title: '' });
  213. getCourseVideoList(params, this.pageNum).then((res) => {
  214. uni.hideLoading();
  215. if (res.code == 200) {
  216. setTimeout(() => {
  217. if (this.pageNum == 1) this.dataList = []; //如果是第一页需手动制空列表
  218. this.dataList = this.dataList.concat(res.data.list); //追加新数据
  219. this.totalNum = res.data.total;
  220. this.reqDataCode = 1;
  221. this.refreshing = false;
  222. this.isLastPage = res.data.isLastPage;
  223. if (this.isLastPage) {
  224. this.refreshText = '加载完成';
  225. }
  226. if (res.data.isLastPage) {
  227. this.loadMoreText = '没有更多数据了!';
  228. this.showLoadMore = false;
  229. } else {
  230. this.loadMoreText = '加载中...';
  231. }
  232. }, 200);
  233. } else {
  234. this.refreshing = false;
  235. this.refreshText = '加载完成';
  236. this.reqDataCode = -1;
  237. }
  238. },
  239. (rej) => {}
  240. ).catch(() => {
  241. //联网失败, 结束加载
  242. this.refreshing = false;
  243. this.refreshText = '加载完成';
  244. this.reqDataCode = -1;
  245. });
  246. },
  247. closePopup() {
  248. const subNVue = uni.getSubNVueById('catalogueN');
  249. subNVue.hide('slide-out-bottom');
  250. },
  251. doSearch() {
  252. this.pageNum = 1;
  253. this.upCallback();
  254. },
  255. refreshPage() {
  256. this.pageNum = 1;
  257. this.upCallback();
  258. },
  259. onKeyInput: function (event) {
  260. this.refreshPage();
  261. },
  262. canShowVip(item) {
  263. return true;
  264. if (this.myUserInfo.isVip) {
  265. return false;
  266. }
  267. return item.isVip == 1 && item.isBuy == 0;
  268. }
  269. }
  270. };
  271. </script>
  272. <style scoped lang="scss">
  273. page {
  274. background-color: white;
  275. }
  276. .cateitem {
  277. /* es es-ac es-icon-auto es-view-w-x es-pt-15 es-pb-15 es-mb-16 */
  278. padding: 20rpx;
  279. margin-bottom: 20rpx;
  280. border-radius: 16rpx 16rpx 16rpx 16rpx;
  281. }
  282. .cate-bg1 {
  283. background-color: #FCF0E7;
  284. .cateitem-title {
  285. color: #FF5030 !important;
  286. }
  287. .cateitem-sub {
  288. color: #FF5030 !important;
  289. }
  290. }
  291. .cate-bg2 {
  292. background-color: #F5F7FA;
  293. .cateitem-sub {
  294. color: #757575
  295. }
  296. }
  297. .freeflag {
  298. min-width: 68rpx;
  299. // height: 32rpx;
  300. padding: 4rpx 12rpx;
  301. text-align: center;
  302. line-height: 32rpx;
  303. position: absolute;
  304. right: 0;
  305. top: 0;
  306. border-radius: 0 16rpx 0 16rpx;
  307. &-free {
  308. // background: url('@/static/image/hall/free_lable_bg.png') no-repeat right / 100% 32rpx;
  309. background-color: #FF5030;
  310. }
  311. &-member {
  312. // background: url('@/static/image/hall/member_label_bg.png') no-repeat right / 100% 32rpx;
  313. background-color: #FEC75C;
  314. }
  315. }
  316. .fl-row {
  317. display: flex;
  318. flex-direction: row;
  319. }
  320. .pBox {
  321. background-color: #171a1d;
  322. box-sizing: border-box;
  323. }
  324. .es-icon-course-icon-6 {
  325. background-image: url(../../static/images/other/course/icon-6.png);
  326. }
  327. .es-icon-course-close {
  328. background-image: url(../../static/images/other/course/close.png);
  329. }
  330. .es-icon-course-cate-bg1 {
  331. background-image: url(../../static/images/other/course/cate-bg1.png);
  332. }
  333. .es-icon-course-cate-bg2 {
  334. background-image: url(../../static/images/other/course/cate-bg2.png);
  335. }
  336. .es-icon-course-cate-bg3 {
  337. background-image: url(../../static/images/other/course/cate-bg3.png);
  338. }
  339. .es-icon-course-play-loading {
  340. background-image: url(../../static/images/other/course/play-loading.png);
  341. }
  342. .es-icon-course-cate-vip {
  343. background-image: url(../../static/images/other/course/vip.png);
  344. }
  345. .es-icon-search-search {
  346. background-image: url(../../static/images/other/search/search.png);
  347. }
  348. .bgImg {
  349. position: absolute;
  350. left: 0;
  351. right: 0;
  352. top: 0;
  353. bottom: 0;
  354. }
  355. .vip {
  356. position: absolute;
  357. right: 0;
  358. top: 0;
  359. }
  360. .video {
  361. height: 380rpx;
  362. position: relative;
  363. display: flex;
  364. }
  365. .video .cover {
  366. position: absolute;
  367. left: 0;
  368. top: 0;
  369. width: 100%;
  370. height: 100%;
  371. border-radius: 20rpx;
  372. }
  373. .video .playIcon {
  374. position: absolute;
  375. width: 44rpx;
  376. height: 44rpx;
  377. z-index: 10;
  378. right: 26rpx;
  379. bottom: 50rpx;
  380. }
  381. .video video {
  382. width: 100%;
  383. height: 100%;
  384. border-radius: 20rpx;
  385. }
  386. .video .video-1,
  387. .video .video-2,
  388. .video .video-3,
  389. .video .video-4 {
  390. position: absolute;
  391. width: 20rpx;
  392. height: 20rpx;
  393. z-index: 1;
  394. }
  395. .video .video-1 {
  396. left: 0;
  397. top: 0;
  398. }
  399. .video .video-2 {
  400. right: 0;
  401. top: 0;
  402. }
  403. .video .video-3 {
  404. left: 0;
  405. bottom: 0;
  406. }
  407. .video .video-4 {
  408. right: 0;
  409. bottom: 0;
  410. }
  411. .refresh {
  412. display: flex;
  413. flex-direction: row;
  414. justify-content: center;
  415. height: 50px;
  416. }
  417. .loading-more {
  418. align-items: center;
  419. justify-content: center;
  420. padding-top: 14px;
  421. padding-bottom: 14px;
  422. text-align: center;
  423. }
  424. .loading-more-text {
  425. font-size: 28rpx;
  426. color: #999;
  427. }
  428. </style>