upload project source code
This commit is contained in:
304
前端源码/uni-app/api/affinity.ts
Normal file
304
前端源码/uni-app/api/affinity.ts
Normal file
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* 缘分合盘 API
|
||||
*/
|
||||
|
||||
// 请求参数类型
|
||||
export interface AffinityPersonInfo {
|
||||
name: string;
|
||||
gender: 'male' | 'female';
|
||||
birth_date: string; // 显示格式:1990年1月1日 子时
|
||||
birth_date_api: string; // API格式:1990-01-01 00:30:00
|
||||
}
|
||||
|
||||
export interface AffinityCalculateRequest {
|
||||
relationship: 'couple' | 'married' | 'crush' | 'partner' | 'friend' | 'family';
|
||||
person1: AffinityPersonInfo;
|
||||
person2: AffinityPersonInfo;
|
||||
}
|
||||
|
||||
// 响应数据类型
|
||||
export interface AffinitySixDimension {
|
||||
personality: number; // 性格
|
||||
emotion: number; // 情感
|
||||
family: number; // 家庭
|
||||
wealth: number; // 财运
|
||||
career: number; // 事业
|
||||
health: number; // 健康
|
||||
}
|
||||
|
||||
export interface AffinityAnalysisCard {
|
||||
id: string;
|
||||
icon: string;
|
||||
iconBg: string;
|
||||
title: string;
|
||||
score: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface AffinityPastLife {
|
||||
description: string;
|
||||
depth: string;
|
||||
relationship: string;
|
||||
}
|
||||
|
||||
export interface AffinityMatchItem {
|
||||
label: string;
|
||||
match: number;
|
||||
desc: string;
|
||||
}
|
||||
|
||||
export interface AffinityGuide {
|
||||
realNeeds: string;
|
||||
redZone: string;
|
||||
tips: string[];
|
||||
}
|
||||
|
||||
export interface AffinityMonthlyFortune {
|
||||
heats: number[];
|
||||
heatLabels: string[];
|
||||
highlights: string;
|
||||
warnings: string;
|
||||
}
|
||||
|
||||
export interface AffinityTimelineItem {
|
||||
year: string;
|
||||
title: string;
|
||||
desc: string;
|
||||
highlight: boolean;
|
||||
}
|
||||
|
||||
export interface AffinityMasterAdvice {
|
||||
message: string;
|
||||
tips: string[];
|
||||
}
|
||||
|
||||
export interface AffinityUnlockedContent {
|
||||
pastLife: AffinityPastLife;
|
||||
matchItems: AffinityMatchItem[];
|
||||
guide: AffinityGuide;
|
||||
monthlyFortune: AffinityMonthlyFortune;
|
||||
timeline: AffinityTimelineItem[];
|
||||
masterAdvice: AffinityMasterAdvice;
|
||||
}
|
||||
|
||||
export interface AffinityCalculateResponse {
|
||||
relationship: string;
|
||||
relationshipLabel: string;
|
||||
person1: {
|
||||
name: string;
|
||||
gender: string;
|
||||
birthDate: string;
|
||||
};
|
||||
person2: {
|
||||
name: string;
|
||||
gender: string;
|
||||
birthDate: string;
|
||||
};
|
||||
score: number;
|
||||
scoreBadge: string;
|
||||
sixDimension: AffinitySixDimension;
|
||||
radarDesc: string;
|
||||
analysisCards: AffinityAnalysisCard[];
|
||||
unlocked: AffinityUnlockedContent;
|
||||
isUnlocked: boolean;
|
||||
unlockPrice: number;
|
||||
unlockStats: {
|
||||
unlockCount: number;
|
||||
accuracy: string;
|
||||
};
|
||||
}
|
||||
|
||||
// 列表查询相关类型
|
||||
export interface AffinityListRequest {
|
||||
page_no?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export interface AffinityListItem {
|
||||
id: number;
|
||||
uuid: string;
|
||||
user_id: number;
|
||||
relationship: string;
|
||||
person1_name: string;
|
||||
person1_gender: string;
|
||||
person1_birth_date: string;
|
||||
person1_birth_date_api: string;
|
||||
person2_name: string;
|
||||
person2_gender: string;
|
||||
person2_birth_date: string;
|
||||
person2_birth_date_api: string;
|
||||
score: number | null;
|
||||
score_badge: string | null;
|
||||
six_dimension: string | null;
|
||||
radar_desc: string | null;
|
||||
analysis_cards: string | null;
|
||||
is_unlocked: number;
|
||||
unlock_price: number;
|
||||
unlocked_content: string | null;
|
||||
task_status: number;
|
||||
error_message: string | null;
|
||||
created_time: string;
|
||||
updated_time: string;
|
||||
}
|
||||
|
||||
export interface AffinityListResponse {
|
||||
code: number;
|
||||
msg: string;
|
||||
data: {
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
total: number;
|
||||
has_next: boolean;
|
||||
data: AffinityListItem[];
|
||||
};
|
||||
status_code: number;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缘分合盘测算
|
||||
*/
|
||||
export async function calculateAffinity(params: AffinityCalculateRequest): Promise<AffinityCalculateResponse> {
|
||||
// 获取token(避免JSON解析错误)
|
||||
let token = '';
|
||||
try {
|
||||
// 尝试从localStorage获取(Web环境)
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
token = localStorage.getItem('token') || '';
|
||||
// 如果token是JSON字符串,解析它
|
||||
if (token.startsWith('"') && token.endsWith('"')) {
|
||||
token = JSON.parse(token);
|
||||
}
|
||||
} else {
|
||||
// uni-app环境,直接获取字符串
|
||||
token = uni.getStorageSync('token') || '';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取token失败:', e);
|
||||
}
|
||||
|
||||
const response = await uni.request({
|
||||
url: 'https://yifan.action-ai.cn/api/v1/yifan/yifan_affinity/calculate',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
data: params,
|
||||
});
|
||||
|
||||
if (response.status_code !== 200) {
|
||||
throw new Error(response.data?.msg || '网络请求失败');
|
||||
}
|
||||
|
||||
// 处理认证失败,跳转到登录页(必须在检查code之前)
|
||||
if (response.data?.msg === '认证失败,请登录后再试') {
|
||||
uni.showToast({
|
||||
title: '请先登录',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
}, 2000);
|
||||
|
||||
throw new Error(response.data.msg);
|
||||
}
|
||||
|
||||
if (response.data.code !== 200) {
|
||||
throw new Error(response.data.msg || '测算失败');
|
||||
}
|
||||
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询合盘列表
|
||||
*/
|
||||
export async function getAffinityList(params: AffinityListRequest = {}): Promise<AffinityListResponse | null> {
|
||||
// 获取token(避免JSON解析错误)
|
||||
let token = '';
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
token = localStorage.getItem('token') || '';
|
||||
// 如果token是JSON字符串,解析它
|
||||
if (token.startsWith('"') && token.endsWith('"')) {
|
||||
token = token.slice(1, -1);
|
||||
}
|
||||
} else {
|
||||
// uni-app环境,直接获取字符串
|
||||
token = uni.getStorageSync('token') || '';
|
||||
}
|
||||
|
||||
const { page_no = 1, page_size = 10 } = params;
|
||||
|
||||
const response = await uni.request({
|
||||
url: `https://yifan.action-ai.cn/api/v1/yifan/yifan_affinity/list?page_no=${page_no}&page_size=${page_size}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
});
|
||||
|
||||
if (response.data?.msg === '认证失败,请登录后再试') {
|
||||
uni.showToast({ title: '请先登录', icon: 'none', duration: 2000 });
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/login/login' });
|
||||
}, 2000);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.data.code == 0) {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取缘分合盘详情
|
||||
*/
|
||||
export async function getAffinityDetail(id: number) {
|
||||
let token = '';
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
token = localStorage.getItem('token') || '';
|
||||
if (token.startsWith('"') && token.endsWith('"')) {
|
||||
token = token.slice(1, -1);
|
||||
}
|
||||
} else {
|
||||
token = uni.getStorageSync('token') || '';
|
||||
}
|
||||
|
||||
const response = await uni.request({
|
||||
url: `https://yifan.action-ai.cn/api/v1/yifan/yifan_affinity/${id}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
});
|
||||
|
||||
if (response.data?.msg === '认证失败,请登录后再试') {
|
||||
uni.showToast({ title: '请先登录', icon: 'none', duration: 2000 });
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/login/login' });
|
||||
}, 2000);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.data.code == 0) {
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export const affinityApi = {
|
||||
calculateAffinity,
|
||||
getAffinityList,
|
||||
getAffinityDetail,
|
||||
};
|
||||
221
前端源码/uni-app/api/bazi-zeji.ts
Normal file
221
前端源码/uni-app/api/bazi-zeji.ts
Normal file
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
* 八字择吉 API
|
||||
*/
|
||||
|
||||
// 请求参数类型
|
||||
export interface BaziZejiCalculateRequest {
|
||||
name: string;
|
||||
gender: 'male' | 'female';
|
||||
birth_date: string; // 显示格式:1999年11月15日 子时
|
||||
birth_date_api: string; // API格式:1999-11-15 00:30:00
|
||||
birth_place: string; // 出生地
|
||||
zeji_type: 'wedding' | 'business' | 'move' | 'travel' | 'investment' | 'surgery' | 'contract' | 'other';
|
||||
zeji_purpose: string; // 择吉目的描述
|
||||
date_range_start: string; // 期望日期范围开始 YYYY-MM-DD
|
||||
date_range_end: string; // 期望日期范围结束 YYYY-MM-DD
|
||||
}
|
||||
|
||||
// 响应数据类型
|
||||
export interface BaziZejiDate {
|
||||
date: string; // 日期 YYYY-MM-DD
|
||||
lunar: string; // 农历日期
|
||||
desc: string; // 日期描述
|
||||
score: number; // 吉运指数
|
||||
hours: string; // 吉时
|
||||
clash: string; // 冲煞
|
||||
suitable: string[]; // 宜
|
||||
avoid: string[]; // 忌
|
||||
}
|
||||
|
||||
export interface BaziZejiCalculateResponse {
|
||||
name: string;
|
||||
gender: string;
|
||||
birth_date: string;
|
||||
birth_place: string;
|
||||
zeji_type: string;
|
||||
zeji_purpose: string;
|
||||
date_range_start: string;
|
||||
date_range_end: string;
|
||||
advice: string; // 择吉建议
|
||||
dates: BaziZejiDate[]; // 吉日列表
|
||||
}
|
||||
|
||||
// 列表查询相关类型
|
||||
export interface BaziZejiListRequest {
|
||||
page_no?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export interface BaziZejiListItem {
|
||||
id: number;
|
||||
name: string;
|
||||
gender: string;
|
||||
birth_date: string;
|
||||
zeji_type: string;
|
||||
zeji_type_label: string;
|
||||
zeji_purpose: string;
|
||||
date_range_start: string;
|
||||
date_range_end: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface BaziZejiListResponse {
|
||||
code: number;
|
||||
msg: string;
|
||||
data: {
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
total: number;
|
||||
has_next: boolean;
|
||||
data: BaziZejiListItem[];
|
||||
};
|
||||
status_code: number;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 八字择吉测算
|
||||
*/
|
||||
export async function calculateBaziZeji(params: BaziZejiCalculateRequest): Promise<BaziZejiCalculateResponse> {
|
||||
// 获取token(避免JSON解析错误)
|
||||
let token = '';
|
||||
try {
|
||||
// 尝试从localStorage获取(Web环境)
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
token = localStorage.getItem('token') || '';
|
||||
// 如果token是JSON字符串,解析它
|
||||
if (token.startsWith('"') && token.endsWith('"')) {
|
||||
token = JSON.parse(token);
|
||||
}
|
||||
} else {
|
||||
// uni-app环境,直接获取字符串
|
||||
token = uni.getStorageSync('token') || '';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取token失败:', e);
|
||||
}
|
||||
|
||||
const response = await uni.request({
|
||||
url: 'https://yifan.action-ai.cn/api/v1/yifan/yifan_bazi_zeji/calculate',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
data: params,
|
||||
});
|
||||
|
||||
if (response.status_code !== 200) {
|
||||
throw new Error(response.data?.msg || '网络请求失败');
|
||||
}
|
||||
|
||||
// 处理认证失败,跳转到登录页
|
||||
if (response.data?.msg === '认证失败,请登录后再试') {
|
||||
uni.showToast({
|
||||
title: '请先登录',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
}, 2000);
|
||||
|
||||
throw new Error(response.data.msg);
|
||||
}
|
||||
|
||||
if (response.data.code !== 200) {
|
||||
throw new Error(response.data.msg || '测算失败');
|
||||
}
|
||||
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询八字择吉列表
|
||||
*/
|
||||
export async function getBaziZejiList(params: BaziZejiListRequest = {}): Promise<BaziZejiListResponse | null> {
|
||||
// 获取token(避免JSON解析错误)
|
||||
let token = '';
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
token = localStorage.getItem('token') || '';
|
||||
// 如果token是JSON字符串,解析它
|
||||
if (token.startsWith('"') && token.endsWith('"')) {
|
||||
token = token.slice(1, -1);
|
||||
}
|
||||
} else {
|
||||
// uni-app环境,直接获取字符串
|
||||
token = uni.getStorageSync('token') || '';
|
||||
}
|
||||
|
||||
const { page_no = 1, page_size = 10 } = params;
|
||||
|
||||
const response = await uni.request({
|
||||
url: `https://yifan.action-ai.cn/api/v1/yifan/yifan_bazi_zeji/list?page_no=${page_no}&page_size=${page_size}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
});
|
||||
|
||||
if (response.data?.msg === '认证失败,请登录后再试') {
|
||||
uni.showToast({ title: '请先登录', icon: 'none', duration: 2000 });
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/login/login' });
|
||||
}, 2000);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.data.code == 0) {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取八字择吉详情
|
||||
*/
|
||||
export async function getBaziZejiDetail(id: number) {
|
||||
let token = '';
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
token = localStorage.getItem('token') || '';
|
||||
if (token.startsWith('"') && token.endsWith('"')) {
|
||||
token = token.slice(1, -1);
|
||||
}
|
||||
} else {
|
||||
token = uni.getStorageSync('token') || '';
|
||||
}
|
||||
|
||||
const response = await uni.request({
|
||||
url: `https://yifan.action-ai.cn/api/v1/yifan/yifan_bazi_zeji/${id}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
});
|
||||
|
||||
if (response.data?.msg === '认证失败,请登录后再试') {
|
||||
uni.showToast({ title: '请先登录', icon: 'none', duration: 2000 });
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/login/login' });
|
||||
}, 2000);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.data.code == 0) {
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export const baziZejiApi = {
|
||||
calculateBaziZeji,
|
||||
getBaziZejiList,
|
||||
getBaziZejiDetail,
|
||||
};
|
||||
119
前端源码/uni-app/api/cai-yun.ts
Normal file
119
前端源码/uni-app/api/cai-yun.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* 财运解析相关 API
|
||||
*/
|
||||
import request from '@/utils/request'
|
||||
|
||||
export interface WealthAnalysisResponse {
|
||||
jiexi_id: number;
|
||||
report_id: number;
|
||||
name: string;
|
||||
wealth_score: number;
|
||||
wealth_level: string;
|
||||
wealth_trend: string;
|
||||
yuedo_xiangpi?: any;
|
||||
meiri_yuncheng?: any;
|
||||
mingpan_jingpi: {
|
||||
mingzao: string;
|
||||
zhen_taiyang_shi: string;
|
||||
nongli_shengchen: string;
|
||||
qianshi_yinji: string;
|
||||
jinsheng_keti: string;
|
||||
bazi_paipan: {
|
||||
nian: { gan: string; zhi: string };
|
||||
yue: { gan: string; zhi: string };
|
||||
ri: { gan: string; zhi: string };
|
||||
shi: { gan: string; zhi: string };
|
||||
};
|
||||
mingge_cengci: string;
|
||||
guji_duanyu: string;
|
||||
qimen_paipan: string;
|
||||
qimen_geju: string;
|
||||
wuxing_nengliang: {
|
||||
mu: number;
|
||||
huo: number;
|
||||
tu: number;
|
||||
jin: number;
|
||||
shui: number;
|
||||
};
|
||||
dashi_pizhu: string;
|
||||
wuxing_kaiyun: string;
|
||||
shishen_mangdian: string;
|
||||
shiye_caiyun_dingshu: string;
|
||||
hunyin_qinggan: string;
|
||||
wuxing_jiankang: string;
|
||||
shensha_guiren: string;
|
||||
};
|
||||
liunian_zongyun: {
|
||||
dayun_zoushi: string;
|
||||
taisui_jiangjun: string;
|
||||
dangnian_liunian: string;
|
||||
liunian_shensha: string;
|
||||
fenqunti_zhuanyun: {
|
||||
qingnian: string;
|
||||
zhongnian: string;
|
||||
laonian: string;
|
||||
};
|
||||
liunian_jixiong_fangwei: {
|
||||
ji: string[];
|
||||
xiong: string[];
|
||||
};
|
||||
caifu_laiyuan: string;
|
||||
touzi_lingyu_zhiyin: {
|
||||
fangdichan: string;
|
||||
gupiao: string;
|
||||
jijin: string;
|
||||
huangjin: string;
|
||||
};
|
||||
dangnian_jiugong_feixing: string;
|
||||
liunian_huajie: string;
|
||||
};
|
||||
fengshui_jinnang: {
|
||||
guiren_huaxiang: string;
|
||||
waiju_shaji_huajie: {
|
||||
lu_chong: string;
|
||||
jian_dao_sha: string;
|
||||
fan_gong_sha: string;
|
||||
};
|
||||
jiaju_caiwei: {
|
||||
ming_caiwei: string;
|
||||
an_caiwei: string;
|
||||
};
|
||||
zhichang_gaosheng: string;
|
||||
cuiwang_taohua: string;
|
||||
jiaju_zhiwu: Array<{
|
||||
name: string;
|
||||
position: string;
|
||||
effect: string;
|
||||
}>;
|
||||
mengchong_fengshui: string;
|
||||
shuzi_nengliang: {
|
||||
shouji_hao: string;
|
||||
che_pai: string;
|
||||
lou_ceng: string;
|
||||
};
|
||||
aiche_pingan: string;
|
||||
xijin_qianbao: {
|
||||
yanse: string;
|
||||
zhidi: string;
|
||||
shiyong: string;
|
||||
};
|
||||
xingyun_se_peidai: {
|
||||
xingyun_se: string[];
|
||||
peidai_shipin: Array<{
|
||||
name: string;
|
||||
effect: string;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
unlocked: null;
|
||||
is_unlocked: boolean;
|
||||
unlock_price: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据报告id获取财运解析结果
|
||||
* @param reportId 报告ID
|
||||
* @returns 财运解析结果
|
||||
*/
|
||||
export const getWealthAnalysisByReportId = (reportId: number) =>
|
||||
request.get<WealthAnalysisResponse>(`/yifan_caiyun_jiexi/result/by-report/${reportId}`);
|
||||
56
前端源码/uni-app/api/home.ts
Normal file
56
前端源码/uni-app/api/home.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @Author: caoziyuan ziyuan.cao@zhuying.com
|
||||
* @Date: 2026-01-13 14:31:18
|
||||
* @LastEditors: aliyun4247073344 893643761@qq.com
|
||||
* @LastEditTime: 2026-02-28 10:16:04
|
||||
* @FilePath: \uni-app\api\home.ts
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
/**
|
||||
* 首页相关 API
|
||||
*/
|
||||
import { http } from '../utils/request';
|
||||
import type { AboutUsInfo, AboutVideoInfo, CalendarInfo, RecommendedSolutionResponse, NoticeListResponse } from './types';
|
||||
|
||||
export const homePageApi = {
|
||||
/**
|
||||
* 获取文字介绍(关于我们)
|
||||
*/
|
||||
getAboutUs: () => {
|
||||
return http.get<AboutUsInfo>('/yifan_about_us/miniapp/info');
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取视频介绍
|
||||
*/
|
||||
getAboutVideo: () => {
|
||||
return http.get<AboutVideoInfo>('/yifan_about_video/miniapp/info');
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取今天日期(黄历)
|
||||
*/
|
||||
getCalendarToday: () => {
|
||||
return http.get<CalendarInfo>('/yifan_naming_reports/calendar');
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取方案推荐(佳名赏析)
|
||||
*/
|
||||
getRecommendedSolutions: (pageNo = 1, pageSize = 10) => {
|
||||
return http.get<RecommendedSolutionResponse>('/yifan_naming_solutions/recommended', {
|
||||
page_no: pageNo,
|
||||
page_size: pageSize,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取消息轮播列表
|
||||
*/
|
||||
getNoticeList: (pageNo = 1, pageSize = 10) => {
|
||||
return http.get<NoticeListResponse>('/notice/mini/list', {
|
||||
page_no: pageNo,
|
||||
page_size: pageSize,
|
||||
});
|
||||
},
|
||||
};
|
||||
39
前端源码/uni-app/api/index.ts
Normal file
39
前端源码/uni-app/api/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* API 统一导出(当前仅保留真实的小程序登录接口)
|
||||
*/
|
||||
export * from './types';
|
||||
export { userApi } from './user';
|
||||
export { homePageApi } from './home';
|
||||
export { namingApi } from './naming';
|
||||
export { paymentApi } from './payment';
|
||||
export { affinityApi } from './affinity';
|
||||
export { baziZejiApi } from './bazi-zeji';
|
||||
export type {
|
||||
CompanyNamingRequest,
|
||||
CompanyCoreMember,
|
||||
CompanyNamingResponse,
|
||||
SolutionDetailResponse,
|
||||
CompanyAnalysisRequest,
|
||||
CompanyAnalysisResponse,
|
||||
CompanyAnalysisDetailNode,
|
||||
CompanyAnalysisDetails,
|
||||
} from './naming';
|
||||
export type {
|
||||
AffinityCalculateRequest,
|
||||
AffinityCalculateResponse,
|
||||
AffinityPersonInfo,
|
||||
AffinitySixDimension,
|
||||
AffinityAnalysisCard,
|
||||
AffinityUnlockedContent,
|
||||
AffinityListRequest,
|
||||
AffinityListResponse,
|
||||
AffinityListItem,
|
||||
} from './affinity';
|
||||
export type {
|
||||
BaziZejiCalculateRequest,
|
||||
BaziZejiCalculateResponse,
|
||||
BaziZejiDate,
|
||||
BaziZejiListRequest,
|
||||
BaziZejiListResponse,
|
||||
BaziZejiListItem,
|
||||
} from './bazi-zeji';
|
||||
350
前端源码/uni-app/api/naming.ts
Normal file
350
前端源码/uni-app/api/naming.ts
Normal file
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
* @Author: caoziyuan ziyuan.cao@zhuying.com
|
||||
* @Date: 2026-01-14 09:43:15
|
||||
* @LastEditors: caoziyuan ziyuan.cao@zhuying.com
|
||||
* @LastEditTime: 2026-01-14 11:10:33
|
||||
* @FilePath: \uni-app\api\naming.ts
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
/**
|
||||
* 起名相关 API
|
||||
*/
|
||||
import { http } from '../utils/request';
|
||||
|
||||
/**
|
||||
* 起名/改名/测名返回的「方案 JSON」建议在根级包含五行生克与属相模块,字段约定见:
|
||||
* `utils/backend-wuxing-zodiac-spec.ts`(bazi_name_fit、wuxing_bagua、zodiac_sign)。
|
||||
* 生成提示词可用:`buildBackendWuxingZodiacPromptZh()`。
|
||||
*/
|
||||
export interface PersonalNamingRequest {
|
||||
last_name: string;
|
||||
gender: string;
|
||||
birth_date: string;
|
||||
birth_place: string;
|
||||
style_label: string;
|
||||
father_name?: string;
|
||||
father_birth_date?: string;
|
||||
mother_name?: string;
|
||||
mother_birth_date?: string;
|
||||
family_book?: string;
|
||||
}
|
||||
|
||||
export interface PersonalNamingResponse {
|
||||
report_id: number;
|
||||
status?: number;
|
||||
solutions?: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
pinyin?: string;
|
||||
tags?: string[];
|
||||
name_meaning?: string;
|
||||
poetry_source?: string;
|
||||
total_score?: number;
|
||||
wuxing?: string;
|
||||
zodiac?: string;
|
||||
constellation?: string;
|
||||
}>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface PersonalRenamingRequest {
|
||||
last_name: string;
|
||||
gender: string;
|
||||
birth_date: string;
|
||||
birth_place: string;
|
||||
style_label: string;
|
||||
father_name?: string;
|
||||
father_birth_date?: string;
|
||||
mother_name?: string;
|
||||
mother_birth_date?: string;
|
||||
family_book?: string;
|
||||
original_name: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人测名。建议后端同时接收:精确出生时辰、出生地/时区(若有),以便排出八字、喜用与生肖年柱;
|
||||
* 详见 `utils/backend-wuxing-zodiac-spec.ts` 中 RECOMMENDED_PERSONAL_REQUEST_FIELDS。
|
||||
*/
|
||||
export interface PersonalScoringRequest {
|
||||
surname: string;
|
||||
given_name: string;
|
||||
gender: string;
|
||||
birthday: string;
|
||||
}
|
||||
|
||||
// 公司起名核心成员
|
||||
export interface CompanyCoreMember {
|
||||
name: string;
|
||||
birthday: string; // 格式: 'YYYY-MM-DD HH:mm:ss'
|
||||
}
|
||||
|
||||
// 公司起名请求参数
|
||||
export interface CompanyNamingRequest {
|
||||
industry: string; // 行业,如 "科技"
|
||||
address: string; // 地址,如 "临沂"
|
||||
core_members: CompanyCoreMember[]; // 核心成员列表
|
||||
report_id?: number;
|
||||
}
|
||||
|
||||
export interface CompanyRenamingRequest {
|
||||
industry: string;
|
||||
address: string;
|
||||
core_members: CompanyCoreMember[];
|
||||
vision: string;
|
||||
preference: string;
|
||||
original_name: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface CompanyRenamingResponse {
|
||||
report_id: number;
|
||||
status?: number;
|
||||
solutions?: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
pinyin?: string;
|
||||
tags?: string[];
|
||||
name_meaning?: string;
|
||||
poetry_source?: string;
|
||||
total_score?: number;
|
||||
star_rating?: number;
|
||||
is_recommended?: number;
|
||||
}>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 公司起名响应 - request.ts 会解包,实际返回的是 data 部分
|
||||
export interface CompanyNamingResponse {
|
||||
report_id: number;
|
||||
status: number;
|
||||
solutions?: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
pinyin: string;
|
||||
wuxing: string;
|
||||
tags: string[];
|
||||
name_meaning: string;
|
||||
poetry_source: string;
|
||||
total_score: number;
|
||||
star_rating: number;
|
||||
is_recommended: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
// 方案详情响应 - request.ts 会解包,实际返回的是 data 部分
|
||||
export interface SolutionDetailResponse {
|
||||
id: number;
|
||||
report_id: number;
|
||||
name: string;
|
||||
pinyin: string;
|
||||
total_score: number;
|
||||
star_rating: number;
|
||||
wuxing: string;
|
||||
shuxiang: string | null;
|
||||
tags: string[];
|
||||
name_meaning: string;
|
||||
poetry_source: string;
|
||||
is_recommended: number;
|
||||
is_favorited: boolean;
|
||||
sections: Array<{
|
||||
id: number;
|
||||
section_type: string;
|
||||
title: string;
|
||||
summary_data: any;
|
||||
sort_order: number;
|
||||
details: Array<{
|
||||
id: number;
|
||||
detail_type: string;
|
||||
title: string;
|
||||
content: any;
|
||||
sort_order: number;
|
||||
}>;
|
||||
}>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 公司测名/企业运程(company_analysis)请求参数
|
||||
export interface CompanyAnalysisRequest {
|
||||
company_name: string;
|
||||
industry: string;
|
||||
address: string;
|
||||
target_audience: string;
|
||||
members: Array<{ name: string; birth_date: string }>; // 格式: 'YYYY-MM-DD HH:mm:ss'
|
||||
}
|
||||
|
||||
export interface CompanyScoringRequest {
|
||||
company_name: string;
|
||||
industry: string;
|
||||
address: string;
|
||||
target_audience: string;
|
||||
members: Array<{ name: string; birthday: string }>;
|
||||
}
|
||||
|
||||
export type CompanyAnalysisDetailNode =
|
||||
| { type: 'text'; text: string }
|
||||
| { type: 'list'; items: string[] }
|
||||
| { type: 'kv'; items: Array<{ label: string; value: string }> };
|
||||
|
||||
export interface CompanyAnalysisDetails {
|
||||
title: string;
|
||||
nodes: CompanyAnalysisDetailNode[];
|
||||
}
|
||||
|
||||
// 公司测名/企业运程(company_analysis)响应 - request.ts 会解包,实际返回的是 data 部分
|
||||
export interface CompanyAnalysisResponse {
|
||||
header: {
|
||||
name: string;
|
||||
tagLeft: string;
|
||||
tagRight: string;
|
||||
score: number;
|
||||
quote: string;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
characterAnalysis: {
|
||||
characters: Array<{ char: string; stroke: number; element: string; meaning: string }>;
|
||||
analysis: string;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
businessPattern: {
|
||||
radar: { labels: string[]; values: number[] };
|
||||
summary: Array<{ label: string; value: string }>;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
gua: {
|
||||
bg: string;
|
||||
name: string;
|
||||
badge: string;
|
||||
desc: string;
|
||||
tags: string[];
|
||||
insight: string;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
team: {
|
||||
members: Array<{ role: string; score: number; desc: string; match: string }>;
|
||||
note: string;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
years: {
|
||||
items: Array<{ year: string; luck: string; text: string }>;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
wealthTrend: {
|
||||
bars: number[];
|
||||
note: string;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
direction: {
|
||||
note: string;
|
||||
goodDot?: { x: number; y: number };
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
layout: {
|
||||
items: Array<{
|
||||
strong: string;
|
||||
textBefore: string;
|
||||
highlights?: string[];
|
||||
textAfter: string;
|
||||
}>;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
execution: {
|
||||
text: string;
|
||||
details?: CompanyAnalysisDetails;
|
||||
};
|
||||
}
|
||||
|
||||
export interface NewCompanyRenamingRequest {
|
||||
industry: string;
|
||||
address: string;
|
||||
core_members: CompanyCoreMember[];
|
||||
vision: string;
|
||||
preference: string;
|
||||
original_name: string;
|
||||
reason: string;
|
||||
additional_info: string;
|
||||
}
|
||||
|
||||
export interface NewCompanyRenamingResponse {
|
||||
report_id: number;
|
||||
status?: number;
|
||||
solutions?: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
pinyin?: string;
|
||||
tags?: string[];
|
||||
name_meaning?: string;
|
||||
poetry_source?: string;
|
||||
total_score?: number;
|
||||
star_rating?: number;
|
||||
is_recommended?: number;
|
||||
}>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export const namingApi = {
|
||||
personalNaming(params: PersonalNamingRequest): Promise<PersonalNamingResponse> {
|
||||
return http.post('/yifan_naming_reports/personal-naming', params);
|
||||
},
|
||||
|
||||
personalScoring(params: PersonalScoringRequest): Promise<any> {
|
||||
return http.post('/yifan_naming_reports/personal-scoring', params);
|
||||
},
|
||||
|
||||
personalScoringTrial(params: PersonalScoringRequest): Promise<any> {
|
||||
return http.post('/yifan_naming_reports/personal-scoring-trial', params);
|
||||
},
|
||||
|
||||
personalRenaming(params: PersonalRenamingRequest): Promise<PersonalNamingResponse> {
|
||||
return http.post('/yifan_naming_reports/personal-renaming', params);
|
||||
},
|
||||
|
||||
/**
|
||||
* 公司起名
|
||||
*/
|
||||
companyNaming(params: CompanyNamingRequest): Promise<CompanyNamingResponse> {
|
||||
return http.post('/yifan_naming_reports/company-naming', params);
|
||||
},
|
||||
|
||||
companyRenaming(params: CompanyRenamingRequest): Promise<CompanyRenamingResponse> {
|
||||
return http.post('/yifan_naming_reports/company-renaming', params);
|
||||
},
|
||||
|
||||
/**
|
||||
* 公司测名/企业运程
|
||||
*/
|
||||
companyAnalysis(params: CompanyAnalysisRequest): Promise<CompanyAnalysisResponse> {
|
||||
return http.post('/yifan_naming_reports/company-analysis', params);
|
||||
},
|
||||
|
||||
companyScoring(params: CompanyScoringRequest): Promise<any> {
|
||||
return http.post('/yifan_naming_reports/company-scoring', params);
|
||||
},
|
||||
|
||||
companyScoringTrial(params: CompanyScoringRequest): Promise<any> {
|
||||
return http.post('/yifan_naming_reports/company-scoring-trial', params);
|
||||
},
|
||||
|
||||
/**
|
||||
* 测名试用分享回调 - 好友通过分享链接进入小程序后,为分享者增加免费次数
|
||||
*/
|
||||
scoringTrialShareCallback(): Promise<any> {
|
||||
return http.post('/yifan_naming_reports/scoring-trial-share-callback');
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据方案ID获取详情
|
||||
* @param solutionId 方案ID
|
||||
*/
|
||||
getSolutionDetail(solutionId: number | string): Promise<SolutionDetailResponse> {
|
||||
return http.get(`/yifan_naming_solutions/full_detail/${solutionId}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据报告ID获取方案列表
|
||||
* @param reportId 报告ID
|
||||
*/
|
||||
getSolutionsByReportId(reportId: number | string): Promise<any> {
|
||||
return http.get(`/yifan_naming_reports/${reportId}/solutions`);
|
||||
},
|
||||
};
|
||||
25
前端源码/uni-app/api/payment.ts
Normal file
25
前端源码/uni-app/api/payment.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 支付相关接口
|
||||
*/
|
||||
import http from '@/utils/request';
|
||||
import type { CreateOrderParams, CreateOrderResponse, QueryOrderResponse, CloseOrderResponse, ListPayOrdersParams, ListPayOrdersResponse } from './types';
|
||||
|
||||
export const paymentApi = {
|
||||
// 创建支付订单
|
||||
createOrder: (params: CreateOrderParams) =>
|
||||
http.post<CreateOrderResponse>('/yifan_wx_pay/create-order', params, { showLoading: true }),
|
||||
|
||||
// 查询订单状态(使用路径参数)
|
||||
queryOrder: (out_trade_no: string) =>
|
||||
http.get<QueryOrderResponse>(`/yifan_wx_pay/query-order/${out_trade_no}`),
|
||||
|
||||
// 关闭订单(使用路径参数)
|
||||
closeOrder: (out_trade_no: string) =>
|
||||
http.post<CloseOrderResponse>(`/yifan_wx_pay/close-order/${out_trade_no}`, {}, { showLoading: true }),
|
||||
|
||||
// 获取支付订单列表
|
||||
listOrders: (params?: ListPayOrdersParams) =>
|
||||
http.get<ListPayOrdersResponse>('/yifan_wx_pay/list', params),
|
||||
};
|
||||
|
||||
export default paymentApi;
|
||||
842
前端源码/uni-app/api/types.ts
Normal file
842
前端源码/uni-app/api/types.ts
Normal file
@@ -0,0 +1,842 @@
|
||||
/**
|
||||
* 接口类型定义
|
||||
*/
|
||||
|
||||
// 首页滚动列表
|
||||
export interface ActivityDisplayItem {
|
||||
id: number;
|
||||
user_name: string;
|
||||
action: string;
|
||||
service_name: string;
|
||||
service_type?: string;
|
||||
sort_order?: number;
|
||||
}
|
||||
|
||||
// 万年历
|
||||
export interface CalendarToday {
|
||||
lunar: string; // 农历日期,如 "腊月 十二"
|
||||
year: string; // 年份,如 "甲辰年"
|
||||
solar: string; // 公历日期,如 "2024.01.22"
|
||||
yi: string[]; // 宜
|
||||
ji: string[]; // 忌
|
||||
}
|
||||
|
||||
// 黄历信息(接口返回)
|
||||
export interface CalendarInfo {
|
||||
lunar_day: string; // 农历日,如 "一"
|
||||
lunar_month: string; // 农历月,如 "正月"
|
||||
lunar_year: string; // 农历年,如 "丙午年"
|
||||
solar_date: string; // 公历日期,如 "2026.01.14"
|
||||
solar_year: number; // 公历年
|
||||
solar_month: number; // 公历月
|
||||
solar_day: number; // 公历日
|
||||
ganzhi_year: string; // 干支年,如 "丙午"
|
||||
ganzhi_month: string; // 干支月,如 "庚寅"
|
||||
ganzhi_day: string; // 干支日,如 "戊子"
|
||||
zodiac: string; // 生肖,如 "马"
|
||||
yi: string[]; // 宜
|
||||
ji: string[]; // 忌
|
||||
weekday: string; // 星期,如 "星期三"
|
||||
}
|
||||
|
||||
// 佳名赏析
|
||||
export interface GoodNameItem {
|
||||
id: number;
|
||||
name: string; // 名字
|
||||
source: string; // 出处
|
||||
desc: string; // 描述
|
||||
}
|
||||
|
||||
// 方案推荐(佳名赏析)
|
||||
export interface RecommendedSolution {
|
||||
id: number;
|
||||
name: string; // 名字
|
||||
pinyin?: string; // 拼音
|
||||
name_meaning?: string; // 寓意
|
||||
poetry_source?: string; // 诗词出处
|
||||
total_score?: number; // 总分
|
||||
star_rating?: number; // 星级
|
||||
wuxing?: string; // 五行
|
||||
shuxiang?: string; // 属相
|
||||
tags?: string[]; // 标签
|
||||
}
|
||||
|
||||
// 方案推荐分页响应
|
||||
export interface RecommendedSolutionResponse {
|
||||
total: number;
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
items: RecommendedSolution[];
|
||||
}
|
||||
|
||||
// 文字介绍(关于我们)
|
||||
export interface AboutUsInfo {
|
||||
id: number;
|
||||
title: string; // 标题,如 "壹梵缘起"
|
||||
content: string; // 内容,用 \n\n 分隔段落
|
||||
}
|
||||
|
||||
// 视频介绍
|
||||
export interface AboutVideoInfo {
|
||||
id: number;
|
||||
title: string; // 视频标题
|
||||
description?: string; // 视频描述
|
||||
video_url: string; // 视频地址
|
||||
cover_url?: string; // 封面图地址
|
||||
duration?: number; // 视频时长(秒)
|
||||
}
|
||||
|
||||
// 用户相关
|
||||
export interface UserInfo {
|
||||
id: string;
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
level: string;
|
||||
}
|
||||
|
||||
// 小程序登录
|
||||
export interface WxLoginParams {
|
||||
code: string; // 小程序wx.login()获取的code
|
||||
encryptedData?: string; // 手机号加密数据
|
||||
iv?: string; // 加密算法的初始向量
|
||||
parent_id?: string; // 邀请人ID(扫码/分享进入时可选)
|
||||
}
|
||||
|
||||
export interface WxLoginResponse {
|
||||
is_registered: boolean; // 是否已注册
|
||||
access_token: string | null;
|
||||
refresh_token: string | null;
|
||||
token_type: string | null;
|
||||
expires_in: number | null;
|
||||
openid: string;
|
||||
user_info: UserInfo | null;
|
||||
phone?: string; // 解密后的手机号
|
||||
}
|
||||
|
||||
// 小程序注册
|
||||
export interface WxRegisterParams {
|
||||
openid: string;
|
||||
name: string;
|
||||
avatar?: string;
|
||||
mobile?: string;
|
||||
parent_id?: string; // 邀请人ID
|
||||
}
|
||||
|
||||
export interface WxRegisterResponse {
|
||||
is_registered: boolean;
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
openid: string;
|
||||
user_info: UserInfo;
|
||||
}
|
||||
|
||||
// 小程序绑定
|
||||
export interface WxBindParams {
|
||||
openid: string; // 登录返回的openid
|
||||
username: string; // 已有账号用户名
|
||||
password: string; // 已有账号密码
|
||||
}
|
||||
|
||||
export interface WxBindResponse {
|
||||
is_registered: boolean;
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
openid: string;
|
||||
user_info: UserInfo;
|
||||
}
|
||||
|
||||
// 手机号密码注册
|
||||
export interface MobileRegisterParams {
|
||||
mobile: string; // 手机号
|
||||
password: string; // 密码
|
||||
repassword: string; // 确认密码
|
||||
verification_code: string; // 短信验证码
|
||||
inviter_id?: string; // 邀请人id
|
||||
}
|
||||
|
||||
export interface MobileRegisterResponse {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
user_info: UserInfo;
|
||||
}
|
||||
|
||||
// 手机号密码登录
|
||||
export interface MobileLoginParams {
|
||||
mobile: string; // 手机号
|
||||
password: string; // 密码
|
||||
inviter_id?: string; // 邀请人id
|
||||
}
|
||||
|
||||
export interface MobileLoginResponse {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
user_info: UserInfo;
|
||||
}
|
||||
|
||||
/** 当前用户修改用户名与手机号(PUT /api/v1/system/user/current/username-mobile) */
|
||||
export interface UpdateCurrentUserUsernameMobileParams {
|
||||
username: string;
|
||||
mobile: string;
|
||||
}
|
||||
|
||||
/** 成功时 data 可能为更新后的用户信息片段或 null */
|
||||
export type UpdateCurrentUserUsernameMobileResponse = Record<string, unknown> | null;
|
||||
|
||||
// 忘记密码
|
||||
export interface ForgotPasswordParams {
|
||||
mobile: string; // 手机号
|
||||
password: string; // 新密码
|
||||
repassword: string; // 确认密码
|
||||
verification_code: string; // 短信验证码
|
||||
}
|
||||
|
||||
export interface ForgotPasswordResponse {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
user_info: UserInfo;
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
export interface WxLogoutResponse {
|
||||
msg?: string;
|
||||
}
|
||||
// 起名相关
|
||||
export interface NamingParams {
|
||||
lastName: string;
|
||||
firstName?: string;
|
||||
gender: 'male' | 'female';
|
||||
birthDate: string;
|
||||
birthTime?: string;
|
||||
style?: string;
|
||||
}
|
||||
|
||||
export interface GeneratedNameItem {
|
||||
id: string;
|
||||
name: string;
|
||||
score: number;
|
||||
meaning: string;
|
||||
wuxing: string;
|
||||
zodiac: string;
|
||||
}
|
||||
|
||||
export interface NamingDetailResult {
|
||||
id: string;
|
||||
name: string;
|
||||
totalScore: number;
|
||||
meaningAnalysis: string;
|
||||
zodiacAnalysis: string;
|
||||
familyAnalysis: string;
|
||||
strokeAnalysis: string;
|
||||
sancaiAnalysis: string;
|
||||
personalityAnalysis: string;
|
||||
yijingAnalysis: string;
|
||||
luckyTips: {
|
||||
luckyColor: string;
|
||||
luckyNumber: string;
|
||||
suggestedIndustry: string;
|
||||
constellation: string;
|
||||
healthTips: string;
|
||||
};
|
||||
sixDimension: {
|
||||
career: number;
|
||||
wealth: number;
|
||||
health: number;
|
||||
love: number;
|
||||
wisdom: number;
|
||||
social: number;
|
||||
};
|
||||
lifeSimulation: Array<{ age: string; event: string }>;
|
||||
emotionalFortune: string;
|
||||
dailyTips: string[];
|
||||
avatarStyles: string[];
|
||||
poetrySource: string;
|
||||
}
|
||||
|
||||
// 测名相关
|
||||
export interface TestNameParams {
|
||||
lastName: string;
|
||||
firstName: string;
|
||||
gender: 'male' | 'female';
|
||||
birthDate: string;
|
||||
}
|
||||
|
||||
export interface TestNameResult {
|
||||
score: number;
|
||||
analysis: string;
|
||||
wuxing: string;
|
||||
sancai: string;
|
||||
suggestions: string[];
|
||||
}
|
||||
|
||||
/** 测名详解弹窗节点,与 TestNameDetail.vue 中 modal 渲染一致 */
|
||||
export type TestNameDetailNode =
|
||||
| { type: 'text'; text: string }
|
||||
| { type: 'list'; items: string[] }
|
||||
| { type: 'kv'; items: Array<{ label: string; value: string }> };
|
||||
|
||||
/**
|
||||
* 测名「详解」扩展模块(与 header、meaning_and_zodiac 等并列的同级字段)。
|
||||
* 个人:可放在 personalScoring 或方案详情 JSON 根级。
|
||||
* 商号:可放在 companyScoring / 商号详解同一 JSON 根级(CompanyNamingDetail 与个人测名字段名一致)。
|
||||
*/
|
||||
export interface TestNameDetailPhonetics {
|
||||
/** 完整拼音,如 "Zhāng Sān" */
|
||||
pinyin_full?: string;
|
||||
/** 声调与平仄简述,如 "阴平-阳平-上声" / "仄平平" */
|
||||
pingze?: string;
|
||||
/** 音律流畅度、朗朗上口等一句话 */
|
||||
rhythm_summary?: string;
|
||||
/** 简评 */
|
||||
judgement?: string;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
export interface TestNameDetailBaziNameFit {
|
||||
/** 八字喜用神简述 */
|
||||
xiyongshen?: string;
|
||||
/** 姓名五行组合简述 */
|
||||
name_wuxing_profile?: string;
|
||||
/** 是否补益、注意点等 */
|
||||
complement_summary?: string;
|
||||
/** 与八字契合度 0–100,可选 */
|
||||
fit_score?: number;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
export interface TestNameDetailNamePopularity {
|
||||
/** 重名率或重名风险的人文描述 */
|
||||
duplicate_rate_label?: string;
|
||||
/** 如:偏冷门 / 较为常见 / 高频重名 */
|
||||
popularity_tier?: string;
|
||||
interpretation?: string;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
/** 六爻(与本卦 gua 并列,可写动爻、纳甲等延展) */
|
||||
export interface TestNameDetailLiuyao {
|
||||
/** 卦名,如「火水未济」 */
|
||||
hexagram_title?: string;
|
||||
/** 动爻、变卦等一句话 */
|
||||
changing_summary?: string;
|
||||
/** 与姓名关联的断语摘要 */
|
||||
interpretation?: string;
|
||||
/** 六爻爻辞行,字符串数组,最多前端展示 6 条,详文放 details */
|
||||
yao_lines?: string[];
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
/** 五行八卦(姓名与五行、八卦关系) */
|
||||
export interface TestNameDetailWuxingBagua {
|
||||
/** 姓名五行态势简述 */
|
||||
wuxing_sketch?: string;
|
||||
/** 相关卦象、宫位等 */
|
||||
bagua_profile?: string;
|
||||
/** 生克互助简述 */
|
||||
mutual_sketch?: string;
|
||||
summary?: string;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
/** 属相(出生年生肖专项,可与 meaning_and_zodiac 并存) */
|
||||
export interface TestNameDetailZodiacSign {
|
||||
/** 生肖名,如「龙」 */
|
||||
animal?: string;
|
||||
/** 展示用图标或 emoji */
|
||||
animal_icon?: string;
|
||||
/** 地支,如「辰」 */
|
||||
earthly_branch?: string;
|
||||
trait_summary?: string;
|
||||
/** 与所测名字的生合冲刑等 */
|
||||
name_harmony?: string;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
/** 事业规划 */
|
||||
export interface TestNameDetailCareerPlan {
|
||||
summary?: string;
|
||||
milestones?: Array<{
|
||||
phase?: string;
|
||||
period?: string;
|
||||
focus?: string;
|
||||
advice?: string;
|
||||
}>;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
/** 幸运数字 */
|
||||
export interface TestNameDetailLuckyNumbers {
|
||||
/** 主推文案,如「3、8、9」 */
|
||||
primary?: string;
|
||||
/** 备选数字,与 primary 二选一或并存 */
|
||||
numbers?: Array<number | string>;
|
||||
meaning?: string;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
/** 幸运颜色 */
|
||||
export interface TestNameDetailLuckyColors {
|
||||
/** 主推色文案 */
|
||||
primary?: string;
|
||||
colors?: Array<{ name?: string; hex?: string; note?: string }>;
|
||||
meaning?: string;
|
||||
details?: { nodes: TestNameDetailNode[] };
|
||||
}
|
||||
|
||||
// 公司起名/测名
|
||||
export interface CompanyNamingParams {
|
||||
industry: string;
|
||||
address: string;
|
||||
targetAudience: string;
|
||||
members: Array<{ name: string; birthDate: string }>;
|
||||
}
|
||||
|
||||
// 择吉相关
|
||||
export interface AuspiciousParams {
|
||||
birthDate: string;
|
||||
birthTime: string;
|
||||
eventType: string;
|
||||
}
|
||||
|
||||
export interface AuspiciousResult {
|
||||
dates: Array<{
|
||||
date: string;
|
||||
lunar: string;
|
||||
score: number;
|
||||
suitable: string[];
|
||||
avoid: string[];
|
||||
}>;
|
||||
}
|
||||
|
||||
// 收藏相关
|
||||
export interface FavoriteItem {
|
||||
id: string;
|
||||
action: 'naming' | 'renaming';
|
||||
mode: 'personal' | 'company';
|
||||
title: string;
|
||||
subtitle: string;
|
||||
date: string;
|
||||
status: 'completed' | 'pending';
|
||||
}
|
||||
|
||||
// 报告相关
|
||||
export interface ReportItem {
|
||||
id: string;
|
||||
title: string;
|
||||
type: 'fortune' | 'naming' | 'renaming';
|
||||
date: string;
|
||||
price: string;
|
||||
}
|
||||
|
||||
// 支付相关
|
||||
export interface PaymentOrder {
|
||||
orderId: string;
|
||||
payParams: object;
|
||||
}
|
||||
|
||||
export interface OrderStatus {
|
||||
status: string;
|
||||
}
|
||||
|
||||
// 产品相关
|
||||
export interface Product {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
price: number;
|
||||
originalPrice?: number;
|
||||
image?: string;
|
||||
images?: string[];
|
||||
category?: string;
|
||||
categoryId?: string;
|
||||
tags?: string[];
|
||||
status: 'active' | 'inactive' | 'sold_out';
|
||||
stock?: number;
|
||||
salesCount?: number;
|
||||
rating?: number;
|
||||
reviewCount?: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
attributes?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface ProductCategory {
|
||||
id: string;
|
||||
name: string;
|
||||
parentId?: string;
|
||||
icon?: string;
|
||||
sortOrder?: number;
|
||||
children?: ProductCategory[];
|
||||
}
|
||||
|
||||
export interface ProductListParams {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
categoryId?: string;
|
||||
keyword?: string;
|
||||
minPrice?: number;
|
||||
maxPrice?: number;
|
||||
sortBy?: 'price' | 'sales' | 'rating' | 'created_at';
|
||||
sortOrder?: 'asc' | 'desc';
|
||||
status?: 'active' | 'inactive' | 'sold_out';
|
||||
}
|
||||
|
||||
export interface ProductListResponse {
|
||||
items: Product[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
export interface ProductDetail extends Product {
|
||||
content?: string;
|
||||
specifications?: Array<{ name: string; value: string }>;
|
||||
relatedProducts?: Product[];
|
||||
}
|
||||
|
||||
export interface ProductCreateParams {
|
||||
name: string;
|
||||
description?: string;
|
||||
price: number;
|
||||
originalPrice?: number;
|
||||
image?: string;
|
||||
images?: string[];
|
||||
categoryId?: string;
|
||||
tags?: string[];
|
||||
stock?: number;
|
||||
status?: 'active' | 'inactive';
|
||||
attributes?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface ProductUpdateParams extends Partial<ProductCreateParams> {
|
||||
id: string;
|
||||
}
|
||||
|
||||
|
||||
// 合伙人申请
|
||||
export interface PartnerApplyParams {
|
||||
real_name: string; // 真实姓名
|
||||
phone: string; // 手机号码
|
||||
wechat_id?: string; // 微信号(选填)
|
||||
member_level?: 'junior' | 'senior'; // 会员等级(初级/高级)
|
||||
}
|
||||
|
||||
export interface PartnerApplyResponse {
|
||||
id?: number;
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
// 会员折扣配置
|
||||
export interface MembershipDiscountConfigResponse {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 服务价格配置(起名/改名/每日运程/每月运程)
|
||||
export interface MembershipServicePriceConfigResponse {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 我的会员等级与额度
|
||||
export interface MyMembershipQuotaResponse {
|
||||
// 兼容后端可能返回的多种字段命名
|
||||
level?: string;
|
||||
membership_level?: string;
|
||||
level_name?: string;
|
||||
tier_name?: string;
|
||||
quota?: number;
|
||||
total_quota?: number;
|
||||
used_quota?: number;
|
||||
remain_quota?: number;
|
||||
remaining_quota?: number;
|
||||
left_quota?: number;
|
||||
/** 剩余免费改名等额度(后端约定字段) */
|
||||
free_rename_quota?: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
||||
// 我的方案
|
||||
export interface MyReportsParams {
|
||||
page_no?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export interface MyReportItem {
|
||||
id: number;
|
||||
title: string; // 标题
|
||||
subtitle: string; // 副标题
|
||||
category: string; // 类型:personal/company
|
||||
service_type: string; // 服务类型:naming/renaming/test
|
||||
has_solutions: boolean; // 是否有方案
|
||||
created_time: string; // 创建时间
|
||||
relative_time: string; // 相对时间
|
||||
}
|
||||
|
||||
export interface MyReportsResponse {
|
||||
total: number;
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
items: MyReportItem[];
|
||||
}
|
||||
|
||||
|
||||
// 方案详情
|
||||
export interface SolutionFullDetail {
|
||||
id: number;
|
||||
name: string; // 名字
|
||||
pinyin?: string; // 拼音
|
||||
gender?: string; // 性别
|
||||
birth_date?: string; // 出生日期
|
||||
birth_time?: string; // 出生时间
|
||||
lunar_date?: string; // 农历日期
|
||||
total_score?: number; // 总分
|
||||
star_rating?: number; // 星级
|
||||
name_meaning?: string; // 名字寓意
|
||||
poetry_source?: string; // 诗词出处
|
||||
wuxing_analysis?: string; // 五行分析
|
||||
zodiac_analysis?: string; // 生肖分析
|
||||
sancai_analysis?: string; // 三才分析
|
||||
stroke_analysis?: string; // 笔画分析
|
||||
six_dimension?: { // 六维评分
|
||||
career: number;
|
||||
wealth: number;
|
||||
health: number;
|
||||
love: number;
|
||||
wisdom: number;
|
||||
social: number;
|
||||
};
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
|
||||
// 我的收藏
|
||||
export interface MyFavoritesParams {
|
||||
page_no?: number;
|
||||
page_size?: number;
|
||||
category?: 'personal' | 'company'; // 可选,personal=个人名,company=商号,不传查全部
|
||||
}
|
||||
|
||||
export interface MyFavoriteItem {
|
||||
id: number;
|
||||
name: string; // 名字
|
||||
pinyin?: string; // 拼音
|
||||
category: string; // 类型:personal/company
|
||||
created_time: string; // 收藏时间
|
||||
solution_id?: number; // 方案ID
|
||||
tags?: string[]; // 标签
|
||||
}
|
||||
|
||||
export interface MyFavoritesResponse {
|
||||
total: number;
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
items: MyFavoriteItem[];
|
||||
}
|
||||
|
||||
// 添加/取消收藏
|
||||
export interface ToggleFavoriteParams {
|
||||
solution_id: number; // 方案ID
|
||||
}
|
||||
|
||||
export interface ToggleFavoriteResponse {
|
||||
is_favorited: boolean; // 收藏状态
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
// 收藏方案
|
||||
export interface FavoriteSolutionParams {
|
||||
solution_id: number;
|
||||
category: 'personal' | 'company';
|
||||
}
|
||||
|
||||
export interface FavoriteSolutionResponse {
|
||||
is_favorited?: boolean;
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
// 取消收藏
|
||||
export interface UnfavoriteSolutionParams {
|
||||
solution_id: number;
|
||||
}
|
||||
|
||||
export interface UnfavoriteSolutionResponse {
|
||||
is_favorited?: boolean;
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
// 常见问题
|
||||
export interface FAQItem {
|
||||
id: number;
|
||||
question: string; // 问题
|
||||
answer: string; // 答案
|
||||
is_hot: number; // 是否热门 (1=是, 0=否)
|
||||
}
|
||||
|
||||
export interface FAQGroup {
|
||||
category: string; // 分类标识
|
||||
category_name: string; // 分类名称
|
||||
items: FAQItem[]; // 问题列表
|
||||
}
|
||||
|
||||
export interface FAQResponse {
|
||||
data: FAQGroup[]; // 分组列表(注意:返回的是data数组,不是groups)
|
||||
}
|
||||
|
||||
// 隐私政策
|
||||
export interface PrivacyPolicyResponse {
|
||||
id: number;
|
||||
title: string; // 标题
|
||||
content: string; // 内容(HTML或Markdown格式)
|
||||
version: string; // 版本号
|
||||
effective_date: string; // 生效日期
|
||||
updated_at: string; // 更新时间
|
||||
}
|
||||
|
||||
// 意见反馈
|
||||
export interface FeedbackParams {
|
||||
content: string; // 反馈内容(必填)
|
||||
images?: string; // 图片URL,多个用逗号分隔(可选)
|
||||
contact?: string; // 联系方式(可选)
|
||||
feedback_type?: 'suggestion' | 'bug' | 'complaint' | 'other'; // 反馈类型(默认other)
|
||||
}
|
||||
|
||||
export interface FeedbackResponse {
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
// 生成小程序码
|
||||
export interface GenerateQRCodeParams {
|
||||
scene: string; // 场景值,最大32个字符,格式如 "uid=123"
|
||||
page?: string; // 跳转页面路径,默认为首页
|
||||
width?: number; // 二维码宽度,默认430px
|
||||
auto_color?: boolean; // 自动配置线条颜色
|
||||
line_color?: { // 线条颜色
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
};
|
||||
is_hyaline?: boolean; // 是否需要透明底色
|
||||
}
|
||||
|
||||
export interface GenerateQRCodeResponse {
|
||||
qrcode_url: string; // 生成的小程序码图片URL
|
||||
}
|
||||
|
||||
// 微信支付
|
||||
export interface CreateOrderParams {
|
||||
description: string; // 商品描述
|
||||
total_amount: number; // 支付金额(分)
|
||||
business_type: 'company_naming' | 'company_renaming' | 'company_name_analysis' | 'personal_naming' | 'personal_renaming' | 'personal_name_analysis' | 'wealth_analysis' | 'affinity_unlock' | 'partner_apply'; // 业务类型
|
||||
business_id: number; // 业务ID - 用于关联具体的业务记录
|
||||
pay_type: string; // 支付方式,固定为jsapi
|
||||
code?: string; // 用户code,若用户未绑定微信需要传递code信息
|
||||
}
|
||||
|
||||
export interface CreateOrderResponse {
|
||||
out_trade_no: string; // 商户订单号
|
||||
prepay_id: string; // 预支付交易会话标识
|
||||
pay_type: string; // 支付方式
|
||||
h5_url: string | null; // H5支付链接
|
||||
appId: string; // 公众号appId
|
||||
timeStamp: string; // 时间戳
|
||||
nonceStr: string; // 随机字符串
|
||||
package: string; // prepay_id=xxx
|
||||
signType: string; // 签名类型
|
||||
paySign: string; // 签名
|
||||
payment_params?: { // 兼容旧结构
|
||||
appId?: string;
|
||||
timeStamp: string;
|
||||
nonceStr: string;
|
||||
package: string;
|
||||
signType: string;
|
||||
paySign: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface QueryOrderParams {
|
||||
out_trade_no: string; // 商户订单号
|
||||
}
|
||||
|
||||
export interface QueryOrderResponse {
|
||||
out_trade_no: string; // 商户订单号
|
||||
transaction_id?: string; // 微信支付订单号
|
||||
status: 'pending' | 'paid' | 'cancelled' | 'refunded'; // 订单状态
|
||||
total_amount: number; // 支付金额
|
||||
paid_amount?: number; // 实付金额
|
||||
paid_at?: string; // 支付时间
|
||||
business_type: string; // 业务类型
|
||||
business_id: number; // 业务ID
|
||||
description?: string; // 商品描述
|
||||
}
|
||||
|
||||
// 支付订单列表
|
||||
export interface ListPayOrdersParams {
|
||||
page_no?: number | string;
|
||||
page_size?: number | string;
|
||||
}
|
||||
|
||||
export interface ListPayOrdersItem {
|
||||
id: number;
|
||||
out_trade_no: string;
|
||||
transaction_id?: string;
|
||||
description?: string;
|
||||
total_amount: number;
|
||||
business_type: string;
|
||||
trade_state: 'NOTPAY' | 'SUCCESS' | 'REFUND' | 'CLOSED' | string;
|
||||
success_time?: string;
|
||||
}
|
||||
|
||||
export interface ListPayOrdersResponse {
|
||||
total: number;
|
||||
items: ListPayOrdersItem[];
|
||||
}
|
||||
|
||||
// 关闭订单
|
||||
export interface CloseOrderResponse {
|
||||
msg?: string;
|
||||
}
|
||||
|
||||
// 上传图片
|
||||
export interface UploadImageResponse {
|
||||
file_path: string; // 文件路径
|
||||
file_name: string; // 文件名
|
||||
origin_name: string; // 原始文件名
|
||||
file_url: string; // 图片URL(用于回显和上传)
|
||||
}
|
||||
|
||||
// 消息轮播
|
||||
export interface NoticeItem {
|
||||
id: number;
|
||||
uuid?: string;
|
||||
notice_title: string; // 消息标题
|
||||
notice_type: string; // 消息类型
|
||||
notice_content: string; // 消息内容
|
||||
status?: string;
|
||||
description?: string;
|
||||
created_time?: string;
|
||||
updated_time?: string;
|
||||
}
|
||||
|
||||
export interface NoticeListParams {
|
||||
page_no?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export interface NoticeListResponse {
|
||||
total: number;
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
has_next: boolean;
|
||||
items: NoticeItem[];
|
||||
}
|
||||
167
前端源码/uni-app/api/user.ts
Normal file
167
前端源码/uni-app/api/user.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* 用户相关接口
|
||||
*/
|
||||
import http, { BASE_URL, type RequestConfig } from '@/utils/request';
|
||||
import type { WxLoginParams, WxLoginResponse, WxRegisterParams, WxRegisterResponse, WxBindParams, WxBindResponse, MobileRegisterParams, MobileRegisterResponse, MobileLoginParams, MobileLoginResponse, ForgotPasswordParams, ForgotPasswordResponse, WxLogoutResponse, PartnerApplyParams, PartnerApplyResponse, MembershipDiscountConfigResponse, MembershipServicePriceConfigResponse, MyMembershipQuotaResponse, MyReportsParams, MyReportsResponse, SolutionFullDetail, MyFavoritesParams, MyFavoritesResponse, ToggleFavoriteParams, ToggleFavoriteResponse, FavoriteSolutionParams, FavoriteSolutionResponse, UnfavoriteSolutionParams, UnfavoriteSolutionResponse, FAQResponse, PrivacyPolicyResponse, FeedbackParams, FeedbackResponse, GenerateQRCodeResponse, UploadImageResponse, UpdateCurrentUserUsernameMobileParams, UpdateCurrentUserUsernameMobileResponse } from './types';
|
||||
|
||||
/** 与 yifan 同域下的 system 模块接口根路径 */
|
||||
const systemApiBaseUrl = () => String(BASE_URL || '').replace(/\/yifan\/?$/, '/system');
|
||||
|
||||
export const userApi = {
|
||||
// 发送手机短信验证码
|
||||
sendSmsCode: (mobile: string) =>
|
||||
http.post<{ code: number; msg: string; data: any }>('/yifan_wx_auth/send-sms', { mobile }, { showLoading: true }),
|
||||
|
||||
// 手机号密码注册
|
||||
mobileRegister: (params: MobileRegisterParams) =>
|
||||
http.post<MobileRegisterResponse>('/yifan_wx_auth/mobile-register', params, { showLoading: true }),
|
||||
|
||||
// 手机号密码登录
|
||||
mobileLogin: (params: MobileLoginParams) =>
|
||||
http.post<MobileLoginResponse>('/yifan_wx_auth/mobile-login', params, { showLoading: true }),
|
||||
|
||||
// 忘记密码
|
||||
forgotPassword: (params: ForgotPasswordParams) =>
|
||||
http.post<ForgotPasswordResponse>('/yifan_wx_auth/forgot-password', params, { showLoading: true }),
|
||||
|
||||
// 小程序登录
|
||||
wxLogin: (params: WxLoginParams) =>
|
||||
http.post<WxLoginResponse>('/yifan_wx_auth/login', params, { showLoading: true, timeout: 9999999 }),
|
||||
|
||||
// 小程序注册(超时时间设置为30秒)
|
||||
wxRegister: (params: WxRegisterParams) =>
|
||||
http.post<WxRegisterResponse>('/yifan_wx_auth/register', params, { showLoading: true, timeout: 30000 }),
|
||||
|
||||
// 小程序绑定
|
||||
wxBind: (params: WxBindParams) =>
|
||||
http.post<WxBindResponse>('/yifan_wx_auth/bind', params, { showLoading: true }),
|
||||
|
||||
// 退出登录
|
||||
wxLogout: () =>
|
||||
http.post<WxLogoutResponse>('/yifan_wx_auth/logout', {}, { showLoading: true }),
|
||||
|
||||
// 申请成为合伙人
|
||||
applyPartner: (params: PartnerApplyParams) =>
|
||||
http.post<PartnerApplyResponse>('/yifan_partner_apply/apply', params, { showLoading: true }),
|
||||
|
||||
// 我的会员等级与额度
|
||||
getMyMembershipQuota: (options?: Partial<RequestConfig>) =>
|
||||
http.get<MyMembershipQuotaResponse>('/yifan_membership/my-quota', undefined, options),
|
||||
|
||||
// 获取会员折扣配置(初级会员/高级会员)
|
||||
getMembershipDiscountConfig: (options?: Partial<RequestConfig>) =>
|
||||
http.get<MembershipDiscountConfigResponse>('/yifan_membership/discount-config', undefined, options),
|
||||
|
||||
// 获取服务价格配置(起名/改名/每日运程/每月运程)
|
||||
getMembershipServicePriceConfig: (options?: Partial<RequestConfig>) =>
|
||||
http.get<MembershipServicePriceConfigResponse>('/yifan_membership/service-price-config', undefined, options),
|
||||
|
||||
// 修改当前用户用户名与手机号(成功后仅前端合并缓存,不因本接口误清 token/userInfo)
|
||||
updateCurrentUserUsernameMobile: (params: UpdateCurrentUserUsernameMobileParams) =>
|
||||
http.put<UpdateCurrentUserUsernameMobileResponse>(
|
||||
`${systemApiBaseUrl()}/user/current/username-mobile`,
|
||||
params,
|
||||
{ showLoading: true, clearAuthOnError: false }
|
||||
),
|
||||
|
||||
// 我的方案
|
||||
getMyReports: (params?: MyReportsParams, options?: Partial<RequestConfig>) =>
|
||||
http.get<MyReportsResponse>('/yifan_naming_reports/my_reports', params, options),
|
||||
|
||||
// 根据方案id获取详情
|
||||
getSolutionDetail: (id: number) =>
|
||||
http.get<SolutionFullDetail>(`/yifan_naming_solutions/full_detail/${id}`),
|
||||
|
||||
// 我的收藏
|
||||
getMyFavorites: (params?: MyFavoritesParams, options?: Partial<RequestConfig>) =>
|
||||
http.get<MyFavoritesResponse>('/yifan_naming_favorites/my_favorites', params, options),
|
||||
|
||||
// 添加/取消收藏
|
||||
toggleFavorite: (params: ToggleFavoriteParams) =>
|
||||
http.post<ToggleFavoriteResponse>('/yifan_naming_favorites/toggle', params, { showLoading: true }),
|
||||
|
||||
// 收藏方案
|
||||
favoriteSolution: (params: FavoriteSolutionParams) =>
|
||||
http.post<FavoriteSolutionResponse>('/yifan_naming_favorites/favorite', params, { showLoading: true }),
|
||||
|
||||
// 取消收藏
|
||||
unfavoriteSolution: (params: UnfavoriteSolutionParams) =>
|
||||
http.post<UnfavoriteSolutionResponse>('/yifan_naming_favorites/unfavorite', params, { showLoading: true }),
|
||||
|
||||
// 获取常见问题
|
||||
getFAQ: () =>
|
||||
http.get<FAQResponse>('/yifan_faq/mini/grouped'),
|
||||
|
||||
// 获取隐私政策
|
||||
getPrivacyPolicy: () =>
|
||||
http.get<PrivacyPolicyResponse>('/yifan_privacy_policy/mini/current'),
|
||||
|
||||
// 提交意见反馈
|
||||
submitFeedback: (params: FeedbackParams) =>
|
||||
http.post<FeedbackResponse>('/yifan_feedback/mini/submit', params, { showLoading: true }),
|
||||
|
||||
// 生成分享二维码(小程序码)
|
||||
generateShareQRCode: () =>
|
||||
http.post<GenerateQRCodeResponse>('/yifan_wx_auth/generate-qrcode', {}, { showLoading: true }),
|
||||
|
||||
// 上传图片 (H5 版本)
|
||||
uploadImage: async (file: File): Promise<UploadImageResponse> => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('base_url', BASE_URL);
|
||||
|
||||
try {
|
||||
const response = await http.post<UploadImageResponse>(
|
||||
'/yifan_wx_auth/upload-image',
|
||||
formData,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
showLoading: true
|
||||
}
|
||||
);
|
||||
return response;
|
||||
} catch (error: any) {
|
||||
throw new Error(error.msg || '上传失败');
|
||||
}
|
||||
},
|
||||
|
||||
// 选择并上传图片(H5 版本)
|
||||
chooseAndUploadImage: (options?: { count?: number; accept?: string }): Promise<UploadImageResponse[]> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = options?.accept || 'image/*';
|
||||
input.multiple = (options?.count || 1) > 1;
|
||||
|
||||
input.onchange = async (e: Event) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
const files = target.files;
|
||||
|
||||
if (!files || files.length === 0) {
|
||||
reject(new Error('未选择文件'));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const results: UploadImageResponse[] = [];
|
||||
const maxCount = options?.count || 1;
|
||||
const filesToUpload = Array.from(files).slice(0, maxCount);
|
||||
|
||||
for (const file of filesToUpload) {
|
||||
const result = await userApi.uploadImage(file);
|
||||
results.push(result);
|
||||
}
|
||||
resolve(results);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
|
||||
input.click();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default userApi;
|
||||
Reference in New Issue
Block a user