wallet.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { get, post, postL } from './http';
  2. const apis = {
  3. PRE_ONE_KEY: '/api/substituteOrder/preOneKeySubmit',
  4. COUPON: '/api/coupon/pageMyValidCoupon',
  5. BILL: '/api/wallet/bill',
  6. WITHDRAW_PRE: '/api/wallet/withdrawPre',
  7. WITHDRAW: '/api/wallet/withdraw',
  8. WITHDRAW_INFO: '/api/user/withdraw/info', // Bank info
  9. WITHDRAW_SAVE: '/api/user/withdraw/save',
  10. RECHARGE_GENERATE_LINK: '/api/user/recharge/generatePaymentLink',
  11. RECHARGE_CHECK_PAYMENT_STATUS: '/api/user/recharge/checkPaymentStatus',
  12. INFO: '/api/wallet/getByType',
  13. NEW_USER_PROMOTION: '/api/activity/newUserPromotion',
  14. };
  15. export const preOneKeySubmit = async () => {
  16. const res = await post(apis.PRE_ONE_KEY);
  17. return res;
  18. };
  19. export const info = async (type: string, loading = false) => {
  20. // loading handled manually if needed, or pass header
  21. const res = await get(apis.INFO, { type }, { loading });
  22. return res.data;
  23. };
  24. export const bill = async (current: number, size: number, walletType: string, type: string) => {
  25. const res = await post(apis.BILL, { current, size, walletType, type });
  26. return res.data;
  27. };
  28. export const withdrawPre = async (type: string, walletType: string) => {
  29. const res = await get(apis.WITHDRAW_PRE, { type, walletType });
  30. return res.data;
  31. };
  32. export const getWithdraw = async () => {
  33. const res = await get(apis.WITHDRAW_INFO);
  34. return res.data;
  35. };
  36. export const saveWithdraw = async (data: any) => {
  37. const res = await post(apis.WITHDRAW_SAVE, data);
  38. return res.success;
  39. };
  40. export const withdraw = async (data: any) => {
  41. const res = await postL(apis.WITHDRAW, data);
  42. return res.success;
  43. };
  44. export const generatePaymentLink = async (amount: number, payType: string, walletType: string) => {
  45. const res = await postL(apis.RECHARGE_GENERATE_LINK, { amount, payType, walletType });
  46. return res;
  47. };
  48. export const checkPaymentStatus = async (data: { tradeNo: string }) => {
  49. const res = await post(apis.RECHARGE_CHECK_PAYMENT_STATUS, data);
  50. return res;
  51. };
  52. export const getNewUserPromotion = async () => {
  53. const res = await get(apis.NEW_USER_PROMOTION);
  54. return res.data;
  55. };
  56. export default {
  57. preOneKeySubmit,
  58. info,
  59. bill,
  60. withdrawPre,
  61. getWithdraw,
  62. saveWithdraw,
  63. withdraw,
  64. generatePaymentLink,
  65. checkPaymentStatus,
  66. getNewUserPromotion,
  67. coupons: async (size = 30) => {
  68. const res = await post(apis.COUPON, { size }, { loading: true });
  69. return res.data;
  70. },
  71. };