This commit is contained in:
chashaobao
2025-08-31 22:43:00 +08:00
parent 61686950bd
commit aea8323d95
7 changed files with 122 additions and 49 deletions

31
src/utils/coupon.ts Normal file
View File

@ -0,0 +1,31 @@
import http from '@/http';
import { API } from '@/http/api';
import { ClaimMembershipCouponResponse, GenerateMembershipCouponResponse } from '@/types/coupon';
export const generateMembershipCoupon = async () => {
return await http.post<GenerateMembershipCouponResponse>(API.GENERATE_MEMBERSHIP_COUPON);
};
export const claimMembershipCoupon = async (code: string) => {
return await http.post<ClaimMembershipCouponResponse>(API.CLAIM_MEMBERSHIP_COUPON, {
contentType: 'application/x-www-form-urlencoded',
data: { code },
});
};
export const getCouponQrCode = async (code: string) => {
return await http.post(API.GET_VIP_QRCODE, {
contentType: 'application/x-www-form-urlencoded',
responseType: 'arraybuffer',
data: { code },
});
};
export const getCouponCodeFromQuery = (query: Record<string, string>): string | undefined => {
if (query) {
if (query.scene) {
return query.scene.replace('d%3D', '');
}
if (query.d) {
return query.d;
}
}
return undefined;
};