Przeglądaj źródła

fix: 客服悬浮按钮加入在线时间校验,非9:30~21:30弹窗提示后确认再进入

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 2 dni temu
rodzic
commit
4510d7e1e4
1 zmienionych plików z 34 dodań i 1 usunięć
  1. 34 1
      car-wash-mp/src/components/custom-service/index.vue

+ 34 - 1
car-wash-mp/src/components/custom-service/index.vue

@@ -12,7 +12,14 @@
       <view class="cs-button">
         <uv-icon name="kefu-ermai" color="#FFFFFF" size="24"></uv-icon>
       </view>
-      <button class="contact-btn" open-type="contact" @contact="handleContact" send-message-title="YesWash洗车客服" />
+      <button
+        v-if="showContactBtn"
+        class="contact-btn"
+        open-type="contact"
+        @contact="handleContact"
+        send-message-title="YesWash洗车客服"
+      />
+      <view v-else class="contact-btn contact-interceptor" @click.stop="handleIntercept" />
     </movable-view>
   </movable-area>
 </template>
@@ -22,6 +29,13 @@ import { ref } from 'vue'
 
 const POS_KEY = 'kefuPos'
 
+/** 客服在线时间 9:30 ~ 21:30 */
+const isInServiceHours = (): boolean => {
+  const now = new Date()
+  const current = now.getHours() * 60 + now.getMinutes()
+  return current >= 9 * 60 + 30 && current <= 21 * 60 + 30
+}
+
 /* 实时拖拽位置(非响应式,避免与原生拖拽冲突) */
 let dragX = 600
 let dragY = 800
@@ -36,6 +50,7 @@ try {
 } catch {}
 
 const snapPos = ref({ x: dragX, y: dragY })
+const showContactBtn = ref(isInServiceHours())
 let windowInfo: any = null
 
 function getWindowInfo() {
@@ -62,6 +77,20 @@ function onTouchEnd() {
   uni.setStorageSync(POS_KEY, { x: snapX, y: snapY })
 }
 
+const handleIntercept = () => {
+  uni.showModal({
+    title: '客服提示',
+    content: '客服在线时间 9:30~21:30,当前留言可能会延迟回复',
+    cancelText: '取消',
+    confirmText: '继续留言',
+    success: (res) => {
+      if (res.confirm) {
+        showContactBtn.value = true
+      }
+    }
+  })
+}
+
 const handleContact = () => {}
 </script>
 
@@ -113,4 +142,8 @@ const handleContact = () => {}
   padding: 0;
   margin: 0;
 }
+
+.contact-interceptor {
+  opacity: 0;
+}
 </style>