Usage
1. Get List of Claimable Coupons
Retrieve a list of all claimable coupons under the current channel, with pagination support.
Api Method: getCouponCommonList(options?: PageOptions): Promise<PageContent<CouponCommonData>>
Parameter Description:
- options: Pagination options, type
PageOptions, optional, default{}. Detailed type description is as follows:
| Parameter | Description | Type | Required | Default |
|---|---|---|---|---|
pageNumber |
Page number | number |
No | - |
pageSize |
Page size | number |
No | - |
Return Value Description: List of claimable coupons, type Promise<PageContent<CouponCommonData>>. Detailed type description is as follows:
| Property | Description | Type |
|---|---|---|
pageNumber |
Current page number | number |
pageSize |
Items per page | number |
totalItems |
Total records | number |
totalPages |
Total pages | number |
contents |
Content list | I[] |
Example:
const couponList = await coupon.getCouponCommonList({ pageNumber: 1, pageSize: 10 });
console.log('优惠券列表:', couponList.contents);
console.log('总数量:', couponList.totalItems);
2. Claim a Coupon
The user claims a specified coupon.
Api Method: receiveCoupon(couponId: string): Promise<void>
Parameter Description:
- couponId: Coupon ID, type
string, required
Example:
await coupon.receiveCoupon('coupon123');
console.log('优惠券领取成功');
3. Get List of Claimed Coupons
Retrieve a list of coupons claimed by the current user, with pagination support.
Api Method: getCouponUserList(options?: PageOptions): Promise<PageContent<CouponUserData>>
Parameter Description:
- options: Pagination options, type
PageOptions, optional, default{}. Detailed type description is as follows:
| Parameter | Description | Type | Required | Default |
|---|---|---|---|---|
pageNumber |
Page number | number |
No | - |
pageSize |
Page size | number |
No | - |
Return Value Description: List of claimed coupons, type Promise<PageContent<CouponUserData>>. Detailed type description is as follows:
| Property | Description | Type |
|---|---|---|
pageNumber |
Current page number | number |
pageSize |
Items per page | number |
totalItems |
Total records | number |
totalPages |
Total pages | number |
contents |
Content list | I[] |
Example:
const userCoupons = await coupon.getCouponUserList({ pageNumber: 1, pageSize: 10 });
console.log('我的优惠券:', userCoupons.contents);
