1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
export type ApiEnvironment = 'development' | 'staging' | 'production'
 
// 开发环境地址在运行时解析(见 config/development-server.uts),所以这里必须是 import。
import { developmentApiBaseUrl } from './development-server.uts'
 
// 切换环境时只修改这里;页面和业务服务不得自行拼接后台域名。
// 2026-09-29:体验版指向攀枝花测试环境。本机联调改回 'development';生产上线改 'production'。
export const apiEnvironment: ApiEnvironment = 'staging'
 
// Keep the business pages accessible while merchant APIs are still being integrated.
// This flag is ignored outside the development environment.
export const skipMerchantLoginInDevelopment = false
 
// Toggle homepage mock metrics independently from the login bypass.
// When disabled, the dashboard requests the authenticated merchant summary API.
export const useDashboardDemoDataInDevelopment = false
 
// Toggle merchant-center, product, and business-hour demo data independently from login bypass and dashboard demo data.
export const useMerchantManagementDemoDataInDevelopment = false
 
// 后台提供微信小程序合法 HTTPS 域名后,在对应环境填写完整基础地址。
// 开发环境地址由 development-server.uts 在启动时自动探测本机局域网 IP,换网后不需要改代码;
// 本机 IP 会变(见过 192.168.110.26 与 192.168.110.15),写死会表现成"登录不上"。
// 必须与微信后台「开发管理 → 服务器域名」里配的完全一致(不带端口时,请求 URL 也不能带端口)。
const stagingBaseUrl = 'https://rencaika.dqrcfwpt.com'
const productionBaseUrl = ''
 
export const getApiBaseUrl = (): string => {
    if (apiEnvironment == 'production') return productionBaseUrl
    if (apiEnvironment == 'staging') return stagingBaseUrl
    // 每次都现取值:探测是异步完成的,提前取会把启动瞬间的兜底值固化住。
    return developmentApiBaseUrl()
}
 
export const isApiConfigured = (): boolean => getApiBaseUrl().trim().length > 0
 
// 接口路径集中维护,后台路径调整时不需要修改页面。
export const getApiEndpoint = (name: string): string => {
    if (name == 'authLogin') return '/api/merchant/auth/login'
    if (name == 'authRefresh') return '/api/merchant/auth/refresh'
    if (name == 'authLogout') return '/api/merchant/auth/logout'
    if (name == 'merchantAgreement') return '/api/merchant/legal/agreements/'
    if (name == 'merchantDashboard') return '/api/merchant/dashboard/summary'
    if (name == 'merchantBusinessDate') return '/api/merchant/system/business-date'
 
    if (name == 'merchantProfile') return '/api/merchant/profile'
    if (name == 'merchantBusinessStatus') return '/api/merchant/business-status'
    if (name == 'merchantBusinessHours') return '/api/merchant/business-hours'
    if (name == 'merchantProducts') return '/api/merchant/products'
    if (name == 'merchantBenefits') return '/api/merchant/benefits'
    if (name == 'merchantUploadImage') return '/api/merchant/uploads/images'
    if (name == 'merchantOrders') return '/api/merchant/orders'
    if (name == 'merchantOrderDetail') return '/api/merchant/orders/'
    if (name == 'merchantOrderVerify') return '/api/merchant/orders/'
    if (name == 'merchantSettlementStatistics') return '/api/merchant/settlement-statistics'
    if (name == 'verificationScan') return '/api/merchant/verification/scan'
    if (name == 'verificationNumericConfirm') return '/api/merchant/verification/numeric/confirm'
    if (name == 'verificationConfirm') return '/api/merchant/verification/free-stay/confirm'
    if (name == 'verificationFreeStayConfirm') return '/api/merchant/verification/free-stay/confirm'
    if (name == 'benefitVerificationVerify') return '/api/merchant/benefit-verifications/verify'
    if (name == 'manualConsumption') return '/api/merchant/manual-consumptions'
    if (name == 'manualConsumptionQuote') return '/api/merchant/manual-consumptions/quote'
    if (name == 'orderRevokeVerification') return '/api/merchant/orders/revoke-verification'
    if (name == 'merchantOnboardingStatus') return '/api/merchant/onboarding/status'
    if (name == 'merchantOnboarding') return '/api/merchant/onboarding'
    if (name == 'merchantPaymentReadiness') return '/api/merchant/payment-readiness'
    if (name == 'merchantPaymentReadinessVerify') return '/api/merchant/payment-readiness/verify'
    if (name == 'merchantBankCards') return '/api/merchant/bank-cards'
    if (name == 'merchantBankBranches') return '/api/merchant/bank-branches'
    return ''
}