Explorar o código

修复生成链接在测试服的bug

Huanyi hai 2 semanas
pai
achega
74be861146
Modificáronse 2 ficheiros con 45 adicións e 13 borrados
  1. 43 11
      src/views/order/management/components/OrderDetailDrawer.vue
  2. 2 2
      vite.config.ts

+ 43 - 11
src/views/order/management/components/OrderDetailDrawer.vue

@@ -90,7 +90,7 @@
                         <el-descriptions :column="2" size="small" class="pet-desc" border>
                             <el-descriptions-item label="品种">{{ order.petBreed || '-' }}</el-descriptions-item>
                             <el-descriptions-item label="疫苗状态"><span style="color:#67c23a">{{ order.petVaccine || '-'
-                            }}</span></el-descriptions-item>
+                                    }}</span></el-descriptions-item>
                             <el-descriptions-item label="性格特点">{{ order.petCharacter || '-' }}</el-descriptions-item>
                             <el-descriptions-item label="健康状况">{{ order.petHealth || '-' }}</el-descriptions-item>
                         </el-descriptions>
@@ -104,7 +104,7 @@
                         <div class="user-content">
                             <div class="u-row">
                                 <el-avatar :size="40" :src="order.userAvatar">{{ (order.userName || '').charAt(0)
-                                }}</el-avatar>
+                                    }}</el-avatar>
                                 <div class="u-info">
                                     <div class="nm">{{ order.userName }}</div>
                                     <div class="ph">{{ order.contactPhone }}</div>
@@ -136,18 +136,18 @@
                                         ({{ Number(order.platformId) === 1 ? '门店下单' : '平台代下单' }})</el-descriptions-item>
                                     <el-descriptions-item label="宠主信息">{{ order.userName || '-' }} / {{
                                         order.contactPhone || '-'
-                                        }}</el-descriptions-item>
+                                    }}</el-descriptions-item>
                                     <el-descriptions-item label="订单佣金" label-class-name="money-label">
                                         <span style="color:#f56c6c; font-weight:bold;">¥ {{ order.orderCommission ?
                                             (order.orderCommission / 100).toFixed(2) : '0.00' }}</span>
                                     </el-descriptions-item>
 
                                     <el-descriptions-item label="预约时间">{{ getServiceTimeRange(order.serviceTime) || '-'
-                                    }}</el-descriptions-item>
+                                        }}</el-descriptions-item>
                                     <el-descriptions-item label="团购套餐">{{ order.groupBuyPackage || '-'
-                                    }}</el-descriptions-item>
-                                    <el-descriptions-item label="创建时间">{{ order.createTime || '-'
                                         }}</el-descriptions-item>
+                                    <el-descriptions-item label="创建时间">{{ order.createTime || '-'
+                                    }}</el-descriptions-item>
 
                                     <el-descriptions-item label="订单备注" :span="3">
                                         {{ order.remark || '-' }}
@@ -166,7 +166,7 @@
                                     <div class="t-row">
                                         <span class="t-k">起点</span>
                                         <span class="t-v">{{ order.detail?.fromAddress || order.detail?.pickAddr || '-'
-                                            }}</span>
+                                        }}</span>
                                     </div>
                                     <div class="t-row">
                                         <span class="t-k">终点</span>
@@ -187,7 +187,7 @@
                                 <el-descriptions :column="2" border size="default" class="custom-desc">
                                     <el-descriptions-item label="服务地址" :span="2">{{ order.detail?.area || order.address
                                         || '-'
-                                        }}</el-descriptions-item>
+                                    }}</el-descriptions-item>
                                 </el-descriptions>
                             </div>
                         </div>
@@ -199,7 +199,7 @@
                             <div v-if="order.fulfillerName" class="fulfiller-card">
                                 <div class="f-left">
                                     <el-avatar :size="60" :src="order.fulfillerAvatar">{{ order.fulfillerName.charAt(0)
-                                    }}</el-avatar>
+                                        }}</el-avatar>
                                 </div>
                                 <div class="f-right">
                                     <div class="f-row1">
@@ -630,7 +630,7 @@ const currentOrderSteps = computed(() => {
         { title: '订单完成', time: findTime('完成') || '' }
     ]
 
-    let active = 1 // 默认停在「运营派单」
+    let active = 1
 
     switch (status) {
         case 0:
@@ -697,6 +697,38 @@ const handleExportLogs = () => {
     );
 }
 
+/**
+ * 复制文本到剪贴板,兼容 HTTP 环境
+ */
+const copyToClipboard = (text) => {
+    if (navigator.clipboard && window.isSecureContext) {
+        return navigator.clipboard.writeText(text)
+    }
+    // 降级方案:使用传统的 execCommand
+    return new Promise((resolve, reject) => {
+        const textarea = document.createElement('textarea')
+        textarea.value = text
+        textarea.style.position = 'fixed'
+        textarea.style.left = '-9999px'
+        textarea.style.top = '-9999px'
+        document.body.appendChild(textarea)
+        textarea.focus()
+        textarea.select()
+        try {
+            const success = document.execCommand('copy')
+            document.body.removeChild(textarea)
+            if (success) {
+                resolve()
+            } else {
+                reject(new Error('execCommand copy failed'))
+            }
+        } catch (e) {
+            document.body.removeChild(textarea)
+            reject(e)
+        }
+    })
+}
+
 /**
  * 生成履约路径链接并复制到剪贴板
  */
@@ -710,7 +742,7 @@ const handleGenerateFulfillPath = () => {
     const isIp = /^(\d{1,3}\.){3}\d{1,3}$/.test(hostname)
     const baseUrl = isIp ? `http://${hostname}` : 'https://www.hoomeng.pet'
     const url = `${baseUrl}/fulfillPath?orderId=${id}`
-    navigator.clipboard.writeText(url).then(() => {
+    copyToClipboard(url).then(() => {
         ElMessage.success('履约路径已复制到剪贴板')
     }).catch(() => {
         ElMessage({ message: url, type: 'success', duration: 10000, showClose: true })

+ 2 - 2
vite.config.ts

@@ -24,8 +24,8 @@ export default defineConfig(({ mode, command }) => {
       // open: true,
       proxy: {
         [env.VITE_APP_BASE_API]: {
-          target: 'http://127.0.0.1:8080',
-          // target: 'http://111.228.46.254/api',
+          // target: 'http://127.0.0.1:8080',
+          target: 'http://111.228.46.254/api',
           // target: 'https://www.hoomeng.pet/api',
           changeOrigin: true,
           ws: true,