|
@@ -39,15 +39,22 @@
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import { ref } from 'vue'
|
|
- import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
|
+ import { onLoad, onReachBottom } from '@dcloudio/uni-app'
|
|
|
|
+ import { query, count } from '@/api/chat.js'
|
|
|
|
|
|
const uToast = ref()
|
|
const uToast = ref()
|
|
|
|
|
|
const searchInputStyle = {
|
|
const searchInputStyle = {
|
|
backgroundColor: '#E5E5E5'
|
|
backgroundColor: '#E5E5E5'
|
|
}
|
|
}
|
|
|
|
+ const pageNum = ref(1)
|
|
|
|
+ const pageSize = ref(10)
|
|
|
|
+ const visualLoadMore = ref(false)
|
|
|
|
+ const loadMoreStatus = ref('more')
|
|
const searchForm = ref({
|
|
const searchForm = ref({
|
|
- keyword: ''
|
|
|
|
|
|
+ keyword: '',
|
|
|
|
+ pageNumber: 1,
|
|
|
|
+ pageSize: 10
|
|
})
|
|
})
|
|
const list = ref([
|
|
const list = ref([
|
|
{
|
|
{
|
|
@@ -83,16 +90,71 @@
|
|
isRead: false
|
|
isRead: false
|
|
},
|
|
},
|
|
])
|
|
])
|
|
|
|
+
|
|
|
|
+ function onSearch() {
|
|
|
|
+ loadMoreStatus.value = 'more'
|
|
|
|
+ query(searchForm.value).then(res => {
|
|
|
|
+ if (res && res.message === 'success') {
|
|
|
|
+ list.value = res.data
|
|
|
|
+ if (res.count === 0) {
|
|
|
|
+ visualLoadMore.value = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
function onChatClick(chat) {
|
|
function onChatClick(chat) {
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
url: `/pages/chatDetail/chatDetail?id=${chat.id}&title=${chat.title}`
|
|
url: `/pages/chatDetail/chatDetail?id=${chat.id}&title=${chat.title}`
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ onReachBottom(async () => {
|
|
|
|
+ if (loadMoreStatus.value === 'noMore') {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '没有更多啦>﹏<',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ visualLoadMore.value = true
|
|
|
|
+ loadMoreStatus.value = 'loading'
|
|
|
|
+ searchForm.value.pageNum++
|
|
|
|
+ query(searchForm.value).then(res => {
|
|
|
|
+ if (res && res.message === 'success') {
|
|
|
|
+ if (res.data) {
|
|
|
|
+ if (res.count >= list.value.length) {
|
|
|
|
+ if (list.value.length === res.count) {
|
|
|
|
+ loadMoreStatus.value = 'noMore'
|
|
|
|
+ visualLoadMore.value = true
|
|
|
|
+ } else {
|
|
|
|
+ list.value.push(...res.data)
|
|
|
|
+ loadMoreStatus.value = 'more'
|
|
|
|
+ visualLoadMore.value = false
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ loadMoreStatus.value = 'noMore'
|
|
|
|
+ visualLoadMore.value = true
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ loadMoreStatus.value = 'noMore'
|
|
|
|
+ visualLoadMore.value = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
onLoad(() => {
|
|
onLoad(() => {
|
|
- uni.setTabBarBadge({ //显示数字
|
|
|
|
- index: 1, //tabbar下标
|
|
|
|
- text: '999' //数字
|
|
|
|
|
|
+ onSearch()
|
|
|
|
+ count().then(res => {
|
|
|
|
+ if (res && res.message === 'success') {
|
|
|
|
+ uni.setTabBarBadge({ //显示数字
|
|
|
|
+ index: 1, //tabbar下标
|
|
|
|
+ text: `${res.data.amount}` ?? '0' //数字
|
|
|
|
+ })
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
+
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
|
|
|