mescrollUni-item.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <!--
  3. swiper中的transfrom会使fixed失效,此时用height固定高度;
  4. swiper中无法触发mescroll-mixins.js的onPageScroll和onReachBottom方法,只能用mescroll-uni,不能用mescroll-body
  5. -->
  6. <!-- ref动态生成: 字节跳动小程序编辑器不支持一个页面存在相同的ref (如不考虑字节跳动小程序可固定值为 ref="mescrollRef") -->
  7. <!-- top的高度等于悬浮菜单tabs的高度 -->
  8. <mescroll-uni :ref="'mescrollRef' + i" @init="mescrollInit" :height="height" :down="downOption" @down="downCallback"
  9. :up="upOption" @up="upCallback" @emptyclick="emptyClick">
  10. <view class="flex-col list" v-for="(item,index) in rankDate">
  11. <!-- <view class="flex-row justify-center" v-if="index === 0">-->
  12. <!-- <view class="flex-col justify-evenly medal">-->
  13. <!-- <text>第一名:对对对</text>-->
  14. <!-- <text>3000</text>-->
  15. <!-- </view>-->
  16. <!-- </view>-->
  17. <!-- <view class="flex-col justify-evenly medal medal2" v-if="index === 1">-->
  18. <!-- <text>第二名:滴滴滴</text>-->
  19. <!-- <text>2000</text>-->
  20. <!-- </view>-->
  21. <!-- <view class="flex-col justify-evenly medal medal3" v-if="index === 2">-->
  22. <!-- <text>第三名:龙傲天</text>-->
  23. <!-- <text>1000</text>-->
  24. <!-- </view>-->
  25. <view class="flex-row justify-between listItem" :class="{listItemFirst:index === 3}" >
  26. <text>{{index + 1}}.</text>
  27. <text>{{ item.expandUserName }}</text>
  28. <text>{{ item.total }}</text>
  29. </view>
  30. </view>
  31. </mescroll-uni>
  32. </template>
  33. <script>
  34. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  35. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js"
  36. import NextSwipeAction from "../../../components/next-swipe-action/next-swipe-action";
  37. import {object} from "../../../uni_modules/uv-ui-tools/libs/function/test";
  38. export default {
  39. mixins: [MescrollMixin, MescrollMoreItemMixin], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
  40. components: {
  41. NextSwipeAction
  42. },
  43. data() {
  44. return {
  45. downOption: {
  46. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  47. },
  48. upOption: {
  49. auto: false, // 不自动加载
  50. // page: {
  51. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  52. // size: 10 // 每页数据的数量
  53. // },
  54. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  55. empty: {
  56. icon: '/static/dataNull.png',
  57. tip: '暂无内容', // 提示
  58. // btnText: '去看看'
  59. },
  60. textNoMore: '没有更多了'
  61. },
  62. list: [],
  63. }
  64. },
  65. props: {
  66. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  67. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  68. type: Number,
  69. default() {
  70. return 0
  71. }
  72. },
  73. rankDate: [],
  74. height: [Number, String], // mescroll的高度
  75. },
  76. watch: {},
  77. created() {
  78. },
  79. methods: {
  80. openAddRemarkPopup(e) {
  81. console.log(e)
  82. this.$emit('openAddRemarkPopup', e)
  83. },
  84. navigateToPage(url) {
  85. uni.navigateTo({
  86. url: url
  87. })
  88. },
  89. /*下拉刷新的回调 */
  90. downCallback() {
  91. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  92. // loadSwiper();
  93. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  94. this.mescroll.resetUpScroll()
  95. },
  96. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  97. upCallback(page) {
  98. //联网加载数据
  99. let httpData = {
  100. pageNum: page.num,
  101. pageSize: 10
  102. }
  103. this.$api.service.getMyExpandAttacheList(httpData).then((res) => {
  104. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  105. this.mescroll.endSuccess(res.data.data.length, res.data.data.length === 10);
  106. //设置列表数据
  107. if (page.num === 1) this.list = []; //如果是第一页需手动制空列表
  108. this.list = this.list.concat(res.data.data); //追加新数据
  109. this.getImgUrlByOssId(this.list)
  110. console.log(this.list)
  111. }).catch((err) => {
  112. //联网失败, 结束加载
  113. this.mescroll.endErr();
  114. })
  115. },
  116. //点击空布局按钮的回调
  117. emptyClick() {
  118. uni.showToast({
  119. title: '点击了按钮,具体逻辑自行实现'
  120. })
  121. },
  122. // 搜索
  123. doSearch() {
  124. this.list = []; // 先清空列表,显示加载进度
  125. this.mescroll.resetUpScroll();
  126. },
  127. getImgUrlByOssId(list) {
  128. if (list) {
  129. list.forEach((item, index) => {
  130. if (item.img && !item.selfPhotoUrl) {
  131. this.$api.service.getImage(item.img).then(res => {
  132. item.selfPhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  133. this.$set(this.list, index, item)
  134. console.log('+++++++++++++++++', item)
  135. });
  136. }
  137. })
  138. }
  139. },
  140. },
  141. }
  142. </script>
  143. <style>
  144. @import '/common/css/common.css';
  145. @import './index.rpx.css';
  146. </style>