BrowsingHistory.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view>
  3. <rowList :listdata="newsList" ></rowList>
  4. <view class="loadmore" @click="loadmore()" >
  5. {{jiazaitext}}
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import rowList from '@/pages/market/base/rowList.vue' //左右布局
  11. import {collectionList,browsingHistoryPage} from '@/http/api/common.js'
  12. export default {
  13. components: {
  14. rowList,
  15. },
  16. data() {
  17. return {
  18. newsList:[],
  19. jiazaitext:'加载更多',
  20. pageNum:1,
  21. pageSize:10,
  22. showType:'jilu'
  23. }
  24. },
  25. async onLoad(e) {
  26. this.newsList = []
  27. if (e.showType) {
  28. if (e.showType == 'shouchang') {
  29. uni.setNavigationBarTitle({
  30. title: '收藏列表'
  31. })
  32. }
  33. this.showType = e.showType
  34. }
  35. //获取商品列表
  36. await this.getList()
  37. },
  38. onReachBottom() {
  39. this.loadmore()
  40. },
  41. methods: {
  42. //加载更多
  43. loadmore(){
  44. console.log('下拉加载',this.jiazaitext);
  45. if (this.jiazaitext=="加载更多") {
  46. this.pageNum=this.pageNum+1
  47. this.jiazaitext="加载中..."
  48. this.getList()
  49. }
  50. },
  51. async getList(){
  52. let res = {
  53. data:null
  54. }
  55. if (this.showType == 'shouchang') {
  56. //获取收藏列表
  57. res = await collectionList({
  58. pageSize:this.pageSize,
  59. pageNum:this.pageNum,
  60. })
  61. }else{
  62. //获取浏览记录
  63. res = await browsingHistoryPage({
  64. pageSize:this.pageSize,
  65. pageNum:this.pageNum,
  66. })
  67. }
  68. if (res.data?.code == 200) {
  69. let newrows = res.data.data?.rows || []
  70. this.newsList.push(...newrows)
  71. if(this.newsList.length!=res.data.data.total){
  72. this.jiazaitext="加载更多"
  73. }else{
  74. this.jiazaitext="已经到底"
  75. }
  76. }
  77. },
  78. }
  79. }
  80. </script>
  81. <style>
  82. .loadmore{
  83. height:200rpx;
  84. text-align: center;
  85. font-size: 28rpx;
  86. font-weight: 400;
  87. color: #999;
  88. padding-top: 24rpx;
  89. }
  90. </style>