From 89a176544daac5bd347326d23219543a572223d3 Mon Sep 17 00:00:00 2001 From: wangyufei <2267742828@qq.com> Date: Thu, 29 Aug 2024 17:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E6=BB=91=E5=8A=A8=E8=8C=83?= =?UTF-8?q?=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mycomponents/scan/winScanButton.vue | 29 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/mycomponents/scan/winScanButton.vue b/src/mycomponents/scan/winScanButton.vue index 0672ad2a..60135d97 100644 --- a/src/mycomponents/scan/winScanButton.vue +++ b/src/mycomponents/scan/winScanButton.vue @@ -28,22 +28,35 @@ }, props: { - }, - - created() { - }, methods: { + getScreenWidth() { + const systemInfo = uni.getSystemInfoSync(); + return systemInfo.windowWidth; // 屏幕宽度,单位px + }, + getScreenHeight() { + const systemInfo = uni.getSystemInfoSync(); + return systemInfo.windowHeight; // 屏幕宽度,单位px + }, handleTouchStart(e) { this.btnX = e.changedTouches[0].clientX-e.currentTarget.offsetLeft this.btnY = e.changedTouches[0].clientY-e.currentTarget.offsetTop }, - handleTouchMove(e) { - console.log("handleTouchMove",e); + handleTouchMove(e) { + let maxLeft = this.getScreenWidth() - 60 + let maxTop = this.getScreenHeight() - 40 + console.log('maxTop',maxTop) // this.$refs.scanRef.$el.style.left = e.changedTouches[0].clientX-this.btnX+'px' // this.$refs.scanRef.$el.style.top = e.changedTouches[0].clientY-this.btnY+'px' - this.viewLeft = e.changedTouches[0].clientX-this.btnX+'px' - this.viewTop = e.changedTouches[0].clientY-this.btnY+'px' + let newLeft = e.changedTouches[0].clientX-this.btnX + let newTop = e.changedTouches[0].clientY-this.btnY + console.log('newTop',newTop) + if(newTop>0&&newTop0&&newLeft{