2
0

fix:套餐状态判断套餐禁止办理

This commit is contained in:
zhongzm
2025-02-27 18:34:01 +08:00
parent 7899640132
commit c0c4e81cf6
5 changed files with 35 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { ref, onMounted, computed } from 'vue';
import { fetchPackageList, submitOrder } from '@/service/api/auth';
import { fetchPackageList, submitOrder, fetchDashboardData } from '@/service/api/auth';
import { message } from 'ant-design-vue';
import OrderConfirmModal from '@/components/order-confirm/orderConfirmModal.vue';
import { aliPayPcPay,aliPayWapPay, wxPayScanCode, payBalance } from '@/service/api/payment';
@@ -165,6 +165,8 @@ const canUseBalancePay = computed(() => {
// 添加 loading 状态
const paymentLoading = ref(false);
// 添加用户状态
const userPackageStatus = ref<number | null>(null); // 用于存储套餐状态
const fetchPackages = async () => {
isLoading.value = true;
@@ -324,8 +326,24 @@ const fetchUserBalance = async () => {
// console.error('Failed to fetch user balance:', error);
}
};
// 获取仪表盘数据
const fetchDashboardData = async () => {
try {
const response = await authStore.getDashboardData(); // 获取仪表盘数据
if (response && typeof response === 'object' && !response.error) {
userPackageStatus.value = response.status; // 获取套餐状态
}
} catch (error) {
console.error('Failed to fetch dashboard data:', error);
}
};
// 计算属性,检查套餐状态
const isPackageActive = computed(() => {
return userPackageStatus.value === 1; // 如果状态为 1则套餐有效
});
onMounted(async () => {
fetchDashboardData();
await fetchPackages();
await fetchUserBalance();
});
@@ -417,7 +435,7 @@ onMounted(async () => {
<button
class="btn-primary"
@click="handleSubmitOrder"
:disabled="isLoading || !hasPackages"
:disabled="isLoading || !hasPackages || isPackageActive"
>
{{ isLoading ? t('page.common.loading') :
!hasPackages ? t('page.setmeal.noPackages') :