11 changed files with 228 additions and 7 deletions
@ -0,0 +1,71 @@ |
|||
// pages/calibrator/calibrator.js
|
|||
Component({ |
|||
/** |
|||
* 组件的属性列表 |
|||
*/ |
|||
properties: {}, |
|||
|
|||
/** |
|||
* 组件的初始数据 |
|||
*/ |
|||
data: { |
|||
pendingStart: 0, |
|||
success: false, |
|||
lineStyle: "", |
|||
}, |
|||
|
|||
/** |
|||
* 组件的方法列表 |
|||
*/ |
|||
methods: {}, |
|||
lifetimes: { |
|||
attached() { |
|||
const windowInfo = wx.getWindowInfo(); |
|||
const vh = windowInfo.windowHeight; |
|||
wx.startDeviceMotionListening({ interval: "ui" }); |
|||
this.deviceCb = ({ beta, gamma }) => { |
|||
if (this.data.success) return; |
|||
const isGammaPass = |
|||
(gamma > -45 && gamma < 45) || gamma < -135 || gamma > 135; |
|||
let top = |
|||
(((Math.abs(gamma) > 90 ? 180 - Math.abs(beta) : Math.abs(beta)) / |
|||
90) * |
|||
vh) / |
|||
2; |
|||
if (!isGammaPass) { |
|||
if (top < vh / 2) top = vh / 2 - 100; |
|||
else top = vh / 2 + 100; |
|||
} |
|||
const success = top > vh / 2 - 50 && top < vh / 2 + 50; |
|||
if (!success) { |
|||
this.setData({ |
|||
lineStyle: `top: ${top}px;`, |
|||
pendingStart: 0, |
|||
}); |
|||
} else if (!this.data.pendingStart) { |
|||
this.setData({ |
|||
lineStyle: `top: ${top}px;`, |
|||
pendingStart: Date.now(), |
|||
}); |
|||
} else if (Date.now() - this.data.pendingStart > 750) { |
|||
this.setData({ |
|||
lineStyle: `top: ${top}px;`, |
|||
success: true, |
|||
}); |
|||
setTimeout(() => { |
|||
this.triggerEvent("success"); |
|||
}, 500); |
|||
} else { |
|||
this.setData({ |
|||
lineStyle: `top: ${top}px;`, |
|||
}); |
|||
} |
|||
}; |
|||
wx.onDeviceMotionChange(this.deviceCb); |
|||
}, |
|||
detached() { |
|||
wx.offDeviceMotionChange(this.deviceCb); |
|||
wx.stopDeviceMotionListening(); |
|||
}, |
|||
}, |
|||
}); |
|||
@ -0,0 +1,4 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": {} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<view class="calibrator"> |
|||
<view class="title">请竖举手机</view> |
|||
<view class="meta">将摄像头对准周围环境,并保持手机对准水平状态</view> |
|||
<view class="rect"> |
|||
<view class="l1"></view> |
|||
<image src="./p.png" class="p" mode="" /> |
|||
<view class="l2"></view> |
|||
</view> |
|||
<view class="meta1">请校准手机至中间高亮区域</view> |
|||
<view class="line" style="{{ lineStyle }}"> |
|||
<view class="l"></view> |
|||
<image src="./p1.png" class="p" mode="" /> |
|||
</view> |
|||
</view> |
|||
@ -0,0 +1,127 @@ |
|||
.calibrator { |
|||
position: fixed; |
|||
top: 0; |
|||
bottom: 0; |
|||
left: 0; |
|||
right: 0; |
|||
z-index: 10; |
|||
background: rgba(0, 0, 0, 0.8); |
|||
} |
|||
.rect { |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
position: absolute; |
|||
left: 0; |
|||
top: calc(50vh - 40px); |
|||
width: 100vw; |
|||
height: 80px; |
|||
background: rgba(238, 233, 222, 0.3); |
|||
backdrop-filter: blur(3px); |
|||
} |
|||
.rect .l1 { |
|||
position: absolute; |
|||
bottom: 25px; |
|||
left: 14px; |
|||
width: calc(50vw - 30px); |
|||
border-top: 2px dashed rgba(215, 207, 198, 0.4); |
|||
} |
|||
.rect .l2 { |
|||
position: absolute; |
|||
bottom: 25px; |
|||
right: 14px; |
|||
width: calc(50vw - 30px); |
|||
border-top: 2px dashed rgba(215, 207, 198, 0.4); |
|||
} |
|||
.rect .p { |
|||
position: absolute; |
|||
left: 0; |
|||
right: 0; |
|||
bottom: 16px; |
|||
margin: auto; |
|||
width: 24px; |
|||
height: 40px; |
|||
} |
|||
.title { |
|||
position: absolute; |
|||
left: 0; |
|||
right: 0; |
|||
top: calc(50vh - 40px - 192px - 34px); |
|||
margin: auto; |
|||
color: var(--T-G1, #eee9de); |
|||
text-align: center; |
|||
/* 标题-Title1/B */ |
|||
font-family: "PingFang SC"; |
|||
font-size: 24px; |
|||
font-style: normal; |
|||
font-weight: 500; |
|||
line-height: normal; |
|||
z-index: 2; |
|||
} |
|||
.opacity6 { |
|||
opacity: 0.6; |
|||
} |
|||
.meta { |
|||
position: absolute; |
|||
left: 0; |
|||
right: 0; |
|||
top: calc(50vh - 40px - 137px - 41px); |
|||
width: 288px; |
|||
margin: auto; |
|||
padding: 12px; |
|||
border-radius: 16px; |
|||
background: rgba(0, 0, 0, 0.7); |
|||
backdrop-filter: blur(6px); |
|||
color: var(--T-9, #fff); |
|||
text-align: center; |
|||
font-family: "PingFang SC"; |
|||
font-size: 12px; |
|||
font-style: normal; |
|||
font-weight: 400; |
|||
line-height: normal; |
|||
z-index: 2; |
|||
} |
|||
.line { |
|||
position: absolute; |
|||
width: 100vh; |
|||
height: 80px; |
|||
top: 50vh; |
|||
left: 0; |
|||
transform-origin: center; |
|||
transform: translateY(-40px); |
|||
z-index: 1; |
|||
} |
|||
.line .l { |
|||
position: absolute; |
|||
left: 16px; |
|||
right: 16px; |
|||
width: calc(100vw - 32px); |
|||
background: #ffdb00; |
|||
height: 4px; |
|||
border-radius: 100px; |
|||
bottom: 23px; |
|||
z-index: 1; |
|||
} |
|||
.line .p { |
|||
position: absolute; |
|||
width: 30px; |
|||
height: 56px; |
|||
left: calc(50vw - 15px); |
|||
bottom: 11px; |
|||
z-index: 2; |
|||
} |
|||
.meta1 { |
|||
position: absolute; |
|||
left: 0; |
|||
right: 0; |
|||
top: calc(50vh + 40px + 18px); |
|||
color: var(--T-G2, #d1c8b9); |
|||
text-align: center; |
|||
/* Font/正文B2M-14 */ |
|||
font-family: "PingFang SC"; |
|||
font-size: 14px; |
|||
font-style: normal; |
|||
font-weight: 500; |
|||
line-height: normal; |
|||
z-index: 2; |
|||
} |
|||
|
After Width: | Height: | Size: 736 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
Loading…
Reference in new issue