lxr 1 miesiąc temu
rodzic
commit
ab1ea83cbf

+ 1 - 0
src/api/modules/newLoginApi.ts

@@ -173,6 +173,7 @@ export const getIssueCouponList = (params: {
   page?: number;
   couponName?: string;
   couponsFromType?: number;
+  couponType?: number;
 }) => {
   return httpLogin.get(`/alienStore/life-discount-coupon/getStoreAllCouponList`, params);
 };

+ 20 - 35
src/views/dynamicManagement/friendRelation.vue

@@ -476,41 +476,26 @@ const loadCouponOptionsByType = async (distributeType: number) => {
   const key = distributeType === 2 ? "2-couponList" : "1-couponList";
   if (couponOptionsMap.value[key]?.length) return;
   const storeId = localGet("createdId") || "";
-  if (distributeType === 1) {
-    try {
-      const res: any = await getIssueCouponList({
-        storeId,
-        tab: 1,
-        size: 100,
-        page: 1,
-        couponName: "",
-        couponsFromType: 1
-      });
-      const records = res?.data?.records ?? res?.data ?? [];
-      const list = Array.isArray(records) ? records : [];
-      couponDataMap.value[key] = list;
-      couponOptionsMap.value[key] = list.map((item: any) => ({
-        value: String(item.id ?? item.couponId ?? ""),
-        label: item.couponName ?? item.name ?? ""
-      }));
-    } catch (e) {
-      couponDataMap.value[key] = [];
-      couponOptionsMap.value[key] = [];
-    }
-  } else {
-    try {
-      const res: any = await getVoucherList({ storeId, status: 5, size: 100, page: 1 });
-      const records = res?.data?.records ?? res?.data ?? [];
-      const list = Array.isArray(records) ? records : [];
-      couponDataMap.value[key] = list;
-      couponOptionsMap.value[key] = list.map((item: any) => ({
-        value: String(item.id ?? item.voucherId ?? item.couponId ?? ""),
-        label: item.name ?? item.couponName ?? ""
-      }));
-    } catch (e) {
-      couponDataMap.value[key] = [];
-      couponOptionsMap.value[key] = [];
-    }
+  try {
+    const res: any = await getIssueCouponList({
+      storeId,
+      tab: 1,
+      size: 100,
+      page: 1,
+      couponName: "",
+      couponsFromType: 1,
+      couponType: formData.distributeType
+    });
+    const records = res?.data?.records ?? res?.data ?? [];
+    const list = Array.isArray(records) ? records : [];
+    couponDataMap.value[key] = list;
+    couponOptionsMap.value[key] = list.map((item: any) => ({
+      value: String(item.id ?? item.couponId ?? ""),
+      label: item.couponName ?? item.name ?? ""
+    }));
+  } catch (e) {
+    couponDataMap.value[key] = [];
+    couponOptionsMap.value[key] = [];
   }
 };