<template>
<scroll-view scroll-y class="session-list-container" @scroll="onScroll" @scrolltoupper="onScrolltoupper"
@scrolltolower="getList" v-if="list.length > 0" :throttle="false">
<view class="session-list-item" v-for="(item) in list" @click="handleClickSession(item)">
{{ item }}
</view>
</scroll-view>
</template>
<script setup>
import { ref } from 'vue';
const list = ref([]);
const loading = ref(false);
const has_more = ref(null);
const queryForm = ref({ page: 1, page_size: 10, is_active: false });
const getList = () => {
if (has_more.value === false || loading.value) {
return;
}
loading.value = true;
getData().then((res) => {
if (has_more.value === null) {
list.value = res;
} else {
list.value = [...list.value, ...res];
}
has_more.value = true;
loading.value = false;
}).catch(() => {
loading.value = false;
});
};
const getData = () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve([{ id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 }]);
}, 100);
});
};
const onScroll = (event) => {
};
const onScrolltoupper = () => {
};
const handleClickSession = (item) => {
console.log('handleClickSession');
uni.showToast({
title: 'handleClickSession被触发',
icon: 'none',
});
// uni.navigateTo({
// url: '/pages/session/info?id=' + item.session_id,
// });
};
getList();
</script>
<style scoped lang="scss">
.session-list-container {
// padding: 40rpx;
// overflow: auto;
height: 100vh;
width: 100vw;
}
.session-list-item {
border-radius: 28rpx;
background: rgba(255, 255, 255, 0.1);
padding: 30rpx 0;
width: 100%;
position: relative;
.session-list-item-bar-name {
position: absolute;
right: 14rpx;
top: 30rpx;
font-size: 26rpx;
font-weight: 500;
color: rgba(255, 255, 255, 0.5);
width: 300rpx;
text-align: right;
}
.session-list-item-time {
font-size: 26rpx;
font-weight: 500;
color: rgba(255, 255, 255, 0.5);
padding: 0 36rpx;
}
.session-list-item-user {
display: flex;
align-items: center;
margin-top: 28rpx;
>view {
flex: 1;
text-align: center;
font-size: 20rpx;
font-weight: 500;
color: #fff;
&:first-child {
border-right: 1px solid #FFFFFF4C
}
>view:first-child {
font-size: 48rpx;
font-weight: 500;
color: rgba(131, 242, 230, 1);
}
}
}
&:not(:last-child) {
margin-bottom: 20rpx;
}
}
</style>
9***@qq.com (作者)
可以了谢谢大佬,感动哭了!!!!!
2025-11-17 12:02
DCloud_UNI_JBB
回复 9***@qq.com: 记得打个patches,要不然你重新install了代码就丢了
2025-11-17 12:03
9***@qq.com (作者)
回复 DCloud_UNI_JBB: 好的!谢谢!太感谢了!
2025-11-17 12:04