开关
This commit is contained in:
parent
26c133389e
commit
172b902132
82
App.vue
82
App.vue
|
@ -1,11 +1,11 @@
|
|||
<script>
|
||||
var xBlufi = require("./utils/blufi/xBlufi.js");
|
||||
var call;
|
||||
var data_call;
|
||||
var ble_id = "1231";
|
||||
var ble_url;
|
||||
var xBlufi = require("./utils/blufi/xBlufi.js")
|
||||
var call
|
||||
var data_call
|
||||
var ble_id = "1231"
|
||||
var ble_url
|
||||
|
||||
var user_info;
|
||||
var user_info
|
||||
|
||||
// 在文件顶部添加一个变量来存储当前连接的MAC地址
|
||||
var current_connected_mac = null;
|
||||
|
@ -26,28 +26,28 @@ export default {
|
|||
},
|
||||
created() {
|
||||
// #ifdef APP-PLUS
|
||||
plus.navigator.closeSplashscreen();
|
||||
plus.navigator.closeSplashscreen()
|
||||
// #endif
|
||||
console.log('App @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Launch');
|
||||
console.log('App @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Launch')
|
||||
// #ifndef APP-PLUS
|
||||
console.log('App 1111111111111Launch');
|
||||
console.log('App 1111111111111Launch')
|
||||
xBlufi.initXBlufi(1);
|
||||
console.log("xBlufi初始化", xBlufi); // 修改日志输出,确保输出有意义的信息
|
||||
console.log("xBlufi初始化", xBlufi) // 修改日志输出,确保输出有意义的信息
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); // 取消注释,确保事件监听被正确设置
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
});
|
||||
})
|
||||
// #endif
|
||||
|
||||
// 添加以下代码,将方法绑定到 uni 全局对象
|
||||
uni.$emit('init_app_methods', {
|
||||
set_ble_mac: this.set_ble_mac.bind(this)
|
||||
});
|
||||
})
|
||||
},
|
||||
onLaunch(options) {
|
||||
uni.setInnerAudioOption({
|
||||
obeyMuteSwitch: false
|
||||
});
|
||||
})
|
||||
|
||||
},
|
||||
onShow: function () {
|
||||
|
@ -63,14 +63,9 @@ export default {
|
|||
isStart: false,
|
||||
deviceId: ble_id,
|
||||
name: ""
|
||||
});
|
||||
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// });
|
||||
|
||||
})
|
||||
console.log('关闭蓝牙接口', ble_id);
|
||||
call = callback;
|
||||
call = callback
|
||||
}
|
||||
},
|
||||
get_ble_data(callback) {
|
||||
|
@ -78,47 +73,40 @@ export default {
|
|||
data_call = callback;
|
||||
},
|
||||
set_ble_mac(mac) {
|
||||
const bleInfo = this.globalData.bleInfo;
|
||||
|
||||
const bleInfo = this.globalData.bleInfo
|
||||
// 如果MAC地址与当前连接的相同,则不重复连接
|
||||
if (mac === bleInfo.current_connected_mac) {
|
||||
console.log('设备已连接,无需重复连接');
|
||||
return;
|
||||
console.log('设备已连接,无需重复连接')
|
||||
return
|
||||
}
|
||||
|
||||
if (mac != undefined && bleInfo.devicesList) {
|
||||
const device = bleInfo.devicesList.find(device =>
|
||||
device.name && device.name.toLowerCase().includes(mac.toLowerCase())
|
||||
);
|
||||
|
||||
)
|
||||
if (device) {
|
||||
bleInfo.ble_url = '';
|
||||
uni.hideLoading();
|
||||
bleInfo.ble_id = device.deviceId;
|
||||
|
||||
bleInfo.ble_url = ''
|
||||
uni.hideLoading()
|
||||
bleInfo.ble_id = device.deviceId
|
||||
bleInfo.xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: device.deviceId
|
||||
});
|
||||
|
||||
})
|
||||
uni.showToast({
|
||||
title: "连接蓝牙设备中",
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
})
|
||||
bleInfo.xBlufi.notifyInitBleEsp32({
|
||||
deviceId: device.deviceId
|
||||
});
|
||||
|
||||
})
|
||||
// 更新全局MAC地址
|
||||
bleInfo.current_connected_mac = mac;
|
||||
bleInfo.current_connected_mac = mac
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "未找到匹配的设备",
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -126,27 +114,21 @@ export default {
|
|||
console.log("id", id)
|
||||
if (id != undefined) {
|
||||
ble_url = url
|
||||
uni.hideLoading();
|
||||
ble_id = id;
|
||||
uni.hideLoading()
|
||||
ble_id = id
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: id
|
||||
// name
|
||||
});
|
||||
|
||||
})
|
||||
uni.showToast({
|
||||
title: "连接蓝牙设备中",
|
||||
icon: 'none',
|
||||
duration: 3500
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: id
|
||||
});
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// });
|
||||
})
|
||||
}
|
||||
},
|
||||
ble_send(data) {
|
||||
|
|
|
@ -19,7 +19,7 @@ const install = (Vue, vm) => {
|
|||
// },
|
||||
// });
|
||||
Vue.prototype.$u.http.setConfig({
|
||||
// baseUrl: 'http://192.168.2.100:10002',
|
||||
// baseUrl: 'http://192.168.2.8:10002',
|
||||
baseUrl: 'https://kg.chuangtewl.com/prod-api',
|
||||
// loadingText: '加载中...',
|
||||
// loadingTime: 1000,
|
||||
|
|
|
@ -59,14 +59,14 @@
|
|||
<!-- <view class="" v-if="detaobj.suitEndTime && detaobj.suitFeeType == 1">
|
||||
{{formattedTime}}
|
||||
</view> -->
|
||||
<view class="" v-if="detaobj.suitEndTime && detaobj.suitFeeType != 1">
|
||||
<!-- <view class="" v-if="detaobj.suitEndTime && detaobj.suitFeeType != 1">
|
||||
已结束
|
||||
</view>
|
||||
<view class="" v-else>
|
||||
<text
|
||||
v-if="detaobj.suitFeeType == 3 || detaobj.suitFeeType == 4">{{timeDifferenceString == '' ? '1分' : timeDifferenceString}}</text>
|
||||
<text v-if="detaobj.suitFeeType == 2">{{du}}度</text>
|
||||
<text v-if="detaobj.suitFeeType == 1">{{formattedTime == '1秒' ? '0' : formattedTime}}</text>
|
||||
</view> -->
|
||||
<view class="">
|
||||
<!-- <text
|
||||
v-if="detaobj.suitFeeType == 3 || detaobj.suitFeeType == 4">{{timeDifferenceString == '' ? '1分' : timeDifferenceString}}</text> -->
|
||||
<text v-if="detaobj.suitFeeType == 2 || detaobj.suitFeeType == 3">{{du}}度</text>
|
||||
<text v-if="detaobj.suitFeeType == 1 || detaobj.suitFeeType == 4">{{formattedTime == '1秒' ? '0' : formattedTime}}</text>
|
||||
</view>
|
||||
<view class="" v-if="detaobj.suitEndTime">
|
||||
¥{{detaobj.money}}
|
||||
|
@ -78,8 +78,8 @@
|
|||
</view>
|
||||
<view class="time_bot" v-if="!detaobj.suitEndTime || detaobj.suitFeeType == 1">
|
||||
<view class="">
|
||||
<text v-if="detaobj.suitFeeType == 3 || detaobj.suitFeeType == 4">已使用时长</text>
|
||||
<text v-else>订单剩余</text>
|
||||
<!-- <text v-if="detaobj.suitFeeType == 3 || detaobj.suitFeeType == 4">已使用时长</text> -->
|
||||
<text >订单剩余</text>
|
||||
</view>
|
||||
<view class="">
|
||||
<text v-if="detaobj.suitFeeType == 3 || detaobj.suitFeeType == 4">预估金额,以实际金额为准</text>
|
||||
|
@ -789,22 +789,6 @@
|
|||
}
|
||||
that.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
// if(res.data.deviceResult && res.data.deviceResult == false){
|
||||
// uni.showToast({
|
||||
// title: res.data.deviceMsg,
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
// setTimeout(()=>{
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/shouye/index'
|
||||
// })
|
||||
// },1500)
|
||||
// }else{
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/shouye/index'
|
||||
// })
|
||||
// }
|
||||
uni.showToast({
|
||||
title: '结束成功',
|
||||
icon: 'success',
|
||||
|
@ -814,7 +798,7 @@
|
|||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
},1500)
|
||||
},1000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
@ -865,6 +849,7 @@
|
|||
}
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
|
@ -890,7 +875,7 @@
|
|||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.jieshufalg = false
|
||||
that.jieshufalg = false
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
|
@ -928,142 +913,32 @@
|
|||
this.trueboxfalg = false
|
||||
this.jieshuflag = true
|
||||
if (this.onlineStatus == 1) {
|
||||
if (this.detaobj.suitFeeType == 1 || this.detaobj.suitFeeType == 2) {
|
||||
let data = {
|
||||
billId: this.billId
|
||||
}
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.jieshuflag = false
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
}, 1500)
|
||||
} else {
|
||||
this.getDevice()
|
||||
let data = {
|
||||
billId: this.billId
|
||||
}
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.jieshuflag = false
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (this.detaobj.status == 1) {
|
||||
let data = {
|
||||
billNo: this.orderno,
|
||||
channelId: this.channelId
|
||||
}
|
||||
this.$u.put(`/app/bill/pay`, data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let that = this
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: res.data.payParams.timeStamp,
|
||||
nonceStr: res.data.payParams.nonceStr,
|
||||
package: res.data.payParams.packageVal,
|
||||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
|
||||
// 支付成功逻辑
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
setTimeout(() => {
|
||||
that.jieshuflag = false
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
}, 1500)
|
||||
},
|
||||
fail(err) {
|
||||
that.getDevice()
|
||||
that.jieshuflag = false
|
||||
// 支付失败逻辑
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
})
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 1500)
|
||||
} else {
|
||||
let data = {
|
||||
billId: this.billId
|
||||
}
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
let data = {
|
||||
billNo: this.orderno,
|
||||
channelId: this.channelId
|
||||
}
|
||||
this.$u.put(`/app/bill/pay`, data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let that = this
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: res.data.payParams.timeStamp,
|
||||
nonceStr: res.data.payParams.nonceStr,
|
||||
package: res.data.payParams.packageVal,
|
||||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
|
||||
// 支付成功逻辑
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
setTimeout(() => {
|
||||
that.jieshuflag = false
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
}, 1500)
|
||||
},
|
||||
fail(err) {
|
||||
that.jieshuflag = false
|
||||
// 支付失败逻辑
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.getDevice()
|
||||
this.jieshuflag = false
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
this.getDevice()
|
||||
this.jieshuflag = false
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// console.log(this.temperature,'this.temperature');
|
||||
if (this.temperature == null) {
|
||||
|
@ -1071,7 +946,7 @@
|
|||
title: '切换中'
|
||||
})
|
||||
let that = this
|
||||
xBlufi.initXBlufi(1);
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
|
@ -1097,155 +972,56 @@
|
|||
}
|
||||
})
|
||||
} else {
|
||||
if (this.detaobj.suitFeeType == 1 || this.detaobj.suitFeeType == 2) {
|
||||
let data = {
|
||||
billId: this.billId,
|
||||
totalEle: this.temperature
|
||||
}
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: 'close',
|
||||
})
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11close',
|
||||
})
|
||||
let datas = {
|
||||
mac:that.qrResult,
|
||||
reason:'用户结束订单操作',
|
||||
command:'11close',
|
||||
result:'成功'
|
||||
}
|
||||
console.log(datas,'111');
|
||||
that.$u.post(`/app/commandLog/bluetooth`,datas).then(res => {})
|
||||
setTimeout(() => {
|
||||
this.jieshuflag = false
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
}, 1000)
|
||||
}, 1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
// this.baiflag = false
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.jieshuflag = false
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let data = {
|
||||
billId: this.billId,
|
||||
totalEle: this.temperature
|
||||
}
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: 'close',
|
||||
})
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11close',
|
||||
})
|
||||
let datas = {
|
||||
mac:that.qrResult,
|
||||
reason:'用户结束订单操作',
|
||||
command:'11close',
|
||||
result:'成功'
|
||||
}
|
||||
console.log(datas,'111');
|
||||
that.$u.post(`/app/commandLog/bluetooth`,datas).then(res => {})
|
||||
setTimeout(() => {
|
||||
let data = {
|
||||
billNo: that.orderno,
|
||||
channelId: that.channelId
|
||||
}
|
||||
that.$u.put(`/app/bill/pay`,data).then((res) => {
|
||||
if (res.code ==200) {
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: res.data.payParams.timeStamp,
|
||||
nonceStr: res.data.payParams.nonceStr,
|
||||
package: res.data.payParams.packageVal,
|
||||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
|
||||
// 支付成功逻辑
|
||||
uni.showToast({
|
||||
title: res
|
||||
.msg,
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
setTimeout(() => {
|
||||
that.jieshuflag = false
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
},1500)
|
||||
},
|
||||
fail(err) {
|
||||
that.jieshuflag = false
|
||||
// 支付失败逻辑
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
}, 1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
// this.baiflag = false
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.getDevice()
|
||||
this.jieshuflag = false
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
let data = {
|
||||
billId: this.billId,
|
||||
totalEle: this.temperature
|
||||
}
|
||||
|
||||
let that = this
|
||||
this.$u.put(`/app/bill/endUse`, data).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "time@" + 0
|
||||
})
|
||||
let datas = {
|
||||
mac:that.qrResult,
|
||||
reason:'用户结束订单操作',
|
||||
command:'11close',
|
||||
result:'成功'
|
||||
}
|
||||
console.log(datas,'111');
|
||||
that.$u.post(`/app/commandLog/bluetooth`,datas).then(res => {})
|
||||
setTimeout(() => {
|
||||
that.jieshuflag = false
|
||||
uni.reLaunch({
|
||||
url: '/pages/shouye/index'
|
||||
})
|
||||
}, 1000)
|
||||
}, 1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.jieshuflag = false
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1257,7 +1033,6 @@
|
|||
clearInterval(this.timerId)
|
||||
}
|
||||
// 设置定时器,每分钟执行一次 timerCallback 函数
|
||||
// this.timerId = setInterval(this.getDevice,this.shuaxin, 60000)
|
||||
this.timerId = setInterval(() => {
|
||||
this.shuaxin()
|
||||
}, 60000);
|
||||
|
|
|
@ -494,7 +494,7 @@
|
|||
getanya(){
|
||||
if (this.ver_data == '') {
|
||||
let that = this
|
||||
xBlufi.initXBlufi(1);
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
|
@ -580,7 +580,6 @@
|
|||
if(res.data.suitList){
|
||||
this.mapGearTimeToGearAmount(res.data.suitList)
|
||||
}
|
||||
// console.log(res.data.suitList,'1212');
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -612,7 +611,7 @@
|
|||
duration: 1000
|
||||
})
|
||||
}else if((this.phonenumber == '' || this.phonenumber == null) && this.mchShowBillMobile == true){
|
||||
console.log(this.phonenumber,this.mchShowBillMobile);
|
||||
console.log(this.phonenumber,this.mchShowBillMobile)
|
||||
this.getPhoneNumber()
|
||||
this.telslag = true
|
||||
}else {
|
||||
|
@ -622,7 +621,7 @@
|
|||
},
|
||||
// 获取手机号
|
||||
getPhoneNumber(e){
|
||||
console.log(e);
|
||||
console.log(e)
|
||||
this.$u.put(`/app/user/bindWxMobile?mobileCode=${e.detail.code}`).then(res =>{
|
||||
if(res.code == 200){
|
||||
this.zhifuflag = false
|
||||
|
@ -665,7 +664,7 @@
|
|||
billNo:that.orderno,
|
||||
channelId:that.channelId
|
||||
}
|
||||
that.$u.put(`/app/bill/payDeposit`,data).then(res => {
|
||||
that.$u.put(`/app/bill/pay`,data).then(res => {
|
||||
if(res.code == 200){
|
||||
that.payNo = res.data.payBill.payNo
|
||||
uni.requestPayment({
|
||||
|
@ -685,7 +684,6 @@
|
|||
that.$u.put(`/app/bill/${that.payNo}/refreshPayResult`).then(res => {})
|
||||
// 支付成功逻辑
|
||||
uni.reLaunch({
|
||||
// url: '/pages/shouye/index'
|
||||
url:'/page_components/eletj?id=' + that.orderno
|
||||
})
|
||||
uni.setStorageSync('time', that.expireTimeStr)
|
||||
|
@ -728,7 +726,7 @@
|
|||
// console.log(res, '支付成功')
|
||||
if (that.timer) {
|
||||
clearInterval(this.timer)
|
||||
that.timer = null;
|
||||
that.timer = null
|
||||
}
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
|
||||
// 支付成功逻辑
|
||||
|
@ -774,8 +772,8 @@
|
|||
if (this.ver_data == '') {
|
||||
this.czflag = true
|
||||
let that = this
|
||||
xBlufi.initXBlufi(1);
|
||||
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
|
@ -844,7 +842,7 @@
|
|||
billNo:that.orderno,
|
||||
channelId:that.channelId
|
||||
}
|
||||
that.$u.put(`/app/bill/payDeposit`,data).then((res) => {
|
||||
that.$u.put(`/app/bill/pay`,data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
that.payNo = res.data.payBill.payNo
|
||||
uni.requestPayment({
|
||||
|
@ -855,15 +853,16 @@
|
|||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
// console.log(res, '支付成功');
|
||||
// console.log(res, '支付成功')
|
||||
if (that.timer) {
|
||||
clearInterval(this.timer);
|
||||
that.timer = null;
|
||||
clearInterval(this.timer)
|
||||
that.timer = null
|
||||
}
|
||||
// 111111111111111111111111
|
||||
that.$u.put(`/app/payBill/${that.payNo}/refreshPayResult`).then(res =>{
|
||||
// if(res.code == 200){
|
||||
that.$u.get(`/app/bill/byNo/${that.orderno}`).then(res => {
|
||||
let timesc = res.data.syncDeviceSeconds
|
||||
if (res.code == 200) {
|
||||
let datas = {
|
||||
mac:that.mac,
|
||||
|
@ -873,7 +872,7 @@
|
|||
}
|
||||
console.log(datas,'111');
|
||||
that.$u.post(`/app/commandLog/bluetooth`,datas).then(res => {})
|
||||
if(res.data.status == 9){
|
||||
if(res.data.status == 2){
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
|
@ -883,16 +882,11 @@
|
|||
that.startLoading()
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: 'open'
|
||||
customData: "time@" + timesc
|
||||
})
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11open'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
that.zhifuflag = false
|
||||
uni.reLaunch({
|
||||
// url: '/pages/shouye/index'
|
||||
url:'/page_components/eletj?id=' + that.orderno
|
||||
})
|
||||
},1000)
|
||||
|
@ -950,7 +944,7 @@
|
|||
title: '支付失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
}else{
|
||||
|
@ -972,10 +966,10 @@
|
|||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
// console.log(res, '支付成功');
|
||||
// console.log(res, '支付成功')
|
||||
if (that.timer) {
|
||||
clearInterval(this.timer);
|
||||
that.timer = null;
|
||||
clearInterval(this.timer)
|
||||
that.timer = null
|
||||
}
|
||||
// 111111111111111111111111
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res =>{
|
||||
|
@ -983,10 +977,11 @@
|
|||
that.$u.put(`/app/bill/rechargeBillDevice?billNo=${that.orderno}`).then(res=>{
|
||||
that.$u.get('/app/bill/recharge/device/fail/list').then(res => { //充值失败调用
|
||||
if (res.code == 200) {
|
||||
console.log('获取订单状态',res);
|
||||
console.log('获取订单状态',res)
|
||||
if(res.data.length > 0 && res.data != null){
|
||||
let dingobj = res.data[0].billNo
|
||||
console.log(dingobj,'订单号');
|
||||
let times = res.data[0].syncDeviceSeconds
|
||||
console.log(dingobj,'订单号')
|
||||
let datas = {
|
||||
mac:that.mac,
|
||||
reason:'下单' + that.orderno,
|
||||
|
@ -1005,7 +1000,7 @@
|
|||
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "time@" + that.jine
|
||||
customData: "time@" + times
|
||||
})
|
||||
},1500)
|
||||
},
|
||||
|
@ -1018,9 +1013,7 @@
|
|||
content: '设备开启失败,检测到设备蓝牙已断开',
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
// uni.showLoading({
|
||||
// title: '蓝牙连接中'
|
||||
// })
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1132,7 +1125,7 @@
|
|||
billNo:that.orderno,
|
||||
channelId:that.channelId
|
||||
}
|
||||
that.$u.put(`/app/bill/payDeposit`,data).then((res) => {
|
||||
that.$u.put(`/app/bill/pay`,data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
that.payNo = res.data.payBill.payNo
|
||||
uni.requestPayment({
|
||||
|
@ -1143,16 +1136,18 @@
|
|||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
// console.log(res, '支付成功');
|
||||
// console.log(res, '支付成功')
|
||||
if (that.timer) {
|
||||
clearInterval(this.timer);
|
||||
that.timer = null;
|
||||
clearInterval(this.timer)
|
||||
that.timer = null
|
||||
}
|
||||
// 111111111111111111111111
|
||||
that.$u.put(`/app/payBill/${that.payNo}/refreshPayResult`).then(res =>{
|
||||
// if(res.code == 200){
|
||||
that.$u.get(`/app/bill/byNo/${that.orderno}`).then(res => {
|
||||
if (res.code == 200) {
|
||||
let timesc = res.data.syncDeviceSeconds
|
||||
that.$u.get(`/app/bill/recharge/${res.data.billNo}/bluetoothSuccess`).then(res =>{})
|
||||
let datas = {
|
||||
mac:that.mac,
|
||||
reason:'下单' + that.orderno,
|
||||
|
@ -1161,7 +1156,7 @@
|
|||
}
|
||||
console.log(datas,'333');
|
||||
that.$u.post(`/app/commandLog/bluetooth`,datas).then(res => {})
|
||||
if(res.data.status == 9){
|
||||
if(res.data.status == 2){
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
|
@ -1171,12 +1166,9 @@
|
|||
that.startLoading()
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: 'open'
|
||||
customData: "time@" + timesc
|
||||
})
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11open'
|
||||
})
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
if(that.ver_data == ''){
|
||||
uni.showToast({
|
||||
|
@ -1282,6 +1274,7 @@
|
|||
console.log('获取订单状态',res);
|
||||
if(res.data.length > 0 && res.data != null){
|
||||
let dingobj = res.data[0].billNo
|
||||
let times = res.data[0].syncDeviceSeconds
|
||||
console.log(dingobj,'订单号');
|
||||
let datas = {
|
||||
mac:that.mac,
|
||||
|
@ -1300,7 +1293,7 @@
|
|||
that.startLoading()
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "time@" + that.jine
|
||||
customData: "time@" + times
|
||||
})
|
||||
if(that.ver_data != ''){
|
||||
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
||||
|
@ -1455,11 +1448,7 @@
|
|||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList;
|
||||
} else {
|
||||
// uni.showToast({
|
||||
// title: '未找到该设备,请确认该设备在附近',
|
||||
// icon: 'none',
|
||||
// duration: 3000
|
||||
// })
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1482,13 +1471,14 @@
|
|||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
this.ver_data = this.parseCustomData(options.data)
|
||||
console.log("1收到设备发来的自定义数据结果:", this.ver_data);
|
||||
console.log("1收到设备发来的自定义数据结果:",options.data);
|
||||
setTimeout(()=>{
|
||||
this.czflag = false
|
||||
this.zhifuflag = false
|
||||
uni.hideLoading()
|
||||
this.imglanya = 'https://api.ccttiot.com/smartmeter/img/static/uzmkQ6a3gBrJ7SjbfmmU'
|
||||
if (!this.hasCalledGetczly) {
|
||||
this.getlyxx(options.data)
|
||||
this.getczly()
|
||||
this.hasCalledGetczly = true
|
||||
}
|
||||
|
@ -1581,7 +1571,8 @@
|
|||
this.zhifuflag = false
|
||||
uni.hideLoading()
|
||||
|
||||
if (!this.hasCalledGetczlys) {
|
||||
if (!this.hasCalledGetczlys) {
|
||||
this.getlyxx(options.data)
|
||||
this.hasCalledGetczlys = true
|
||||
let that = this
|
||||
let datas = {
|
||||
|
@ -1715,6 +1706,7 @@
|
|||
uni.hideLoading()
|
||||
|
||||
if (!this.hasCalledGetczlyss) {
|
||||
this.getlyxx(options.data)
|
||||
this.hasCalledGetczlyss = true
|
||||
let that = this
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res =>{
|
||||
|
@ -1823,26 +1815,46 @@
|
|||
break;
|
||||
}
|
||||
},
|
||||
// 同步蓝牙信息
|
||||
getlyxx(data){
|
||||
this.$u.put(`/app/device/bltSyncIot?sn=${this.id}&info=${data}`).then(res => {
|
||||
if (res.code == 200) {
|
||||
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 从蓝牙拿到数据进行解析
|
||||
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(1); // 去除前缀 "T"
|
||||
// 返回解析后的数据对象
|
||||
return {
|
||||
voltage,
|
||||
switchState,
|
||||
current,
|
||||
power,
|
||||
remainingPower,
|
||||
setMode
|
||||
const parsedData = {};
|
||||
const prefixMap = {
|
||||
'V': 'voltage',
|
||||
'S': 'switchState',
|
||||
'A': 'current',
|
||||
'P': 'power',
|
||||
'M': 'remainingPower',
|
||||
'T': 'setMode',
|
||||
'W': 'temperature'
|
||||
};
|
||||
// 遍历数组并解析每个字段
|
||||
for (let i = 0; i < dataArray.length; i++) {
|
||||
const field = dataArray[i]
|
||||
for (const prefix in prefixMap) {
|
||||
if (field.startsWith(prefix)) {
|
||||
const value = field.substring(1)
|
||||
const propertyName = prefixMap[prefix]
|
||||
parsedData[propertyName] = isNaN(parseFloat(value)) ? value : parseFloat(value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return parsedData;
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
@ -239,10 +239,13 @@
|
|||
}
|
||||
|
||||
.tip {
|
||||
width: 100%;
|
||||
padding: 0 40rpx;
|
||||
box-sizing: border-box;
|
||||
margin-top: 62rpx;
|
||||
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
font-size: 32rpx;
|
||||
color: #FF8D1A;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
|
|
@ -128,8 +128,57 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
btncq(){
|
||||
this.$u.put(`/app/device/admin/reboot?sn=${this.storeId}`).then(res =>{
|
||||
if(res.code == 200){
|
||||
uni.showToast({
|
||||
title: '重启成功',
|
||||
icon: 'success',
|
||||
duration:2000
|
||||
})
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration:2000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
btnsxs(){
|
||||
|
||||
this.$u.put(`/app/device/admin/uploadData?sn=${this.storeId}`).then(res =>{
|
||||
if(res.code == 200){
|
||||
this.obj = res.data
|
||||
this.id = res.data.deviceId
|
||||
if(res.data.vxs == null){
|
||||
this.xshu = 1
|
||||
}else{
|
||||
this.xshu = res.data.vxs
|
||||
}
|
||||
if (res.data.onlineStatus == 0) {
|
||||
this.onlineStatus = '离线'
|
||||
} else if (res.data.onlineStatus == 1) {
|
||||
this.onlineStatus = '在线'
|
||||
}
|
||||
if (res.data.powerStatus == 0) {
|
||||
this.powerStatus = '关闭'
|
||||
} else if (res.data.powerStatus == 1) {
|
||||
this.powerStatus = '开启'
|
||||
}
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
})
|
||||
uni.hideLoading()
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration:2000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
btnjian(){
|
||||
this.valuedian = Number(this.valuedian) - 1
|
||||
|
@ -239,9 +288,6 @@
|
|||
})
|
||||
this.$u.put(`/app/device/admin/${this.id}/switch?open=true`).then((res) => {
|
||||
if (res.code == 200) {
|
||||
// setTimeout(()=>{
|
||||
// this.btnsx()
|
||||
// },1000)
|
||||
uni.showToast({
|
||||
title: '开启成功',
|
||||
icon: 'success',
|
||||
|
@ -289,13 +335,13 @@
|
|||
if (res.code == 200) {
|
||||
this.getsn()
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
title: '同步成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '刷新失败',
|
||||
title: '同步失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
|
|
|
@ -199,11 +199,11 @@
|
|||
month: now.getMonth() + 1, // 月份从0开始,所以需要+1
|
||||
day: 1 // 设置为月份的第一天
|
||||
}
|
||||
this.kstime = this.yeartime.year + '-' + this.yeartime.month + '-' + (this.yeartime.day < 10 ? '0' + this.yeartime.day : this.yeartime.day)
|
||||
this.kstime = this.yeartime.year + '-' + (this.yeartime.month < 10 ? '0' + this.yeartime.month : this.yeartime.month) + '-' + (this.yeartime.day < 10 ? '0' + this.yeartime.day : this.yeartime.day)
|
||||
this.yeartimes.year = now.getFullYear()
|
||||
this.yeartimes.month = now.getMonth() + 1
|
||||
this.yeartimes.day = now.getDate()
|
||||
this.jstime = this.yeartimes.year + '-' + this.yeartimes.month + '-' + (this.yeartimes.day < 10 ? '0' + this.yeartimes.day : this.yeartimes.day)
|
||||
this.jstime = this.yeartimes.year + '-' + (this.yeartimes.month < 10 ? '0' + this.yeartimes.month : this.yeartimes.month) + '-' + (this.yeartimes.day < 10 ? '0' + this.yeartimes.day : this.yeartimes.day)
|
||||
this.gettime()
|
||||
},
|
||||
methods: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user