Selaa lähdekoodia

fix: 修复领取优惠劵bug

laiqi 11 kuukautta sitten
vanhempi
commit
7b4fcc0854

+ 5 - 0
apps/web-ele/src/views/examine-manage/examine-coupon/order-coupon-form.vue

@@ -83,6 +83,7 @@ async function fetchCouponDetail(coupon2sid: string) {
   }
 }
 
+// 下单确认
 async function handleSubmit(): Promise<boolean> {
   if (!formRef.value) return false;
 
@@ -126,6 +127,7 @@ async function handleSubmit(): Promise<boolean> {
   }
 }
 
+// 下单弹窗
 const [Modal, modalApi] = useVbenModal({
   class: 'w-[700px]',
   title: '优惠券下单',
@@ -169,6 +171,9 @@ const [Modal, modalApi] = useVbenModal({
   },
 });
 
+/**
+ * 打开优惠券下单弹窗
+ */
 function openOrderCouponModal(data?: { coupon2sid?: string }) {
   modalApi.setData(data || {});
   modalApi.open();

+ 17 - 22
apps/web-ele/src/views/examine-manage/examine-coupon/receive-coupon-form.vue

@@ -14,8 +14,12 @@ import { useVbenModal } from '@vben/common-ui';
 
 import { ElMessage } from 'element-plus';
 
-import { getCoupon1ListApi, receiveCouponApi } from '#/api/coupon/coupon1';
-import { getProductListApi } from '#/api/product';
+import {
+  getCoupon1DetailApi,
+  getCoupon1ListApi,
+  receiveCouponApi,
+} from '#/api/coupon/coupon1';
+import { getProductDetailApi, getProductListApi } from '#/api/product';
 import { getCustomerListApi } from '#/api/user';
 import UploadFile from '#/components/upload-file/index.vue';
 
@@ -245,19 +249,13 @@ async function fetchProductInfo(productId: string) {
 
   try {
     productInfoLoading.value = true;
-    const response = await getProductListApi({
+    const response = await getProductDetailApi({
       productsid: productId,
-      pageindex: 1,
-      rows: 1,
     });
 
-    selectedProductInfo.value =
-      response &&
-      response.Data &&
-      Array.isArray(response.Data) &&
-      response.Data.length > 0
-        ? response.Data[0]
-        : null;
+    if (response && Object.keys(response).length > 0) {
+      selectedProductInfo.value = response;
+    }
   } catch (error) {
     console.error('获取产品详细信息失败', error);
     ElMessage.error('获取产品详细信息失败');
@@ -286,19 +284,13 @@ async function fetchCouponInfo(couponId: string) {
 
   try {
     couponInfoLoading.value = true;
-    const response = await getCoupon1ListApi({
+    const response = await getCoupon1DetailApi({
       couponid: couponId,
-      pageindex: 1,
-      rows: 1,
     });
 
-    selectedCouponInfo.value =
-      response &&
-      response.Data &&
-      Array.isArray(response.Data) &&
-      response.Data.length > 0
-        ? response.Data[0]
-        : null;
+    if (response && Object.keys(response).length > 0) {
+      selectedCouponInfo.value = response;
+    }
   } catch (error) {
     console.error('获取优惠券详细信息失败', error);
     ElMessage.error('获取优惠券详细信息失败');
@@ -308,6 +300,7 @@ async function fetchCouponInfo(couponId: string) {
   }
 }
 
+// 用户类型切换,重置表单
 function handleUserTypeChange() {
   formData.usersname = '';
   formData.idNumber = '';
@@ -320,6 +313,7 @@ function handleUserTypeChange() {
   formRef.value?.clearValidate();
 }
 
+// 确认
 async function handleSubmit(): Promise<boolean> {
   if (!formRef.value) return false;
   try {
@@ -428,6 +422,7 @@ const [Modal, modalApi] = useVbenModal({
   },
 });
 
+// 领取优惠劵对外暴露方法,外部调用
 function openReceiveCouponModal(data?: {
   couponId?: string;
   merchantId?: string;