diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 95f3534..9fb848a 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -19,8 +19,8 @@ const install = (Vue, vm) => { // }, // }); Vue.prototype.$u.http.setConfig({ - baseUrl: 'http://192.168.2.100:10002', - // baseUrl: 'https://kg.chuangtewl.com/prod-api', + // baseUrl: 'http://192.168.2.100:10002', + baseUrl: 'https://kg.chuangtewl.com/prod-api', // loadingText: '加载中...', // loadingTime: 1000, // 设置自定义头部content-type diff --git a/page_components/eletj.vue b/page_components/eletj.vue index d4c3942..0e77ee8 100644 --- a/page_components/eletj.vue +++ b/page_components/eletj.vue @@ -515,7 +515,7 @@ // 开启和关闭 btnkq() { - if (this.onlineStatus == 1) { + if (this.onlineStatus == 0) { if (this.tdtxt == '开启') { this.$u.put(`/app/bill/switchDevice?billId=${this.billId}&open=false`).then((res) => { if (res.code == 200) { @@ -558,18 +558,97 @@ }) } } else { - if (this.tdtxt == '开启') { - this.tdtxt = '关闭' - getApp().ble_send("close"); - getApp().ble_send("11close"); + if (this.ver_data == null) { + this.jieshufalg = true + uni.showLoading({ + title: '切换中' + }) + xBlufi.initXBlufi(1) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + // 停止蓝牙搜索 + setTimeout(() => { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: this.deviceId, + name: this.name + }) + xBlufi.notifyInitBleEsp32({ + deviceId: this.deviceId + }) + let name = '' + let index = this.name.indexOf('-') + if (index !== -1) { + name = this.name.slice(index + 1) + } + if (this.sbobj.powerStatus == 0) { + this.imgflag = false + } else { + this.imgflag = true + } + }, 1000) + } else { + // console.log(this.tdtxt,'020202'); + if (this.tdtxt == '开启') { + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + // console.log('close关闭'); + that.tdtxt = '关闭' + that.imgflag = false + xBlufi.notifySendCustomData({ + customData: 'close' + }) + xBlufi.notifySendCustomData({ + customData: '11close' + }) + }, 1000) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:', err) + } + }) + } + } + }) + } else { + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + // console.log('open开启'); + that.tdtxt = '开启' + that.imgflag = true + xBlufi.notifySendCustomData({ + customData: 'open' + }) + xBlufi.notifySendCustomData({ + customData: '11open' + }) + }, 1000) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:', err) + } + }) + } + } + }) + } + } } - else - { - this.tdtxt = '开启' - getApp().ble_send("open"); - getApp().ble_send("11open"); - } - } }, @@ -670,7 +749,7 @@ this.getzfqd() this.getprice() if (this.detaobj.suitFeeMode == 1) { - if (this.onlineStatus == 1) { + if (this.onlineStatus == 0) { let that = this uni.showModal({ title: '提示', @@ -692,7 +771,7 @@ uni.reLaunch({ url: '/pages/shouye/index' }) - },1000) + },1500) }else{ uni.reLaunch({ url: '/pages/shouye/index' @@ -710,15 +789,38 @@ } }) } else { - // if (this.temperature == null) { + if (this.temperature == null) { + this.jieshufalg = true + uni.showLoading({ + title: '切换中' + }) + let that = this + xBlufi.initXBlufi(1); + xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); + 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) uni.showModal({ title: '温馨提示', content: `检测到该设备未联网,为您切换为蓝牙模式,支付的时候靠近该设备,并打开蓝牙`, showCancel: false, success: function(res) { - + } }) + } else { this.jieshufalg = true let data = { billId: this.billId, @@ -731,8 +833,12 @@ uni.getConnectedBluetoothDevices({ success(res) { setTimeout(() => { - getApp().ble_send("close"); - getApp().ble_send("11close"); + xBlufi.notifySendCustomData({ + customData: 'close' + }) + xBlufi.notifySendCustomData({ + customData: '11close' + }) uni.showToast({ title: res.msg, icon: 'success', @@ -743,8 +849,8 @@ uni.reLaunch({ url: '/pages/shouye/index' }) - }, 500) - }, 1000) + }, 1000) + }, 1500) }, fail(err) { console.error('获取已连接蓝牙设备信息失败:', err) @@ -764,7 +870,7 @@ }) } }) - // } + } } } else { this.getsb() @@ -792,7 +898,7 @@ uni.reLaunch({ url: '/pages/shouye/index' }) - }, 1000) + }, 1500) } else { this.getDevice() this.jieshuflag = false @@ -832,7 +938,7 @@ uni.reLaunch({ url: '/pages/shouye/index' }) - }, 1000) + }, 1500) }, fail(err) { that.getDevice() @@ -886,7 +992,7 @@ uni.reLaunch({ url: '/pages/shouye/index' }) - }, 1000) + }, 1500) }, fail(err) { that.jieshuflag = false @@ -913,37 +1019,38 @@ } } } else { - // if (this.temperature == null) { - // uni.showModal({ - // title: '温馨提示', - // content: `检测到该设备未联网,为您切换为蓝牙模式,支付的时候靠近该设备,并打开蓝牙`, - // showCancel: false, - // success: function(res) { - // // uni.showLoading({ - // // title: '请稍等' - // // }) - // } - // }) - // let that = this - // xBlufi.initXBlufi(1); - // xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); - // 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) - - // } else { + // console.log(this.temperature,'this.temperature'); + if (this.temperature == null) { + uni.showLoading({ + title: '切换中' + }) + let that = this + xBlufi.initXBlufi(1); + xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); + 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) + uni.showModal({ + title: '温馨提示', + content: `检测到该设备未联网,为您切换为蓝牙模式,支付的时候靠近该设备,并打开蓝牙`, + showCancel: false, + success: function(res) { + + } + }) + } else { if (this.detaobj.suitFeeType == 1 || this.detaobj.suitFeeType == 2) { let data = { billId: this.billId, @@ -957,15 +1064,19 @@ uni.getConnectedBluetoothDevices({ success(res) { setTimeout(() => { - getApp().ble_send("close"); - getApp().ble_send("11close"); + xBlufi.notifySendCustomData({ + customData: 'close', + }) + xBlufi.notifySendCustomData({ + customData: '11close', + }) setTimeout(() => { this.jieshuflag = false uni.reLaunch({ url: '/pages/shouye/index' - }) - }, 500) - }, 1000) + }) + }, 1000) + }, 1500) }, fail(err) { console.error('获取已连接蓝牙设备信息失败:', err) @@ -1000,8 +1111,12 @@ uni.getConnectedBluetoothDevices({ success(res) { setTimeout(() => { - getApp().ble_send("close"); - getApp().ble_send("11close"); + xBlufi.notifySendCustomData({ + customData: 'close', + }) + xBlufi.notifySendCustomData({ + customData: '11close', + }) setTimeout(() => { let data = { billNo: that.orderno, @@ -1030,7 +1145,7 @@ uni.reLaunch({ url: '/pages/shouye/index' }) - },1000) + },1500) }, fail(err) { that.jieshuflag = false @@ -1068,8 +1183,8 @@ } }) } - - // } + + } } }, @@ -1258,6 +1373,79 @@ url: "/page_components/eletj?id=" + this.id }) }, + + funListenDeviceMsgEvent: function(options) { + switch (options.type) { + 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.qrResult) { + 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 + } + }) + } + break; + case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED: + console.log("连接回调:" + JSON.stringify(options)) + if (options.result) { + // console.log('125451245') + { + xBlufi.notifyInitBleEsp32({ + deviceId: this.deviceId + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents) + 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) + this.temperature = this.ver_data.temperature / 1000 + setTimeout(() => { + // this.czflag = false + this.jieshuflag = false + this.jieshufalg = false + uni.hideLoading() + }, 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) { // 将字符串按照 "@" 分割成数组 const dataArray = data.split('@') diff --git a/page_fenbao/statulist/myorder/detailxq/index.vue b/page_fenbao/statulist/myorder/detailxq/index.vue index 6de7cb0..2e4d635 100644 --- a/page_fenbao/statulist/myorder/detailxq/index.vue +++ b/page_fenbao/statulist/myorder/detailxq/index.vue @@ -7,7 +7,13 @@ 订单号{{detailobj.billNo == undefined ? '--' : detailobj.billNo}} - + + 订单状态 + + 未开始 + + + 订单状态 已支付 diff --git a/page_fenbao/statulist/myorder/index.vue b/page_fenbao/statulist/myorder/index.vue index 50810a0..f3af08a 100644 --- a/page_fenbao/statulist/myorder/index.vue +++ b/page_fenbao/statulist/myorder/index.vue @@ -11,7 +11,12 @@ 订单号:{{item.billNo}} 消费时间:{{item.createTime}} - + + + 未开始 + + + 已支付 diff --git a/page_user/mapditu/orderxq.vue b/page_user/mapditu/orderxq.vue index e203ea0..d7c5e95 100644 --- a/page_user/mapditu/orderxq.vue +++ b/page_user/mapditu/orderxq.vue @@ -99,6 +99,14 @@ margin-top: 30rpx;align-items: center;"> 退款 + + 结束订单 + @@ -178,6 +186,44 @@ } }, methods: { + // 点击结束订单 + btnjs(){ + let that = this + uni.showModal({ + title: '提示', + content: '您确定要提前结束用户订单吗?', + success: function(res) { + if (res.confirm) { + let data = { + billId: that.billId + } + that.$u.put(`/app/bill/endUse`, data).then(res => { + if (res.code == 200) { + if(res.data.deviceResult == false){ + uni.showToast({ + title: res.data.deviceMsg, + icon: 'none', + duration: 2000 + }) + }else{ + uni.showToast({ + title:'结束成功', + icon: 'success', + duration: 2000 + }) + } + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 1000 + }) + } + }) + } + } + }) + }, // 点击去提交 btntijiao(){ this.tiflag = false