使用方式
更新時間:2025-07-03 14:46:06
一、取得可領取優惠券列表
取得當前頻道下所有可領取的優惠券列表,支援分頁查詢。
Api 方法: getCouponCommonList(options?: PageOptions): Promise<PageContent<CouponCommonData>>
參數說明:
- options:分頁選項,
PageOptions類型,選傳,預設{},詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
pageNumber |
頁數 | number |
否 | - |
pageSize |
頁碼 | number |
否 | - |
回傳值說明: 可領取優惠券列表,Promise<PageContent<CouponCommonData>> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
pageNumber |
當前頁數 | number |
pageSize |
每頁數量 | number |
totalItems |
總記錄數 | number |
totalPages |
總頁數 | number |
contents |
內容列表 | I[] |
範例:
const couponList = await coupon.getCouponCommonList({ pageNumber: 1, pageSize: 10 });
console.log('优惠券列表:', couponList.contents);
console.log('总数量:', couponList.totalItems);
二、領取優惠券
使用者領取指定的優惠券。
Api 方法: receiveCoupon(couponId: string): Promise<void>
參數說明:
- couponId:優惠券 ID,
string類型,必傳
範例:
await coupon.receiveCoupon('coupon123');
console.log('优惠券领取成功');
三、取得已領取優惠券列表
取得目前使用者已領取的優惠券列表,支援分頁查詢。
Api 方法: getCouponUserList(options?: PageOptions): Promise<PageContent<CouponUserData>>
參數說明:
- options:分頁選項,
PageOptions類型,選傳,預設{},詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
pageNumber |
頁數 | number |
否 | - |
pageSize |
頁碼 | number |
否 | - |
回傳值說明: 已領取優惠券列表,Promise<PageContent<CouponUserData>> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
pageNumber |
當前頁數 | number |
pageSize |
每頁數量 | number |
totalItems |
總記錄數 | number |
totalPages |
總頁數 | number |
contents |
內容列表 | I[] |
範例:
const userCoupons = await coupon.getCouponUserList({ pageNumber: 1, pageSize: 10 });
console.log('我的优惠券:', userCoupons.contents);
