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