feat(礼品卡): 优化颜色主题并添加核销功能
- 修改礼品卡颜色主题,使用渐变色提升视觉效果 - 添加礼品卡核销功能,包括生成和验证核销码 -优化礼品卡组件,增加状态显示和使用说明 - 新增礼品卡颜色测试页面,用于验证颜色
This commit is contained in:
@@ -113,6 +113,22 @@ export async function getShopGift(id: number) {
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code查询礼品卡
|
||||
* @param code
|
||||
*/
|
||||
export async function getShopGiftByCode(code: string) {
|
||||
const res = await request.get<ApiResult<ShopGift>>(
|
||||
'/shop/shop-gift/by-code/' + code
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 兑换礼品卡
|
||||
*/
|
||||
@@ -178,3 +194,52 @@ export async function exportShopGift(ids?: number[]) {
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成礼品卡核销码
|
||||
*/
|
||||
export async function generateVerificationCode(giftId: number) {
|
||||
const res = await request.post<ApiResult<{ verificationCode: string; expireTime: string }>>(
|
||||
'/shop/shop-gift/generate-verification-code',
|
||||
{ giftId }
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证核销码
|
||||
*/
|
||||
export async function verifyGiftCard(params: { verificationCode?: string; giftCode?: string }) {
|
||||
const res = await request.post<ApiResult<ShopGift>>(
|
||||
'/shop/shop-gift/verify',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成礼品卡核销
|
||||
*/
|
||||
export async function completeVerification(params: {
|
||||
giftId: number;
|
||||
verificationCode: string;
|
||||
storeId?: number;
|
||||
storeName?: string;
|
||||
operatorId?: number;
|
||||
operatorName?: string;
|
||||
}) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/shop/shop-gift/complete-verification',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user