ts_aimz_uni/common/js/net/payApi.js

58 lines
2.0 KiB
JavaScript
Raw Normal View History

2025-04-17 17:44:39 +08:00
import {
request
} from './http.js'
// 公共API
const apiPath = {
getBuyPackageList: '/api/proj/servicepkg/packageinfo/listpage/${type}/self', //获取可以购买的套餐包列表
getPayOrder: '/api/pay/get-pay', //获取支付订单
enterprisePay: '/api/pay/pay-account-recharge/${accountRechargeId}', //企业付款完成支付
enterpriseAccountInfo: '/api/pay/get-pay-system-bank', //获取公司账户信息
2025-06-24 14:08:30 +08:00
wxPayParams: '/api/accountrecharge/save-wx-pay-prepay-id', //获取微信支付所需参数 rechargeMoney金额 packageInfoId套餐包ID
bdPayParams: '/api/accountrecharge/save-bd-pay-order-info'
2025-04-17 17:44:39 +08:00
}
2025-06-24 14:08:30 +08:00
const proName = 'operator'
2025-04-17 17:44:39 +08:00
class PayApi {
2025-06-24 14:08:30 +08:00
// 通用路径参数替换方法
static #replacePathParams(path, params) {
return Object.entries(params).reduce(
(acc, [key, value]) => acc.replace(`{${key}}`, value),
path
)
}
// 通用请求方法
static requestHandler(endpoint, method, data = null, pathParams = {}) {
const path = Object.keys(pathParams).length ?
this.#replacePathParams(endpoint, pathParams) :
endpoint
return request(path, method, data, proName)
}
2025-04-17 17:44:39 +08:00
static doGetBuyPackageList(type, data) {
const path = apiPath.getBuyPackageList.replace('${type}', type);
return request(path, "GET", data);
}
//对公转账完成
static doCompleteEnterprisePay(url, data) {
const path = apiPath.enterprisePay.replace('${accountRechargeId}', url)
return request(path, "POST", data)
}
//获取账户信息
static doGetEnterpriseAccountInfo() {
return request(apiPath.enterpriseAccountInfo, "GET")
}
//获取订单
static doGetOrder(data) {
return request(apiPath.getPayOrder, "POST", data)
}
2025-06-24 14:08:30 +08:00
// 获取微信支付参数
2025-04-17 17:44:39 +08:00
static doGetWxPayParams(data) {
2025-06-24 14:08:30 +08:00
return this.requestHandler(apiPath.wxPayParams, "POST", data);
}
// 获取百度支付参数
static doGetBdPayParams(data) {
return this.requestHandler(apiPath.bdPayParams, "POST", data);
2025-04-17 17:44:39 +08:00
}
}
2025-04-16 16:15:41 +08:00
export default PayApi;