From 4caed43416ee5c7408083a8a4220f200695e108e Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Sat, 15 Feb 2025 14:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- page_components/eletj.vue | 43 ++++++++++++++++++++++++++++-- page_components/fuwu/index.vue | 48 ++++++++++++---------------------- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/page_components/eletj.vue b/page_components/eletj.vue index e11cede..16d56a6 100644 --- a/page_components/eletj.vue +++ b/page_components/eletj.vue @@ -253,6 +253,7 @@ var xBlufi = require("@/page_components/blufi/xBlufi.js") import uniEcCanvas from '@/components/uni-ec-canvas/uni-ec-canvas.vue' import * as echarts from '@/components/uni-ec-canvas/echarts' +import { Counter } from './blufi/crypto/aes' let chart = null export default { components: { @@ -323,7 +324,9 @@ ver_data:null, ver_dataflag:1, modelId:[], - devicesarr:[] + devicesarr:[], + timedingshi: null, // 定时器 + countdown: 30, // 倒计时时间 } }, onLoad(option) { @@ -336,6 +339,7 @@ if(option.deviceId){ this.ver_dataflag = 3 xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + this.startTimerdingshi() }else{ xBlufi.notifyStartDiscoverBle({'isStart': true}) xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) @@ -354,6 +358,7 @@ onUnload: function() { console.log("unload "); this.stopTimer(); + this.clearTimer() clearInterval(this.timerone); this.timerone= null xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); @@ -416,6 +421,33 @@ } }, methods: { + // 启动定时器 + startTimerdingshi() { + let that = this + that.clearTimer(); // 先清除之前的定时器 + that.timedingshi = setInterval(() => { + that.countdown--; // 倒计时减 1 + console.log(that.countdown,that.deviceId); + if (that.countdown <= 0) { + xBlufi.notifyConnectBle({ + isStart: false, + deviceId: that.deviceId, + name: that.name + }) + that.clearTimer() // 倒计时结束,清除定时器 + uni.reLaunch({ + url:'/pages/shouye/index' + }) + } + }, 1000); // 每秒执行一次 + }, + // 清除定时器 + clearTimer() { + if (this.timedingshi) { + clearInterval(this.timedingshi); // 清除定时器 + this.timedingshi = null; + } + }, // 点击续单 跳转到重新下单 btnxudan(){ let that = this @@ -604,6 +636,8 @@ } else { // console.log(this.tdtxt,'020202'); if (this.tdtxt == '开启') { + this.countdown = 30; // 重置倒计时时间 + this.startTimerdingshi() let that = this uni.getNetworkType({ success(res) { @@ -627,6 +661,8 @@ } }) } else { + this.countdown = 30; // 重置倒计时时间 + this.startTimerdingshi() let that = this uni.getNetworkType({ success(res) { @@ -995,7 +1031,9 @@ } this.onlineStatus = res.data.onlineStatus this.qrResult = res.data.mac - this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':') + if(this.ver_dataflag != 3){ + this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':') + } this.modelId = res.data.modelTags if(this.ver_dataflag != 3){ this.getlanya() @@ -1218,6 +1256,7 @@ setTimeout(()=>{ this.ver_dataflag = 3 },2000) + this.startTimerdingshi() xBlufi.notifyInitBleEsp32({ deviceId: this.deviceId }) diff --git a/page_components/fuwu/index.vue b/page_components/fuwu/index.vue index 6c964ff..ccaf5ca 100644 --- a/page_components/fuwu/index.vue +++ b/page_components/fuwu/index.vue @@ -178,15 +178,15 @@ - + + @@ -308,7 +308,7 @@ export default { zhekou: '', exit: 0, modelId:[], - devicesarr:[] + devicesarr:[], } }, onLoad(option) { @@ -319,22 +319,8 @@ export default { }else{ xBlufi.initXBlufi(1) - // wx.openBluetoothAdapter({ - // success: function (res) { - // console.log('蓝牙适配器初始化成功') - // xBlufi.initXBlufi(1) - // }, - // fail: function (err) { - // uni.showToast({ - // title: '蓝牙权限获取失败,请打开系统蓝牙和定位', - // icon: 'none', - // duration:3000 - // }) - // console.error('蓝牙适配器初始化失败,可能是因为没有权限', err) - // } - // }) } - this.swindleflag = true + // this.swindleflag = true if (option.q) { function getQueryParam(url, paramName) { let regex = new RegExp(`[?&]${paramName}=([^&]*)`) @@ -516,17 +502,17 @@ export default { console.log(this.jine); }, // 点击我已知晓隐藏防骗提示 - btnswindleflag() { - this.swindleflag = false - if (this.onlineStatus == 0) { - // if (this.ver_data == '') { + // btnswindleflag() { + // this.swindleflag = false + // if (this.onlineStatus == 0) { + // // if (this.ver_data == '') { - // } else { - // this.ver_dataflag = 3 - // uni.hideLoading() - // } - } - }, + // // } else { + // // this.ver_dataflag = 3 + // // uni.hideLoading() + // // } + // } + // }, // 获取支付渠道 getzfqd() { this.$u.get(`/app/channel/recharge/enabledList?mchId=` + this.deviceobj.userId).then(res => { @@ -805,7 +791,7 @@ export default { this.getzfqd() //调用获取支付渠道 // 判断该设备有没有套餐 if (this.deviceobj.suitList.length == 0 || this.deviceobj.suitList == '') { - this.swindleflag = false + // this.swindleflag = false if (this.userId == this.deviceobj.userId && this.deviceobj.suitList.length == 0) { let that = this uni.showModal({