From 7392a4a7effa69ff49cea134a38fee3f42650d35 Mon Sep 17 00:00:00 2001
From: "3321822538@qq.com" <3321822538@qq.com>
Date: Tue, 23 Jul 2024 18:00:01 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E8=93=9D=E7=89=99?=
=?UTF-8?q?=E8=BF=9E=E6=8E=A5=20WiFi=E8=BF=9E=E6=8E=A5=20=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E7=BB=91=E5=AE=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/http.interceptor.js | 8 +-
page_components/bindsz.vue | 411 +++++++++++++++++++----------
page_components/wentdetail.vue | 6 +-
page_components/wifilist/index.vue | 320 ++++++++++++++++++----
page_user/sbdetail.vue | 177 +++++++++++--
pages.json | 3 +-
pages/index/index.vue | 106 +++++++-
pages/my.vue | 49 +++-
pages/shouye/index.vue | 259 +++++++++++-------
9 files changed, 1009 insertions(+), 330 deletions(-)
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 52fb418..0a8a705 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -20,10 +20,10 @@ const install = (Vue, vm) => {
// },
// });
Vue.prototype.$u.http.setConfig({
- baseUrl: 'http://192.168.2.143:10002',
- // baseUrl: 'https://kg.chuangtewl.com/prod-api',
- loadingText: '努力加载中~',
- loadingTime: 1000,
+ // baseUrl: 'http://192.168.2.143:10002',
+ baseUrl: 'https://kg.chuangtewl.com/prod-api',
+ // loadingText: '努力加载中~',
+ // loadingTime: 1000,
// 设置自定义头部content-type
header: {
'content-type': 'application/json;charset=UTF-8',
diff --git a/page_components/bindsz.vue b/page_components/bindsz.vue
index 7036974..085ba1a 100644
--- a/page_components/bindsz.vue
+++ b/page_components/bindsz.vue
@@ -6,15 +6,16 @@
-
-
+
+
@@ -183,6 +184,42 @@
+
+
+
+
+ 正在连接该设备蓝牙
+
+
+ 请将手机与设备尽量靠近
+
+
+
+
+
+
+
+
+
+ 蓝牙连接失败
+
+
+ 请确保手机足够靠近设备
+
+
+ 并且设备处于上电状态
+
+
+
+ 取消
+
+
+ 重新连接
+
+
+
@@ -192,6 +229,8 @@
export default {
data() {
return {
+ bluetoothflag:false,
+ shibaiflag:false,
bgc: {
backgroundColor: "#8883f0",
},
@@ -274,6 +313,10 @@
}
},
methods: {
+ btnlyqx(){
+ this.shibaiflag = false
+ this.bluetoothflag = false
+ },
// 修改图片
getImage(e) {
let _this = this
@@ -355,127 +398,132 @@
},
// 点击wifi进行配网
btnwifi(){
- uni.showLoading({
- title: '蓝牙连接中...'
- })
- if(this.deviceId == ''){
- 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);
- }
- let data = {
- storeId: this.storeId,
- mac: this.mac
- }
- this.$u.put('/app/device/bind', data).then((res) => {
- if (res.code == 200) {
- // uni.showToast({
- // title: '绑定成功',
- // icon: 'success',
- // duration: 2000
- // })
- uni.hideLoading();
- uni.removeStorageSync('mac');
- let systemInfo = uni.getSystemInfoSync();
- if (systemInfo.platform == 'android') {
- uni.hideLoading()
- // 当前设备是 Android
- uni.navigateTo({
- url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
- })
- } else if (systemInfo.platform == 'ios') {
- uni.hideLoading()
- // 当前设备是 iOS
- uni.navigateTo({
- url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
- })
- }
- }else if(res.msg == '设备编号和mac不能同时为空'){
- uni.hideLoading()
- uni.showToast({
- title: '未连接到设备,请查看蓝牙是否打开以及在设备范围内',
- icon: 'none',
- duration: 2000
- });
- } else {
- uni.hideLoading()
- uni.showToast({
- title: res.msg,
- icon: 'none',
- duration: 2000
- });
- // uni.navigateBack()
- }
- })
- }, 1000)
- }else{
- let name = ''
- let index = this.name.indexOf('-');
- if (index !== -1) {
- name = this.name.slice(index + 1);
- }
- let data = {
- storeId: this.storeId,
- mac: this.mac
- }
- this.$u.put('/app/device/bind', data).then((res) => {
- if (res.code == 200) {
- uni.showToast({
- title: '绑定成功',
- icon: 'none',
- duration: 2000
+ this.shibaiflag = false
+ this.bluetoothflag = true
+ // console.log(this.deviceId,'idididididdidii');
+ if(this.setMode == null){
+ xBlufi.initXBlufi(1)
+ xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': true
})
- uni.hideLoading();
- uni.removeStorageSync('mac');
- let systemInfo = uni.getSystemInfoSync();
- if (systemInfo.platform == 'android') {
- // 当前设备是 Android
- uni.navigateTo({
- url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
+
+ // 停止蓝牙搜索
+ setTimeout(() => {
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': false
})
- } else if (systemInfo.platform == 'ios') {
- // 当前设备是 iOS
- uni.navigateTo({
- url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
+ 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);
+ }
+ let data = {
+ storeId: this.storeId,
+ mac: this.mac
+ }
+ this.$u.put('/app/device/bind', data).then((res) => {
+ if (res.code == 200) {
+ uni.hideLoading();
+ this.shibaiflag = false
+ this.bluetoothflag = false
+ uni.removeStorageSync('mac');
+ let systemInfo = uni.getSystemInfoSync();
+ if (systemInfo.platform == 'android') {
+ // 当前设备是 Android
+ uni.navigateTo({
+ url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
+ })
+ } else if (systemInfo.platform == 'ios') {
+ // 当前设备是 iOS
+ uni.navigateTo({
+ url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
+ })
+ }
+ }else if(res.msg == '设备编号和mac不能同时为空'){
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ // uni.showToast({
+ // title: '连接失败',
+ // icon: 'none',
+ // duration: 2000
+ // });
+ } else {
+ // uni.showToast({
+ // title: res.msg,
+ // icon: 'none',
+ // duration: 2000
+ // });
+ // uni.navigateBack()
+ }
+ })
+ }, 1000)
+ }else{
+ let name = ''
+ let index = this.name.indexOf('-');
+ if (index !== -1) {
+ name = this.name.slice(index + 1);
}
- }else if(res.msg == '设备编号和mac不能同时为空'){
- uni.showToast({
- title: '未连接到设备,请查看蓝牙是否打开以及在设备范围内',
- icon: 'none',
- duration: 2000
- });
- } else {
- uni.showToast({
- title:res.msg,
- icon: 'none',
- duration: 2000
- });
+ let data = {
+ storeId: this.storeId,
+ mac: this.mac
+ }
+ this.$u.put('/app/device/bind', data).then((res) => {
+ if (res.code == 200) {
+ // uni.showToast({
+ // title: '绑定成功',
+ // icon: 'none',
+ // duration: 2000
+ // })
+ this.shibaiflag = false
+ this.bluetoothflag = false
+ uni.hideLoading();
+ uni.removeStorageSync('mac');
+ let systemInfo = uni.getSystemInfoSync();
+ if (systemInfo.platform == 'android') {
+ // 当前设备是 Android
+ uni.navigateTo({
+ url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
+ })
+ } else if (systemInfo.platform == 'ios') {
+ // 当前设备是 iOS
+ uni.navigateTo({
+ url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
+ })
+ }
+ }else {
+ if(res.msg == '设备编号和mac不能同时为空'){
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ uni.hideLoading()
+ // uni.showToast({
+ // title: '连接失败',
+ // icon: 'none',
+ // duration: 2000
+ // })
+ } else {
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ uni.hideLoading()
+ uni.showToast({
+ title:res.msg,
+ icon: 'none',
+ duration: 2000
+ })
+ // uni.navigateBack()
+ }
+ }
+ })
}
- })
- }
- },
+ },
sremakes() {
if(this.wateringList.length == 0){
@@ -722,31 +770,31 @@
// console.log("文件读取中", options.data);
break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
-
let ver_data = this.parseCustomData(options.data)
this.setMode = Math.floor(ver_data.setMode / 60)
- console.log("1收到设备发来的自定义数据结果:", ver_data,this.setMode);
+ console.log("1收到设备发来的自定义数据结果:", ver_data,this.setMode)
break;
-
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
let devicesarr = options.data
// console.log(devicesarr,'devicesarrdevicesarr');
devicesarr.forEach(device => {
- const mac = device.name.substring(5);
+ const mac = device.name.substring(5)
if (device.name == this.qrResult) {
this.deviceId = device.deviceId
this.name = device.name
this.mac = device.name.slice(5, 17)
- console.log(this.mac, 'macmacmac');
+ // console.log(this.mac, 'macmacmac');
+ // this.devicesList = uniqueDevicesList;
}
})
}
- break;
-
+ break;
+
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
// console.log("连接回调:" + JSON.stringify(options));
if (options.result) {
+ this.bluetoothflag = false
uni.hideLoading();
// uni.showToast({
// title: '连接成功',
@@ -757,18 +805,24 @@
"连接回调options.data.name:" + options.data.name);
}
} else {
- // uni.hideLoading()
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ uni.hideLoading()
// uni.showToast({
// title: '设备离线或不在范围内',
// icon: 'none',
// duration: 2000
// })
}
-
+
break;
-
+
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
+ setTimeout(()=>{
+ uni.hideLoading()
+ this.bluetoothflag = false
+ },3000)
console.log("蓝牙未开启", options);
// uni.showToast({
// title: '蓝牙未开启',
@@ -783,13 +837,13 @@
// searching: true
// });
}
-
+
break;
-
+
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
if (options.result) {
let uniqueDevicesList = Array.from(new Set(this.devicesList));
-
+
// 将去重后的数组重新赋值给 this.devicesList
this.devicesList = uniqueDevicesList;
let list = []
@@ -800,23 +854,27 @@
if (res.data == false) {
list.push(device)
} else {
-
+
}
})
-
+
});
setTimeout(() => {
this.devicesList = list
}, 200)
-
+
console.log('蓝牙停止搜索ok');
} else {
//蓝牙停止搜索失败
console.log('蓝牙停止搜索失败');
}
-
+ this.searching = false
+ // _this.setData({
+ // searching: false
+ // });
+
break;
-
+
}
},
parseCustomData(data) {
@@ -852,6 +910,86 @@
/deep/ .u-icon__icon{
padding-bottom: 22rpx;
}
+ .bluetoothbox{
+ width: 100%;
+ height: 100vh;
+ background-color: #f4f1f6;
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 99;
+ text-align: center;
+ .img{
+ margin-top: 400rpx;
+ width: 320rpx;
+ height: 320rpx;
+ }
+ .one{
+ font-size: 36rpx;
+ color: #000;
+ // margin-top: 80rpx;
+ }
+ .two{
+ margin-top: 30rpx;
+ font-size: 24rpx;
+ color: #ccc;
+ }
+ .thr{
+ margin-top: 30rpx;
+ font-size: 28rpx;
+ color: #ccc;
+ }
+ .anfour{
+ display: flex;
+ margin-top: 30rpx;
+ justify-content: space-between;
+ padding: 0 220rpx;
+ box-sizing: border-box;
+ .qx{
+ width: 100rpx;
+ height: 70rpx;
+ line-height: 70rpx;
+ text-align: center;
+ border: 1px solid #3D3D3D;
+ border-radius: 10rpx;
+ }
+ .cx{
+ width: 200rpx;
+ height: 70rpx;
+ line-height: 70rpx;
+ text-align: center;
+ background-color: #8883F0;
+ color: #fff;
+ border-radius: 10rpx;
+ }
+ }
+ .stop{
+ font-size: 36rpx;
+ color: #000;
+ margin-top: 380rpx;
+ }
+ .xtop{
+ margin-top: 30rpx;
+ font-size: 24rpx;
+ color: #ccc;
+ }
+ .xqx{
+ width: 530rpx;
+ height: 90rpx;
+ line-height: 90rpx;
+ // border: 1px solid #808080;
+ border-radius: 20rpx;
+ text-align: center;
+ background-color: #fff;
+ margin: auto;
+ margin-top: 200rpx;
+ }
+ image{
+ width: 500rpx;
+ height: 500rpx;
+ margin-top: 100rpx;
+ }
+ }
page {
background-color: #F7FAFE;
}
@@ -1064,6 +1202,7 @@
// flex-wrap: wrap;
// align-items: center;
margin-top: 40rpx;
+ margin-bottom: 30rpx;
.imgbox {
// width: 33%;
image {
diff --git a/page_components/wentdetail.vue b/page_components/wentdetail.vue
index 8fa35a5..7b57b85 100644
--- a/page_components/wentdetail.vue
+++ b/page_components/wentdetail.vue
@@ -1,6 +1,6 @@
-
@@ -18,7 +18,8 @@
data() {
return {
type:'',
- listobj:{}
+ listobj:{},
+ tit:''
}
},
onLoad(option) {
@@ -47,6 +48,7 @@
this.$u.get(`/app/article/licence/${this.type}`).then((res) => {
if (res.code == 200) {
this.listobj = res.data
+ this.tit = res.data.title
}
})
},
diff --git a/page_components/wifilist/index.vue b/page_components/wifilist/index.vue
index a18cec4..93a9181 100644
--- a/page_components/wifilist/index.vue
+++ b/page_components/wifilist/index.vue
@@ -22,22 +22,22 @@
@@ -54,11 +54,88 @@
- 手动输入WiFi
- 下一步
+ 手动添加其他网络
+
+
+
+
+
+
+
+ 连接网络
+
+
+ {{ssid}}
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+ {{textwifi}}
+
+
+
+
+
+
+
+
+
+ 手动添加
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+ {{ textwifi }}
+
+
+
+
+
+
+
+
+ 发现网络失败
+
+
+ 请确保你的设备处于局域网范围内
+
+
+
+ 手动添加
+
+
+ 重新发现
+
+
+
+
@@ -72,6 +149,10 @@
// },nin
data() {
return {
+ passmm:false,
+ password:'',
+ sdmaskflag:false,
+ maskflag:false,
options: {},
optionsobj: {},
version: '2.0',
@@ -86,10 +167,7 @@
wifiList: "",
item: '',
textwb: '重新扫描',
- list: [{
- BSSID: '',
- SSID: ''
- }],
+ list: [],
picflag: false,
indexs: -1,
wififlag: true, //wifi列表flag
@@ -100,6 +178,7 @@
bgc: {
backgroundColor: "#8883f0",
},
+ textwifi:'连接'
};
},
@@ -190,18 +269,18 @@
});
// 去重
for (var i = 0; i < that.wifiList.length; i++) {
- for (var j = i + 1; j < that.wifiList
- .length; j++) {
- if (that.wifiList[i].SSID == that.wifiList[j]
- .SSID) {
+ for (var j = i + 1; j < that.wifiList.length; j++) {
+ if (that.wifiList[i].SSID == that.wifiList[j].SSID) {
that.wifiList.splice(j, 1);
j--
}
}
}
that.signalStrengthflag = true
- that.list = that.wifiList
- console.log(that.list, '1010'); //在这里提取列表数据
+ that.list = that.wifiList.filter(item => {
+ return item.SSID !== ''
+ })
+ // console.log(that.list, '1010'); //在这里提取列表数据
});
},
fail: function(err) {
@@ -289,8 +368,9 @@
// 点击判断索引是否相同显示图片
btnqhwifi(index, item) {
- this.indexs = index
+ // this.indexs = index
this.ssid = item.SSID
+ this.maskflag = true
},
// 点击进行下一步
btnxyb() {
@@ -309,16 +389,17 @@
}
},
btnsd() {
+ this.sdmaskflag = true
this.ssid = ''
- uni.navigateTo({
- url: '/page_user/wifijoint/index?objlist=' + JSON.stringify(this.objlist) + '&ssid=' + JSON.stringify(this.ssid)
- })
+ // uni.navigateTo({
+ // url: '/page_user/wifijoint/index?objlist=' + JSON.stringify(this.objlist) + '&ssid=' + JSON.stringify(this.ssid)
+ // })
},
// 点击连接操作
content_wf() {
- if (!this.name) {
+ if (!this.ssid) {
uni.showToast({
title: 'SSID不能为空',
icon: 'none'
@@ -332,12 +413,13 @@
});
return;
}
- uni.showLoading({
- title: '正在配网',
- mask: true
- })
+ // uni.showLoading({
+ // title: '正在配网',
+ // mask: true
+ // })
+ this.textwifi = '连接中...'
xBlufi.notifySendCustomData({
- customData: "ssid@" + this.name + "pass@" + this.password
+ customData: "ssid@" + this.ssid + "pass@" + this.password
})
// xBlufi.notifySendCustomData({
// customData: "ssid@" + this.name
@@ -355,31 +437,33 @@
funListenDeviceMsgEvent: function(options) {
let that = this;
switch (options.type) {
- case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
- console.log('状态', options.result)
- uni.showModal({
- title: '很抱歉提醒你!',
- content: '蓝牙异常断开,请重新连接…',
- showCancel: false,
- success: function(res) {
- uni.navigateTo({
- url:'/pages/index/index'
- })
- }
- });
- this.statusflag = false
- uni.hideLoading();
- }
- break;
+ // case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
+ // console.log('状态', options.result)
+ // this.textwifi = '连接'
+ // uni.showModal({
+ // title: '很抱歉提醒你!',
+ // content: '蓝牙异常断开,请重新连接…',
+ // showCancel: false,
+ // success: function(res) {
+ // uni.switchTab({
+ // url:'/pages/index/index'
+ // })
+ // }
+ // });
+ // this.statusflag = false
+ // uni.hideLoading();
+ // }
+ // break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT:
uni.hideLoading();
if (!options.result)
+ this.textwifi = '连接',
this.statusflag = false,
uni.hideLoading(),
uni.showModal({
title: '温馨提示',
- content: '配网失败,请重试',
+ content: '配网失败,请选择2.4GWiFi连接并确保密码正确',
showCancel: false //是否显示取消按钮
});
else {
@@ -387,6 +471,7 @@
let ssid = options.data.ssid;
this.statusflag = false
uni.hideLoading();
+ this.textwifi = '连接'
uni.showModal({
title: '温馨提示',
content: `连接成功`,
@@ -430,13 +515,13 @@
console.log('初始化失败');
uni.showModal({
title: '温馨提示',
- content: `设备初始化失败`,
+ content: `设备初始化失败,请重新连接`,
showCancel: false,
//是否显示取消按钮
success: function(res) {
- // uni.redirectTo({
- // url: '../search/search'
- // });
+ uni.switchTab({
+ url:'/pages/index/index'
+ })
}
});
}
@@ -476,10 +561,101 @@