feat: 球局详情完善 & 订单详情完善
This commit is contained in:
@@ -1,47 +1,120 @@
|
||||
import httpService from './httpService'
|
||||
import type { ApiResponse } from './httpService'
|
||||
import httpService from "./httpService";
|
||||
import type { ApiResponse } from "./httpService";
|
||||
|
||||
// 用户接口
|
||||
export interface GameDetail {
|
||||
id: number,
|
||||
title: string,
|
||||
venue_id: number,
|
||||
creator_id: number,
|
||||
game_date: string,
|
||||
start_time: string,
|
||||
end_time: string,
|
||||
max_participants: number,
|
||||
current_participants: number,
|
||||
ntrp_level: string,
|
||||
play_style: string,
|
||||
description: string,
|
||||
status: string,
|
||||
created_at: string,
|
||||
updated_at: string,
|
||||
interface VenueImage {
|
||||
id: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface Weather {
|
||||
fxDate: string;
|
||||
tempMax: string;
|
||||
tempMin: string;
|
||||
iconDay: string;
|
||||
textDay: string;
|
||||
iconNight: string;
|
||||
textNight: string;
|
||||
humidity: string;
|
||||
}
|
||||
|
||||
interface UserActionStatus {
|
||||
can_assess: boolean;
|
||||
can_join: boolean;
|
||||
can_substitute: boolean;
|
||||
can_pay: boolean;
|
||||
waiting_start: boolean;
|
||||
is_substituting: boolean;
|
||||
}
|
||||
|
||||
export interface GameData {
|
||||
image_list: string[];
|
||||
description_tag: string[];
|
||||
start_time: string;
|
||||
end_time: string;
|
||||
venue_description_tag: string[];
|
||||
venue_image_list: VenueImage[];
|
||||
remark_tag: string[];
|
||||
create_time: string;
|
||||
last_modify_time: string;
|
||||
id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
game_type: string;
|
||||
play_type: string;
|
||||
publisher_id: string;
|
||||
venue_id: string;
|
||||
max_players: number;
|
||||
current_players: number;
|
||||
price: string;
|
||||
price_mode: string;
|
||||
court_type: string;
|
||||
court_surface: string;
|
||||
gender_limit: string;
|
||||
skill_level_min: string;
|
||||
skill_level_max: string;
|
||||
is_urgent: string;
|
||||
is_substitute_supported: string;
|
||||
max_substitute_players: number;
|
||||
current_substitute_count: number;
|
||||
is_wechat_contact: number;
|
||||
wechat_contact: string;
|
||||
privacy_level: string;
|
||||
member_visibility: string;
|
||||
match_status: number;
|
||||
venue_description: string;
|
||||
location_name: string;
|
||||
location: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
deadline_hours: number;
|
||||
remark: string;
|
||||
venue_dtl: any | null;
|
||||
formal_members: any[];
|
||||
substitute_members: any[];
|
||||
participants: any[];
|
||||
participant_count: number;
|
||||
max_participants: number;
|
||||
weather: Weather[];
|
||||
user_action_status: UserActionStatus;
|
||||
}
|
||||
|
||||
export enum MATCH_STATUS {
|
||||
NOT_STARTED = 0, // 未开始
|
||||
IN_PROGRESS = 1, //进行中
|
||||
FINISHED = 2 //已结束
|
||||
NOT_STARTED = 0, // 未开始
|
||||
IN_PROGRESS = 1, //进行中
|
||||
FINISHED = 2, //已结束
|
||||
}
|
||||
|
||||
// 响应接口
|
||||
export interface Response {
|
||||
code: string
|
||||
message: string
|
||||
data: GameDetail
|
||||
export interface UpdateLocationRes {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
country: string;
|
||||
province: string;
|
||||
city: string;
|
||||
district: string;
|
||||
}
|
||||
|
||||
// 发布球局类
|
||||
class GameDetailService {
|
||||
// 用户登录
|
||||
async getDetail(id: number): Promise<ApiResponse<Response>> {
|
||||
return httpService.post('/games/detail', { id }, {
|
||||
async getDetail(id: number): Promise<ApiResponse<GameData>> {
|
||||
return httpService.post(
|
||||
"/games/detail",
|
||||
{ id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async updateLocation(location: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}): Promise<ApiResponse<UpdateLocationRes>> {
|
||||
return httpService.post("/user/update_location", location, {
|
||||
showLoading: true,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 导出认证服务实例
|
||||
export default new GameDetailService()
|
||||
export default new GameDetailService();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
import httpService, { ApiResponse } from "./httpService";
|
||||
import tokenManager from '../utils/tokenManager';
|
||||
import { useUser } from '@/store/userStore';
|
||||
import tokenManager from "../utils/tokenManager";
|
||||
import { useUser } from "@/store/userStore";
|
||||
|
||||
// 微信用户信息接口
|
||||
export interface WechatUserInfo {
|
||||
@@ -49,7 +49,7 @@ export interface UserStats {
|
||||
export interface PhoneLoginParams {
|
||||
phone: string;
|
||||
verification_code: string;
|
||||
user_code: string
|
||||
user_code: string;
|
||||
}
|
||||
|
||||
export interface UserInfoType {
|
||||
@@ -105,7 +105,7 @@ export const wechat_auth_login = async (
|
||||
try {
|
||||
await useUser.getState().fetchUserInfo();
|
||||
} catch (error) {
|
||||
console.error('更新用户信息到 store 失败:', error);
|
||||
console.error("更新用户信息到 store 失败:", error);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -158,7 +158,7 @@ export const phone_auth_login = async (
|
||||
try {
|
||||
await useUser.getState().fetchUserInfo();
|
||||
} catch (error) {
|
||||
console.error('更新用户信息到 store 失败:', error);
|
||||
console.error("更新用户信息到 store 失败:", error);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -410,4 +410,40 @@ export const updateUserPhone = async (payload: ChangePhoneParams) => {
|
||||
console.error("更新用户手机号失败:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// 获取指定用户信息
|
||||
export const getUserInfoById = async (id) => {
|
||||
try {
|
||||
const response = await httpService.post("/user/detail_by_id", { id });
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("获取用户信息失败:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// 关注用户
|
||||
export const followUser = async (following_id) => {
|
||||
try {
|
||||
const response = await httpService.post("/wch_users/follow", {
|
||||
following_id,
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("关注失败:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// 取消关注用户
|
||||
export const unFollowUser = async (following_id) => {
|
||||
try {
|
||||
const response = await httpService.post("/wch_users/unfollow", {
|
||||
following_id,
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("取消关注失败:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,90 +1,125 @@
|
||||
import httpService from './httpService'
|
||||
import type { ApiResponse } from './httpService'
|
||||
import { requestPayment } from '@tarojs/taro'
|
||||
import httpService from "./httpService";
|
||||
import type { ApiResponse } from "./httpService";
|
||||
|
||||
export interface SignType {
|
||||
/** 仅在微信支付 v2 版本接口适用 */
|
||||
MD5
|
||||
MD5;
|
||||
/** 仅在微信支付 v2 版本接口适用 */
|
||||
'HMAC-SHA256'
|
||||
"HMAC-SHA256";
|
||||
/** 仅在微信支付 v3 版本接口适用 */
|
||||
RSA
|
||||
RSA;
|
||||
}
|
||||
|
||||
export enum OrderStatus {
|
||||
PENDING = 0,
|
||||
PAID,
|
||||
FINISHED,
|
||||
}
|
||||
|
||||
export interface PayMentParams {
|
||||
order_id: number,
|
||||
order_no: string,
|
||||
status: number,
|
||||
appId: string,
|
||||
timeStamp: string,
|
||||
nonceStr: string,
|
||||
package: string,
|
||||
signType: keyof SignType,
|
||||
paySign: string
|
||||
order_id: number;
|
||||
order_no: string;
|
||||
status: number;
|
||||
appId: string;
|
||||
timeStamp: string;
|
||||
nonceStr: string;
|
||||
package: string;
|
||||
signType: keyof SignType;
|
||||
paySign: string;
|
||||
}
|
||||
|
||||
// 用户接口
|
||||
export interface OrderResponse {
|
||||
participant_id: number,
|
||||
payment_required: boolean,
|
||||
payment_params: PayMentParams
|
||||
participant_id: number;
|
||||
payment_required: boolean;
|
||||
payment_params: PayMentParams;
|
||||
}
|
||||
|
||||
export interface OrderInfo {
|
||||
time: string
|
||||
address: string
|
||||
registrant_nickname: string
|
||||
registrant_phone: string
|
||||
cost: string
|
||||
time: string;
|
||||
address: string;
|
||||
registrant_nickname: string;
|
||||
registrant_phone: string;
|
||||
cost: string;
|
||||
}
|
||||
|
||||
export interface RefundPolicy {
|
||||
application_time: string
|
||||
refund_rule: string
|
||||
application_time: string;
|
||||
refund_rule: string;
|
||||
}
|
||||
|
||||
export interface GameStatus {
|
||||
current_players: number
|
||||
max_players: number
|
||||
is_full: boolean
|
||||
can_join: boolean
|
||||
current_players: number;
|
||||
max_players: number;
|
||||
is_full: boolean;
|
||||
can_join: boolean;
|
||||
}
|
||||
|
||||
export interface GameDetails {
|
||||
game_id: number
|
||||
game_title: string
|
||||
game_description: string
|
||||
game_id: number;
|
||||
game_title: string;
|
||||
game_description: string;
|
||||
}
|
||||
|
||||
export interface GameOrderRes {
|
||||
order_info: OrderInfo
|
||||
refund_policy: RefundPolicy[]
|
||||
notice: string
|
||||
game_status: GameStatus
|
||||
game_details: GameDetails
|
||||
order_info: OrderInfo;
|
||||
refund_policy: RefundPolicy[];
|
||||
notice: string;
|
||||
game_status: GameStatus;
|
||||
game_details: GameDetails;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 发布球局类
|
||||
class OrderService {
|
||||
// 查询订单列表
|
||||
async getOrderList() {
|
||||
return httpService.post('/user/orders', {}, { showLoading: true })
|
||||
}
|
||||
// 创建订单
|
||||
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
|
||||
return httpService.post('/payment/create_order', { game_id }, {
|
||||
showLoading: true,
|
||||
})
|
||||
return httpService.post("/user/orders", {}, { showLoading: true });
|
||||
}
|
||||
|
||||
async getOrderInfo(game_id: number): Promise<ApiResponse<GameOrderRes>> {
|
||||
return httpService.post('/payment/check_order', { game_id }, {
|
||||
showLoading: true,
|
||||
})
|
||||
// 获取订单详情
|
||||
async getOrderDetail(order_id: number): Promise<ApiResponse<any>> {
|
||||
return httpService.post(
|
||||
"/payment/order_details",
|
||||
{ order_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
|
||||
return httpService.post(
|
||||
"/payment/create_order",
|
||||
{ game_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 检查订单信息
|
||||
async getCheckOrderInfo(game_id: number): Promise<ApiResponse<GameOrderRes>> {
|
||||
return httpService.post(
|
||||
"/payment/check_order",
|
||||
{ game_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 获取未支付订单
|
||||
async getUnpaidOrder(game_id: number): Promise<ApiResponse<any>> {
|
||||
return httpService.post(
|
||||
"/payment/get_unpaid_order",
|
||||
{ game_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 导出认证服务实例
|
||||
export default new OrderService()
|
||||
export default new OrderService();
|
||||
|
||||
Reference in New Issue
Block a user