refactor(api): 更新 API调用以使用新的请求工具- 将所有 API 调用中的 request-legacy 替换为 request
- 优化部分 API 调用的参数传递方式 - 统一导入 ApiResult 和 PageResult 类型的路径
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import request from '@/utils/request-legacy';
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ShopGift, ShopGiftParam, GiftRedeemParam, GiftUseParam } from './model';
|
||||
import {ShopGift, ShopGiftParam, GiftRedeemParam, GiftUseParam, QRCodeParam} from './model';
|
||||
|
||||
/**
|
||||
* 分页查询礼品卡
|
||||
@@ -196,12 +196,12 @@ export async function exportShopGift(ids?: number[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成礼品卡核销码
|
||||
* 生成礼品卡核销码(可用)
|
||||
*/
|
||||
export async function generateVerificationCode(giftId: number) {
|
||||
const res = await request.post<ApiResult<{ verificationCode: string; expireTime: string }>>(
|
||||
'/shop/shop-gift/generate-verification-code',
|
||||
{ giftId }
|
||||
export async function generateVerificationCode(data: QRCodeParam) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/qr-code/create-encrypted-qr-code',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
@@ -243,3 +243,18 @@ export async function completeVerification(params: {
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密二维码数据
|
||||
*/
|
||||
export async function decryptQrData(params: { token: string; encryptedData: string }) {
|
||||
const res = await request.post<ApiResult<string>>(
|
||||
'/qr-code/decrypt-qr-data',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user