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