|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<view> |
|
|
|
<view class="scan_float" ref="scanRef" @click="goScan('bottom')" @touchstart="handleTouchStart" @touchmove.prevent="handleTouchMove"> |
|
|
|
<view class="scan_float" :style="{left:viewLeft,top:viewTop}" ref="scanRef" @click="goScan('bottom')" @touchstart="handleTouchStart" @touchmove.prevent="handleTouchMove"> |
|
|
|
<image src="@/static/icons_ui/icon_scan_white.svg"></image> |
|
|
|
<view>扫描</view> |
|
|
|
</view> |
|
|
@ -22,24 +22,46 @@ |
|
|
|
}, |
|
|
|
btnX:20, |
|
|
|
btnY:20, |
|
|
|
viewLeft:'auto', |
|
|
|
viewTop:'auto', |
|
|
|
} |
|
|
|
}, |
|
|
|
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); |
|
|
|
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' |
|
|
|
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' |
|
|
|
let newLeft = e.changedTouches[0].clientX-this.btnX |
|
|
|
let newTop = e.changedTouches[0].clientY-this.btnY |
|
|
|
console.log('newTop',newTop) |
|
|
|
if(newTop>0&&newTop<maxTop){ |
|
|
|
this.viewTop = newTop+'px' |
|
|
|
} |
|
|
|
if(newLeft>0&&newLeft<maxLeft){ |
|
|
|
this.viewLeft = newLeft+'px' |
|
|
|
} |
|
|
|
// const query = uni.createSelectorQuery().in(this) |
|
|
|
// console.log('scanRef',query.select("#scanRef")) |
|
|
|
// query.select("#scanRef").boundingClientRect((data=>{ |
|
|
|
// console.log('得到的位置信息',data) |
|
|
|
// })).exec(); |
|
|
|
}, |
|
|
|
|
|
|
|
goScan(content) { |
|
|
|