api
tj
2025-05-29 05d1310a6ec27656712c0c5e5e57b3365d3faf56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// sub-pages/utils/api.ts
 
import { ref, Ref } from 'vue'
import { FilmCategoryTree, FilmWorks } from '@/types/index'
import http from '@/plugins/http.js'
import message from '@/plugins/message'
 
export const getTabList = async (
    parentId: string,
    targetList: Ref<FilmCategoryTree[]>,
    isShowDefault: boolean = true
) => {
    const { code, data } = await http.request('get', '/api/film/category/list', {
        params: { parentId }
    })
 
    if (code === 0) {
        const defaultOption: FilmCategoryTree = {
            id: '',
            name: '全部',
            parentId,
            imageUrl: '',
            color: '',
            sortBy: 0,
            shown: true,
            levelLimit: '',
            childrenCount: 0,
            children: []
        }
        if (isShowDefault) {
            targetList.value = [defaultOption, ...data]
        } else {
            targetList.value = data
        }
 
        console.log('tabList', targetList.value)
    } else {
        message.showToast('系统异常,无法获取数据') // 或者用 uni.showToast()
        return null
    }
}