This commit is contained in:
吴鹏 2025-09-09 11:25:47 +08:00
parent d07b934889
commit 9cf84ebcef
3 changed files with 151 additions and 27 deletions

View File

@ -16,7 +16,7 @@ const install = (Vue, vm) => {
// },
// });
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',
loadingText: '努力加载中~',
loadingTime: 800,

View File

@ -37,6 +37,8 @@
return {
bgc: {
backgroundColor: " ",
kazuoid:'',
q:''
},
}
},
@ -46,6 +48,62 @@
} else {
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() {
xBlufi.notifyStartDiscoverBle({
@ -71,8 +129,9 @@
this.$u.get(`/getInfo`).then(res => {
if (res.code == 200) {
if(num == 1){ //
console.log(11111);
uni.navigateTo({
url: '/pages/myorder/index'
url: '/pages/myorder/index?q=' + this.q
})
}else if(num == 2){ //
uni.navigateTo({

View File

@ -166,7 +166,8 @@
findDeviceTimer: null,
duration:'',
channelId:'',
channellist:[]
channellist:[],
shibainum:0
}
},
onLoad(option) {
@ -181,15 +182,7 @@
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({
@ -202,9 +195,9 @@
if (res.code == 200) {
this.yonghuobj = res.data
this.smflag = false
uni.switchTab({
url:'/pages/index/index'
})
// uni.switchTab({
// url:'/pages/index/index'
// })
setTimeout(() => {
this.getcishu()
}, 500)
@ -235,6 +228,10 @@
},
onShow() {
this.tabindex = 0
xBlufi.initXBlufi(1)
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
this.getqudao()
this.getinfo()
@ -357,7 +354,7 @@
},
// 线
findDevice() {
const matchedDevice = this.devicesarr.find(device => device.name.slice(-12) === this.mac.slice(-12)) //12mac
const matchedDevice = this.devicesarr.find(device => device.name.slice(-12) == this.mac.slice(-12)) //12mac
if (matchedDevice) { //
xBlufi.notifyStartDiscoverBle({
'isStart': false
@ -506,7 +503,7 @@
},
//
startCountdown() {
this.countdown = this.duration
this.countdown = this.yonghuobj.devices[0].duration
this.countdownTimer = setInterval(() => {
if (this.countdown > 0) {
this.countdown--
@ -545,16 +542,16 @@
if (res.code == 200 && res.data.db >= 1) {
if (res.data.iot == false) { // true
if (this.ver_dataflag == 3) { //
xBlufi.notifySendCustomData({
customData: "11time" + this.duration + '@' //
})
uni.showToast({
title: "爆灯成功",
icon: 'success',
duration: 2000
})
this.getcishu()
this.startCountdown() //
// xBlufi.notifySendCustomData({
// customData: "11time" + this.yonghuobj.devices[0].duration + '@' //
// })
// uni.showToast({
// title: "",
// icon: 'success',
// duration: 2000
// })
// this.getcishu()
// this.startCountdown() //
} else {
uni.showToast({
title: '设备离线',
@ -571,6 +568,74 @@
this.getcishu()
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 {
console.log(res.msg);
uni.showToast({