feat:天平监听问题
This commit is contained in:
@@ -403,12 +403,8 @@ const fieldClick = (field, key) => {
|
||||
let decimalPosition = field.decimalPosition
|
||||
if (decimalPosition == null || decimalPosition < -1) decimalPosition = -1
|
||||
numKeyboardParam.decimal = decimalPosition
|
||||
if (currentFillingWay.value == 'collect') {
|
||||
listenDeviceData()
|
||||
} else {
|
||||
closeDeviceListener()
|
||||
}
|
||||
}
|
||||
|
||||
const currentFillingIndex = ref(0)
|
||||
const fillingWay = computed(() => {
|
||||
if (selectedField.value.fillingWay) {
|
||||
@@ -420,6 +416,16 @@ const fillingWay = computed(() => {
|
||||
const currentFillingWay = computed(() => {
|
||||
return fillingWay.value[currentFillingIndex.value] || ''
|
||||
})
|
||||
watch(
|
||||
() => currentFillingWay.value,
|
||||
newVal => {
|
||||
if (newVal == 'collect') {
|
||||
listenDeviceData()
|
||||
} else {
|
||||
closeDeviceListener()
|
||||
}
|
||||
}
|
||||
)
|
||||
const switchFillingWay = () => {
|
||||
currentFillingIndex.value = (currentFillingIndex.value + 1) % fillingWay.value.length
|
||||
}
|
||||
@@ -1047,8 +1053,11 @@ const listenDeviceData = () => {
|
||||
uni.$on('deviceData', res => {
|
||||
switch (res.deviceType) {
|
||||
case 'balance':
|
||||
console.log(res.deviceId)
|
||||
|
||||
if (currentAuncel.value.id === res.deviceId) {
|
||||
console.log('天平信息', res)
|
||||
console.log(res)
|
||||
|
||||
currentAuncel.value.weightData = res.weightData
|
||||
currentAuncel.value.weightUnit = res.weightUnit
|
||||
currentAuncel.value.weightStable = res.weightStable
|
||||
@@ -1076,7 +1085,6 @@ const listenDeviceData = () => {
|
||||
//控制设备状态
|
||||
uni.$on('controlDevice', res => {
|
||||
if (currentAuncel.value.id === res.deviceId) {
|
||||
console.log('控制', res.deviceId)
|
||||
currentAuncel.value.id = ''
|
||||
currentAuncel.value.name = ''
|
||||
currentAuncel.value.code = ''
|
||||
@@ -1253,7 +1261,7 @@ onLoad(param => {
|
||||
|
||||
onShow(() => {
|
||||
loadDevice()
|
||||
listenDeviceData()
|
||||
// listenDeviceData()
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
|
||||
Reference in New Issue
Block a user