uni.connectSocket({
url: '',
success: res => {
console.log(res);
}
});
uni.onSocketOpen(res => {
if (this.autoOff) {
this.working = true;
if(this.autoOff) getApp().globalData.navi.playTTS("虫连成功", true);
}
this.sendLoaction();
this.localTimer = setInterval(e => {
this.sendLoaction();
}, 10000);
this.workTimer = setInterval(e => {
this.updateTimer();
}, 1000);
});
uni.onSocketMessage(res => {
let obj = this.dealData(res.data);
console.log(obj, this.orderinfo);
if (obj.id && !this.myorder.id && this.ignoreArr.indexOf(obj.id) < 0) {
// TODO
}
if (obj.voice && (this.myorder.id || obj.force == 1)) {
}
});
//监听打开失败
uni.onSocketError(function(res) {
console.log('WebSocket连接打开失败,请检查!', res);
});
uni.onSocketClose(e => {
console.log('close Ws', e);
this.working = false;
clearInterval(this.workTimer);
clearInterval(this.localTimer);
this.getWork();
});
5***@qq.com (作者)
可以正常返回应用,没有重新打开APP的过程。
2021-12-17 11:26
5***@qq.com (作者)
一开始我以为是定时器太多的问题,现在把定时器简化成一个。今天上午测试还是没有正确触发
2021-12-17 11:29
DCloud_Android_ST
回复 5***@qq.com: 请提供一下完整HXdemo示例我们这边测试下 还有如何得知已断开?
2021-12-17 11:38
5***@qq.com (作者)
回复 DCloud_Android_ST: 我们先找了个第三方的插件试试,如果还不行,再反馈。谢谢了
2021-12-17 12:04