feat: 首页更新
This commit is contained in:
37
services/gameService.ts
Normal file
37
services/gameService.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 游戏服务
|
||||
* 处理租户相关的 API 请求
|
||||
*/
|
||||
|
||||
import { request } from '@/utils/network/api';
|
||||
|
||||
/**
|
||||
* API 响应接口
|
||||
*/
|
||||
interface ApiResponse<T = any> {
|
||||
code: number;
|
||||
message: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* tenant 服务类
|
||||
*/
|
||||
class GameService {
|
||||
/**
|
||||
* 获取首页数据
|
||||
*/
|
||||
getHomePageData(data?: Record<string, any>): Promise<ApiResponse> {
|
||||
return request.post('/v2', data, {
|
||||
headers: {
|
||||
cmdId: 381119,
|
||||
paramType: 1,
|
||||
apiName: 'getHomePageData',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 导出单例
|
||||
export const gameService = new GameService();
|
||||
export default gameService;
|
||||
@@ -5,4 +5,5 @@
|
||||
export { default as authService } from './authService';
|
||||
export { default as userService } from './userService';
|
||||
export { default as tenantService } from './tenantService';
|
||||
export { default as gameService } from './gameService';
|
||||
|
||||
|
||||
233
services/mockHomeService.ts
Normal file
233
services/mockHomeService.ts
Normal file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* 首页 Mock 数据服务
|
||||
* 用于开发和测试,模拟真实 API 响应
|
||||
*/
|
||||
|
||||
import type {
|
||||
Banner,
|
||||
Notice,
|
||||
GameCategory,
|
||||
Game,
|
||||
HighPrizeGame,
|
||||
NavItem,
|
||||
} from '@/types/home';
|
||||
|
||||
/**
|
||||
* Mock 轮播图数据
|
||||
*/
|
||||
export const mockBanners: Banner[] = [
|
||||
{
|
||||
id: '1',
|
||||
subject: 'https://via.placeholder.com/1080x350/FF6B6B/FFFFFF?text=Banner+1',
|
||||
link_type: 1,
|
||||
content: 'https://example.com',
|
||||
title: '新年大优惠',
|
||||
description: '充值送彩金',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
subject: 'https://via.placeholder.com/1080x350/4ECDC4/FFFFFF?text=Banner+2',
|
||||
link_type: 1,
|
||||
content: 'https://example.com',
|
||||
title: '周末狂欢',
|
||||
description: '返水最高50%',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
subject: 'https://via.placeholder.com/1080x350/45B7D1/FFFFFF?text=Banner+3',
|
||||
link_type: 1,
|
||||
content: 'https://example.com',
|
||||
title: '限时活动',
|
||||
description: '邀请好友送奖金',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock 公告数据
|
||||
*/
|
||||
export const mockNotices: Notice[] = [
|
||||
{
|
||||
id: '1',
|
||||
title: '系统维护通知',
|
||||
content: '系统将于今晚22:00-23:00进行维护,期间无法正常使用',
|
||||
content_type: 1,
|
||||
create_time: '2025-11-08 10:00:00',
|
||||
formatDate: '2025-11-08',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
title: '新游戏上线',
|
||||
content: '全新游戏《幸运转盘》已上线,欢迎体验',
|
||||
content_type: 1,
|
||||
create_time: '2025-11-07 15:30:00',
|
||||
formatDate: '2025-11-07',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
title: '活动规则更新',
|
||||
content: '详见活动页面',
|
||||
content_type: 3,
|
||||
create_time: '2025-11-06 09:00:00',
|
||||
formatDate: '2025-11-06',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock 游戏分类
|
||||
*/
|
||||
export const mockGameCategories: GameCategory[] = [
|
||||
{ id: 0, key: 'recommend', name: '推荐', icon: 'star', big_type: 0 },
|
||||
{ id: 1, key: 'chess', name: '棋牌', icon: 'chess', big_type: 1 },
|
||||
{ id: 2, key: 'electronic', name: '电子', icon: 'game', big_type: 2 },
|
||||
{ id: 3, key: 'fishing', name: '捕鱼', icon: 'fish', big_type: 3 },
|
||||
{ id: 4, key: 'sports', name: '体育', icon: 'sports', big_type: 4 },
|
||||
{ id: 5, key: 'lottery', name: '彩票', icon: 'lottery', big_type: 5 },
|
||||
{ id: 6, key: 'live', name: '直播', icon: 'live', big_type: 6 },
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock 游戏数据
|
||||
*/
|
||||
export const mockGames: Game[] = [
|
||||
{
|
||||
id: '1',
|
||||
play_id: 1001,
|
||||
play_up_name: '真人百家乐',
|
||||
play_cname: '标准版',
|
||||
icon: 'https://via.placeholder.com/100/FF6B6B/FFFFFF?text=Game+1',
|
||||
big_type: 1,
|
||||
index: 1,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
play_id: 1002,
|
||||
play_up_name: '电子老虎机',
|
||||
play_cname: '幸运转盘',
|
||||
icon: 'https://via.placeholder.com/100/4ECDC4/FFFFFF?text=Game+2',
|
||||
big_type: 2,
|
||||
index: 2,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
play_id: 1003,
|
||||
play_up_name: '捕鱼达人',
|
||||
play_cname: '经典版',
|
||||
icon: 'https://via.placeholder.com/100/45B7D1/FFFFFF?text=Game+3',
|
||||
big_type: 3,
|
||||
index: 3,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
play_id: 1004,
|
||||
play_up_name: '体育竞技',
|
||||
play_cname: '足球',
|
||||
icon: 'https://via.placeholder.com/100/96CEB4/FFFFFF?text=Game+4',
|
||||
big_type: 4,
|
||||
index: 4,
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
play_id: 1005,
|
||||
play_up_name: '彩票游戏',
|
||||
play_cname: '双色球',
|
||||
icon: 'https://via.placeholder.com/100/FFEAA7/FFFFFF?text=Game+5',
|
||||
big_type: 5,
|
||||
index: 5,
|
||||
},
|
||||
{
|
||||
id: '6',
|
||||
play_id: 1006,
|
||||
play_up_name: '真人直播',
|
||||
play_cname: '美女荷官',
|
||||
icon: 'https://via.placeholder.com/100/DFE6E9/FFFFFF?text=Game+6',
|
||||
big_type: 6,
|
||||
index: 6,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock 高奖金游戏数据
|
||||
*/
|
||||
export const mockHighPrizeGames: HighPrizeGame[] = [
|
||||
{
|
||||
id: '1',
|
||||
play_id: 1001,
|
||||
play_up_name: '真人百家乐',
|
||||
play_cname: '标准版',
|
||||
icon: 'https://via.placeholder.com/100/FF6B6B/FFFFFF?text=Prize+1',
|
||||
big_type: 1,
|
||||
index: 1,
|
||||
payout_amount: 50000,
|
||||
bet_amount: 1000,
|
||||
odds: 50000,
|
||||
cust_name: '幸运用户***',
|
||||
avatar: 'https://via.placeholder.com/50/FF6B6B/FFFFFF?text=User',
|
||||
update_time: '2025-11-08 14:30:00',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
play_id: 1002,
|
||||
play_up_name: '电子老虎机',
|
||||
play_cname: '幸运转盘',
|
||||
icon: 'https://via.placeholder.com/100/4ECDC4/FFFFFF?text=Prize+2',
|
||||
big_type: 2,
|
||||
index: 2,
|
||||
payout_amount: 100000,
|
||||
bet_amount: 500,
|
||||
odds: 200000,
|
||||
cust_name: '幸运玩家***',
|
||||
avatar: 'https://via.placeholder.com/50/4ECDC4/FFFFFF?text=User',
|
||||
update_time: '2025-11-08 13:15:00',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
play_id: 1003,
|
||||
play_up_name: '捕鱼达人',
|
||||
play_cname: '经典版',
|
||||
icon: 'https://via.placeholder.com/100/45B7D1/FFFFFF?text=Prize+3',
|
||||
big_type: 3,
|
||||
index: 3,
|
||||
payout_amount: 75000,
|
||||
bet_amount: 800,
|
||||
odds: 93750,
|
||||
cust_name: '大奖得主***',
|
||||
avatar: 'https://via.placeholder.com/50/45B7D1/FFFFFF?text=User',
|
||||
update_time: '2025-11-08 12:00:00',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock 快速导航项
|
||||
*/
|
||||
export const mockNavItems: NavItem[] = [
|
||||
{ id: '1', name: '充值', icon: 'recharge', action: 'recharge' },
|
||||
{ id: '2', name: '提现', icon: 'withdraw', action: 'withdraw' },
|
||||
{ id: '3', name: '活动', icon: 'activity', action: 'activity' },
|
||||
{ id: '4', name: '客服', icon: 'service', action: 'service' },
|
||||
{ id: '5', name: '帮助', icon: 'help', action: 'help' },
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取 Mock 首页数据
|
||||
*/
|
||||
export const getMockHomePageData = () => {
|
||||
return {
|
||||
banners: mockBanners,
|
||||
notices: mockNotices,
|
||||
categories: mockGameCategories,
|
||||
games: mockGames,
|
||||
highPrizeGames: mockHighPrizeGames,
|
||||
navItems: mockNavItems,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取 Mock 游戏列表(支持分类过滤)
|
||||
*/
|
||||
export const getMockGamesByCategory = (categoryId: number) => {
|
||||
if (categoryId === 0) {
|
||||
return mockGames; // 推荐分类返回所有游戏
|
||||
}
|
||||
return mockGames.filter((game) => game.big_type === categoryId);
|
||||
};
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
*/
|
||||
|
||||
import { request } from '@/utils/network/api';
|
||||
// import type { User, UpdateProfileFormData } from '@/schemas/user';
|
||||
|
||||
/**
|
||||
* API 响应接口
|
||||
*/
|
||||
interface ApiResponse<T = any> {
|
||||
code: number;
|
||||
success: string;
|
||||
message: string;
|
||||
data: T;
|
||||
}
|
||||
@@ -32,7 +31,6 @@ class TenantService {
|
||||
cmdId: 371130,
|
||||
headerType: 1,
|
||||
apiName: 'getPlatformData',
|
||||
tid: '',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user