This commit is contained in:
zpc 2025-07-25 13:27:18 +08:00
parent 9d9aa3d006
commit d98c40d8a2
3 changed files with 121 additions and 96 deletions

View File

@ -6,106 +6,121 @@
:hide-empty-view="hideEmptyView" :refresher-enabled="false" @contentHeightChanged="contentHeightChanged"
:auto="false" :auto-clean-list-when-reload="false">
<!-- 如果希望其他view跟着页面滚动可以放在z-paging标签内 -->
<view class="item" v-for="(item, index) in dataList" :key="index">
<view class="item-title">{{ item.title }}</view>
<view class="item-detail">{{ item.detail }}</view>
<view class="item-line"></view>
<view class="grid-container">
<view v-for="(item, index) in dataList" :key="index">
<guyu-home-goods-item :goods-item="item" />
<!-- <view class="item-title">{{ item.title }}</view>
<view class="item-detail">{{ item.detail }}</view>
<view class="item-line"></view> -->
</view>
</view>
</z-paging>
</view>
</template>
<script>
export default {
data() {
return {
// v-model
dataList: [],
height: 0,
hideEmptyView: true,
completeFunc: null
}
<script setup>
import { ref, watch, nextTick, defineProps, defineExpose } from 'vue';
// props
const props = defineProps({
// indexswiper
tabIndex: {
type: Number,
default: 0
},
props: {
// indexswiper
tabIndex: {
type: Number,
default: function () {
return 0
}
},
// swiperindex
currentIndex: {
type: Number,
default: function () {
return 0
}
}
},
watch: {
currentIndex: {
handler(newVal) {
if (newVal === this.tabIndex) {
// item
this.$nextTick(() => {
setTimeout(() => {
this.$refs.paging.reload();
}, 100);
})
}
},
immediate: true
}
},
methods: {
queryList(pageNo, pageSize) {
//
// pageNopageSize
//
const params = {
pageNo: pageNo,
pageSize: pageSize,
type: this.tabIndex + 1
}
let c = [];
for (let i = 0; i < 10; i++) {
c.push({
title: '测试' + i,
detail: '详情' + i
})
}
this.$refs.paging.complete(c);
this.hideEmptyView = false;
//使z-paging
if (this.completeFunc) {
this.completeFunc();
}
},
//
reload(completeFunc) {
//
this.completeFunc = completeFunc;
// z-pagingreload
this.$refs.paging.reload();
},
// swiper
contentHeightChanged(height) {
const finalHeight = this.dataList.length ? height : 0;
// z-tabs使slot="top"viewminHeightslot="top"view
const minHeight = uni.getSystemInfoSync().windowHeight - uni.upx2px(80);
this.$emit('heightChanged', Math.max(finalHeight, minHeight));
},
//
doLoadMore() {
this.$refs.paging.doLoadMore();
},
//
clear() {
this.$refs.paging.clear();
this.hideEmptyView = true;
}
// swiperindex
currentIndex: {
type: Number,
default: 0
}
}
});
// emit
const emit = defineEmits(['heightChanged']);
//
// v-model
const dataList = ref([]);
const height = ref(0);
const hideEmptyView = ref(true);
const completeFunc = ref(null);
const paging = ref(null);
// currentIndex
watch(
() => props.currentIndex,
(newVal) => {
if (newVal === props.tabIndex) {
// item
nextTick(() => {
setTimeout(() => {
paging.value.reload();
}, 100);
});
}
},
{ immediate: true }
);
//
//
const queryList = (pageNo, pageSize) => {
// pageNopageSize
//
const params = {
pageNo: pageNo,
pageSize: pageSize,
type: props.tabIndex + 1
}
let c = [];
for (let i = 0; i < 10; i++) {
c.push({
title: '测试' + i,
detail: '详情' + i
})
}
paging.value.complete(c);
hideEmptyView.value = false;
//使z-paging
if (completeFunc.value) {
completeFunc.value();
}
};
//
const reload = (completeFn) => {
//
completeFunc.value = completeFn;
// z-pagingreload
paging.value.reload();
};
// swiper
const contentHeightChanged = (height) => {
const finalHeight = dataList.value.length ? height : 0;
// z-tabs使slot="top"viewminHeightslot="top"view
const minHeight = uni.getSystemInfoSync().windowHeight - uni.upx2px(80);
emit('heightChanged', Math.max(finalHeight, minHeight));
};
//
const doLoadMore = () => {
paging.value.doLoadMore();
};
//
const clear = () => {
paging.value.clear();
hideEmptyView.value = true;
};
//
defineExpose({
reload,
doLoadMore,
clear
});
</script>
<style>
@ -140,4 +155,14 @@ export default {
width: 100%;
background-color: #eeeeee;
}
.grid-container {
width: 100%;
display: grid;
/* 3列等宽 */
grid-template-columns: repeat(2, 1fr);
/* 间距 */
gap: 20rpx;
padding: 20rpx 0rpx;
}
</style>

View File

@ -2,8 +2,7 @@
<view class="tabs-container">
<view class="tabs-wrapper">
<template v-for="(item, index) in slideLableList" :key="index">
<view class="tab-item-wrapper" @click="clickTab(index)"
:style="{ width: item.width }">
<view class="tab-item-wrapper" @click="clickTab(index)" :style="{ width: item.width }">
<SlideLabel ref="slideLabels" :defaultColor="item.active ? '#F5D677' : '#fff'">
<text class="tab-text myZt-500w">{{ item.name }}</text>
</SlideLabel>
@ -94,7 +93,7 @@ const getLableWidth = (name) => {
return t + "rpx";
}
const systemWidth = parseInt(uni.getSystemInfoSync().screenWidth * 0.96);
const systemWidth = parseInt(uni.getWindowInfo().screenWidth * 0.96);
const emit = defineEmits(['change']);
let isClick = false;
//

View File

@ -188,6 +188,7 @@ defineExpose({
.right-cover {
height: 100%;
top: 0;
/* border-radius: 25rpx; */
}
.left-cover {