This commit is contained in:
3321822538@qq.com 2024-05-30 17:24:10 +08:00
parent 53901aec4f
commit 63cf0b1e50
8 changed files with 173 additions and 170 deletions

View File

@ -21,7 +21,7 @@ const install = (Vue, vm) => {
// }); // });
Vue.prototype.$u.http.setConfig({ Vue.prototype.$u.http.setConfig({
// baseUrl: 'http://192.168.2.184:3000/dev-api', // baseUrl: 'http://192.168.2.184:3000/dev-api',
baseUrl: 'https://kaiguan.chuantewulian.cn/prod-api', baseUrl: 'https://kg.chuantewulian.cn/prod-api',
loadingText: '努力加载中~', loadingText: '努力加载中~',
loadingTime: 1000, loadingTime: 1000,
// 设置自定义头部content-type // 设置自定义头部content-type

View File

@ -85,7 +85,7 @@
} }
let sceneValue = option.q let sceneValue = option.q
let decodedValue = decodeURIComponent(sceneValue); let decodedValue = decodeURIComponent(sceneValue);
this.id = getQueryParam(decodedValue, 'deviceNo') this.id = getQueryParam(decodedValue, 's')
console.log(this.id) console.log(this.id)
this.startTimer() this.startTimer()
this.gettaoc() this.gettaoc()

View File

@ -79,7 +79,7 @@
} }
let sceneValue = res.result let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue); let decodedValue = decodeURIComponent(sceneValue);
this.deviceNo = getQueryParam(decodedValue, 'deviceNo') this.deviceNo = getQueryParam(decodedValue, 's')
// this.deviceNo = res.result; // this.deviceNo = res.result;
}, },
fail: err => { fail: err => {

View File

@ -180,14 +180,10 @@
} }
let sceneValue = res.result let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue); let decodedValue = decodeURIComponent(sceneValue);
let id = getQueryParam(decodedValue, 'deviceNo') let id = getQueryParam(decodedValue, 's')
this.$u.get(`/app/device/${id}/bySn`).then((res) => { this.$u.get(`/app/device/${id}/bySn`).then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.qrResult = 'CTKG-' + res.data.mac this.qrResult = 'CTKG-' + res.data.mac
// console.log(this.qrResult);
// uni.navigateTo({
// url:'/page_fenbao/device/lianjie?mac=' + this.qrResult + '&storeId=' + this.storeId
// })
xBlufi.initXBlufi(1); xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({ xBlufi.notifyStartDiscoverBle({
@ -243,7 +239,8 @@
} else { } else {
uni.showToast({ uni.showToast({
title: '没有发现设备', title: '没有发现设备',
icon: 'none' icon: 'none',
duration:2000
}); });
} }
break; break;

View File

@ -180,7 +180,7 @@
} }
let sceneValue = res.result let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue); let decodedValue = decodeURIComponent(sceneValue);
let id = getQueryParam(decodedValue, 'deviceNo') let id = getQueryParam(decodedValue, 's')
this.$u.get(`/app/device/${id}/withSuitList`).then((res) =>{ this.$u.get(`/app/device/${id}/withSuitList`).then((res) =>{
if(res.code == 200){ if(res.code == 200){
uni.navigateTo({ uni.navigateTo({

View File

@ -188,11 +188,11 @@
token: '', token: '',
userImgs: '', userImgs: '',
imgflag: true, imgflag: true,
mac:"", mac: "",
name:'', name: '',
deviceId:'', deviceId: '',
storeId:'', storeId: '',
qrResult:'' qrResult: ''
} }
}, },
onLoad(option) { onLoad(option) {
@ -322,7 +322,7 @@
icon: 'success', icon: 'success',
duration: 2000 duration: 2000
}) })
}else if(res.code == 500){ } else if (res.code == 500) {
uni.showToast({ uni.showToast({
title: '设备不在线', title: '设备不在线',
icon: 'none', icon: 'none',
@ -455,9 +455,9 @@
// url: '/page_fenbao/device/lianjie?mac=' + this.deviceInfo.mac + '&storeId=' + this // url: '/page_fenbao/device/lianjie?mac=' + this.deviceInfo.mac + '&storeId=' + this
// .deviceInfo.storeId // .deviceInfo.storeId
// }) // })
uni.showLoading({ uni.showLoading({
title: '加载中...' title: '加载中...'
}); });
xBlufi.initXBlufi(1); xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({ xBlufi.notifyStartDiscoverBle({
@ -480,154 +480,158 @@
} }
}, },
funListenDeviceMsgEvent: function(options) { funListenDeviceMsgEvent: function(options) {
switch (options.type) { switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) { if (options.result) {
let devicesarr = options.data let devicesarr = options.data
// console.log(devicesarr,'devicesarrdevicesarr'); // console.log(devicesarr,'devicesarrdevicesarr');
devicesarr.forEach(device => { devicesarr.forEach(device => {
const mac = device.name.substring(5); const mac = device.name.substring(5);
if (device.name == this.qrResult) { if (device.name == this.qrResult) {
this.deviceId = device.deviceId this.deviceId = device.deviceId
this.name = device.name this.name = device.name
this.mac = device.name.slice(5,17) this.mac = device.name.slice(5, 17)
console.log(this.mac,'macmacmac'); console.log(this.mac, 'macmacmac');
this.devicesList = uniqueDevicesList; this.devicesList = uniqueDevicesList;
} }
}); });
} }
break; break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED: case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
console.log("连接回调:" + JSON.stringify(options)); console.log("连接回调:" + JSON.stringify(options));
if (options.result) { if (options.result) {
uni.hideLoading(); uni.hideLoading();
// uni.showToast({ // uni.showToast({
// title: '', // title: '',
// icon: 'none' // icon: 'none'
// }); // });
{ {
console.log("连接回调options.data.deviceId" + options.data.deviceId, console.log("连接回调options.data.deviceId" + options.data.deviceId,
"连接回调options.data.name" + options.data.name); "连接回调options.data.name" + options.data.name);
let name = '' let name = ''
let index = this.name.indexOf('-'); let index = this.name.indexOf('-');
if (index !== -1) { if (index !== -1) {
name = this.name.slice(index + 1); name = this.name.slice(index + 1);
} }
let data = { let data = {
storeId:this.storeId, storeId: this.storeId,
mac:this.mac mac: this.mac
} }
this.$u.put('/app/device/bind', data).then((res) => { this.$u.put('/app/device/bind', data).then((res) => {
if (res.code == 200) { if (res.code == 200) {
uni.showToast({ uni.showToast({
title: '绑定成功', title: '绑定成功',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}); });
uni.hideLoading(); uni.hideLoading();
uni.removeStorageSync('mac'); uni.removeStorageSync('mac');
let vm = this let vm = this
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '你已绑定成功,需前去配网吗?', content: '你已绑定成功,需前去配网吗?',
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
let systemInfo = uni.getSystemInfoSync(); let systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform === 'android') { if (systemInfo.platform === 'android') {
// Android // Android
uni.navigateTo({ uni.navigateTo({
url: '/page_components/wifilist/index?deviceId=' + options url: '/page_components/wifilist/index?deviceId=' +
.data.deviceId + '&name=' + options.data.name options
}) .data.deviceId + '&name=' +
} else if (systemInfo.platform === 'ios') { options.data.name
// iOS })
uni.navigateTo({ } else if (systemInfo.platform === 'ios') {
url: '/page_fenbao/device/wifivideo?deviceId=' + options // iOS
.data.deviceId + '&name=' + options.data.name uni.navigateTo({
}) url: '/page_fenbao/device/wifivideo?deviceId=' +
} options
} else if (res.cancel) { .data.deviceId + '&name=' +
console.log('用户点击了取消'); options.data.name
} })
} }
}) } else if (res.cancel) {
}else if(res.code == 500){ console.log('用户点击了取消');
uni.showToast({ }
title: '该设备已被绑定', }
icon: 'none', })
duration: 2000 } else if (res.code == 500) {
}); uni.showToast({
} else { title: '该设备已被绑定',
uni.showToast({ icon: 'none',
title: '连接失败', duration: 2000
icon: 'none', });
duration: 2000 } else {
}); uni.showToast({
// uni.navigateBack() title: '连接失败',
} icon: 'none',
}) duration: 2000
} });
} // uni.navigateBack()
}
break; })
}
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: }
if (!options.result) {
console.log("蓝牙未开启", options); break;
uni.showToast({
title: '蓝牙未开启', case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
icon: 'none', if (!options.result) {
duration: 3000 console.log("蓝牙未开启", options);
}); uni.showToast({
} else { title: '蓝牙未开启',
// this.searching = true icon: 'none',
// duration: 3000
// _this.setData({ });
// searching: true } else {
// }); // this.searching = true
} //
// _this.setData({
break; // searching: true
// });
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: }
if (options.result) {
let uniqueDevicesList = Array.from(new Set(this.devicesList)); break;
// this.devicesList case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
this.devicesList = uniqueDevicesList; if (options.result) {
let list = [] let uniqueDevicesList = Array.from(new Set(this.devicesList));
filteredDevices.forEach(device => {
// MAC MAC 6 // this.devicesList
let macFromName = device.name.substring(device.name.length - 12); this.devicesList = uniqueDevicesList;
this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { let list = []
if (res.data == false) { filteredDevices.forEach(device => {
list.push(device) // MAC MAC 6
} else { let macFromName = device.name.substring(device.name.length - 12);
this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => {
} if (res.data == false) {
}) list.push(device)
} else {
});
setTimeout(() => { }
this.devicesList = list })
}, 200)
});
console.log('蓝牙停止搜索ok'); setTimeout(() => {
} else { this.devicesList = list
// }, 200)
console.log('蓝牙停止搜索失败');
} console.log('蓝牙停止搜索ok');
this.searching = false } else {
// _this.setData({ //
// searching: false console.log('蓝牙停止搜索失败');
// }); }
this.searching = false
break; // _this.setData({
} // searching: false
}, // });
break;
}
},
} }
} }
@ -763,11 +767,12 @@
// margin-top: 50rpx; // margin-top: 50rpx;
display: flex; display: flex;
// flex-wrap: nowrap; // flex-wrap: nowrap;
width: 100%; width: 100%;
justify-content: space-between; justify-content: space-between;
padding-left: 80rpx; padding-left: 80rpx;
padding-right: 120rpx; padding-right: 120rpx;
box-sizing: border-box; box-sizing: border-box;
.cont { .cont {
.tit { .tit {
font-size: 28rpx; font-size: 28rpx;

View File

@ -109,7 +109,7 @@
} }
let sceneValue = res.result let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue); let decodedValue = decodeURIComponent(sceneValue);
this.qrResult = getQueryParam(decodedValue, 'deviceNo') this.qrResult = getQueryParam(decodedValue, 's')
// this.qrResult = res.result; // // this.qrResult = res.result; //
}, },
fail: err => { fail: err => {

View File

@ -216,7 +216,8 @@
} }
let sceneValue = res.result let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue); let decodedValue = decodeURIComponent(sceneValue);
let id = getQueryParam(decodedValue, 'deviceNo') let id = getQueryParam(decodedValue, 's')
console.log(res,id);
this.$u.get(`/app/device/${id}/withSuitList`).then((res) => { this.$u.get(`/app/device/${id}/withSuitList`).then((res) => {
if (res.code == 200) { if (res.code == 200) {
uni.navigateTo({ uni.navigateTo({