catalogueN.nvue 11 KB

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