综合办公系统
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

mescroll-body-part.vue 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <!-- mescroll-body本质是原生page的滚动,无法像mescroll-uni那样用flex布局嵌在某个view中使用局部区域滚动, 但是可以通过fixed定位其他元素来实现"局部区域滚动"-->
  3. <view>
  4. <!-- 顶部 fixed定位 -->
  5. <view class="top-warp">
  6. <view>顶部区域</view>
  7. <view style="font-size: 24rpx;">mescroll-body 通过fixed定位其他元素,实现"局部区域滚动"</view>
  8. </view>
  9. <!-- 左边 fixed定位 -->
  10. <scroll-view class="left-warp" :scroll-y="true">
  11. <view class="tab" :class="{active:i==tabIndex}" v-for="(tab,i) in tabs" :key="i" @click="tabChange(i)">{{tab}}</view>
  12. </scroll-view>
  13. <!-- mescroll-body跟随page滚动, 不可fixed定位, 可设置 top, bottom, topbar, bottombar, safearea的偏移量-->
  14. <mescroll-body ref="mescrollRef" top="88" bottom="100" @init="mescrollInit" @down="downCallback" @up="upCallback">
  15. <good-list :list="goods"></good-list>
  16. </mescroll-body>
  17. <!-- 底部 fixed定位 -->
  18. <view class="bottom-warp"> 底部区域 </view>
  19. </view>
  20. </template>
  21. <script>
  22. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  23. import {apiSearch} from "@/api/mock.js"
  24. export default {
  25. mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  26. data() {
  27. return {
  28. goods: [], // 数据列表
  29. tabs: ['全部', '奶粉', '面膜', '图书', '果汁', '奶瓶', '美素', '花王', '韩蜜', '口红', '毛巾', '玩具', '衣服'],
  30. tabIndex: 0 // tab下标
  31. }
  32. },
  33. methods: {
  34. upCallback(page) {
  35. //联网加载数据
  36. let keyword = this.tabs[this.tabIndex]
  37. apiSearch(page.num, page.size, keyword).then(curPageData=>{
  38. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  39. this.mescroll.endSuccess(curPageData.length);
  40. //设置列表数据
  41. if(page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  42. this.goods=this.goods.concat(curPageData); //追加新数据
  43. }).catch(()=>{
  44. //联网失败, 结束加载
  45. this.mescroll.endErr();
  46. })
  47. },
  48. // 切换菜单
  49. tabChange(i){
  50. if(this.tabIndex != i){
  51. this.tabIndex = i
  52. this.goods = []; // 先置空列表,显示加载进度条
  53. this.mescroll.resetUpScroll(); // 重置列表数据
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. /* 顶部 fixed定位*/
  61. .top-warp{
  62. z-index: 200;
  63. position: fixed;
  64. top: var(--window-top);
  65. left: 0;
  66. width: 100%;
  67. height: 88rpx;
  68. padding-top: 10rpx;
  69. font-size: 28rpx;
  70. text-align: center;
  71. background-color: #CFE0DA;
  72. }
  73. /* 左边 fixed定位*/
  74. .left-warp{
  75. z-index: 100;
  76. position: fixed;
  77. top: var(--window-top);
  78. left: 0;
  79. bottom: 100rpx;
  80. width: 180rpx;
  81. padding-top: 88rpx;
  82. background-color: #eee;
  83. .tab{
  84. font-size: 28rpx;
  85. padding: 28rpx;
  86. &.active{
  87. background-color: #fff;
  88. }
  89. }
  90. }
  91. // 设置padding
  92. .mescroll-body,
  93. /deep/.mescroll-body{
  94. padding-left: 180rpx;
  95. }
  96. /* 底部 fixed定位*/
  97. .bottom-warp{
  98. z-index: 200;
  99. position: fixed;
  100. left: 0;
  101. bottom: 0;
  102. width: 100%;
  103. height: 100rpx;
  104. line-height: 100rpx;
  105. text-align: center;
  106. background-color: #FF6990;
  107. }
  108. </style>