1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <view>
-
- <rowList :listdata="newsList" ></rowList>
- <view class="loadmore" @click="loadmore()" >
- {{jiazaitext}}
- </view>
- </view>
- </template>
- <script>
- import rowList from '@/pages/market/base/rowList.vue' //左右布局
- import {collectionList,browsingHistoryPage} from '@/http/api/common.js'
- export default {
- components: {
- rowList,
- },
- data() {
- return {
- newsList:[],
- jiazaitext:'加载更多',
- pageNum:1,
- pageSize:10,
- showType:'jilu'
- }
- },
- async onLoad(e) {
- this.newsList = []
- if (e.showType) {
- if (e.showType == 'shouchang') {
- uni.setNavigationBarTitle({
- title: '收藏列表'
- })
- }
- this.showType = e.showType
- }
- //获取商品列表
- await this.getList()
-
- },
- onReachBottom() {
- this.loadmore()
- },
- methods: {
- //加载更多
- loadmore(){
- console.log('下拉加载',this.jiazaitext);
- if (this.jiazaitext=="加载更多") {
- this.pageNum=this.pageNum+1
- this.jiazaitext="加载中..."
- this.getList()
- }
- },
- async getList(){
- let res = {
- data:null
- }
- if (this.showType == 'shouchang') {
- //获取收藏列表
- res = await collectionList({
- pageSize:this.pageSize,
- pageNum:this.pageNum,
- })
- }else{
- //获取浏览记录
- res = await browsingHistoryPage({
- pageSize:this.pageSize,
- pageNum:this.pageNum,
- })
- }
- if (res.data?.code == 200) {
- let newrows = res.data.data?.rows || []
- this.newsList.push(...newrows)
-
- if(this.newsList.length!=res.data.data.total){
- this.jiazaitext="加载更多"
- }else{
- this.jiazaitext="已经到底"
- }
- }
- },
-
- }
- }
- </script>
- <style>
- .loadmore{
- height:200rpx;
- text-align: center;
- font-size: 28rpx;
- font-weight: 400;
- color: #999;
- padding-top: 24rpx;
- }
- </style>
-
|