https:
wx.startDeviceMotionListening({interval:'ui',
success(e) {
wx.onDeviceMotionChange((res) => {
if (res.alpha) {
let timestamp = Date.now()
console.log("motion时间戳",timestamp)
let motion = res
motion.timestamp = timestamp
let time = new Date().toLocaleTimeString()
motion.time = time
let data = {
type: "device",
tag_id: app.globalData.tagId,
data: {
motion: motion
}
}
// console.log("设备值",res)
let count=that.data.sendCount+1
if(that.data.sendCount%4==0){
sendSocketMessage(data,app.globalData)
}
that.setLocationMakerDirection(res.alpha)
// //console.log("罗盘", res.direction)
that.setData({
angle: res.alpha,
sendCount:count
})
}
})
}
})