tj
2025-05-30 d9a780fa538cb7a83aefa04e75cb53185d690d7d
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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'
import {FilmWorksQueryDTO} from '@/types/index'
 
export const getParentTabList = async (
   targetList: Ref<FilmCategoryTree[]>,
    isShowDefault: boolean = true
) => {
    const { code, data } = await http.request('get', '/api/film/category/parentList', {
        params: {  }
    })
 
    if (code === 0) {
        const defaultOption: FilmCategoryTree = {
            id: '',
            name: '全部',
            imageUrl: '',
            color: '',
            sortBy: 0,
            shown: true,
            levelLimit: '',
            childrenCount: 0,
            children: []
        }
        if (isShowDefault) {
            targetList.value = [defaultOption, ...data]
        } else {
            targetList.value = data
        }
 
    } else {
        message.showToast('系统异常,无法获取数据') // 或者用 uni.showToast()
        return null
    }
}
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
        }
 
    } else {
        message.showToast('系统异常,无法获取数据') // 或者用 uni.showToast()
        return null
    }
}
 
 
export const getFilmWorksBase = async (query: FilmWorksQueryDTO) => {
    const { code, data } = await http.request('get', '/api/filmWorks/list', {
      params: query
    });
  
    if (code === 0) {
      return data.records;
    } else {
        message.showToast('系统异常,无法获取数据');
      return null;
    }
  }