<template> <view class="sort-page"> <view class="sort-body"> <!-- 左侧分类 --> <view class="leftTab"> <scroll-view scroll-y="true" class="tabBox"> <block v-for="(item,index) in tabList" :key="item.id"> <view class="tabItem" :class="tabCurrent == item.id ?'tabActive':''" @click="changeTab(item.id)"> {{item.categoryName}} </view> </block> </scroll-view> </view> <!-- 右侧商品 --> <view class="rightGoods" v-show="listIndex && listIndex.length>0"> <scroll-view class="whiteBox" scroll-y="true" refresher-default-style="none" @scrolltoupper="toupperTop" @scrolltolower="lowerMore"> <view class="list"> <view class='l-item' v-for="item in listIndex" :key="item.id" @click="goProduct(item)"> <image class='item-img' :src='item.goodsImage'></image> <view class='item-text'>{{item.goodsName}}</view> </view> </view> </scroll-view> </view> </view> </view> </template> <script> import { switchShowTabbar, isLogin,initSettings } from '@/utils/index' export default { data() { return { // 分类列表 tabList: [], tabCurrent: 1, fromStore: false, pageNum: 1, pageSize: 50,//每页展示几条数据 total: 0, hasNextText:'上拉加载更多', loadFlag:true, hasNextPage:false, listIndex:[], inputValue:'' } }, onLoad(options) { // 有传值说明是从门店进入 if (options.fromStore) { this.fromStore = options.fromStore } this.init() this.initSearch() }, methods: { init(){ const self=this self.$request('/pawn/category/getCategoryList','POST').then((res)=>{ self.tabList=res.result console.log(res,'9766') }) }, initSearch(){ const self=this const {tabCurrent,pageNum,pageSize}=self const parmas={ "categoryId":tabCurrent, "current": pageNum, "size": pageSize, "sort": "id desc" } console.log(parmas,'parmas') self.$request('/pawn/category/getGoodsPage','POST',parmas).then((res)=>{ console.log(res,'res') const {current,records,total,size}=res.result const hasNextPage=total-self.pageSize*self.pageNum>0?true:false //是否有下一页 if(self.loadFlag){ console.log(33); self.listIndex=self.listIndex.concat(records) }else{ console.log(34); self.listIndex=records } self.hasNextPage=hasNextPage self.loadFlag=false console.log(self.hasNextPage,'sort8888') }) }, goProduct(item){ const params={ goodId:item.id } uni.navigateTo({ url:'/pages/productDetails/productDetails?mydata='+encodeURIComponent(JSON.stringify(params)) }) }, changeTab(index) { console.log(index,'indexhyyy') this.tabCurrent = index // this.categoryId=index this.pageNum=1 if(index!=0){ this.recommandStatus='' }else{ this.recommandStatus=1 } this.initSearch() }, goInput(e){ console.log(e.detail.value,'9644') this.inputValue=e.detail.value this.pageNum=1 this.initSearch() }, toupperTop(e){ console.log(e,'到顶了'); }, lowerMore(e){ console.log(e,'触底了'); if(!this.hasNextPage){ // uni.showToast({ // icon: 'none', // title: '到底了', // }) return false; } if(this.loadFlag) return; this.loadFlag=true, this.pageNum=this.pageNum+1 this.initSearch(); } }, onShow() { this.buryingPoint('app:sort_pageView') this.init() this.initSearch() initSettings() } } </script> <style src="./index.less" lang="less" scoped></style>