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