From 45d4816c3aeeee769112665fa8299207752756d3 Mon Sep 17 00:00:00 2001
From: aaron <>
Date: Mon, 14 Apr 2025 23:17:07 +0800
Subject: [PATCH] update
---
src/views/coupon/ActivityList.vue | 142 +++++++++++++++++++++++++++++-
1 file changed, 138 insertions(+), 4 deletions(-)
diff --git a/src/views/coupon/ActivityList.vue b/src/views/coupon/ActivityList.vue
index 2146cb6..c7e9129 100644
--- a/src/views/coupon/ActivityList.vue
+++ b/src/views/coupon/ActivityList.vue
@@ -37,6 +37,7 @@
编辑
获取二维码
+ 获取链接
@@ -255,6 +256,41 @@
+
+
+
+
+
@@ -274,7 +310,8 @@ import {
Checkbox,
Card,
Divider,
- Spin
+ Spin,
+ Button
} from 'ant-design-vue'
import PageContainer from '@/components/PageContainer.vue'
import dayjs from 'dayjs'
@@ -297,7 +334,8 @@ export default defineComponent({
ACard: Card,
ADivider: Divider,
QrcodeVue,
- ASpin: Spin
+ ASpin: Spin,
+ AButton: Button
},
setup() {
@@ -714,6 +752,11 @@ export default defineComponent({
const qrCodeModalVisible = ref(false)
const qrCodeUrl = ref('')
const qrCodeLoading = ref(false)
+
+ // 活动链接相关
+ const linkModalVisible = ref(false)
+ const activityLink = ref('')
+ const linkLoading = ref(false)
// 获取活动二维码
const handleGetQrCode = async (record) => {
@@ -722,7 +765,7 @@ export default defineComponent({
qrCodeLoading.value = true
try {
- const res = await request.get(`/api/coupon-activities/${record.id}/get_url_link`)
+ const res = await request.get(`/api/coupon-activities/${record.id}/get_qr_code`)
if (res.code === 200) {
qrCodeUrl.value = res.data
} else {
@@ -738,6 +781,58 @@ export default defineComponent({
}
}
+ // 获取活动链接
+ const handleGetLink = async (record) => {
+ // 先显示模态框
+ linkModalVisible.value = true
+ linkLoading.value = true
+
+ try {
+ const res = await request.get(`/api/coupon-activities/${record.id}/get_url_link`)
+ if (res.code === 200) {
+ activityLink.value = res.data
+ } else {
+ message.error('获取活动链接失败')
+ linkModalVisible.value = false
+ }
+ } catch (error) {
+ console.error('获取活动链接失败:', error)
+ message.error('获取活动链接失败')
+ linkModalVisible.value = false
+ } finally {
+ linkLoading.value = false
+ }
+ }
+
+ // 复制链接到剪贴板
+ const copyLink = () => {
+ if (!activityLink.value) {
+ message.error('链接为空,无法复制')
+ return
+ }
+
+ // 创建临时输入框
+ const input = document.createElement('input')
+ input.value = activityLink.value
+ document.body.appendChild(input)
+ input.select()
+
+ try {
+ document.execCommand('copy')
+ message.success('复制成功')
+ } catch (error) {
+ console.error('复制失败:', error)
+ message.error('复制失败')
+ } finally {
+ document.body.removeChild(input)
+ }
+ }
+
+ // 取消链接模态框
+ const handleLinkModalCancel = () => {
+ linkModalVisible.value = false
+ }
+
// 取消二维码模态框
const handleQrCodeModalCancel = () => {
qrCodeModalVisible.value = false
@@ -776,7 +871,14 @@ export default defineComponent({
handleGetQrCode,
handleQrCodeModalCancel,
getCouponConfigValue,
- handleCouponConfigChange
+ handleCouponConfigChange,
+ // 新增链接相关
+ linkModalVisible,
+ activityLink,
+ linkLoading,
+ handleGetLink,
+ copyLink,
+ handleLinkModalCancel
}
}
})
@@ -949,4 +1051,36 @@ export default defineComponent({
margin-top: 16px;
color: rgba(0, 0, 0, 0.65);
}
+
+/* 链接相关样式 */
+.link-container {
+ padding: 10px 0;
+}
+
+.link-loading {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100px;
+}
+
+.link-loading p {
+ margin-top: 16px;
+ color: rgba(0, 0, 0, 0.65);
+}
+
+.link-content {
+ margin-bottom: 16px;
+}
+
+.link-input {
+ font-size: 14px;
+}
+
+.link-tip {
+ text-align: center;
+ color: rgba(0, 0, 0, 0.65);
+ font-size: 14px;
+}
\ No newline at end of file