similar.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view>
  3. <view class="box defaultBgc">
  4. <scroll-view class="scrollBox" :scroll-y="true" :scroll-top="scrollTop" @scrolltolower="loadingMore" @scroll="onScroll" style="position:relative;">
  5. <PositionList :list="positionListData" :noMore="false"></PositionList>
  6. <uni-load-more :status="more" />
  7. </scroll-view>
  8. </view>
  9. </view>
  10. </template>
  11. <script setup>
  12. import { ref, reactive } from 'vue'
  13. import PositionList from '@/components/PositionList'
  14. import { dealDictArrayData } from '@/utils/position'
  15. import { getSimilarPosition } from '@/api/position'
  16. const props = defineProps({
  17. id: String
  18. })
  19. const more = ref('more')
  20. const positionListData = ref([])
  21. const query = reactive({
  22. pageSize: 10,
  23. pageNo: 1,
  24. id: props.id
  25. })
  26. console.log(props.id, '==================')
  27. const getData = async () => {
  28. try {
  29. const res = await getSimilarPosition(query)
  30. const arr = res?.data?.list || []
  31. // 推荐接口返回数据需要拼接
  32. const list = arr
  33. positionListData.value.push(...dealDictArrayData(list))
  34. if (positionListData.value.length === +res.data.total) {
  35. more.value = 'noMore'
  36. return
  37. }
  38. } catch (error) {
  39. query.pageNo--
  40. more.value = 'more'
  41. }
  42. }
  43. const scrollTop = ref(0)
  44. const old = ref({
  45. scrollTop: 0
  46. })
  47. const onScroll = (e) =>{
  48. old.value.scrollTop = e.detail.scrollTop
  49. }
  50. // 加载更多
  51. const loadingMore = () => {
  52. more.value = 'loading'
  53. query.pageNo++
  54. getData()
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. .stick {
  59. z-index: 1;
  60. position: sticky;
  61. top: 0;
  62. }
  63. .stickFilter {
  64. z-index: 1;
  65. position: sticky;
  66. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  67. top: 120rpx;
  68. }
  69. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  70. .pb-10 {
  71. padding-bottom: 10px;
  72. }
  73. .pb-20 { padding-bottom: 20px; }
  74. .px-5 { padding-left: 5px; padding-right: 5px; }
  75. .px-10 { padding-left: 10px; padding-right: 10px; }
  76. .mx-10 { margin-left: 10px; margin-right: 10px }
  77. .mx-20 { margin-left: 20px; margin-right: 20px; }
  78. .mb-10 { margin-bottom: 10px; }
  79. .box {
  80. height: 100vh;
  81. overflow: hidden;
  82. padding-bottom: 120rpx;
  83. box-sizing: border-box;
  84. display: flex;
  85. flex-direction: column;
  86. }
  87. .scrollBox{
  88. flex: 1;
  89. height: 0 !important;
  90. padding-bottom: 24rpx;
  91. box-sizing: border-box;
  92. }
  93. :deep(.uni-searchbar__box) {
  94. width: calc(100% - 105px);
  95. height: 40px !important;
  96. border: 1px solid #00B760;
  97. padding-right: 20px;
  98. flex: none;
  99. }
  100. .search-btn {
  101. position: absolute;
  102. right: 11px;
  103. top: 10px;
  104. width: 110px;
  105. height: 40px;
  106. font-size: 16px;
  107. background-color: #00B760;
  108. color: #fff;
  109. border-radius: 0 5px 5px 0;
  110. z-index: 9;
  111. }
  112. :deep(.picker-view) {
  113. padding-bottom: 80px !important;
  114. }
  115. </style>