tj
2025-06-05 859352ee2e233e8ae80277539af62d982a317c6a
sub-pages/utils/api.ts
@@ -4,7 +4,39 @@
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[]>,
@@ -33,9 +65,22 @@
            targetList.value = data
        }
        console.log('tabList', targetList.value)
    } 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;
    }
  }