综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view>
  3. <mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  4. <swiper style="min-height: 300rpx" autoplay="true" interval="3000" duration="300" circular="true">
  5. <swiper-item>
  6. <image style="width: 100%;height: auto;" src="https://www.mescroll.com/img/swiper1.jpg" mode="widthFix"/>
  7. </swiper-item>
  8. <swiper-item>
  9. <image style="width: 100%;height: auto;" src="https://www.mescroll.com/img/swiper2.jpg" mode="widthFix"/>
  10. </swiper-item>
  11. </swiper>
  12. <view class="demo-tip">
  13. <view>仅测试mescroll-uni使用sticky的情况</view>
  14. <view>与mescroll-body使用的区别:</view>
  15. <view>1. mescroll-uni 无需配置 :sticky="true"</view>
  16. <view>2. sticky的top 无需考虑var(--window-top)</view>
  17. </view>
  18. <!-- sticky吸顶悬浮的菜单, 父元素必须是 mescroll -->
  19. <view class="sticky-tabs">
  20. <me-tabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></me-tabs>
  21. </view>
  22. <!-- 数据列表 -->
  23. <good-list :list="goods"></good-list>
  24. </mescroll-uni>
  25. </view>
  26. </template>
  27. <script>
  28. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  29. import {apiSearch} from "@/api/mock.js"
  30. export default {
  31. mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  32. data() {
  33. return {
  34. goods: [], // 数据列表
  35. tabs: ['全部', '母婴', '图书'],
  36. tabIndex: 0 // tab下标
  37. }
  38. },
  39. methods: {
  40. /*下拉刷新的回调 */
  41. downCallback() {
  42. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  43. // loadSwiper();
  44. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  45. this.mescroll.resetUpScroll()
  46. },
  47. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  48. upCallback(page) {
  49. let keyword = this.tabs[this.tabIndex]
  50. apiSearch(page.num, page.size, keyword).then(curPageData=>{
  51. if(page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  52. this.goods=this.goods.concat(curPageData); //追加新数据
  53. this.mescroll.endSuccess(curPageData.length); // 隐藏加载状态栏
  54. }).catch(()=>{
  55. //联网失败, 结束加载
  56. this.mescroll.endErr();
  57. })
  58. },
  59. // 切换菜单
  60. tabChange () {
  61. this.goods = []; // 置空列表,显示加载进度条
  62. this.mescroll.resetUpScroll()
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. /*
  69. sticky生效条件:
  70. 1、父元素不能overflow:hidden或者overflow:auto属性。(mescroll-body设置:sticky="true"即可, mescroll-uni本身没有设置overflow)
  71. 2、必须指定top、bottom、left、right4个值之一,否则只会处于相对定位
  72. 3、父元素的高度不能低于sticky元素的高度
  73. 4、sticky元素仅在其父元素内生效,所以父元素必须是 mescroll
  74. */
  75. .sticky-tabs{
  76. z-index: 990;
  77. position: sticky;
  78. top: 0;
  79. background-color: #fff;
  80. }
  81. .demo-tip{
  82. padding: 18rpx;
  83. font-size: 24rpx;
  84. text-align: center;
  85. }
  86. </style>