修复bug
This commit is contained in:
parent
831a718d19
commit
4f0d5c4390
|
@ -543,6 +543,15 @@
|
||||||
this.imgflag = true
|
this.imgflag = true
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
setTimeout(() =>{
|
||||||
|
if(this.ver_data == '' || this.ver_data == null){
|
||||||
|
uni.showToast({
|
||||||
|
title: '未搜索到蓝牙,请重试',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},15000)
|
||||||
} else {
|
} else {
|
||||||
// console.log(this.tdtxt,'020202');
|
// console.log(this.tdtxt,'020202');
|
||||||
if (this.tdtxt == '开启') {
|
if (this.tdtxt == '开启') {
|
||||||
|
@ -1240,24 +1249,20 @@
|
||||||
const date = new Date(dateTimeString)
|
const date = new Date(dateTimeString)
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
// 计算时间差(毫秒)
|
// 计算时间差(毫秒)
|
||||||
const diff = now - date
|
const diff = now - date
|
||||||
|
|
||||||
// 将毫秒转换为天、小时、分钟和秒
|
// 将毫秒转换为天、小时、分钟和秒
|
||||||
const days = Math.floor(diff / (1000 * 60 * 60 * 24))
|
const days = Math.floor(diff / (1000 * 60 * 60 * 24))
|
||||||
const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
|
const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
|
||||||
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
|
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
|
||||||
const seconds = Math.floor((diff % (1000 * 60)) / 1000)
|
const seconds = Math.floor((diff % (1000 * 60)) / 1000)
|
||||||
|
|
||||||
// 创建一个对象来存储结果,并忽略零值
|
// 创建一个对象来存储结果,并忽略零值
|
||||||
const timeDifference = {
|
const timeDifference = {
|
||||||
days: days > 0 ? days : undefined,
|
days: days > 0 ? days : undefined,
|
||||||
hours: hours > 0 ? hours : undefined,
|
hours: hours > 0 ? hours : undefined,
|
||||||
minutes: minutes > 0 ? minutes : undefined,
|
minutes: minutes > 0 ? minutes : undefined,
|
||||||
seconds: seconds > 0 ? seconds : undefined
|
seconds: seconds > 0 ? seconds : undefined
|
||||||
};
|
}
|
||||||
|
|
||||||
// 转换为字符串,忽略未定义的属性
|
// 转换为字符串,忽略未定义的属性
|
||||||
let result = ''
|
let result = ''
|
||||||
if (timeDifference.days !== undefined) {
|
if (timeDifference.days !== undefined) {
|
||||||
|
@ -1329,7 +1334,6 @@
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getDevice()
|
this.getDevice()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
|
|
||||||
// this.loadings=true
|
// this.loadings=true
|
||||||
// this.initChart()
|
// this.initChart()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1350,14 +1354,11 @@
|
||||||
changeidx(index) {
|
changeidx(index) {
|
||||||
this.curtitidx = index
|
this.curtitidx = index
|
||||||
},
|
},
|
||||||
|
|
||||||
toydfx() {
|
toydfx() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/page_components/eletj?id=" + this.id
|
url: "/page_components/eletj?id=" + this.id
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
funListenDeviceMsgEvent: function(options) {
|
funListenDeviceMsgEvent: function(options) {
|
||||||
switch (options.type) {
|
switch (options.type) {
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||||
|
@ -1402,7 +1403,7 @@
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
if (!this.hasCalledGetczly) {
|
if (!this.hasCalledGetczly) {
|
||||||
this.btnjieshu()
|
// this.btnjieshu()
|
||||||
this.hasCalledGetczly = true
|
this.hasCalledGetczly = true
|
||||||
}
|
}
|
||||||
// this.czflag = false
|
// this.czflag = false
|
||||||
|
@ -1470,28 +1471,6 @@
|
||||||
return parsedData
|
return parsedData
|
||||||
},
|
},
|
||||||
|
|
||||||
// parseCustomData(data) {
|
|
||||||
// // 将字符串按照 "@" 分割成数组
|
|
||||||
// const dataArray = data.split('@');
|
|
||||||
// // 根据约定,解析各个字段的值
|
|
||||||
// const voltage = parseFloat(dataArray[0].substring(1)); // 去除前缀 "V",并将字符串转换为浮点数
|
|
||||||
// const switchState = dataArray[1].substring(1); // 去除前缀 "S"
|
|
||||||
// const current = parseFloat(dataArray[2].substring(1)); // 去除前缀 "A",并将字符串转换为浮点数
|
|
||||||
// const power = parseFloat(dataArray[4].substring(1)); // 去除前缀 "P",并将字符串转换为浮点数
|
|
||||||
// const remainingPower = parseFloat(dataArray[5].substring(1)); // 去除前缀 "M",并将字符串转换为浮点数
|
|
||||||
// const setMode = dataArray[6].substring(1); // 去除前缀 "T"
|
|
||||||
|
|
||||||
// // 返回解析后的数据对象
|
|
||||||
// return {
|
|
||||||
// voltage,
|
|
||||||
// switchState,
|
|
||||||
// current,
|
|
||||||
// power,
|
|
||||||
// remainingPower,
|
|
||||||
// setMode
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -204,7 +204,9 @@
|
||||||
mchShowBillMobile:'',
|
mchShowBillMobile:'',
|
||||||
telslag:false,
|
telslag:false,
|
||||||
userId:'',
|
userId:'',
|
||||||
hasCalledGetczly:false
|
hasCalledGetczly:false,
|
||||||
|
hasCalledGetczlys:false,
|
||||||
|
hasCalledGetczlyss:false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
|
@ -784,11 +786,49 @@
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||||
that.ver_data = ''
|
that.ver_data = ''
|
||||||
uni.showToast({
|
uni.showModal({
|
||||||
title: '蓝牙已断开,充值失败',
|
title: '温馨提示',
|
||||||
icon: 'none',
|
content: '设备开启失败,检测到设备蓝牙已断开',
|
||||||
duration: 2000
|
showCancel: false,
|
||||||
|
success: function(res) {
|
||||||
|
// uni.showLoading({
|
||||||
|
// title: '蓝牙连接中'
|
||||||
|
// })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
// this.czflag = true
|
||||||
|
// let that = this
|
||||||
|
// xBlufi.initXBlufi(1);
|
||||||
|
// xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvents);
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': true
|
||||||
|
// })
|
||||||
|
// setTimeout(() => {
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': false
|
||||||
|
// })
|
||||||
|
// if (that.devicesList.length > 0) {
|
||||||
|
// xBlufi.notifyConnectBle({
|
||||||
|
// isStart: true,
|
||||||
|
// deviceId: that.deviceId,
|
||||||
|
// name: that.name
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }, 2000)
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// if(this.ver_data == ''){
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未连接成功,如多次失败请点击右上角联系客服咨询',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 5000
|
||||||
|
// })
|
||||||
|
// this.czflag = false
|
||||||
|
// this.zhifuflag = false
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// uni.hideLoading()
|
||||||
|
// },5000)
|
||||||
|
// }
|
||||||
|
// },10000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -880,14 +920,53 @@
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||||
|
let that = this
|
||||||
that.ver_data = ''
|
that.ver_data = ''
|
||||||
uni.showToast({
|
uni.showModal({
|
||||||
title: '蓝牙已断开,充值失败',
|
title: '温馨提示',
|
||||||
icon: 'none',
|
content: '设备开启失败,检测到设备蓝牙已断开',
|
||||||
duration: 2000
|
showCancel: false,
|
||||||
})
|
success: function(res) {
|
||||||
|
// uni.showLoading({
|
||||||
|
// title: '蓝牙连接中'
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// that.czflag = true
|
||||||
|
// xBlufi.initXBlufi(1);
|
||||||
|
// xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEventss);
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': true
|
||||||
|
// })
|
||||||
|
// setTimeout(() => {
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': false
|
||||||
|
// })
|
||||||
|
// if (that.devicesList.length > 0) {
|
||||||
|
// xBlufi.notifyConnectBle({
|
||||||
|
// isStart: true,
|
||||||
|
// deviceId: that.deviceId,
|
||||||
|
// name: that.name
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }, 2000)
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// if(that.ver_data == ''){
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未连接成功,如多次失败请点击右上角联系客服咨询',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 5000
|
||||||
|
// })
|
||||||
|
// that.czflag = false
|
||||||
|
// that.zhifuflag = false
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// uni.hideLoading()
|
||||||
|
// },5000)
|
||||||
|
// }
|
||||||
|
// },10000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(that.ver_data != ''){
|
||||||
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
that.zhifuflag = false
|
that.zhifuflag = false
|
||||||
|
@ -905,6 +984,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('手机未连接网络')
|
console.log('手机未连接网络')
|
||||||
// this.baiflag = false
|
// this.baiflag = false
|
||||||
|
@ -1047,12 +1127,50 @@
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||||
|
let that = this
|
||||||
that.ver_data = ''
|
that.ver_data = ''
|
||||||
uni.showToast({
|
uni.showModal({
|
||||||
title: '蓝牙已断开,充值失败',
|
title: '温馨提示',
|
||||||
icon: 'none',
|
content: '设备开启失败,检测到设备蓝牙已断开',
|
||||||
duration: 2000
|
showCancel: false,
|
||||||
|
success: function(res) {
|
||||||
|
// uni.showLoading({
|
||||||
|
// title: '蓝牙连接中'
|
||||||
|
// })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
// that.czflag = true
|
||||||
|
// xBlufi.initXBlufi(1);
|
||||||
|
// xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvents);
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': true
|
||||||
|
// })
|
||||||
|
// setTimeout(() => {
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': false
|
||||||
|
// })
|
||||||
|
// if (that.devicesList.length > 0) {
|
||||||
|
// xBlufi.notifyConnectBle({
|
||||||
|
// isStart: true,
|
||||||
|
// deviceId: that.deviceId,
|
||||||
|
// name: that.name
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }, 2000)
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// if(that.ver_data == ''){
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未连接成功,如多次失败请点击右上角联系客服咨询',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 5000
|
||||||
|
// })
|
||||||
|
// that.czflag = false
|
||||||
|
// that.zhifuflag = false
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// uni.hideLoading()
|
||||||
|
// },5000)
|
||||||
|
// }
|
||||||
|
// },10000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -1140,18 +1258,8 @@
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "time@" + that.jine
|
customData: "time@" + that.jine
|
||||||
})
|
})
|
||||||
},1000)
|
|
||||||
},
|
if(that.ver_data != ''){
|
||||||
fail(err) {
|
|
||||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
|
||||||
that.ver_data = ''
|
|
||||||
uni.showToast({
|
|
||||||
title: '蓝牙已断开,充值失败',
|
|
||||||
icon: 'none',
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
that.zhifuflag = false
|
that.zhifuflag = false
|
||||||
|
@ -1178,6 +1286,72 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
},1000)
|
||||||
|
|
||||||
|
},
|
||||||
|
fail(err) {
|
||||||
|
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||||
|
let that = this
|
||||||
|
that.ver_data = ''
|
||||||
|
uni.showModal({
|
||||||
|
title: '温馨提示',
|
||||||
|
content: '设备开启失败,检测到设备蓝牙已断开',
|
||||||
|
showCancel: false,
|
||||||
|
success: function(res) {
|
||||||
|
// uni.showLoading({
|
||||||
|
// title: '蓝牙连接中'
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// that.czflag = true
|
||||||
|
// xBlufi.initXBlufi(1);
|
||||||
|
// xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEventss);
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': true
|
||||||
|
// })
|
||||||
|
// setTimeout(() => {
|
||||||
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': false
|
||||||
|
// })
|
||||||
|
// if (that.devicesList.length > 0) {
|
||||||
|
// xBlufi.notifyConnectBle({
|
||||||
|
// isStart: true,
|
||||||
|
// deviceId: that.deviceId,
|
||||||
|
// name: that.name
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }, 2000)
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// if(that.ver_data == ''){
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未连接成功,如多次失败请点击右上角联系客服咨询',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 5000
|
||||||
|
// })
|
||||||
|
// that.czflag = false
|
||||||
|
// that.zhifuflag = false
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// uni.hideLoading()
|
||||||
|
// },5000)
|
||||||
|
// }else{
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未连接成功,如多次失败请点击右上角联系客服咨询',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 5000
|
||||||
|
// })
|
||||||
|
// that.czflag = false
|
||||||
|
// that.zhifuflag = false
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// uni.hideLoading()
|
||||||
|
// },5000)
|
||||||
|
// }
|
||||||
|
// },10000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log('手机未连接网络')
|
console.log('手机未连接网络')
|
||||||
// this.baiflag = false
|
// this.baiflag = false
|
||||||
|
@ -1323,7 +1497,6 @@
|
||||||
xBlufi.notifyInitBleEsp32({
|
xBlufi.notifyInitBleEsp32({
|
||||||
deviceId: this.deviceId
|
deviceId: this.deviceId
|
||||||
});
|
});
|
||||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);
|
|
||||||
this.deviceIds = options.data.deviceId
|
this.deviceIds = options.data.deviceId
|
||||||
this.name = this.name
|
this.name = this.name
|
||||||
}
|
}
|
||||||
|
@ -1369,6 +1542,296 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
funListenDeviceMsgEvents: function(options) {
|
||||||
|
switch (options.type) {
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||||
|
if (!options.result) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '很抱歉提醒你!',
|
||||||
|
content: '小程序与设备异常断开',
|
||||||
|
showCancel: false,
|
||||||
|
//是否显示取消按钮
|
||||||
|
success: function(res) {
|
||||||
|
this.ver_data = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||||
|
if (options.result) {
|
||||||
|
let devicesarr = options.data
|
||||||
|
console.log(devicesarr,this.mac,'111');
|
||||||
|
devicesarr.forEach(device => {
|
||||||
|
const mac = device.name.substring(4);
|
||||||
|
if (device.name.slice(5, 17) == this.mac.slice(5, 17)) {
|
||||||
|
this.deviceId = device.deviceId
|
||||||
|
this.name = device.name
|
||||||
|
// console.log(device.name,this.mac,'222');
|
||||||
|
this.devicesList.push(device);
|
||||||
|
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||||
|
// 将去重后的数组重新赋值给 this.devicesList
|
||||||
|
this.devicesList = uniqueDevicesList;
|
||||||
|
} else {
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未找到该设备,请确认该设备在附近',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 3000
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||||
|
console.log("连接回调:" + JSON.stringify(options));
|
||||||
|
if (options.result) {
|
||||||
|
// console.log('125451245')
|
||||||
|
{
|
||||||
|
xBlufi.notifyInitBleEsp32({
|
||||||
|
deviceId: this.deviceId
|
||||||
|
});
|
||||||
|
this.deviceIds = options.data.deviceId
|
||||||
|
this.name = this.name
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||||
|
this.ver_data = this.parseCustomData(options.data)
|
||||||
|
console.log("1收到设备发来的自定义数据结果:", this.ver_data);
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.czflag = false
|
||||||
|
this.zhifuflag = false
|
||||||
|
uni.hideLoading()
|
||||||
|
|
||||||
|
if (!this.hasCalledGetczlys) {
|
||||||
|
this.hasCalledGetczlys = true
|
||||||
|
let that = this
|
||||||
|
uni.getNetworkType({
|
||||||
|
success(res) {
|
||||||
|
if (res.networkType !== 'none') {
|
||||||
|
uni.getConnectedBluetoothDevices({
|
||||||
|
success(res) {
|
||||||
|
that.jzflag = true
|
||||||
|
that.startLoading()
|
||||||
|
setTimeout(()=> {
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: 'open'
|
||||||
|
})
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: '11open'
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
that.zhifuflag = false
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/page_components/eletj?id=' + that.orderno
|
||||||
|
})
|
||||||
|
},1000)
|
||||||
|
},1500)
|
||||||
|
},
|
||||||
|
fail(err) {
|
||||||
|
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('手机未连接网络')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},1000)
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||||
|
if (options.result) {
|
||||||
|
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||||
|
let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) === "CTKG");
|
||||||
|
// 将过滤后的数组重新赋值给 this.devicesList
|
||||||
|
this.devicesList = filteredDevices;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||||
|
if (!options.result) {
|
||||||
|
this.lanyaflag = true
|
||||||
|
uni.showToast({
|
||||||
|
title: '蓝牙未开启',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.lanyaflag = false
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
funListenDeviceMsgEventss: function(options) {
|
||||||
|
switch (options.type) {
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||||
|
if (!options.result) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '很抱歉提醒你!',
|
||||||
|
content: '小程序与设备异常断开',
|
||||||
|
showCancel: false,
|
||||||
|
//是否显示取消按钮
|
||||||
|
success: function(res) {
|
||||||
|
this.ver_data = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||||
|
if (options.result) {
|
||||||
|
let devicesarr = options.data
|
||||||
|
console.log(devicesarr,this.mac,'111');
|
||||||
|
devicesarr.forEach(device => {
|
||||||
|
const mac = device.name.substring(4);
|
||||||
|
if (device.name.slice(5, 17) == this.mac.slice(5, 17)) {
|
||||||
|
this.deviceId = device.deviceId
|
||||||
|
this.name = device.name
|
||||||
|
// console.log(device.name,this.mac,'222');
|
||||||
|
this.devicesList.push(device);
|
||||||
|
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||||
|
// 将去重后的数组重新赋值给 this.devicesList
|
||||||
|
this.devicesList = uniqueDevicesList;
|
||||||
|
} else {
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '未找到该设备,请确认该设备在附近',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 3000
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||||
|
console.log("连接回调:" + JSON.stringify(options));
|
||||||
|
if (options.result) {
|
||||||
|
// console.log('125451245')
|
||||||
|
{
|
||||||
|
xBlufi.notifyInitBleEsp32({
|
||||||
|
deviceId: this.deviceId
|
||||||
|
});
|
||||||
|
this.deviceIds = options.data.deviceId
|
||||||
|
this.name = this.name
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||||
|
this.ver_data = this.parseCustomData(options.data)
|
||||||
|
console.log("1收到设备发来的自定义数据结果:", this.ver_data);
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.czflag = false
|
||||||
|
this.zhifuflag = false
|
||||||
|
uni.hideLoading()
|
||||||
|
|
||||||
|
if (!this.hasCalledGetczlyss) {
|
||||||
|
this.hasCalledGetczlyss = true
|
||||||
|
let that = this
|
||||||
|
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res =>{
|
||||||
|
// if(res.code == 200 || res.code == 500){
|
||||||
|
that.$u.put(`/app/bill/rechargeBillDevice?billNo=${that.orderno}`).then(res=>{
|
||||||
|
that.$u.get('/app/bill/recharge/device/fail/list').then(res => { //充值失败调用
|
||||||
|
if (res.code == 200) {
|
||||||
|
console.log('获取订单状态',res);
|
||||||
|
if(res.data.length > 0 && res.data != null){
|
||||||
|
let dingobj = res.data[0].billNo
|
||||||
|
console.log(dingobj,'订单号');
|
||||||
|
uni.getNetworkType({
|
||||||
|
success(res) {
|
||||||
|
if (res.networkType !== 'none') {
|
||||||
|
uni.getConnectedBluetoothDevices({
|
||||||
|
success(res) {
|
||||||
|
that.jzflag = true
|
||||||
|
that.startLoading()
|
||||||
|
setTimeout(()=> {
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: "time@" + that.jine
|
||||||
|
})
|
||||||
|
},1500)
|
||||||
|
},
|
||||||
|
fail(err) {
|
||||||
|
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(that.ver_data != ''){
|
||||||
|
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
that.zhifuflag = false
|
||||||
|
console.log('蓝牙离线充值成功11')
|
||||||
|
setTimeout(() => {
|
||||||
|
if(that.ver_data == ''){
|
||||||
|
uni.showToast({
|
||||||
|
title: '蓝牙已断开,蓝牙充值失败',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
that.zhifuflag = false
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/page_components/eletj?id=' + that.orderno
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},1000)
|
||||||
|
}else{
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('手机未连接网络')
|
||||||
|
// this.baiflag = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pages/shouye/index'
|
||||||
|
})
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},1000)
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||||
|
if (options.result) {
|
||||||
|
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||||
|
let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) === "CTKG");
|
||||||
|
// 将过滤后的数组重新赋值给 this.devicesList
|
||||||
|
this.devicesList = filteredDevices;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||||
|
if (!options.result) {
|
||||||
|
this.lanyaflag = true
|
||||||
|
uni.showToast({
|
||||||
|
title: '蓝牙未开启',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.lanyaflag = false
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 从蓝牙拿到数据进行解析
|
// 从蓝牙拿到数据进行解析
|
||||||
parseCustomData(data) {
|
parseCustomData(data) {
|
||||||
// 将字符串按照 "@" 分割成数组
|
// 将字符串按照 "@" 分割成数组
|
||||||
|
|
|
@ -628,28 +628,28 @@
|
||||||
wx.closeBLEConnection({
|
wx.closeBLEConnection({
|
||||||
deviceId: this.objlist.deviceId,
|
deviceId: this.objlist.deviceId,
|
||||||
})
|
})
|
||||||
uni.showModal({
|
// uni.showModal({
|
||||||
title: '温馨提示',
|
// title: '温馨提示',
|
||||||
content: `设备初始化失败,请重新连接`,
|
// content: `设备初始化失败,请重新连接`,
|
||||||
showCancel: false,
|
// showCancel: false,
|
||||||
//是否显示取消按钮
|
// //是否显示取消按钮
|
||||||
success: function(res) {
|
// success: function(res) {
|
||||||
let systemInfo = uni.getSystemInfoSync();
|
// let systemInfo = uni.getSystemInfoSync();
|
||||||
if (systemInfo.platform == 'android') {
|
// if (systemInfo.platform == 'android') {
|
||||||
// 当前设备是 Android
|
// // 当前设备是 Android
|
||||||
uni.navigateBack()
|
// uni.navigateBack()
|
||||||
} else if (systemInfo.platform == 'ios') {
|
// } else if (systemInfo.platform == 'ios') {
|
||||||
// 当前设备是 iOS
|
// // 当前设备是 iOS
|
||||||
uni.navigateBack({
|
// uni.navigateBack({
|
||||||
delta:2
|
// delta:2
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// uni.switchTab({
|
// // uni.switchTab({
|
||||||
// url:'/pages/index/index'
|
// // url:'/pages/index/index'
|
||||||
|
// // })
|
||||||
|
// }
|
||||||
// })
|
// })
|
||||||
}
|
|
||||||
})
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user