| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- // 接口文档:https://hyperion-novel-qa-app.mokamrp.com/swagger-ui/#/
- import { requestAll, requestLogin, post, postWithCommonParams, uploadTrackLog } from '../utils/request'
- export const userLogin = (data) => requestLogin(data)
- // 获取token
- const getToken = () => {
- return wx.getStorageSync('accessToken') || ''
- }
- // 添加token到header
- const addTokenToHeader = () => {
- return {
- token: getToken()
- }
- }
- export const getBannerList = (channel) => {
- return requestAll('/novel/banner', {channel}, 'GET', addTokenToHeader())
- }
- export const getChapterList = (channel) => {
- return requestAll('/novel/chapter/list', {channel}, 'GET', addTokenToHeader())
- }
- // /novel/cardNovels
- export const getCardNovels = (channel) => {
- return requestAll('/novel/cardNovels', {channel}, 'GET', addTokenToHeader())
- }
- // /novel/cardNovelsMore
- export const getCardNovelsMore = (id) => {
- if (!id) {
- return Promise.reject(new Error('缺少必要参数: id'));
- }
- return requestAll('/novel/cardNovelsMore', {id}, 'GET', addTokenToHeader())
- }
- // /category/list
- export const getCategoryList = (category) => {
- if (!category) {
- return Promise.reject(new Error('缺少必要参数: category'));
- }
- return requestAll('/category/list', {category}, 'GET', addTokenToHeader())
- }
- // /novel/detail
- export const getNovelDetail = (id) => {
- if (!id) {
- return Promise.reject(new Error('缺少必要参数: id'));
- }
- return requestAll('/novel/detail', {id}, 'GET', addTokenToHeader())
- }
- // /novel/search
- export const getNovelSearch = ({
- keyword,
- page = 1,
- size = 10,
- category
- }) => {
- // 创建基本参数对象
- const params = {keyword, page, size};
- // 如果category有值,才添加到参数中
- if (category) {
- params.category = category;
- }
- return requestAll('/novel/search', params, 'GET', addTokenToHeader());
- }
- // /user/bookshelf 获取书架列表
- export const getBookshelfList = () => {
- return requestAll('/user/bookshelf', {}, 'GET', addTokenToHeader())
- }
- // /user/bookshelf 添加书架
- export const addBookshelf = (data) => {
- return requestAll('/user/bookshelf', data, 'POST', addTokenToHeader())
- }
- // /user/bookshelf 移除用户书架
- export const removeBookshelf = (data) => {
- return requestAll('/user/bookshelf', data, 'DELETE', addTokenToHeader())
- }
- // /user/chapter/unlock-status 获取章节解锁状态
- export const getChapterUnlockStatus = (data) => {
- return requestAll('/user/chapter/unlock-status-val', data, 'GET', addTokenToHeader())
- }
- // /user/browsing-history 新增用户阅读历史
- export const addBrowsingHistory = (data) => {
- return requestAll('/user/browsing-history', data, 'POST', addTokenToHeader())
- }
- // /user/chapter/unlock 解锁章节
- export const unlockChapter = (data) => {
- return requestAll('/user/chapter/unlock', data, 'POST', addTokenToHeader())
- }
- // 获取阅读记录
- export const getBrowsingHistory = () => {
- return requestAll('/user/browsing-history', {}, 'GET', addTokenToHeader())
- }
- // 获取短剧列表
- export function getVideoList(params = {}) {
- const {page = 1, size = 10, tag_id = 2245, filter_id = "", next_id = "",gh_id = ""} = params;
- const requestData = {
- tag_id: tag_id,
- filter_id: filter_id,
- next_id: next_id,
- count: size,
- uuid: getApp().globalData.uuid, // 固定值,实际应用中可能需要动态生成
- gh_id: gh_id // 固定值
- };
- return postWithCommonParams("https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getvideolist", requestData)
- .then(data => {
- return data;
- // 处理返回数据的格式转换,确保与页面期望的数据结构一致
- if (data) {
- return data.map(video => ({
- id: video.id,
- title: video.title,
- cover: video.cover_image,
- playCount: video.views || '0'
- }));
- }
- return [];
- });
- }
- // 获取视频详情
- export function getVideoDetail(params = {}) {
- if (!params.id) {
- return Promise.reject(new Error('缺少必要参数: id'));
- }
- return postWithCommonParams('https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getvideoinfo', params);
- }
- // 获取真实视频播放地址
- export function getRealVideoUrl(id, tagId) {
- if (!id || !tagId) {
- return Promise.reject(new Error('缺少必要参数: id 或 tagId'));
- }
- const url = `https://applet.xiaoduer.cn/coral/cashvideo/getOasVideoUrl?id=${id}&tagId=${tagId}`;
- return postWithCommonParams(url, {}, 'GET');
- }
- // 获取相关视频列表
- export function getRelatedVideos(params = {}) {
- const {tag_id = 2250, count = 10, filter_id = "", gh_id = ""} = params;
- const requestData = {
- tag_id,
- count,
- filter_id,
- uuid: getApp().globalData.uuid,
- gh_id: gh_id
- };
- return post("https://applet.xiaoduer.cn/cashvideoapi/cashvideo/getrandvideolistpro", requestData);
- }
- /**
- * 获取 uuid
- */
- export function getUuid(body) {
- return postWithCommonParams('https://applet.xiaoduer.cn/api/user/getuuid', body)
- }
- // https://applet.xiaoduer.cn/coral/template/config
- export function getTemplateConfig(body) {
- return postWithCommonParams('https://applet.xiaoduer.cn/coral/template/config', body)
- }
- // 导出postWithCommonParams
- export { postWithCommonParams };
- /**
- * 打点
- */
- export const recordLog = (body) => uploadTrackLog('/track', body)
|