feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -7,23 +7,10 @@ import {
|
||||
normalizeEarningWithdrawalPayload
|
||||
} from './earning-contract.js'
|
||||
import { normalizeResourcePathId } from './request-normalizers.js'
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
createRequestError,
|
||||
requestStrict
|
||||
} from './request-client.js'
|
||||
|
||||
const requireRemoteEarning = (label, operation) => {
|
||||
if (hasRemoteConfig()) return
|
||||
throw createRequestError(
|
||||
`${label}${operation}需要真实服务,当前本地预览不会伪造结果`,
|
||||
operation === '读取' ? 'REMOTE_READ_REQUIRED' : 'REMOTE_WRITE_REQUIRED'
|
||||
)
|
||||
}
|
||||
import { requestStrict } from './request-client.js'
|
||||
|
||||
export const earningApi = {
|
||||
async getEarningSummary(requestOptions = {}) {
|
||||
requireRemoteEarning('收益汇总', '读取')
|
||||
const earningSummary = await requestStrict({
|
||||
url: '/genealogy/app/earnings/summary',
|
||||
method: 'GET'
|
||||
@@ -34,7 +21,6 @@ export const earningApi = {
|
||||
},
|
||||
|
||||
async getEarningLedgerPage(query = {}, requestOptions = {}) {
|
||||
requireRemoteEarning('收益明细', '读取')
|
||||
const ledgerPage = await requestStrict({
|
||||
url: '/genealogy/app/earnings/ledger',
|
||||
method: 'GET',
|
||||
@@ -47,7 +33,6 @@ export const earningApi = {
|
||||
},
|
||||
|
||||
async getEarningWithdrawalPage(query = {}, requestOptions = {}) {
|
||||
requireRemoteEarning('提现记录', '读取')
|
||||
const withdrawalPage = await requestStrict({
|
||||
url: '/genealogy/app/earnings/withdrawals',
|
||||
method: 'GET',
|
||||
@@ -60,7 +45,6 @@ export const earningApi = {
|
||||
},
|
||||
|
||||
async requestEarningWithdrawal(payload, requestOptions = {}) {
|
||||
requireRemoteEarning('提现申请', '写入')
|
||||
const withdrawal = await requestStrict({
|
||||
url: '/genealogy/app/earnings/withdrawals',
|
||||
method: 'POST',
|
||||
@@ -73,7 +57,6 @@ export const earningApi = {
|
||||
|
||||
async cancelEarningWithdrawal(withdrawalId, requestOptions = {}) {
|
||||
const normalizedWithdrawalId = normalizeResourcePathId(withdrawalId, '提现记录标识')
|
||||
requireRemoteEarning('取消提现', '写入')
|
||||
const withdrawal = await requestStrict({
|
||||
url: `/genealogy/app/earnings/withdrawals/${normalizedWithdrawalId}/cancel`,
|
||||
method: 'POST'
|
||||
|
||||
Reference in New Issue
Block a user