2025-10-21 19:37:39 +08:00

108 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 建行生活 API 接口
*
* @author Billy
* @date 2025-01-17
*/
import request from '@/sheep/request';
const ccbApi = {
/**
* URL跳转登录
* 建行App会携带加密参数跳转到此地址
*/
login: (params) => {
return request({
url: 'ccblife/login',
method: 'GET',
params: params,
custom: {
showLoading: true,
auth: false
}
});
},
/**
* 自动登录JSBridge方式
* H5在建行App内打开时通过JSBridge获取用户信息后调用
*/
autoLogin: (data) => {
return request({
url: 'ccblife/autoLogin',
method: 'POST',
data: data,
custom: {
showLoading: true,
auth: false
}
});
},
/**
* 生成支付串
* 用于调起建行收银台
*/
createPayment: (orderId) => {
console.log('[建行API] 调用createPayment接口, order_id:', orderId);
return request({
url: 'ccbpayment/createPayment',
method: 'POST',
data: {
order_id: orderId
},
custom: {
showLoading: true,
auth: true
}
}).then(res => {
console.log('[建行API] createPayment响应:', res);
return res;
}).catch(err => {
console.error('[建行API] createPayment错误:', err);
return err;
});
},
/**
* 查询订单支付状态 (轮询用)
*
* ⚠️ 重要: 本接口只查询状态,不更新订单!
* 订单状态由建行异步通知(notify)接口更新。
*
* @deprecated paymentCallback已废弃,改用本方法
*/
queryPaymentStatus: (orderId) => {
return request({
url: 'ccbpayment/queryPaymentStatus',
method: 'GET',
params: {
order_id: orderId
},
custom: {
showLoading: false,
auth: true
}
});
},
/**
* @deprecated 2025-01-20 该方法存在安全漏洞,已废弃
* @see queryPaymentStatus
*/
paymentCallback: (data) => {
// 向后兼容:调用查询接口
return request({
url: 'ccbpayment/callback',
method: 'POST',
data: data,
custom: {
showLoading: false,
auth: true
}
});
}
};
export default ccbApi;