myFavoriteVideo.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="content">
  3. <es-nav-title title="视频收藏" mode="fav"></es-nav-title>
  4. <view class="sticky-tabs" :style="{top:88+'px'}" >
  5. <me-tabs :value="tabIndex" :tabs="mtabs" :height="88" @change="tabChange"></me-tabs>
  6. </view>
  7. <mescroll-uni ref="mescrollRef" style="background-color: #FAFAFA;" @init="mescrollInit" :top="mescrollTopY" bottom="0" :down="downOption" @down="downCallback" :up="upOption"
  8. @up="upCallback" @emptyclick="emptyClick">
  9. <view class="es-bc-fa es-p-r" >
  10. <view class="es es-mt-10" style="flex-wrap: wrap;margin-right: -20rpx;padding: 0 24rpx;">
  11. <view class="es-br-18 item" v-for="(item, index) in dataList" :key="index" @click="handleDetail()">
  12. <image class="cover" :src="item.cover" mode="aspectFill"></image>
  13. <view class="botbox es x-c">
  14. <image class="es-w-20 es-h-20 es-mr-6" src="../../static/images/other/course/like.png"></image>
  15. <text class="es es-c-white es-fs-24 es-fw-500">{{item.likeNum}}</text>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </mescroll-uni>
  21. </view>
  22. </template>
  23. <script>
  24. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  25. import { getFavoriteVideoList } from '@/api/shortvideo'
  26. export default {
  27. mixins: [MescrollMixin], // 使用mixin
  28. components: {
  29. },
  30. data() {
  31. return {
  32. tabTop:0,
  33. mtabs:["我的喜欢","我的收藏","我的评论"],
  34. downOption: { //下拉刷新
  35. use:true,
  36. auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
  37. },
  38. upOption: {
  39. auto: false, // 不自动加载
  40. page: {
  41. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  42. size: 10 // 每页数据的数量
  43. },
  44. textNoMore:"已经到底了",
  45. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  46. toTop:{
  47. width:0,
  48. },
  49. empty:{
  50. tip: '~ 暂无数据 ~', // 提示
  51. btnText: '刷新重试',
  52. icon:"/static/images/icon_img_empty.png"
  53. },
  54. },
  55. dataList:[],
  56. tabIndex:0,
  57. mescrollTopY:0,
  58. }
  59. },
  60. mounted() {
  61. const system = uni.getSystemInfoSync();
  62. let navigationBarHeight=44,tabHei=110,searchBarHei=44;
  63. let tempHei=navigationBarHeight+system.statusBarHeight;
  64. tempHei=tempHei+uni.upx2px(tabHei);
  65. this.mescrollTopY=tempHei+"px";
  66. },
  67. methods: {
  68. handleDetail() {
  69. const tabIndexType = this.tabIndex+1
  70. uni.navigateTo({
  71. url: "/pages/user/myliving-app?tabIndexType="+tabIndexType
  72. })
  73. },
  74. /*下拉刷新的回调 */
  75. downCallback() {
  76. this.refreshPage();
  77. },
  78. /*上拉加载的回调*/
  79. upCallback(page) {
  80. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  81. let params={"type":this.tabIndex+1};
  82. getFavoriteVideoList(params,page.num).then(res => {
  83. if(res.code==200){
  84. setTimeout(()=>{
  85. this.mescroll.endByPage(res.data.list.length, res.data.pages);
  86. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  87. this.dataList=this.dataList.concat(res.data.list); //追加新数据
  88. this.totalNum=res.data.total;
  89. },300);
  90. }else{
  91. this.mescroll.endByPage(0, 1);
  92. }
  93. },
  94. rej => {}
  95. ).catch(()=>{
  96. //联网失败, 结束加载
  97. this.mescroll.endErr();
  98. });
  99. },
  100. refreshPage(){
  101. this.mescroll.hideTopBtn();
  102. this.mescroll.resetUpScroll(true);
  103. },
  104. tabChange(index){
  105. console.log("qxj tabChange");
  106. this.tabIndex=index;
  107. this.refreshPage();
  108. },
  109. //点击空布局按钮的回调
  110. emptyClick() {
  111. this.refreshPage();
  112. },
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. page{
  118. height: 100%;
  119. background-color: #f7f7f7;
  120. }
  121. .sticky-tabs{
  122. z-index: 11;
  123. position: sticky;
  124. top: 140rpx;
  125. background-color: #fff;
  126. height: 80rpx;
  127. align-items: center;
  128. }
  129. .item{
  130. border-radius: 18rpx;
  131. width: calc(33% - 20rpx);
  132. height:290rpx ;
  133. position: relative;
  134. margin-right: 20rpx;
  135. margin-bottom: 20rpx;
  136. .cover{
  137. width: 100%;
  138. height: 100%;
  139. border-radius: 10rpx;
  140. }
  141. .botbox{
  142. position: absolute;
  143. bottom: 0;
  144. left: 0;
  145. width: 100%;
  146. height: 38rpx;
  147. background: rgba(0,0,0, 0.3);
  148. border-radius: 10rpx;
  149. }
  150. }
  151. </style>