爆灯
This commit is contained in:
parent
d07b934889
commit
9cf84ebcef
|
@ -16,7 +16,7 @@ const install = (Vue, vm) => {
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
Vue.prototype.$u.http.setConfig({
|
Vue.prototype.$u.http.setConfig({
|
||||||
// baseUrl: 'http://192.168.2.81:4301',
|
// baseUrl: 'http://192.168.2.241:4301',
|
||||||
baseUrl: 'https://bao.chuangtewl.com/prod-api',
|
baseUrl: 'https://bao.chuangtewl.com/prod-api',
|
||||||
loadingText: '努力加载中~',
|
loadingText: '努力加载中~',
|
||||||
loadingTime: 800,
|
loadingTime: 800,
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
return {
|
return {
|
||||||
bgc: {
|
bgc: {
|
||||||
backgroundColor: " ",
|
backgroundColor: " ",
|
||||||
|
kazuoid:'',
|
||||||
|
q:''
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -46,6 +48,62 @@
|
||||||
} else {
|
} else {
|
||||||
xBlufi.initXBlufi(1)
|
xBlufi.initXBlufi(1)
|
||||||
}
|
}
|
||||||
|
if (option.q) { //判断是否直接扫码进入 解析携带参数
|
||||||
|
this.q = option.q
|
||||||
|
const getQueryParam = (url, paramName) => {
|
||||||
|
const regex = new RegExp(`[?&]${paramName}=([^&]*)`)
|
||||||
|
const results = regex.exec(url)
|
||||||
|
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null
|
||||||
|
}
|
||||||
|
const sceneValue = option.q
|
||||||
|
const decodedValue = decodeURIComponent(sceneValue)
|
||||||
|
this.kazuoid = getQueryParam(decodedValue, 'k')
|
||||||
|
console.log(this.kazuoid,option.q);
|
||||||
|
if (!this.kazuoid) { //判断是否解析成功 有无id
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '无效的二维码',
|
||||||
|
confirmText: '知道了',
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.showLoading({
|
||||||
|
title: '绑定中...',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
// 有id的话 一进入直接就进行绑定操作
|
||||||
|
this.$u.get(`/app/booth/getBoothDetail/${this.kazuoid}`).then(res => {
|
||||||
|
uni.hideLoading()
|
||||||
|
if (res.code == 200) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: res.msg,
|
||||||
|
confirmText: '知道了',
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '绑定失败,请重试',
|
||||||
|
confirmText: '知道了',
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
|
@ -71,8 +129,9 @@
|
||||||
this.$u.get(`/getInfo`).then(res => {
|
this.$u.get(`/getInfo`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
if(num == 1){ //跳转爆灯
|
if(num == 1){ //跳转爆灯
|
||||||
|
console.log(11111);
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/myorder/index'
|
url: '/pages/myorder/index?q=' + this.q
|
||||||
})
|
})
|
||||||
}else if(num == 2){ //跳转拼桌
|
}else if(num == 2){ //跳转拼桌
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
|
|
|
@ -166,7 +166,8 @@
|
||||||
findDeviceTimer: null,
|
findDeviceTimer: null,
|
||||||
duration:'',
|
duration:'',
|
||||||
channelId:'',
|
channelId:'',
|
||||||
channellist:[]
|
channellist:[],
|
||||||
|
shibainum:0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
|
@ -181,15 +182,7 @@
|
||||||
this.kazuoid = getQueryParam(decodedValue, 'k')
|
this.kazuoid = getQueryParam(decodedValue, 'k')
|
||||||
console.log(this.kazuoid,option.q);
|
console.log(this.kazuoid,option.q);
|
||||||
if (!this.kazuoid) { //判断是否解析成功 有无id
|
if (!this.kazuoid) { //判断是否解析成功 有无id
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '无效的二维码',
|
|
||||||
confirmText: '知道了',
|
|
||||||
showCancel: false,
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
|
@ -202,9 +195,9 @@
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.yonghuobj = res.data
|
this.yonghuobj = res.data
|
||||||
this.smflag = false
|
this.smflag = false
|
||||||
uni.switchTab({
|
// uni.switchTab({
|
||||||
url:'/pages/index/index'
|
// url:'/pages/index/index'
|
||||||
})
|
// })
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getcishu()
|
this.getcishu()
|
||||||
}, 500)
|
}, 500)
|
||||||
|
@ -235,6 +228,10 @@
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.tabindex = 0
|
this.tabindex = 0
|
||||||
|
xBlufi.initXBlufi(1)
|
||||||
|
xBlufi.notifyStartDiscoverBle({
|
||||||
|
'isStart': true
|
||||||
|
})
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
this.getqudao()
|
this.getqudao()
|
||||||
this.getinfo()
|
this.getinfo()
|
||||||
|
@ -357,7 +354,7 @@
|
||||||
},
|
},
|
||||||
// 判断离线连接蓝牙
|
// 判断离线连接蓝牙
|
||||||
findDevice() {
|
findDevice() {
|
||||||
const matchedDevice = this.devicesarr.find(device => device.name.slice(-12) === this.mac.slice(-12)) //截取最后12位mac号进行判断是否存在相同的
|
const matchedDevice = this.devicesarr.find(device => device.name.slice(-12) == this.mac.slice(-12)) //截取最后12位mac号进行判断是否存在相同的
|
||||||
if (matchedDevice) { //如果有则停止搜索 进行连接
|
if (matchedDevice) { //如果有则停止搜索 进行连接
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': false
|
'isStart': false
|
||||||
|
@ -506,7 +503,7 @@
|
||||||
},
|
},
|
||||||
// 爆灯成功开始倒计时 需倒计时结束后方可再次点击
|
// 爆灯成功开始倒计时 需倒计时结束后方可再次点击
|
||||||
startCountdown() {
|
startCountdown() {
|
||||||
this.countdown = this.duration
|
this.countdown = this.yonghuobj.devices[0].duration
|
||||||
this.countdownTimer = setInterval(() => {
|
this.countdownTimer = setInterval(() => {
|
||||||
if (this.countdown > 0) {
|
if (this.countdown > 0) {
|
||||||
this.countdown--
|
this.countdown--
|
||||||
|
@ -545,16 +542,16 @@
|
||||||
if (res.code == 200 && res.data.db >= 1) {
|
if (res.code == 200 && res.data.db >= 1) {
|
||||||
if (res.data.iot == false) { //判断是否进行蓝牙充值 为true则进行蓝牙发送命令
|
if (res.data.iot == false) { //判断是否进行蓝牙充值 为true则进行蓝牙发送命令
|
||||||
if (this.ver_dataflag == 3) { //判断蓝牙是否已经连接
|
if (this.ver_dataflag == 3) { //判断蓝牙是否已经连接
|
||||||
xBlufi.notifySendCustomData({
|
// xBlufi.notifySendCustomData({
|
||||||
customData: "11time" + this.duration + '@' //进行蓝牙发送命令
|
// customData: "11time" + this.yonghuobj.devices[0].duration + '@' //进行蓝牙发送命令
|
||||||
})
|
// })
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: "爆灯成功",
|
// title: "爆灯成功",
|
||||||
icon: 'success',
|
// icon: 'success',
|
||||||
duration: 2000
|
// duration: 2000
|
||||||
})
|
// })
|
||||||
this.getcishu()
|
// this.getcishu()
|
||||||
this.startCountdown() //爆灯成功后进行禁用倒计时
|
// this.startCountdown() //爆灯成功后进行禁用倒计时
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '设备离线',
|
title: '设备离线',
|
||||||
|
@ -571,6 +568,74 @@
|
||||||
this.getcishu()
|
this.getcishu()
|
||||||
this.startCountdown() //爆灯成功后进行禁用倒计时
|
this.startCountdown() //爆灯成功后进行禁用倒计时
|
||||||
}
|
}
|
||||||
|
}else if(res.code == 20001){
|
||||||
|
uni.showLoading({
|
||||||
|
title: '爆灯开启中...',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
const findDevice = () =>{
|
||||||
|
this.ver_dataflag = 2
|
||||||
|
const matchedDevice = this.devicesarr.find(device => {
|
||||||
|
if(device.name){
|
||||||
|
console.log(device.localName.slice(-12),this.yonghuobj.devices[0].mac.slice(-12));
|
||||||
|
return device.localName.slice(-12) == this.yonghuobj.devices[0].mac.slice(-12)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (matchedDevice) {
|
||||||
|
xBlufi.notifyStartDiscoverBle({
|
||||||
|
'isStart': false
|
||||||
|
})
|
||||||
|
xBlufi.notifyConnectBle({
|
||||||
|
isStart: true,
|
||||||
|
deviceId: matchedDevice.deviceId,
|
||||||
|
name: matchedDevice.name
|
||||||
|
})
|
||||||
|
this.deviceid = matchedDevice.deviceId
|
||||||
|
this.devicename = matchedDevice.name
|
||||||
|
setTimeout(()=>{
|
||||||
|
if(this.ver_dataflag == 3){
|
||||||
|
uni.hideLoading()
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: "11time" + this.yonghuobj.devices[0].duration + '@' //进行蓝牙发送命令
|
||||||
|
})
|
||||||
|
console.log('10101010');
|
||||||
|
this.$u.put(`/app/booth/${this.yonghuobj.boothId}/lighting?requiredIot=false`).then(res={})
|
||||||
|
this.getcishu()
|
||||||
|
this.startCountdown() //爆灯成功后进行禁用倒计时
|
||||||
|
let data = {
|
||||||
|
mac:this.yonghuobj.devices[0].mac,
|
||||||
|
reason:'用户蓝牙开启',
|
||||||
|
command:"11time" + this.yonghuobj.devices[0].duration + '@',
|
||||||
|
result:'sucess'
|
||||||
|
}
|
||||||
|
this.$u.post(`/app/commandLog/bluetooth`,data).then(res => {})
|
||||||
|
}else{
|
||||||
|
this.ver_dataflag = 1
|
||||||
|
this.shibainum = 0
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},4000)
|
||||||
|
} else {
|
||||||
|
if(this.shibainum < 3){
|
||||||
|
this.shibainum++
|
||||||
|
this.findDeviceTimer = setTimeout(findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文
|
||||||
|
}else{
|
||||||
|
this.ver_dataflag = 1
|
||||||
|
this.shibainum = 0
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '爆灯失败',
|
||||||
|
confirmText: '知道了',
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
findDevice()
|
||||||
} else {
|
} else {
|
||||||
console.log(res.msg);
|
console.log(res.msg);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user