|
|
|
@ -21,7 +21,7 @@ const Profession = () => { |
|
|
|
|
* more 开启加载更多 |
|
|
|
|
*/ |
|
|
|
|
async function getData(more = false) { |
|
|
|
|
if (categoryId) { |
|
|
|
|
if (!categoryId) return; |
|
|
|
|
const oldData = new Map<number, KillData>(data) |
|
|
|
|
const categoryData = oldData.get(categoryId) |
|
|
|
|
const page = more ? (categoryData?.page || 0) + 1 : categoryData?.page || 1 |
|
|
|
@ -31,6 +31,10 @@ const Profession = () => { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (!data.has(categoryId)) { |
|
|
|
|
Taro.showLoading() |
|
|
|
|
} |
|
|
|
|
const res = await HomeApi.skillList(categoryId!, page, 10) |
|
|
|
|
const dataList = res.data.reduce((pre, cur) => { |
|
|
|
|
const index = pre.findIndex(d => d.id === cur.id) |
|
|
|
@ -42,14 +46,15 @@ const Profession = () => { |
|
|
|
|
return pre |
|
|
|
|
}, categoryData?.data || []) |
|
|
|
|
oldData.delete(categoryId) |
|
|
|
|
|
|
|
|
|
oldData.set(categoryId, { |
|
|
|
|
data: dataList, |
|
|
|
|
total: res.total, |
|
|
|
|
page: page |
|
|
|
|
}) |
|
|
|
|
setData(oldData) |
|
|
|
|
} catch (e) { |
|
|
|
|
} |
|
|
|
|
Taro.hideLoading() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|