Explorar el Código

代金券详情

lxr hace 2 meses
padre
commit
b3eef23342

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

@@ -102,7 +102,10 @@ export const getStoreOcrData = params => {
 export const getFriendCouponList = (params: any) => {
   return httpLogin.get(`/alienStore/life-discount-coupon-store-friend/getReceivedSendFriendCouponList`, params);
 };
-
+// 获取好友代金券列表
+export const getCouponDetail = (params: any) => {
+  return httpLogin.get(`/alienStore/coupon/getCouponDetail`, params);
+};
 // 获取好友优惠券列表
 export const getFriendCouponDetail = (params: any) => {
   return httpLogin.get(`/alienStore/life-discount-coupon/getCounponDetailById`, params);

+ 18 - 9
src/views/dynamicManagement/friendCoupon.vue

@@ -262,13 +262,13 @@ const columns = computed(() => {
 // 初始化请求参数 - 好友赠我传 storeUserId
 const initParam = reactive({
   storeUserId: localGet("createdId"), // 好友赠我:当前店铺ID(接收方)
-  friendStoreUserId: undefined as number | undefined, // 我赠好友:当前用户ID(赠送方)
-  type: activeName.value
+  friendStoreUserId: undefined as number | undefined // 我赠好友:当前用户ID(赠送方)
+  // type: activeName.value
 });
 
 // Tab切换处理
 const handleTabClick = () => {
-  initParam.type = activeName.value;
+  // initParam.type = activeName.value;
 
   // 根据当前 tab 设置正确的参数
   if (activeName.value === "myGift") {
@@ -295,8 +295,8 @@ const dataCallback = (data: any) => {
 // 获取表格列表
 const getTableList = (params: any) => {
   const newParams = {
-    ...params,
-    type: activeName.value === "friendMessage" ? 0 : 1 // 0-好友赠我,1-我赠好友
+    ...params
+    //type: activeName.value === "friendMessage" ? 0 : 1 // 0-好友赠我,1-我赠好友
   };
 
   return getFriendCouponList(newParams);
@@ -366,12 +366,21 @@ const handleGiftSubmit = async () => {
 
 // 查看详情
 const viewDetail = (row: any) => {
-  router.push({
-    path: "/dynamicManagement/friendCouponDetail",
-    query: {
+  let query = {};
+  if (row.voucherId) {
+    query = {
+      voucherId: row.voucherId,
+      type: activeName.value
+    };
+  } else {
+    query = {
       couponId: row.couponId,
       type: activeName.value
-    }
+    };
+  }
+  router.push({
+    path: "/dynamicManagement/friendCouponDetail",
+    query: query
   });
 };
 

+ 37 - 14
src/views/dynamicManagement/friendCouponDetail.vue

@@ -28,16 +28,22 @@
           <!-- 面值 -->
           <div class="detail-item">
             <div class="detail-label">面值(元)</div>
-            <div class="detail-value">
+            <div class="detail-value" v-if="couponId">
               {{ formatCurrency(couponModel.nominalValue, 2, "¥") }}
             </div>
+            <div class="detail-value" v-else>
+              {{ formatCurrency(couponModel.nominalValue ?? couponModel.price, 2, "¥") }}
+            </div>
           </div>
           <!-- 有效期至 -->
           <div class="detail-item">
             <div class="detail-label">有效期至</div>
-            <div class="detail-value">
+            <div class="detail-value" v-if="couponId">
               {{ couponModel.endGetDate }}
             </div>
+            <div class="detail-value" v-else>
+              {{ couponModel.endDate }}
+            </div>
           </div>
           <!-- 优惠券数量 -->
           <div class="detail-item">
@@ -117,7 +123,7 @@
 import { ref, onMounted } from "vue";
 import { useRouter, useRoute } from "vue-router";
 import { ElMessage } from "element-plus";
-import { getFriendCouponDetail } from "@/api/modules/newLoginApi";
+import { getFriendCouponDetail, getCouponDetail } from "@/api/modules/newLoginApi";
 import { formatCurrency } from "@/utils/formatCurrency";
 import { localGet } from "@/utils";
 
@@ -128,7 +134,8 @@ const router = useRouter();
 const route = useRoute();
 
 // 页面ID参数
-const id = ref<string>("");
+const couponId = ref<string>("");
+const voucherId = ref<string>("");
 
 // 优惠券类型(好友赠我 friendMessage / 我赠好友 myGift)
 const type = ref<string>("");
@@ -174,9 +181,13 @@ const couponModel = ref<any>({
  * 从路由参数中获取couponId并加载详情数据
  */
 onMounted(async () => {
-  id.value = (route.query.couponId as string) || "";
+  if (route.query.voucherId) {
+    voucherId.value = (route.query.voucherId as string) || "";
+  } else if (route.query.couponId) {
+    couponId.value = (route.query.couponId as string) || "";
+  }
   type.value = (route.query.type as string) || "";
-  if (id.value) {
+  if (voucherId.value || couponId.value) {
     await loadDetailData();
   } else {
     ElMessage.warning("缺少优惠券ID参数");
@@ -199,15 +210,27 @@ const goBack = () => {
  */
 const loadDetailData = async () => {
   try {
-    // 使用 couponId 获取详情数据
-    const res: any = await getFriendCouponDetail({
-      counponId: id.value
-    });
+    if (voucherId.value) {
+      const res: any = await getCouponDetail({
+        id: voucherId.value
+      });
+      if (res.code === 200) {
+        couponModel.value = res.data;
+        console.log(couponModel.value, "couponModel.value");
+      } else {
+        ElMessage.error(res.msg);
+      }
+    } else if (couponId.value) {
+      // 使用 couponId 获取详情数据
+      const res: any = await getFriendCouponDetail({
+        counponId: couponId.value
+      });
 
-    if (res.code === 200) {
-      couponModel.value = res.data;
-    } else {
-      ElMessage.error(res.msg);
+      if (res.code === 200) {
+        couponModel.value = res.data;
+      } else {
+        ElMessage.error(res.msg);
+      }
     }
   } catch (error) {
     ElMessage.error("加载详情数据出错");