diff --git a/page_components/blufi/xBlufi-wx-impl.js b/page_components/blufi/xBlufi-wx-impl.js index 73a0452..980f056 100644 --- a/page_components/blufi/xBlufi-wx-impl.js +++ b/page_components/blufi/xBlufi-wx-impl.js @@ -1145,7 +1145,7 @@ function init() { // && devices.devices[0].name != 'SMART_R2XS' // && devices.devices[0].name != 'SMART_R2XS' // ) - if (devices.devices[0].name.indexOf("CTKG") != -1 || devices.devices[0].name.indexOf("CTPO") != -1){ + if (devices.devices[0].name.indexOf("CTKG") != -1 || devices.devices[0].name.indexOf("CTPO") != -1 || devices.devices[0].name.indexOf("CCYK") != -1){ // console.log("跳过",devices.devices[0].name) // isnotexist = false; isnotexist = true; diff --git a/page_components/eletj.vue b/page_components/eletj.vue index 74ad8e4..f53f6ac 100644 --- a/page_components/eletj.vue +++ b/page_components/eletj.vue @@ -276,7 +276,8 @@ totalElectriQuantity: '', suitStartEle: '', sbobj: {}, - jieshufalg:false + jieshufalg:false, + channelId:'' } }, onLoad(option) { @@ -360,6 +361,13 @@ this.stopTimer(); }, methods: { + getzfqd(){ + this.$u.get(`/app/channel/recharge/enabledList`).then(res =>{ + if(res.code == 200){ + this.channelId = res.data[0].channelId + } + }) + }, btns() { // if(this.opflag){ // uni.navigateBack() @@ -370,9 +378,10 @@ // } }, btnljzf() { + this.getzfqd() let data = { billNo: this.orderno, - channelId: 5 + channelId: this.channelId } this.$u.put(`/app/bill/pay`, data).then((res) => { if (res.code == 200) { @@ -420,6 +429,7 @@ }) }, btnjieshu() { + this.getzfqd() if (this.detaobj.suitFeeMode == 1) { if (this.onlineStatus == 1) { let that = this @@ -495,6 +505,9 @@ xBlufi.notifySendCustomData({ customData: 'close' }) + xBlufi.notifySendCustomData({ + customData: '11close' + }) uni.showToast({ title: res.msg, icon: 'success', @@ -568,7 +581,7 @@ if (this.detaobj.status == 1) { let data = { billNo: this.orderno, - channelId: 5 + channelId: this.channelId } this.$u.put(`/app/bill/pay`, data).then((res) => { if (res.code == 200) { @@ -623,7 +636,7 @@ if (res.code == 200) { let data = { billNo: this.orderno, - channelId: 5 + channelId: this.channelId } this.$u.put(`/app/bill/pay`, data).then((res) => { if (res.code == 200) { @@ -723,7 +736,10 @@ success(res) { setTimeout(() => { xBlufi.notifySendCustomData({ - customData: 'close' + customData: 'close', + }) + xBlufi.notifySendCustomData({ + customData: '11close', }) setTimeout(() => { this.jieshuflag = false @@ -767,12 +783,15 @@ success(res) { setTimeout(() => { xBlufi.notifySendCustomData({ - customData: 'close' + customData: 'close', + }) + xBlufi.notifySendCustomData({ + customData: '11close', }) setTimeout(() => { let data = { billNo: that.orderno, - channelId: 5 + channelId: that.channelId } that.$u.put(`/app/bill/pay`,data).then((res) => { if (res.code ==200) { diff --git a/page_components/fuwu/index.vue b/page_components/fuwu/index.vue index f358003..b1be440 100644 --- a/page_components/fuwu/index.vue +++ b/page_components/fuwu/index.vue @@ -178,7 +178,8 @@ suitGearTime:[], suitPrice:'', payNo:'', - q:'' + q:'', + channelId:'' } }, onLoad(option) { @@ -216,6 +217,7 @@ }, onShow() { // this.getuserinfo() + this.getzfqd() setTimeout(()=>{ if (this.id != '') { this.$u.get("/app/user/userInfo").then((res) => { @@ -253,6 +255,21 @@ }) }, methods: { + getzfqd(){ + this.$u.get(`/app/channel/recharge/enabledList`).then(res =>{ + if(res.code == 200){ + this.channelId = res.data[0].channelId + uni.hideLoading() + }else{ + uni.hideLoading() + uni.showToast({ + title:res.msg, + icon: 'none', + duration:2000 + }) + } + }) + }, getone(){ let that = this let data = { @@ -421,6 +438,10 @@ duration: 1000 }) } else if (this.onlineStatus == 1) { + uni.showLoading({ + title: '准备支付中...' + }) + this.getzfqd() this.zhifuflag = false let that = this let data = { @@ -451,7 +472,7 @@ if(this.suitFeeType == 3 || this.suitFeeType == 4){ let data = { billNo:that.orderno, - channelId:5 + channelId:that.channelId } that.$u.put(`/app/bill/payDeposit`,data).then(res => { if(res.code == 200){ @@ -500,9 +521,9 @@ }else{ let data = { billNo:that.orderno, - channelId:5 + channelId:that.channelId } - that.$u.put(`/app/bill/pay/`,data).then((res) => { + that.$u.put(`/app/bill/pay`,data).then((res) => { if (res.code == 200) { uni.requestPayment({ provider: 'wxpay', @@ -600,6 +621,10 @@ } },10000) } else { + uni.showLoading({ + title: '准备支付中...' + }) + this.getzfqd() this.zhifuflag = false let that = this let data = { @@ -620,7 +645,7 @@ if(this.suitFeeType == 3 || this.suitFeeType == 4){ let data = { billNo:that.orderno, - channelId:5 + channelId:that.channelId } that.$u.put(`/app/bill/payDeposit`,data).then((res) => { if (res.code == 200) { @@ -655,6 +680,9 @@ xBlufi.notifySendCustomData({ customData: 'open' }) + xBlufi.notifySendCustomData({ + customData: '11open' + }) setTimeout(() => { that.zhifuflag = true uni.reLaunch({ @@ -755,9 +783,9 @@ }else{ let data = { billNo:that.orderno, - channelId:5 + channelId:that.channelId } - that.$u.put(`/app/bill/pay/`,data).then((res) => { + that.$u.put(`/app/bill/pay`,data).then((res) => { if (res.code == 200) { uni.requestPayment({ provider: 'wxpay', diff --git a/page_fenbao/device/joinDevice.vue b/page_fenbao/device/joinDevice.vue index b207c1c..6729ac7 100644 --- a/page_fenbao/device/joinDevice.vue +++ b/page_fenbao/device/joinDevice.vue @@ -1,60 +1,95 @@ @@ -65,10 +100,6 @@ export default { data() { return { - titleflag: false, //提示隐藏 - bgc: { - backgroundColor: "#F7FAFE", - }, devicesList: [ // {name:'110000', // mac:'11111'} @@ -79,201 +110,438 @@ tishiflag: false, option: '', bluthlist: [], //蓝牙数组 - status: 'loading', + // status: 'loading', statusflag: false, Bluetoothmac: '', - mac:'', - ishave:false, - ver_data:null, - deviceInfo:{}, - gps:{}, - isband:false, - status:false + mac: '', + ishave: false, + ver_data: null, + deviceInfoss: {}, + gps: {}, + isband: false, + // status: false, + deviceIds: '', + name: '', + orderinfo: {}, + dl: 0, + czmoney: true, + iscz: true, + banben: '请点击选择版本', + modelId: '', + bgc: { + backgroundColor: "#F7FAFE", + }, + sn: '', + carstause: false, + isbands: false, + show: false, + list: [], + hardwareInfo: {}, + showbind: false, + storeId:'' + + } }, onLoad(e) { console.log(e); - this.mac=e.mac - this.$u.get(`/app/device/${this.mac}/isBind`).then((res) => { - if (res.data == false) { - xBlufi.initXBlufi(1); - console.log("xBlufi", xBlufi.XMQTT_SYSTEM); - xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); - xBlufi.notifyStartDiscoverBle({ - 'isStart': true - }); - - // 两秒后停止蓝牙搜索 - setTimeout(() => { - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }); - // 判断是否存在浇花器设备 - if (this.devicesList.length == 0) { - uni.showToast({ - title: '暂无发现对应设备,请靠近设备', - icon: 'none' - }); - } else { - this.texts = '扫描到以下设备,请点击连接!' - } - this.status=true - }, 2000) - }else{ - uni.showToast({ - title: '改设备已经被绑定', - icon: 'none', - duration: 3000 - }); - } - }) - + this.mac = e.mac + this.Binddevice() + this.isbands = false + this.carstause = false + if(uni.getStorageSync('banben') || uni.getStorageSync('banbenid')){ + this.banben = uni.getStorageSync('banben') + this.modelId = uni.getStorageSync('banbenid') + } }, - // 分享到好友(会话) - onShareAppMessage: function () { - return { - title: '创想物联', - path: '/pages/shouye/index' - } - }, - - // 分享到朋友圈 - onShareTimeline: function () { - return { - title: '创想物联', - query: '', - path: '/pages/shouye/index' - } - }, - onShow: function() { - // this.openBluetoothAdapter() + onShow() { + this.getlist() }, onUnload: function() { xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.notifyStartDiscoverBle({ 'isStart': false }); - }, - onHide(){ + onHide() { xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.notifyStartDiscoverBle({ 'isStart': false }); }, - onBeforeUnmount(){ + onBeforeUnmount() { xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.notifyStartDiscoverBle({ 'isStart': false }); }, watch: { - - ishave(newValue) { - if (newValue === true) { - // 当 ishave 的值变为 true 时执行相应的操作 - // 这里可以放置你想要执行的代码 - console.log('ishave 的值变为 true'); - this.devicesList.forEach(device => { - // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) - let macFromName = device.name.substring(device.name.length - 12); - // console.log(macFromName); - // 与 this.mac 进行比较 - if (macFromName ==this.mac) { - // 如果相同,则将 this.ishave 设置为 true - console.log(device); - this.deviceInfo=device - // this.ishave = true; - this.createBLEConnection(device) - - console.log('对比正确'); - }else{ - console.log('对比失败'); - } - }); - - } - } - }, - mounted() { - this.videoContext = uni.createVideoContext('myVideo', this) + + + }, methods: { - btnyc(){ - this.titleflag=false + confirm(e) { + // console.log(e); + this.banben = e[0].label + this.modelId = e[0].value + uni.setStorageSync('banben', this.banben) + uni.setStorageSync('banbenid', this.modelId) + // uni.setStorageSync('hardwareVersionId', e[0].value); + // this.hardwareVersionId = e[0].value + // const hardwareVersionId =this.hardwareVersionId + + // if (hardwareVersionId) { + // const matchedVersion = this.Versionlist.find(version => version.id === + // hardwareVersionId); + // if (matchedVersion) { + // this.hardwareInfo = matchedVersion; + // } + // } + }, - towifi(){ - let systemInfo = uni.getSystemInfoSync(); - if (systemInfo.platform === 'android') { - // 当前设备是 Android - - } else if (systemInfo.platform === 'ios') { - // 当前设备是 iOS - uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + options - .data.deviceId + '&name=' + options.data.name - }) + getlist() { + this.$u.get('/app/model/all').then((res) => { + if (res.code === 200) { + this.Versionlist = res.data + const hardwareVersionId = uni.getStorageSync('hardwareVersionId'); + + if (hardwareVersionId) { + this.hardwareVersionId = hardwareVersionId + const matchedVersion = this.Versionlist.find(version => version.id === + hardwareVersionId); + if (matchedVersion) { + this.hardwareInfo = matchedVersion; + } + } + + this.list = res.data.map(item => ({ + value: item.modelId, + label: item.modelName + })); + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }); + } + }) + }, + send() { + this.$u.post('/app/device/ring?sn=' + this.sn).then((res) => { + if (res.code === 200) { + + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }); + } + }) + }, + changeBind() { + this.$u.post(`/appVerify/updateSn?sn=` + this.sn + '&mac=' + this.mac + '&hardwareVersionId=' + this + .hardwareVersionId).then((res) => { + if (res.code === 200) { + uni.showToast({ + title: '绑定成功', + icon: 'none', + duration: 2000 + }); + setTimeout(() => { + uni.navigateBack({ + delta: 1 // delta值为1时表示返回的页面层数 + }); + }, 2000) + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }); + } + }) + }, + backpage() { + uni.navigateBack({ + delta: 1 // delta值为1时表示返回的页面层数 + }); + }, + bind() { + let data = { + sn: this.storeId, + mac: this.mac, + modelId: this.modelId } - }, - bind(){ - if(this.ishave&&this.isband){ - uni.setStorageSync('mac', this.mac); - let that =this - setTimeout(()=>{ - uni.switchTab({ - url:'/pages/index/index' + this.$u.post('/app/device', data).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: '录入成功', + icon: 'success', + duration: 2000 }) - },) + setTimeout(()=>{ + uni.navigateBack() + },1500) + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }); + } + }) - - } + // this.$u.post(`/appVerify/band?sn=` + this.sn + '&mac=' + this.mac + '&hardwareVersionId=' + this + // .hardwareVersionId).then((res) => { + + // if (res.code == 200) { + + // uni.showToast({ + // title: '绑定成功', + // icon: 'none', + // duration: 2000 + // }); + // setTimeout(() => { + // uni.navigateBack({ + // delta: 1 // delta值为1时表示返回的页面层数 + // }); + // }, 2000) + + // } else { + // if (res.msg == '该MAC号已经存在') { + // this.showbind = true + // } else { + // uni.showToast({ + // title: res.msg, + // icon: 'none', + // duration: 2000 + // }); + + // } + + // } + // }) }, + qrcode() { + uni.scanCode({ + onlyFromCamera: true, + scanType: ['qrCode'], + success: res => { + function getQueryParam(url, paramName) { + let regex = new RegExp(`[?&]${paramName}=([^&]*)`) + let results = regex.exec(url); + return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null + } + let sceneValue = res.result + let decodedValue = decodeURIComponent(sceneValue) + let id = getQueryParam(decodedValue, 's') + this.storeId = id + }, + fail: err => { + console.error('扫描失败:', err) + uni.showToast({ + title: '扫描失败', + icon: 'none' + }) + } + }) + }, + + Binddevice() { + uni.showLoading({ + title: '连接中..' + }) + xBlufi.initXBlufi(1); + console.log("xBlufi", xBlufi.XMQTT_SYSTEM); + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + + + // 两秒后停止蓝牙搜索 + setTimeout(() => { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + setTimeout(() => { + uni.hideLoading() + if (this.devicesList.length == 0) { + uni.showToast({ + title: '暂无发现对应设备,请重试', + icon: 'none' + }); + } else { + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 将去重后的数组重新赋值给 this.devicesList + this.devicesList = uniqueDevicesList; + // console.log(this.devicesList,'this.devicesListthis.devicesList'); + this.devicesList.forEach(device => { + // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) + let macFromName = device.name.substring(device.name.length - 12); + console.log(macFromName, 'macFromNamemacFromName'); + // 与 this.mac 进行比较 + if (macFromName == this.mac) { + // 如果相同,则将 this.ishave 设置为 true + console.log(device); + this.deviceInfoss = device + // this.ishave = true; + this.createBLEConnection(device) + + console.log('对比正确1111111111'); + } else { + console.log('对比错误'); + + } + }); + } + }, 200) + // 判断是否存在浇花器设备 + + // this.status = true + }, 2000) + + }, + reboot() { + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11reboot" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + open() { + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "open" + }); + xBlufi.notifySendCustomData({ + customData: "11open" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + close() { + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "close" + }); + xBlufi.notifySendCustomData({ + customData: "11close" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + ring() { + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11play1@" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + btnyc() { + this.titleflag = false + }, + // 解析自定义数据 - 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(3); // 去除前缀 "SET" - - // 返回解析后的数据对象 - return { - voltage, - switchState, - current, - power, - remainingPower, - setMode - }; - }, - + funListenDeviceMsgEvent: function(options) { switch (options.type) { case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: if (options.result) { let devicesarr = options.data // this.devicesList = options.data - // console.log(devicesarr,'devicesarrdevicesarr'); + devicesarr.forEach(device => { - const mac = device.name.substring(6); - if (device.name.substring(0, 5) === "CTPOW") { + + // this.$u.get(`/app/device/${mac}/isBind`, data).then((res) => { - // if (res.data == false) { - this.devicesList.push(device); - let uniqueDevicesList = Array.from(new Set(this.devicesList)); - - // 将去重后的数组重新赋值给 this.devicesList - this.devicesList = uniqueDevicesList; - - - } - + // if (res.data == false) { + this.devicesList.push(device); + + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 将去重后的数组重新赋值给 this.devicesList + this.devicesList = uniqueDevicesList; + }); } break; @@ -286,62 +554,54 @@ title: '连接成功', icon: 'none' }); { - console.log("连接回调options.data.deviceId:" + options.data.deviceId, - "连接回调options.data.name:" + options.data.name); - uni.setStorageSync('deviceIds', options.data.deviceId); - uni.setStorageSync('name', options.data.name); - xBlufi.notifyInitBleEsp32({ - deviceId: this.deviceInfo.deviceId - }); - xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents); - this.isband=true - - + + xBlufi.notifyInitBleEsp32({ + deviceId: options.data.deviceId + }); + + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents); + + this.deviceIds = options.data.deviceId + this.name = options.data.name + // 连接成功绑定设备 + // let params = { + // mac: this.Bluetoothmac, + // userId: this.$store.state.user.userId + // } let systemInfo = uni.getSystemInfoSync(); if (systemInfo.platform === 'android') { // 当前设备是 Android - + } else if (systemInfo.platform === 'ios') { // 当前设备是 iOS - + // uni.navigateTo({ + // url: '/pages/wifilist/index?deviceId=' + options + // .data.deviceId + '&name=' + options.data.name + // }) } } } break; case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: - - this.ver_data =this.parseCustomData(options.data) - // console.log("1收到设备发来的自定义数据结果:", this.ver_data); + + // this.ver_data = this.parseCustomData(options.data) + if (options.data) { + this.carstause = true + } + // console.log("1收到设备发来的自定义数据结果:", this.ver_data); break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: if (options.result) { - let uniqueDevicesList = Array.from(new Set(this.devicesList)); - - // 过滤出名称字段的前五个字母为 "CTPOW" 的项 - let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "CTKG"); - - // 将过滤后的数组重新赋值给 this.devicesList - this.devicesList = filteredDevices; - filteredDevices.forEach(device => { - // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) - let macFromName = device.name.substring(device.name.length - 12); - // console.log(macFromName); - // 与 this.mac 进行比较 - if (macFromName ==this.mac) { - // 如果相同,则将 this.ishave 设置为 true - console.log(device); - this.ishave = true; - // this.createBLEConnection(device) - // console.log('对比正确'); - }else{ - uni.showToast({ - title: '未搜索到对应设备,请靠近设备重新扫描', - icon: 'none', - duration: 2000 - }); - } - }); + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 过滤出名称字段的前五个字母为 "CTPOW" 的项 + let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) === + "BBLE"); + + // 将过滤后的数组重新赋值给 this.devicesList + this.devicesList = filteredDevices; + // console.log('蓝牙停止搜索ok',this.devicesList); } else { //蓝牙停止搜索失败 @@ -359,6 +619,7 @@ //4、建立连接 createBLEConnection(e) { + console.log('调用了'); xBlufi.notifyStartDiscoverBle({ 'isStart': false }); @@ -373,11 +634,18 @@ deviceId: e.deviceId, name }); - + // for (var i = 0; i < this.devicesList.length; i++) { + // if (e.deviceId === this.devicesList[i].deviceId) { + + // uni.showLoading({ + // title: '连接蓝牙设备中...' + // }); + // } + // } }, // 点击重新搜索 Search() { - if(this.status){ + if (this.status) { xBlufi.notifyStartDiscoverBle({ 'isStart': true }); @@ -387,11 +655,11 @@ // 重新搜索 // this.startBluetoothDevicesDiscovery() this.statusflag = true - this.status=false + this.status = false this.texts = '正在扫描蓝牙设备...' setTimeout(() => { this.statusflag = false - this.status=true + this.status = true if (this.searching) { xBlufi.notifyStartDiscoverBle({ 'isStart': false @@ -399,7 +667,7 @@ // 判断是否存在浇花器设备 if (this.devicesList.length == 0) { uni.showToast({ - title: '暂无发现对应设备,请靠近设备', + title: '暂无发现对应设备,请重试', icon: 'none' }); } else { @@ -413,86 +681,57 @@ }, 2000) } + }, - funListenDeviceMsgEvents: function (options) { + funListenDeviceMsgEvents: function(options) { let that = this; switch (options.type) { - case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: - { - console.log('状态', options.result) - uni.showModal({ - title: '很抱歉提醒你!', - content: '小程序与设备异常断开', - showCancel: false, - success: function (res) { - - } + case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: { + console.log('状态', options.result) + if (options.result == false) { + this.carstause = false + uni.showToast({ + title: '设备断开链接,请重新点击蓝牙链接', + icon: 'none' }); - this.statusflag = false - uni.hideLoading(); + // uni.showModal({ + // title: '很抱歉提醒你!', + // content: '小程序与设备异常断开', + // showCancel: false, + // success: function(res) { + // // uni.navigateBack({ + // // url: '../search/search' + // // }); + // } + // }); + // this.statusflag = false + uni.hideLoading(); } - break; - - case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT: - uni.hideLoading(); - if (!options.result) - this.statusflag = false, - uni.hideLoading(), - uni.showModal({ - title: '温馨提示', - content: '配网失败,请重试', - showCancel: false //是否显示取消按钮 - }); - else { - if (options.data.progress == 100) { - let ssid = options.data.ssid; - this.statusflag = false - uni.hideLoading(); - uni.showModal({ - title: '温馨提示', - // content: `连接成功路由器【${options.data.ssid}】`, - content: `连接成功路由器`, - showCancel: false, - success: function (res) { - let ids = that.$store.state.user.deviceId - getwifi(ids).then(res => { - console.log(res); - uni.switchTab({ - url:'/pages/index' - }) - }) - } - }) - - } - } - break; + } + break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA: this.loadPercent = options.data; this.loadText = '文件读取中' console.log("文件读取中", options.data); break; case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: - - this.ver_data =this.parseCustomData(options.data) - // console.log("1收到设备发来的自定义数据结果:", this.ver_data); + // this.isband = true + // this.ver_data = this.parseCustomData(options.data) + console.log("1收到设备发来的自定义数据结果:", options.data); + if (options.data) { + this.carstause = true + } break; - + case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT: uni.hideLoading(); if (options.result) { console.log('初始化成功'); } else { console.log('初始化失败'); - uni.showModal({ - title: '温馨提示', - content: `设备初始化失败`, - showCancel: false, - //是否显示取消按钮 - success: function (res) { - - } - }); + + } break; } @@ -500,261 +739,256 @@ // 点击隐藏没有设备提示 btnhd() { this.tishiflag = false - } - } + }, + + + + + + + + + + + + + + + + + + + } } \ No newline at end of file diff --git a/page_fenbao/statulist/taocanlist/addtaocan/index.vue b/page_fenbao/statulist/taocanlist/addtaocan/index.vue index 2e893b9..827d7ee 100644 --- a/page_fenbao/statulist/taocanlist/addtaocan/index.vue +++ b/page_fenbao/statulist/taocanlist/addtaocan/index.vue @@ -313,8 +313,19 @@ - + + + + + + + + + 我已知晓 + + + @@ -423,8 +434,10 @@ pdvalue: '', dfvalue: '', jdvalue: '', - timevalue: '' - + timevalue: '', + contwz:'', + contwzflag:false, + contwzflags:false } }, onLoad(option) { @@ -438,6 +451,8 @@ } }, onShow() { + this.getuser() + this.getxieyi() if (uni.getStorageSync('tcidlist')) { this.deviceList = uni.getStorageSync('tcidlist') } @@ -484,9 +499,160 @@ this.$set(this.backgroundColor, index, this.backcolor) } }, - - - + + // 用户协议 + getxieyi(){ + this.$u.get(`/app/article/licence/mch`).then(res => { + if(res.code == 200){ + this.contwz = res.data.content + } + }) + }, + // 点击我已知晓 + btnzx(){ + this.$u.put(`/app/user/readMchLicence`).then((res) => { + if (res.code == 200) { + this.getuser() + this.btnmsk = false + this.contwzflag = false + } + }) + }, + // 获取用户信息 + getuser(){ + this.$u.get("/app/user/userInfo").then((res) => { + if (res.code == 200) { + if(res.data.readMchLicence == false){ + this.contwzflags = true + }else{ + this.contwzflags = false + } + } + }) + }, + btnadd() { + let regex = /^\d+(\.\d{1,2})?$/ + let regexs = /^\d+$/ + if (this.description == '') { + uni.showToast({ + title: '详细说明不能为空', + icon: 'none', + duration: 1000, + }) + } else { + this.btnmsk = true + if (this.title == '确定') { + if(this.contwzflags == false){ + this.contwzflag = false + let colorMap = { + "#64B6A7": 0, + "#468DFF": 1, + "#8883F0": 2, + "#FF4444": 3 + } + this.gearTime = [] + this.backgroundColor.forEach(color => { + this.gearTime.push(colorMap[color]); + }) + let arrs = [...this.deviceList.map(item => item.deviceId)] + if (this.feeType == 3 || this.feeType == 4) { + this.gearAmount = [] + this.gearAmount.push(this.gdvalue, this.pdvalue, this.dfvalue, this.jdvalue) + } + let data = { + // deviceId: this.deviceId, + name: this.name, + value:this.feeType == 3 || this.feeType == 4 ? (this.duvalue = null) : this.duvalue, + price: this.qianvalue, + description: this.description, + timeUnit: this.feeType == 3 || this.feeType == 4 || this.feeType == 2 ? (this.timeUnit = null) : this.timeUnit, + deviceIds: arrs, + feeMode: this.feeMode, + feeType: this.feeType, + gearAmount: this.gearAmount, + gearTime: this.feeType === 3 || this.feeType === 4 ? this.gearTime : (this.gearTime = []), + enabledLowPowerClose:this.checked, + lowPower:this.power + } + this.$u.post('/app/suit', data).then((res) => { + if (res.code == 200) { + uni.removeStorageSync('tcidlist') + uni.showToast({ + title: '新建套餐成功', + icon: 'success', + duration: 1000, + }) + setTimeout(() => { + this.btnmsk = false + uni.navigateBack() + }, 1000) + } else { + this.btnmsk = false + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 1000, + }) + } + }) + }else{ + this.contwzflag = true + } + } else { + let colorMap = { + "#64B6A7": 0, + "#468DFF": 1, + "#8883F0": 2, + "#FF4444": 3 + } + this.gearTime = [] + this.backgroundColor.forEach(color => { + this.gearTime.push(colorMap[color]); + }) + let arrs = [...this.deviceList.map(item => item.deviceId)] + if (this.feeType == 3 || this.feeType == 4) { + this.gearAmount = [] + this.gearAmount.push(this.gdvalue, this.pdvalue, this.dfvalue, this.jdvalue) + } + let data = { + suitId: this.suitId, + name: this.name, + value: this.duvalue, + price: this.qianvalue, + description: this.description, + timeUnit: this.timeUnit, + deviceIds: arrs, + feeMode: this.feeMode, + feeType: this.feeType, + gearAmount: this.gearAmount, + gearTime: this.feeType === 3 || this.feeType === 4 ? this.gearTime : (this.gearTime = []), + enabledLowPowerClose:this.checked, + lowPower:this.power + } + this.$u.put('/app/suit', data).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: '修改套餐成功', + icon: 'success', + duration: 1000, + }) + setTimeout(() => { + this.btnmsk = false + uni.navigateBack() + }, 1000) + } else { + this.btnmsk = false + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 1000, + }) + } + }) + } + } + }, + // 收费模式 单次and智能 radioChange(e) { // console.log(e); @@ -616,8 +782,7 @@ // 跳转选择设备 btnaddsb() { uni.navigateTo({ - url: '/page_components/shebeixz?id=' + this.suitId + '&title=' + this.title + '&list=' + JSON - .stringify(this.deviceList) + url: '/page_components/shebeixz?id=' + this.suitId + '&title=' + this.title + '&list=' + JSON.stringify(this.deviceList) }) }, btnxl(index) { @@ -640,6 +805,8 @@ this.duvalue = res.data.value this.description = res.data.description this.deviceList = res.data.deviceList + this.checked = res.data.enabledLowPowerClose + this.power = res.data.lowPower this.deviceList.forEach(item => { this.tcidlist.push(item.deviceId) }) @@ -753,121 +920,6 @@ }) }, - btnadd() { - console.log(this.backgroundColor, '121212'); - let regex = /^\d+(\.\d{1,2})?$/ - let regexs = /^\d+$/ - if (this.description == '') { - uni.showToast({ - title: '详细说明不能为空', - icon: 'none', - duration: 1000, - }) - } else { - this.btnmsk = true - if (this.title == '确定') { - let colorMap = { - "#64B6A7": 0, - "#468DFF": 1, - "#8883F0": 2, - "#FF4444": 3 - } - this.gearTime = [] - this.backgroundColor.forEach(color => { - this.gearTime.push(colorMap[color]); - }) - let arrs = [...this.deviceList.map(item => item.deviceId)] - if (this.feeType == 3 || this.feeType == 4) { - this.gearAmount = [] - this.gearAmount.push(this.gdvalue, this.pdvalue, this.dfvalue, this.jdvalue) - } - let data = { - // deviceId: this.deviceId, - name: this.name, - value:this.feeType == 3 || this.feeType == 4 ? (this.duvalue = null) : this.duvalue, - price: this.qianvalue, - description: this.description, - timeUnit: this.feeType == 3 || this.feeType == 4 || this.feeType == 2 ? (this.timeUnit = null) : this.timeUnit, - deviceIds: arrs, - feeMode: this.feeMode, - feeType: this.feeType, - gearAmount: this.gearAmount, - gearTime: this.feeType === 3 || this.feeType === 4 ? this.gearTime : (this.gearTime = []) - } - this.$u.post('/app/suit', data).then((res) => { - if (res.code == 200) { - uni.removeStorageSync('tcidlist') - uni.showToast({ - title: '新建套餐成功', - icon: 'success', - duration: 1000, - }) - setTimeout(() => { - this.btnmsk = false - uni.navigateBack() - }, 1000) - } else { - this.btnmsk = false - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 1000, - }) - } - }) - } else { - let colorMap = { - "#64B6A7": 0, - "#468DFF": 1, - "#8883F0": 2, - "#FF4444": 3 - } - this.gearTime = [] - this.backgroundColor.forEach(color => { - this.gearTime.push(colorMap[color]); - }) - let arrs = [...this.deviceList.map(item => item.deviceId)] - if (this.feeType == 3 || this.feeType == 4) { - this.gearAmount = [] - this.gearAmount.push(this.gdvalue, this.pdvalue, this.dfvalue, this.jdvalue) - } - let data = { - suitId: this.suitId, - name: this.name, - value: this.duvalue, - price: this.qianvalue, - description: this.description, - timeUnit: this.timeUnit, - deviceIds: arrs, - feeMode: this.feeMode, - feeType: this.feeType, - gearAmount: this.gearAmount, - gearTime: this.feeType === 3 || this.feeType === 4 ? this.gearTime : (this.gearTime = []) - } - this.$u.put('/app/suit', data).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '修改套餐成功', - icon: 'success', - duration: 1000, - }) - setTimeout(() => { - this.btnmsk = false - uni.navigateBack() - }, 1000) - } else { - this.btnmsk = false - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 1000, - }) - } - }) - } - } - } - } } diff --git a/page_fenbao/zhuce.vue b/page_fenbao/zhuce.vue index 78f0f20..890cf69 100644 --- a/page_fenbao/zhuce.vue +++ b/page_fenbao/zhuce.vue @@ -7,16 +7,14 @@ - + 状态:已录入 未录入 - - SN码: + + SN码:{{item.sn == undefined ? '--' : item.sn}} @@ -25,15 +23,16 @@ 蓝牙强度:{{item.RSSI}} - 型号选择:{{item.xuanz == undefined ? '--' : item.xuanz}} - + --> - - {{item.lj}} - 扫码 - 录入 + + + 选择 + @@ -287,26 +286,37 @@ this.titleflag = true } else { let arr = [] + // console.log(this.devicesLists,'101010'); this.devicesLists.forEach(item => { arr.push(item.name.slice(5)) }) this.arrs = arr.join(',') - this.$u.get(`/app/device/getExistMac/${this.arrs}`).then(res => { - if (res.code == 200) { - const existingDevices = new Set(res.data); // 将 res.data 转换为 Set,以提高查找效率 - this.devicesLists = this.devicesLists.map(device => { - const trimmedName = device.name.slice(5); // 假设前缀总是5个字符长 - const flags = existingDevices.has(trimmedName); // true 如果存在,否则 false - return { - ...device, - flags, // 直接使用 flags 变量 - sn: '', - lj:'连接' - } - }) - } + this.$u.get(`/app/device/getExistMac/${this.arrs}`).then(res => { + if (res.code == 200 && Array.isArray(res.data)) { + const existingDevices = new Map(res.data.map(item => [item.mac, true])); // 使用Map来存储已找到的MAC + + this.devicesLists = this.devicesLists.map(device => { + const trimmedName = device.name.slice(5); // 假设name中包含MAC地址的一部分 + const mac = trimmedName; // 如果trimmedName直接就是MAC,则不需要再处理 + device.found = existingDevices.has(mac); // 添加一个found属性来标记是否找到 + if (device.found) { + const sn = res.data.find(val => val.mac === mac)?.sn; // 从res.data中找到匹配的sn + if (sn) { + device.sn = sn; // 设置sn + } + device.flags = true; // 设置flags为true,因为找到了匹配的MAC + } else { + device.flags = false; // 可选:如果你想要明确表示未找到 + } + return device; // 但map函数仍然需要return来保持结构 + }); + this.devicesLists.sort((a, b) => { + if (a.found && !b.found) return 1; // b排在a前面(即a在后面) + if (!a.found && b.found) return -1; // a排在b前面 + return 0; + }); + } }) - console.log(this.devicesLists,'0202') setTimeout(()=>{ uni.hideLoading() },2000) @@ -326,92 +336,104 @@ // 发送开关 createBLEConnections(e) { - this.arrs = '' - this.qrResult = e.name //拿到所点击的mac号 - if (this.ver_data == null) { //判断是否有连接蓝牙 - xBlufi.initXBlufi(1) - xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) - xBlufi.notifyStartDiscoverBle({ - 'isStart': true - }) - uni.showLoading({ - title: '连接准备中...' - }) - // 停止蓝牙搜索 - setTimeout(() => { - setTimeout(()=>{ - uni.showLoading({ - title: '连接中...' - }) - setTimeout(()=>{ - uni.hideLoading() - uni.showToast({ - title: '连接成功', - icon: 'success', - duration: 2000 - }) - this.devicesLists.forEach(item => { - if (item.name == this.qrResult) { - item.lj = '开关' - } - }) - },2000) - },500) - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }) - xBlufi.notifyConnectBle({ - isStart: true, - deviceId: this.deviceId, - name: this.name - }) - xBlufi.notifyInitBleEsp32({ - deviceId: this.deviceId - }) - }, 1000) - }else{ //有连接则发送命令 - uni.showLoading({ - title: '执行中...' + let Bluetoothmac = e.name.substring(5) + uni.navigateTo({ + url:'/page_fenbao/device/joinDevice?mac='+Bluetoothmac }) - let that = this //改变this指向 - uni.getNetworkType({ - success(res) { - if (res.networkType !== 'none') { - uni.getConnectedBluetoothDevices({ - success(res) { - setTimeout(() => { //一秒后发送开启命令 - xBlufi.notifySendCustomData({ - customData: 'open' - }) - setTimeout(()=>{ //发送开启命令两秒后发送关闭命令 - xBlufi.notifySendCustomData({ - customData: 'close' - }) - setTimeout(()=>{ //发送关闭命令后一秒后断开连接 - uni.hideLoading() - that.ver_data = null - xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent); - wx.closeBLEConnection({ - deviceId: that.deviceId, - }) - that.devicesLists.forEach(item => { - if (item.name == that.qrResult) { - item.lj = '连接' - } - }) - // console.log('guanbi'); - },1000) - },2000) - }, 1000) - }, - fail(err) { - console.error('获取已连接蓝牙设备信息失败:', err) - } - }) - } - } - }) - } + + // this.arrs = '' + // this.qrResult = e.name //拿到所点击的mac号 + // if (this.ver_data == null) { //判断是否有连接蓝牙 + // xBlufi.initXBlufi(1) + // xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': true + // }) + // this.devicesList.forEach(device => { + // if (device.name == this.qrResult) { + // this.deviceId = device.deviceId + // this.name = device.name + // this.mac = device.name.slice(5, 17) + // } + // }) + // uni.showLoading({ + // title: '连接准备中...' + // }) + // // 停止蓝牙搜索 + // setTimeout(() => { + // setTimeout(()=>{ + // uni.showLoading({ + // title: '连接中...' + // }) + // setTimeout(()=>{ + // uni.hideLoading() + // uni.showToast({ + // title: '连接成功', + // icon: 'success', + // duration: 2000 + // }) + // this.devicesLists.forEach(item => { + // if (item.name == this.qrResult) { + // item.lj = '开关' + // } + // }) + // },2000) + // },500) + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': false + // }) + // xBlufi.notifyConnectBle({ + // isStart: true, + // deviceId: this.deviceId, + // name: this.name + // }) + // xBlufi.notifyInitBleEsp32({ + // deviceId: this.deviceId + // }) + // }, 1000) + // }else{ //有连接则发送命令 + // uni.showLoading({ + // title: '执行中...' + // }) + // let that = this //改变this指向 + // uni.getNetworkType({ + // success(res) { + // if (res.networkType !== 'none') { + // uni.getConnectedBluetoothDevices({ + // success(res) { + // setTimeout(() => { //一秒后发送开启命令 + // xBlufi.notifySendCustomData({ + // customData: 'open' + // }) + // setTimeout(()=>{ //发送开启命令两秒后发送关闭命令 + // xBlufi.notifySendCustomData({ + // customData: 'close' + // }) + // setTimeout(()=>{ //发送关闭命令后一秒后断开连接 + // uni.hideLoading() + // that.ver_data = null + // xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent); + // wx.closeBLEConnection({ + // deviceId: that.deviceId, + // }) + // that.devicesLists.forEach(item => { + // if (item.name == that.qrResult) { + // item.lj = '连接' + // } + // }) + // // console.log('guanbi'); + // },1000) + // },2000) + // }, 1000) + // }, + // fail(err) { + // console.error('获取已连接蓝牙设备信息失败:', err) + // } + // }) + // } + // } + // }) + // } }, // 请求已经录入设备的mac getluru() { diff --git a/page_user/Feedback.vue b/page_user/Feedback.vue index 392365a..6c782c3 100644 --- a/page_user/Feedback.vue +++ b/page_user/Feedback.vue @@ -2,88 +2,72 @@ - + - - - - 小丁 + + + + + - - - - 微信号:mozixuan1598 - - - 复制 - - - - - 手机号:13850396941 - - - 复制 - - + + 复制可帮您快速拨打电话及搜索微信 + @@ -101,7 +85,8 @@ imglist: [], token: '', contact: '', - stause: false + stause: false, + list:[] } }, computed: { @@ -109,8 +94,7 @@ }, onLoad() { - // this.getQiniuToken() - // this.getstause() + this.getstause() }, // 分享到好友(会话) onShareAppMessage: function() { @@ -129,9 +113,10 @@ } }, methods: { - btnfzsj() { + + btnfzsj(text) { uni.setClipboardData({ - data:'13850396941', + data:text, success: () => { uni.showToast({ title: '复制成功', @@ -141,9 +126,9 @@ } }) }, - btnfzwx() { + btnfzwx(text) { uni.setClipboardData({ - data:'mozixuan1598', + data:text, success: () => { uni.showToast({ title: '复制成功', @@ -155,14 +140,9 @@ }, getstause() { - - this.$u.get('/app/config/wa').then((res) => { + this.$u.get(`/app/customerService/list?pageSize=999&pageNum=1&orderByColumn=sort&isAsc=desc`).then((res) => { if (res.code == 200) { - console.log(res) - this.stause = res.data - if (this.stause == true) { - - } + this.list = res.rows } }) }, @@ -270,14 +250,33 @@ /deep/ .u-icon__icon { padding-bottom: 22rpx; } - + .topimg{ + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 498rpx; + } + .list{ + position: fixed; + top: 30rpx; + left: 50%; + transform: translateX(-50%); + z-index: 1; + height: 71vh; + overflow: scroll; + } .kflist { display: flex; - margin-top: 82rpx; - + margin-top: 32rpx; + background-color: #fff; + padding: 22rpx; + box-sizing: border-box; + border-radius: 30rpx; + width: 662rpx; .kflt { text-align: center; - margin-right: 16rpx; + // margin-right: 16rpx; image { width: 118rpx; @@ -286,29 +285,36 @@ } .kfrt { - width: 532rpx; + width:100%; height: 154rpx; - background: #8883F0; border-radius: 14rpx 14rpx 14rpx 14rpx; - padding: 8rpx 30rpx; + padding: 4rpx 30rpx; box-sizing: border-box; - + position: relative; + image{ + width: 500rpx; + height: 151rpx; + position: absolute; + top: 0; + left: 0; + } .wz { display: flex; justify-content: space-between; align-items: center; - margin-top: 20rpx; + padding-top: 20rpx; + box-sizing: border-box; font-size: 32rpx; - color: #FFFFFF; - + color: #3D3D3D; .fz { width: 72rpx; - height: 40rpx; + height: 38rpx; border-radius: 4rpx 4rpx 4rpx 4rpx; - border: 1rpx solid #FFFFFF; + border: 1rpx solid #8883F0; font-size: 24rpx; - color: #FFFFFF; + color: #8883F0; text-align: center; + z-index: 1; } } } @@ -316,7 +322,7 @@ .kfname { font-weight: 600; font-size: 32rpx; - color: #8883F0; + color: #3D3D3D; } } diff --git a/page_user/sbdetail.vue b/page_user/sbdetail.vue index 982c686..0134e27 100644 --- a/page_user/sbdetail.vue +++ b/page_user/sbdetail.vue @@ -154,7 +154,7 @@ - + @@ -163,16 +163,27 @@ height: 80rpx;align-items: center;justify-content: space-between;background-color: #fff;border-radius: 20rpx;"> 手动操作:{{tdtxt}} - - + + + + + + + + - 请输入您需要充值的时长(分钟) - + 请输入您需要充值的时长或度数 + + + + 取消 + + @@ -245,10 +258,26 @@ }, data() { return { + showflag: false, + imgflag: false, wemflag: false, btnmsk: false, bluetoothflag: false, shibaiflag: false, + danwei: '', + listdanwei: [{ + value: 1, + label: '小时' + }, { + value: 2, + label: '分钟' + }, { + value: 3, + label: '秒钟' + }, { + value: 4, + label: '度' + }], bgc: { backgroundColor: "#8883f0", }, @@ -283,12 +312,13 @@ timer: null, url: "", deviceNo: '', - modelId:[] + modelId: [] } }, onLoad(option) { let id = option.id this.id = id + this.$u.get(`/app/device/${this.id}/refreshIot`).then((res) => {}) // this.getDevice(id) if (option.flag) { this.opflag = false @@ -328,7 +358,7 @@ // 展示秒或0(如果秒也为0) return this.timeday.seconds > 0 ? `${this.timeday.seconds}秒` : '0' } - } + } }, beforeDestroy() { // 组件销毁前清除定时器,防止内存泄漏 @@ -349,7 +379,7 @@ console.log("unload "); xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); wx.closeBLEConnection({ - deviceId: this.deviceId, + deviceId: this.deviceId, }) }, onShow() { @@ -362,6 +392,12 @@ this.drawCanvas() }, methods: { + // 选择时长单位 + btnconfirm(e) { + this.danwei = e[0].label + this.damweiid = e[0].value + }, + capture() { var pages = getCurrentPages(); //获取当前页面信息 var page = pages[pages.length - 1]; @@ -454,14 +490,16 @@ this.$u.put(`/app/device/${this.id}/changePower?status=0`).then((res) => { if (res.code == 200) { this.tdtxt = '关闭' - this.checked = false + this.imgflag = false + this.deviceInfo.status = 1 uni.showToast({ title: res.msg, icon: 'success', duration: 2000 }) } else { - this.checked = false + this.imgflag = true + this.tdtxt = '开启' uni.showToast({ title: res.msg, icon: 'none', @@ -472,15 +510,17 @@ } else { this.$u.put(`/app/device/${this.id}/changePower?status=1`).then((res) => { if (res.code == 200) { - this.checked = true + this.imgflag = true this.tdtxt = '开启' + this.deviceInfo.status = 2 uni.showToast({ title: res.msg, icon: 'success', duration: 2000 }) } else { - this.checked = false + this.imgflag = false + this.tdtxt = '关闭' uni.showToast({ title: res.msg, icon: 'none', @@ -518,9 +558,9 @@ name = this.name.slice(index + 1) } if (this.deviceInfo.powerStatus == 0) { - this.checked = false + this.imgflag = false } else { - this.checked = true + this.imgflag = true } }, 1000) } else { @@ -535,10 +575,14 @@ setTimeout(() => { // console.log('close关闭'); that.tdtxt = '关闭' - that.checked = false + that.imgflag = false + that.deviceInfo.status = 1 xBlufi.notifySendCustomData({ customData: 'close' }) + xBlufi.notifySendCustomData({ + customData: '11close' + }) }, 1000) }, fail(err) { @@ -558,10 +602,14 @@ setTimeout(() => { // console.log('open开启'); that.tdtxt = '开启' - that.checked = true + that.imgflag = true + that.deviceInfo.status = 2 xBlufi.notifySendCustomData({ customData: 'open' }) + xBlufi.notifySendCustomData({ + customData: '11open' + }) }, 1000) }, fail(err) { @@ -682,10 +730,10 @@ } } if (res.data.powerStatus == 0) { - this.checked = false + this.imgflag = false this.tdtxt = '关闭' } else { - this.checked = true + this.imgflag = true this.tdtxt = '开启' } this.loadings = true @@ -801,7 +849,7 @@ duration: 2000 }) that.getDevice(that.id) - this.checked = false + this.imgflag = false this.tdtxt = '关闭' } else if (res.msg == '设备剩余时间不足,无需归零') { uni.showToast({ @@ -815,37 +863,6 @@ icon: 'none', duration: 2000 }) - // uni.showLoading({ - // title: '充值中...' - // }) - // let vm = this; // 将外部的 this 绑定到 vm 上 - // uni.getNetworkType({ - // success(res) { - // if (res.networkType !== 'none') { - // uni.getConnectedBluetoothDevices({ - // success(res) { - // console.log('已连接的蓝牙设备信息:', res); - // xBlufi.notifySendCustomData({ - // customData: "time@" + 0 - // }); - // }, - // fail(err) { - // console.error('获取已连接蓝牙设备信息失败:', err); - // } - // }) - // // vm.$u.get(`/app/bill/recharge/${vm.billNo}/bluetoothSuccess`).then(res => { - // // if(res.code == 200){ - // // setTimeout(()=>{ - // // uni.hideLoading() - // // uni.navigateBack() - // // },1000) - // // } - // // }) - // } else { - // console.log('手机未连接网络'); - // } - // } - // }) } }) } else if (res.cancel) { @@ -877,7 +894,7 @@ this.btnmsk = false this.shibaiflag = false this.bluetoothflag = true - console.log(this.deviceId,'idididididdidii'); + console.log(this.deviceId, 'idididididdidii'); if (this.setMode == null) { xBlufi.initXBlufi(1) xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) @@ -917,12 +934,14 @@ if (systemInfo.platform == 'android') { // 当前设备是 Android uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + this.deviceId + '&name=' + this.name + url: '/page_components/wifilist/index?deviceId=' + this + .deviceId + '&name=' + this.name }) } else if (systemInfo.platform == 'ios') { // 当前设备是 iOS uni.navigateTo({ - url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId + '&name=' + this.name + url: '/page_fenbao/device/wifivideo?deviceId=' + this + .deviceId + '&name=' + this.name }) } } else if (res.msg == '设备编号和mac不能同时为空') { @@ -968,12 +987,14 @@ if (systemInfo.platform == 'android') { // 当前设备是 Android uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + this.deviceId +'&name=' + this.name + url: '/page_components/wifilist/index?deviceId=' + this.deviceId + + '&name=' + this.name }) } else if (systemInfo.platform == 'ios') { // 当前设备是 iOS uni.navigateTo({ - url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId +'&name=' + this.name + url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId + + '&name=' + this.name }) } } else { @@ -1013,51 +1034,75 @@ } let id = this.deviceInfo.deviceId this.vipflag = false - this.$u.put('/app/device/addTime/' + id + '?amount=' + this.cztime).then(res => { - if (res.code == 200) { - uni.showToast({ - title: '充值成功', - icon: 'success', - duration: 2000 + if (this.deviceInfo.onlineStatus == 1) { + this.$u.put('/app/device/addTime/' + id + '?amount=' + this.cztime).then(res => { + if (res.code == 200) { + uni.showToast({ + title: '充值成功', + icon: 'success', + duration: 2000 + }) + this.getDevice(this.id) + this.cztime = '' + } else if (res.code == 500) { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + } else { + if (this.setMode == null) { + this.btnmsk = false + this.shibaiflag = false + this.bluetoothflag = true + xBlufi.initXBlufi(1) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true }) - this.getDevice(this.id) - this.cztime = '' - } else if (res.code == 500) { - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 + // 停止蓝牙搜索 + setTimeout(() => { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: this.deviceId, + name: this.name + }) + xBlufi.notifyInitBleEsp32({ + deviceId: this.deviceId + }) + }, 1000) + } else { + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + that.deviceInfo.status = 2 + that.imgflag = true + xBlufi.notifySendCustomData({ + customData: '11open' + }) + xBlufi.notifySendCustomData({ + customData: 'open' + }) + }, 1000) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:', err) + } + }) + } + } }) - // let vm = this; // 将外部的 this 绑定到 vm 上 - // uni.getNetworkType({ - // success(res) { - // if (res.networkType !== 'none') { - // uni.getConnectedBluetoothDevices({ - // success(res) { - // console.log('已连接的蓝牙设备信息:', res); - // xBlufi.notifySendCustomData({ - // customData: "time@" + vm.setMode + vm.cztime - // }); - // }, - // fail(err) { - // console.error('获取已连接蓝牙设备信息失败:', err); - // } - // }) - // // vm.$u.get(`/app/bill/recharge/${vm.billNo}/bluetoothSuccess`).then(res => { - // // if(res.code == 200){ - // // setTimeout(()=>{ - // // uni.hideLoading() - // // uni.navigateBack() - // // },1000) - // // } - // // }) - // } else { - // console.log('手机未连接网络'); - // } - // } - // }) } - }) + } }, btnqx() { this.vipflag = false @@ -1080,14 +1125,14 @@ case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: if (options.result) { let devicesarr = options.data - console.log(devicesarr,'devicesarrdevicesarr') + console.log(devicesarr, 'devicesarrdevicesarr') devicesarr.forEach(device => { const mac = device.name.substring(5) if (device.name.slice(5, 17) == this.qrResult) { this.deviceId = device.deviceId this.name = device.name this.mac = device.name.slice(5, 17) - console.log(this.mac,this.deviceId,this.name, 'macmacmac') + // console.log(this.mac, this.deviceId, this.name, 'macmacmac') // this.devicesList = uniqueDevicesList } }) @@ -1301,6 +1346,14 @@ } } + .picjt { + position: fixed; + top: 190rpx; + right: 60rpx; + width: 16rpx; + height: 30rpx; + } + .bluetoothbox { width: 100%; height: 100vh; @@ -1417,7 +1470,7 @@ .tanc { width: 610rpx; - height: 282rpx; + max-height: 360rpx; background: #FFFFFF; border-radius: 30rpx 30rpx 30rpx 30rpx; position: fixed; diff --git a/page_user/yetx.vue b/page_user/yetx.vue index c39e2a5..98907cd 100644 --- a/page_user/yetx.vue +++ b/page_user/yetx.vue @@ -1,6 +1,6 @@