From 790fdf41146372c7e3548632e52be861c66f49c1 Mon Sep 17 00:00:00 2001 From: xjs Date: Sat, 8 Mar 2025 10:18:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0navbar,fab=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fab/FabButton.vue | 67 ++++-- src/login-sub/components/LoginMask.vue | 52 +++-- src/login-sub/components/Overlay.vue | 54 +++++ src/login-sub/components/navbar/Navbar.vue | 190 ++++++++++++++++++ src/login-sub/components/navbar/left.jpg | Bin 0 -> 1124 bytes src/login-sub/index.vue | 12 +- src/pages-sub/components/navbar/Navbar.vue | 190 ++++++++++++++++++ src/pages-sub/components/navbar/left.jpg | Bin 0 -> 1124 bytes src/pages-sub/customerService/index/index.vue | 9 +- 9 files changed, 535 insertions(+), 39 deletions(-) create mode 100644 src/login-sub/components/Overlay.vue create mode 100644 src/login-sub/components/navbar/Navbar.vue create mode 100644 src/login-sub/components/navbar/left.jpg create mode 100644 src/pages-sub/components/navbar/Navbar.vue create mode 100644 src/pages-sub/components/navbar/left.jpg diff --git a/src/components/fab/FabButton.vue b/src/components/fab/FabButton.vue index 03fa26a..b94f71c 100644 --- a/src/components/fab/FabButton.vue +++ b/src/components/fab/FabButton.vue @@ -6,11 +6,7 @@ @touchend.stop="endDrag" :style="{ right: position.x + 'px', bottom: position.y + 'px' }" > - + @@ -31,28 +27,73 @@ const props = defineProps({ const systemInfo = uni.getSystemInfoSync() const position = ref({ x: props.initialX, y: props.initialY }) const startPosition = ref({ x: 0, y: 0 }) +const startTime = ref(0) +const longPressTimer = ref(null) +const canDrag = ref(false) +const moveDistance = ref(0) const startDrag = (event: TouchEvent) => { startPosition.value = { x: event.touches[0].clientX, y: event.touches[0].clientY } + startTime.value = Date.now() + canDrag.value = false + moveDistance.value = 0 + + // 设置长按定时器,300ms后允许拖动 + longPressTimer.value = setTimeout(() => { + if (!canDrag.value) { + canDrag.value = true + } + }, 300) as unknown as number } const onDrag = (event: TouchEvent) => { const deltaX = event.touches[0].clientX - startPosition.value.x const deltaY = event.touches[0].clientY - startPosition.value.y + + // 计算移动距离 + moveDistance.value = Math.sqrt(deltaX * deltaX + deltaY * deltaY) + + // 如果移动距离超过阈值,立即允许拖动 + if (moveDistance.value > 10 && !canDrag.value) { + canDrag.value = true + if (longPressTimer.value) { + clearTimeout(longPressTimer.value) + longPressTimer.value = null + } + } + + if (!canDrag.value) return + position.value = { x: position.value.x - deltaX, y: position.value.y - deltaY } startPosition.value = { x: event.touches[0].clientX, y: event.touches[0].clientY } } const endDrag = () => { - const windowWidth = systemInfo.windowWidth - const windowHeight = systemInfo.windowHeight - const buttonWidth = 128 // 按钮宽度 - const buttonHeight = 128 // 按钮高度 + // 清除长按定时器 + if (longPressTimer.value) { + clearTimeout(longPressTimer.value) + longPressTimer.value = null + } - if (position.value.x < 0) position.value.x = 0 - if (position.value.y < 0) position.value.y = 0 - if (position.value.x + buttonWidth > windowWidth) position.value.x = windowWidth - buttonWidth - if (position.value.y + buttonHeight > windowHeight) position.value.y = windowHeight - buttonHeight + // 如果移动距离小于阈值且触摸时间小于300ms,则触发点击事件 + if (!canDrag.value && moveDistance.value < 10 && Date.now() - startTime.value < 300) { + handleClick() + return + } + + // 如果是拖动结束,处理边界 + if (canDrag.value) { + const windowWidth = systemInfo.windowWidth + const windowHeight = systemInfo.windowHeight + const buttonWidth = 128 // 按钮宽度 + const buttonHeight = 128 // 按钮高度 + + if (position.value.x < 0) position.value.x = 0 + if (position.value.y < 0) position.value.y = 0 + if (position.value.x + buttonWidth > windowWidth) position.value.x = windowWidth - buttonWidth + if (position.value.y + buttonHeight > windowHeight) + position.value.y = windowHeight - buttonHeight + } } const handleClick = () => { diff --git a/src/login-sub/components/LoginMask.vue b/src/login-sub/components/LoginMask.vue index 7d7f275..c0cc6bf 100644 --- a/src/login-sub/components/LoginMask.vue +++ b/src/login-sub/components/LoginMask.vue @@ -1,7 +1,8 @@ diff --git a/src/login-sub/components/Overlay.vue b/src/login-sub/components/Overlay.vue new file mode 100644 index 0000000..bb9c6a3 --- /dev/null +++ b/src/login-sub/components/Overlay.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/login-sub/components/navbar/Navbar.vue b/src/login-sub/components/navbar/Navbar.vue new file mode 100644 index 0000000..726f11d --- /dev/null +++ b/src/login-sub/components/navbar/Navbar.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/src/login-sub/components/navbar/left.jpg b/src/login-sub/components/navbar/left.jpg new file mode 100644 index 0000000000000000000000000000000000000000..69b166b7f5603c88c4eaaa78ed7ddbf4500e6211 GIT binary patch literal 1124 zcmex=Jq?U}9uuW@2GxWo2Ojs;&jfGq4D< z3Mm>ovIz$!vMUve7&T5@$f4}C@t|nX#SbdRNkvVZTw>x9l2WQ_>Kd9_CZ=ZQ7M51d zF0O9w9-dyoA)#U65s^{JDXD4c8JStdC8cHM6_r)ZEv;?s9i3g1CQq3GGAU*RJ2VdF$b$$4{OP zfBE|D`;VW$K>lK6V1@@7#A9gw0tNyj6AKG73p>bPj7;S~%q+;ls%Xe2|7hR2HvN+71rvU$hPsLW&c-qQSp8xD z1NX!Fj5P&6ww8aq{OEeyA5-4>{dU@MFQw{Q^}9=duFK2MQ}6b@oV(_Mx2&G^j4ifC zuc}L~n(CVSY`wB|+4P9r`)4`uzVEZjKU$mq;QCQp^#}ePHuewwd!^J+uDC{ z_#6D-{$YQyx{JU7Fs}$dTF3sMp=s6e$MVA2`?suH{c(O+cl^iiNAEJ_rf#jZJ|fR& z6KIqDcj<$QguR!))~5Sj*4xTyI{Wo$e_7AfKe`?EU&#AX!2fbt0~f=e?Ld?I{xcl3 z*z%v@HnabS`N!g$<8r$>M O_wQ_t_38}&Zvp^f@x9#u literal 0 HcmV?d00001 diff --git a/src/login-sub/index.vue b/src/login-sub/index.vue index 93f03ac..9687771 100644 --- a/src/login-sub/index.vue +++ b/src/login-sub/index.vue @@ -9,11 +9,17 @@