myFavoriteVideo.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <es-nav-title title="视频收藏" mode="fav"></es-nav-title>
  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(index)">
  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: 20 // 每页数据的数量
  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. onLoad(options) {
  61. this.tabIndex = Number(options.tabIndex || 0)
  62. uni.$on("refreshPage",res=>{
  63. this.refreshPage();
  64. })
  65. },
  66. onUnload() {
  67. uni.$off("refreshPage")
  68. },
  69. mounted(option) {
  70. const system = uni.getSystemInfoSync();
  71. let navigationBarHeight=44,tabHei=110,searchBarHei=44;
  72. let tempHei=navigationBarHeight+system.statusBarHeight;
  73. tempHei=tempHei+uni.upx2px(tabHei);
  74. this.mescrollTopY=tempHei+"px";
  75. },
  76. methods: {
  77. handleDetail(index) {
  78. const tabIndexType = this.tabIndex+1
  79. let curPageNum = Math.floor(index / 10) + 1
  80. uni.navigateTo({
  81. url: "/pages/user/myliving-app?tabIndexType="+tabIndexType+"&k="+index+'&curPageNum='+curPageNum
  82. })
  83. },
  84. /*下拉刷新的回调 */
  85. downCallback() {
  86. this.refreshPage();
  87. },
  88. /*上拉加载的回调*/
  89. upCallback(page) {
  90. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  91. let params={"type":this.tabIndex+1};
  92. getFavoriteVideoList(params,page.num,page.size).then(res => {
  93. if(res.code==200){
  94. setTimeout(()=>{
  95. this.mescroll.endByPage(res.data.list.length, res.data.pages);
  96. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  97. this.dataList=this.dataList.concat(res.data.list); //追加新数据
  98. this.totalNum=res.data.total;
  99. },300);
  100. }else{
  101. this.dataList= []; //追加新数据
  102. this.totalNum= 0
  103. this.mescroll.endByPage(0, 1);
  104. }
  105. },
  106. rej => {}
  107. ).catch(()=>{
  108. this.dataList= []; //追加新数据
  109. this.totalNum= 0
  110. //联网失败, 结束加载
  111. this.mescroll.endErr();
  112. });
  113. },
  114. refreshPage(){
  115. this.mescroll.hideTopBtn();
  116. this.mescroll.resetUpScroll(true);
  117. },
  118. tabChange(index){
  119. console.log("qxj tabChange");
  120. this.tabIndex=index;
  121. this.refreshPage();
  122. },
  123. //点击空布局按钮的回调
  124. emptyClick() {
  125. this.refreshPage();
  126. },
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. page{
  132. // height: 100%;
  133. background-color: #f7f7f7;
  134. }
  135. .top-fixed{
  136. width: 100%;
  137. position: absolute;
  138. top: 0;
  139. left: 0;
  140. z-index: 10;
  141. height: 88upx;
  142. background-color: #fff;
  143. }
  144. .sticky-tabs{
  145. z-index: 11;
  146. width: 100%;
  147. left: 0;
  148. position: fixed;
  149. top: 88rpx;
  150. background-color: #fff;
  151. height: 88rpx;
  152. align-items: center;
  153. }
  154. .item{
  155. border-radius: 18rpx;
  156. width: calc(33% - 20rpx);
  157. height:290rpx ;
  158. position: relative;
  159. margin-right: 20rpx;
  160. margin-bottom: 20rpx;
  161. .cover{
  162. width: 100%;
  163. height: 100%;
  164. border-radius: 10rpx;
  165. }
  166. .botbox{
  167. position: absolute;
  168. bottom: 0;
  169. left: 0;
  170. width: 100%;
  171. height: 38rpx;
  172. background: rgba(0,0,0, 0.3);
  173. border-radius: 10rpx;
  174. }
  175. }
  176. </style>