From 08a9c27934b31731972e134ed948dcd5eea5cd4c Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Fri, 18 Apr 2025 13:42:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=87=E8=8A=B1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.interceptor.js | 2 +- page_user/lanya.vue | 532 +++++++++++++++++++++---------------- page_user/upload.vue | 48 ++-- pages/index/index.vue | 53 +++- 4 files changed, 366 insertions(+), 269 deletions(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index ded5d64..77dc897 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -21,7 +21,7 @@ const install = (Vue, vm) => { // }); Vue.prototype.$u.http.setConfig({ baseUrl: 'https://yxd.ccttiot.com/prod-api', - // baseUrl: 'http://192.168.0.107:8081', + // baseUrl: 'http://192.168.0.101:8081', loadingText: '努力加载中~', loadingTime: 800, // 设置自定义头部content-type diff --git a/page_user/lanya.vue b/page_user/lanya.vue index 0b0b2ba..d501620 100644 --- a/page_user/lanya.vue +++ b/page_user/lanya.vue @@ -1,266 +1,316 @@ \ No newline at end of file diff --git a/page_user/upload.vue b/page_user/upload.vue index 7f3c5aa..930996a 100644 --- a/page_user/upload.vue +++ b/page_user/upload.vue @@ -23,10 +23,11 @@ - + 固件更新 - - + + + 可更新 @@ -72,7 +73,6 @@ 切记在蓝牙范围内,以防升级失败 - @@ -84,7 +84,6 @@ xpshow: false, gjshow: false, xptxt: '', - gjtxt: 'v2.1.2', nameflag: false, xplist: [{ value: '1', @@ -119,7 +118,8 @@ intervalId: null, progress:0, shengjiflag:false, - xctime:'--' + xctime:'--', + version:'' } }, // 分享到好友(会话) @@ -140,16 +140,18 @@ onLoad(option) { xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) this.deviceid = option.deviceid - if(option.xctime){ + if(option.xctime != '--'){ if(option.xctime != '--' && option.ver){ - this.ver = option.ver + this.ver = 'V' + option.ver.slice(3) this.xctime = option.xctime console.log(11); }else{ - this.ver = 1 + this.ver = 'V1' this.xctime = option.xctime console.log(22); } + }else{ + this.ver = null } this.getshebxq() @@ -207,18 +209,11 @@ xpconfirm(e) { this.xptxt = e[0].label }, - getbanben(){ - this.$u.get(`/app/model/${this.user.modelId}`).then(res => { - if (res.code == 200) { - this.file = res.data.asDeviceVersion.file - console.log(this.file) - // this.file = 'https://wc.chuangtewl.com/download/water_flower.bin' - } - }) - }, getbanbens(){ this.$u.get(`/app/model/${this.user.modelId}`).then(res => { if (res.code == 200) { + this.version = res.data.version + console.log(this.ver,'当前蓝牙版本号',this.version,'最新蓝牙版本号'); this.file = res.data.asDeviceVersion.file console.log(this.file) // this.file = 'https://wc.chuangtewl.com/download/water_flower.bin' @@ -237,8 +232,7 @@ }, // 选择固件版本 gjconfirm(e) { - // this.gjtxt = e[0].label - // if(this.ver != ''){ + if(this.ver != null && this.ver != this.version){ if(this.file == '' || this.file == null){ uni.showToast({ title: '暂无新版本', @@ -257,13 +251,13 @@ this.shengjiflag = true this.startProgress() } - // }else{ - // uni.showToast({ - // title: '请连接蓝牙获取版本号', - // icon: 'none', - // duration: 2000 - // }) - // } + }else{ + uni.showToast({ + title: '已是最新版本', + icon: 'none', + duration: 2000 + }) + } }, // 点击取消修改设备名称 btnqx() { diff --git a/pages/index/index.vue b/pages/index/index.vue index 6cce239..466b486 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -894,12 +894,55 @@ break case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: console.log("1收到设备发来的自定义数据结果:", options.data,options.data.length) - this.datalist = options.data.slice(0, -1) + ";" - this.vardataflag = 3 - if(this.pre == 'WATER'){ - this.getchuli() + if (options.data.indexOf("prom:") !== -1) { + console.log('固件升级中') + var indexOld = options.data.substring(options.data.indexOf('prom:')) + console.log("indexOld", indexOld); + var load_num = indexOld.substring( + indexOld.indexOf("prom:") + 5, + indexOld.indexOf("@") + ) + this.progress = Number(load_num); + console.log("load_num", load_num); + console.log("升级进度:", this.progress) + if (this.progress === 6000) { + console.log('固件成功') + this.progress = 100 + uni.showToast({ + title: '固件升级成功', + icon: 'success', + duration: 2000 + }) + setTimeout(()=>{ + this.shengjiflag = false + uni.reLaunch({ + url:'/pages/index/index' + }) + },2000) + } + if (this.progress === 9000) { + console.log('固件升级失败') + this.progress = 99 + uni.showToast({ + title: '固件升级失败', + icon: 'none', + duration: 2000 + }) + setTimeout(()=>{ + this.shengjiflag = false + uni.reLaunch({ + url:'/pages/index/index' + }) + },1000) + } }else{ - this.getcsbshuju() + this.datalist = options.data.slice(0, -1) + ";" + this.vardataflag = 3 + if(this.pre == 'WATER'){ + this.getchuli() + }else{ + this.getcsbshuju() + } } break case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: