|
@@ -62,11 +62,6 @@ const load = async () => {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
finished.value = false
|
|
finished.value = false
|
|
|
page.value = 1
|
|
page.value = 1
|
|
|
- console.log('load 请求参数', {
|
|
|
|
|
- lang: locale.value == 'vn' ? 'vi' : locale.value,
|
|
|
|
|
- page: { current: page.value, row: props.queryParams?.pageSize || props.pageSize },
|
|
|
|
|
- ...props.queryParams
|
|
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const res = await props.fetchData({
|
|
const res = await props.fetchData({
|
|
@@ -99,29 +94,20 @@ const loadMore = async () => {
|
|
|
page: { current: nextPage, row: props.queryParams?.pageSize || props.pageSize },
|
|
page: { current: nextPage, row: props.queryParams?.pageSize || props.pageSize },
|
|
|
...props.queryParams
|
|
...props.queryParams
|
|
|
}
|
|
}
|
|
|
- console.log('loadMore 请求参数', params) // ① 查看请求参数
|
|
|
|
|
-
|
|
|
|
|
const res = await props.fetchData(params)
|
|
const res = await props.fetchData(params)
|
|
|
- console.log('loadMore 响应结果', res) // ② 查看完整响应
|
|
|
|
|
-
|
|
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
const newList = res.data || []
|
|
const newList = res.data || []
|
|
|
- console.log('newList 长度', newList.length, newList) // ③ 查看新数据
|
|
|
|
|
-
|
|
|
|
|
if (newList.length > 0) {
|
|
if (newList.length > 0) {
|
|
|
list.value.push(...newList)
|
|
list.value.push(...newList)
|
|
|
page.value = nextPage
|
|
page.value = nextPage
|
|
|
- console.log('当前列表长度', list.value.length)
|
|
|
|
|
}
|
|
}
|
|
|
// 更新 finished 状态
|
|
// 更新 finished 状态
|
|
|
const totalRows = res.page?.rowTotal || total.value
|
|
const totalRows = res.page?.rowTotal || total.value
|
|
|
finished.value = list.value.length >= totalRows
|
|
finished.value = list.value.length >= totalRows
|
|
|
- console.log('finished', finished.value, '总条数', totalRows)
|
|
|
|
|
} else {
|
|
} else {
|
|
|
throw new Error(res.msg || '请求失败')
|
|
throw new Error(res.msg || '请求失败')
|
|
|
}
|
|
}
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
- console.error('加载更多失败', err)
|
|
|
|
|
uni.showToast({ title: err.message || '加载更多失败', icon: 'none' })
|
|
uni.showToast({ title: err.message || '加载更多失败', icon: 'none' })
|
|
|
} finally {
|
|
} finally {
|
|
|
loadingMore.value = false
|
|
loadingMore.value = false
|
|
@@ -132,7 +118,6 @@ const handleItemClick = (item) => {
|
|
|
}
|
|
}
|
|
|
const lang = computed(() => uni.getLocale())
|
|
const lang = computed(() => uni.getLocale())
|
|
|
watch(lang, (val) => {
|
|
watch(lang, (val) => {
|
|
|
- console.log('lang 变化', val)
|
|
|
|
|
load()
|
|
load()
|
|
|
}, { immediate: true })
|
|
}, { immediate: true })
|
|
|
defineExpose({ load, loadMore })
|
|
defineExpose({ load, loadMore })
|