activity.ts 1002 B

12345678910111213141516171819202122232425262728293031323334
  1. // 活动服务 - 新人大礼包、优惠券等
  2. import { get, post, postL } from './http';
  3. const apis = {
  4. NEWBIE_GIFT_BAG: '/api/activity/newbieGiftBag/info',
  5. COUPON_LIST_VALID: '/api/coupon/listValidCoupon',
  6. COUPON_BATCH_RECEIVE: '/api/coupon/batchReceive',
  7. };
  8. // 新人大礼包信息
  9. export const getNewbieGiftBagInfo = async () => {
  10. const res = await get<any>(apis.NEWBIE_GIFT_BAG);
  11. return res.success && res.data ? res.data : null;
  12. };
  13. // 获取可领优惠券列表
  14. export interface CouponItem {
  15. id: string;
  16. amount: number;
  17. fullAmount: number;
  18. endTime: string;
  19. name?: string;
  20. }
  21. export const listValidCoupon = async (scene: string, targetObj?: any) => {
  22. const res = await post<CouponItem[]>(apis.COUPON_LIST_VALID, { scene, targetObj });
  23. return res.success && res.data ? res.data : [];
  24. };
  25. // 一键领取优惠券
  26. export const batchReceiveCoupon = async (ids: string[]) => {
  27. const res = await postL<any>(apis.COUPON_BATCH_RECEIVE, { ids });
  28. return res.success;
  29. };