feat: get is vip
This commit is contained in:
@ -82,7 +82,10 @@ function ProductGroupDialog(props: IProps) {
|
||||
return;
|
||||
}
|
||||
// 否则:如果有解锁次数,显示是否确定消费。无解锁次数,显示不无次数 UI
|
||||
const [time, detail] = await Promise.all([requestProductBalance(PRODUCT_CODE), requestGroupDetail(blGroupId)]);
|
||||
const [[time], detail] = await Promise.all([
|
||||
requestProductBalance(PRODUCT_CODE),
|
||||
requestGroupDetail(blGroupId),
|
||||
]);
|
||||
setGroupDetail(detail);
|
||||
if (time <= 0) {
|
||||
setStatus(DialogStatus.GROUP_NEED_BUY_ADD);
|
||||
|
@ -102,7 +102,7 @@ function ProductJobWithGroupDialog(props: Omit<IProps, 'visible'>) {
|
||||
return;
|
||||
}
|
||||
// 否则:如果有解锁次数,显示是否确定消费。无解锁次数,显示不无次数 UI
|
||||
const time = await requestProductBalance(ProductType.AddGroup);
|
||||
const [time] = await requestProductBalance(ProductType.AddGroup);
|
||||
if (time <= 0) {
|
||||
setStatus(DialogStatus.JOB_CONTACT_NEED_BUY_GROUP);
|
||||
} else {
|
||||
@ -119,7 +119,7 @@ function ProductJobWithGroupDialog(props: Omit<IProps, 'visible'>) {
|
||||
return;
|
||||
}
|
||||
// 自动报单
|
||||
const time = await requestProductBalance(ProductType.GetJob);
|
||||
const [time] = await requestProductBalance(ProductType.GetJob);
|
||||
if (time <= 0) {
|
||||
setStatus(DialogStatus.JOB_UNABLE_UNLOCK);
|
||||
} else {
|
||||
|
@ -63,7 +63,7 @@ function ProductJobDialog(props: Omit<IProps, 'visible'>) {
|
||||
}, []);
|
||||
|
||||
const handleAfterBuy = useCallback(async () => {
|
||||
const time = await requestProductBalance(PRODUCT_CODE);
|
||||
const [time] = await requestProductBalance(PRODUCT_CODE);
|
||||
if (time <= 0) {
|
||||
Toast.error('发生错误请重试');
|
||||
onClose();
|
||||
@ -110,14 +110,14 @@ function ProductJobDialog(props: Omit<IProps, 'visible'>) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const time = await requestProductBalance(PRODUCT_CODE);
|
||||
const [time, isPaidVip] = await requestProductBalance(PRODUCT_CODE);
|
||||
if (time <= 0) {
|
||||
const allowBuy = await requestAllBuyProduct(PRODUCT_CODE);
|
||||
setShowContact(true);
|
||||
setStatus(allowBuy ? DialogStatus.JOB_BUY : DialogStatus.JOB_UNABLE_UNLOCK);
|
||||
}
|
||||
// 创建模卡之后可以直接解锁一次, 分享后解锁一次
|
||||
else if (getSkipPrejobAction() || skipPreAction) {
|
||||
else if (isPaidVip || getSkipPrejobAction() || skipPreAction) {
|
||||
const productInfo = await requestUseProduct(PRODUCT_CODE, { jobId: data.id });
|
||||
setShowPrejob(false);
|
||||
if (!skipPreAction) {
|
||||
@ -132,6 +132,7 @@ function ProductJobDialog(props: Omit<IProps, 'visible'>) {
|
||||
// handleContact(productInfo.declarationTypeResult);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
Toast.error('出错了,请重试');
|
||||
handleCloseDialog();
|
||||
} finally {
|
||||
|
@ -115,7 +115,7 @@ export function CompanyPublishJobDialog(props: IProps) {
|
||||
try {
|
||||
const productCode = ProductType.CompanyPublishJob;
|
||||
Taro.showLoading();
|
||||
const time = await requestProductBalance(productCode);
|
||||
const [time] = await requestProductBalance(productCode);
|
||||
if (time <= 0) {
|
||||
setStatus(DialogStatus.COMPANY_PUBLISH_JOB_BUY);
|
||||
return;
|
||||
|
@ -70,7 +70,7 @@ export default function GroupBuy(props: IProps) {
|
||||
if (status !== OrderStatus.Success) {
|
||||
throw new Error('order status error');
|
||||
}
|
||||
const time = await requestProductBalance(ProductType.AddGroup);
|
||||
const [time] = await requestProductBalance(ProductType.AddGroup);
|
||||
log('handleBuy new addGroupTime', time);
|
||||
onConfirm(time);
|
||||
} catch (e) {
|
||||
|
@ -13,6 +13,7 @@ export interface ProductInfo {
|
||||
balance: number;
|
||||
created: number;
|
||||
updated: number;
|
||||
isPaidVip?: boolean;
|
||||
// 报单类型信息,只有 use 接口返回值才有
|
||||
declarationTypeResult?: DeclarationTypeResult;
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ export async function requestUseProduct(
|
||||
}
|
||||
|
||||
// 获取某个产品的剩余解锁次数
|
||||
export async function requestProductBalance(productCode: ProductType) {
|
||||
export async function requestProductBalance(productCode: ProductType): Promise<[number, boolean | undefined]> {
|
||||
const data: GetProductDetailRequest = { productCode, userId: getUserId() };
|
||||
const { balance } = await http.post<ProductInfo>(API.GET_PRODUCT_DETAIL, {
|
||||
const { balance, isPaidVip } = await http.post<ProductInfo>(API.GET_PRODUCT_DETAIL, {
|
||||
data,
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
});
|
||||
return balance;
|
||||
return [balance, isPaidVip];
|
||||
}
|
||||
|
||||
// 是否可以购买某一个产品
|
||||
|
Reference in New Issue
Block a user