|
|
|
@ -23,6 +23,7 @@ const Profession = () => { |
|
|
|
|
const [data, setData] = useState<Map<number, KillData>>(new Map) |
|
|
|
|
const [enable, setEnable] = useState(true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* more 开启加载更多 |
|
|
|
|
*/ |
|
|
|
@ -62,31 +63,31 @@ const Profession = () => { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Taro.useDidShow(useCallback(() => { |
|
|
|
|
if (categoryId) { |
|
|
|
|
let tempMap = new Map() |
|
|
|
|
tempMap.set(categoryId, { |
|
|
|
|
data: [], |
|
|
|
|
total: undefined, |
|
|
|
|
page: 1 |
|
|
|
|
}) |
|
|
|
|
setData(tempMap) |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
}, [data])) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
console.log(categoryId,'categoryId') |
|
|
|
|
categoryId && getData() |
|
|
|
|
}, [categoryId]) |
|
|
|
|
|
|
|
|
|
async function getCategory() { |
|
|
|
|
Taro.useDidShow(async () => { |
|
|
|
|
const oldData = new Map<number, KillData>(data) |
|
|
|
|
if (categoryId) { |
|
|
|
|
const data = await userApi.collectList(categoryId!, 1, 10) |
|
|
|
|
oldData.delete(categoryId) |
|
|
|
|
oldData.set(categoryId, { |
|
|
|
|
data: data.list, |
|
|
|
|
total: data.total, |
|
|
|
|
page: 1 |
|
|
|
|
}) |
|
|
|
|
setData(oldData) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
async function getCategory() { |
|
|
|
|
const res = [{name: '视频', id: 2}, {name: '文章', id: 1}, {name: '课程', id: 3}, {name: '其他', id: 4}] |
|
|
|
|
const newTabs = res.map<TabList>(d => ({title: d.name, value: d.id})) |
|
|
|
|
setTabs(newTabs) |
|
|
|
|
setCategoryId(newTabs[0].value as number) |
|
|
|
|
// setEnable(false)
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -95,7 +96,7 @@ const Profession = () => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function jumpInfo(info: any) { |
|
|
|
|
console.log(info, 'info') |
|
|
|
|
|
|
|
|
|
if (info.article) { |
|
|
|
|
Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${info.owner_id}`}) |
|
|
|
|
} else if (info.course) { |
|
|
|
@ -105,6 +106,9 @@ const Profession = () => { |
|
|
|
|
} else if (info.brand) { |
|
|
|
|
Taro.navigateTo({url: `/pages/preview/brand/info/info?id=${info.owner_id}`}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function swiperChange(e) { |
|
|
|
|