cloudroam
2025-07-17 f3ea52bf97e61f6917ccaab904817d74d9d4860c
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// 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;
    }
  }
 
export const getFilmLocationBase = async (query: FilmWorksQueryDTO) => {
    const { code, data } = await http.request('get', '/api/filmLocation/list', {
        params: query
    });
 
    if (code === 0) {
        return data.records;
    } else {
        message.showToast('系统异常,无法获取数据');
        return null;
    }
}
// 获取用户点赞的电影列表
export const getFilmLikeList = async (query: { userId: string }) => {
    const { code, data } = await http.request('get', '/api/filmWorks/like/list', {
        params: query
    });
 
    if (code === 0) {
        return data.records;
    } else {
        message.showToast('系统异常,无法获取数据');
        return null;
    }
};
 
// 获取用户收藏的电影列表
export const getFilmCollectList = async (query: { userId: string }) => {
    const { code, data } = await http.request('get', '/api/filmWorks/collect/list', {
        params: query
    });
 
    if (code === 0) {
        return data.records;
    } else {
        message.showToast('系统异常,无法获取数据');
        return null;
    }
};