This commit is contained in:
3321822538@qq.com 2024-10-18 17:59:38 +08:00
parent 8dc30f5c4d
commit 40f03b2215
21 changed files with 617 additions and 76 deletions

View File

@ -87,6 +87,22 @@
minutekq:'--'
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -49,6 +49,22 @@
},
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -68,6 +68,22 @@
flag:false
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -19,6 +19,22 @@
flag:false
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -3,9 +3,51 @@
<u-navbar :is-back="true" title='添加设备' title-color="#000" :border-bottom="false" :background="bgc"
id="navbar">
</u-navbar>
<button @click="btnkq">开启</button>
<view class="" style="width: 100%;height: 50rpx;"></view>
<button @click="btngb">关闭</button>
<!-- 有搜索到设备 -->
<view class="you" v-if="flags">
<view class="topone">
<image src="https://api.ccttiot.com/smartmeter/img/static/ubrPcpGQEXTadkBa1gKh" mode=""></image> 扫描到以下设备点击添加
</view>
<view class="toptwo">
如未找到想添加的设备点击重新搜索
</view>
<view class="list">
<view class="list_item" v-for="(item,index) in devicesList" :key="index">
<image src="https://api.ccttiot.com/smartmeter/img/static/ufPWKlVzDbHNflX0jUIv" mode=""></image>
<view class="cen">
<view class="name">
丁丁浇花器
</view>
<view class="devmac">
MAC{{item.name}}
</view>
</view>
<view class="add">
添加
</view>
</view>
</view>
</view>
<!-- 未搜索到设备 -->
<view class="wei" v-else>
<image src="https://api.ccttiot.com/smartmeter/img/static/uQ4g6A27FGtF34ebOtea" mode=""></image>
<view class="sbname">
搜索附近的设备失败
</view>
<view class="sbwz">
搜索失败点击重新搜索注意打开蓝牙
</view>
</view>
<!-- 点击搜索 -->
<view class="btnss" @click="btnss" v-if="flag">
重新搜索
</view>
<view class="btnss" v-else>
重新搜索
</view>
</view>
</template>
@ -19,11 +61,28 @@
backgroundColor: "#fff",
},
active:1,
flag:false,
flag:true,
devicesList:[],
deviceId:'',
name:'',
mac:'2952BB7A4EE0',
flags:true
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
@ -47,52 +106,35 @@
}, 2000)
},
methods:{
btnkq(){
let that = this
uni.getNetworkType({
success(res) {
if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({
success(res) {
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData: '11open'
})
},1500)
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
} else {
console.log('手机未连接网络')
}
}
})
},
btngb(){
let that = this
uni.getNetworkType({
success(res) {
if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({
success(res) {
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData: '11close'
})
},1500)
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
} else {
console.log('手机未连接网络')
}
}
})
},
btnss(){
uni.showLoading({
title: '搜索中...'
})
this.flag = false
let that = this
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({
'isStart': false
})
if (that.devicesList.length > 0) {
that.flags = true
xBlufi.notifyConnectBle({
isStart: true,
deviceId: that.deviceId,
name: that.name
})
}else{
that.flags = false
}
uni.hideLoading()
that.flag = true
}, 2000)
},
//
@ -117,18 +159,19 @@
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
let devicesarr = options.data
this.devicesList = devicesarr
console.log(devicesarr,'111');
devicesarr.forEach(device => {
const mac = device.name.substring(4);
if (device.name.slice(5, 17) == this.mac) {
this.deviceId = device.deviceId
this.name = device.name
console.log(device.name,this.mac,'222');
this.devicesList.push(device);
let uniqueDevicesList = Array.from(new Set(this.devicesList));
this.devicesList = uniqueDevicesList;
}
})
// devicesarr.forEach(device => {
// const mac = device.name.substring(4);
// if (device.name.slice(5, 17) == this.mac) {
// this.deviceId = device.deviceId
// this.name = device.name
// console.log(device.name,this.mac,'222');
// this.devicesList.push(device);
// let uniqueDevicesList = Array.from(new Set(this.devicesList));
// this.devicesList = uniqueDevicesList;
// }
// })
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
@ -163,7 +206,8 @@
title: '蓝牙未开启',
icon: 'none',
duration: 3000
});
})
this.flags = false
return
} else {
@ -202,12 +246,111 @@
/deep/ .uicon-nav-back{
margin-bottom: 22rpx;
}
.wei{
text-align: center;
image{
width: 380rpx;
height: 394rpx;
}
.sbname{
font-size: 40rpx;
color: #3D3D3D;
margin-top: 80rpx;
width: 100%;
text-align: center;
}
.sbwz{
font-size: 28rpx;
color: #737B80;
margin-top: 24rpx;
width: 100%;
text-align: center;
}
}
.btnss{
width: 512rpx;
height: 92rpx;
background: #48893B;
border-radius: 46rpx 46rpx 46rpx 46rpx;
border-radius: 50rpx;
text-align: center;
line-height: 92rpx;
font-weight: 600;
font-size: 40rpx;
color: #FFFFFF;
position: fixed;
left: 50%;
transform: translateX(-50%);
bottom: 106rpx;
}
.list{
width: 100%;
border-radius: 20rpx;
margin: auto;
margin-top: 72rpx;
.list_item{
margin-top: 18rpx;
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 152rpx;
background: #FFFFFF;
border-radius: 20rpx;
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0,0,0,0.08);
padding: 18rpx 30rpx;
box-sizing: border-box;
image{
width: 96rpx;
height: 94rpx;
}
.cen{
.name{
font-size: 32rpx;
color: #50565A;
}
.devmac{
font-size: 24rpx;
color: #BDBCBC;
margin-top: 6rpx;
}
}
.add{
width: 108rpx;
height: 60rpx;
background: #FFFFFF;
border: 3rpx solid #48893B;
filter: blur(0px);
border-radius: 20rpx;
text-align: center;
line-height: 60rpx;
font-size: 28rpx;
color: #48893B;
}
}
}
page{
width: 100%;
padding: 20rpx 30rpx;
padding: 20rpx 64rpx;
box-sizing: border-box;
background-color: #fff;
}
.topone{
font-size: 36rpx;
color: #3D3D3D;
display: flex;
image{
width: 48rpx;
height: 48rpx;
}
}
.toptwo{
font-size: 28rpx;
color: #737B7F;
margin-top: 14rpx;
width: 100%;
padding-left: 48rpx;
box-sizing: border-box;
}
</style>

View File

@ -90,6 +90,22 @@
},
computed: {
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {

View File

@ -46,6 +46,22 @@
maskpic: ''
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
this.gettiken()
this.getinfo()

View File

@ -38,6 +38,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad(option) {
this.cartpic = JSON.parse(option.cart)
this.zwlist = JSON.parse(option.list)

View File

@ -69,6 +69,22 @@
list:[]
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad(option) {
this.plantId = option.plantId
this.getxq()

View File

@ -94,6 +94,22 @@
}],
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -18,6 +18,22 @@
tit:''
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad(option) {
this.tit = option.tit
},

View File

@ -81,7 +81,7 @@
<view class="switch_he">
<image src="https://api.ccttiot.com/smartmeter/img/static/u7NwkNOoQYYsvHVMkDlu" mode=""></image>
<view class="yushui">
雨水感应 <u-switch v-model="yschecked" active-color="#7FAD76" size="40"></u-switch>
雨水感应 <u-switch v-model="yschecked" @change="btnyushui" active-color="#7FAD76" size="40"></u-switch>
</view>
</view>
<view class="switch_he">
@ -203,6 +203,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
let that = this
xBlufi.initXBlufi(1);
@ -222,11 +238,66 @@
})
}
}, 2000)
},
onShow() {
},
mounted() {
},
methods: {
//
btnyushui(){
let that = this
if(that.yschecked == true){
uni.getNetworkType({
success(res) {
if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({
success(res) {
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData:'qlose'
})
that.yschecked = false
},1500)
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
} else {
console.log('手机未连接网络')
}
}
})
}else{
console.log(11);
let that = this
uni.getNetworkType({
success(res) {
if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({
success(res) {
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData:'qpen'
})
that.yschecked = true
},1500)
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
} else {
console.log('手机未连接网络')
}
}
})
}
},
//
btnaddsb(){
uni.navigateTo({
@ -260,8 +331,6 @@
duration: 3000
})
}else{
this.sdjsflag = false
this.kgflag = true
let that = this
uni.getNetworkType({
success(res) {
@ -272,6 +341,8 @@
xBlufi.notifySendCustomData({
customData: "11time@" + that.jstime
})
that.sdjsflag = false
that.kgflag = true
},1500)
},
fail(err) {
@ -286,10 +357,30 @@
}
},
//
//
btnkq() {
this.kgflag = false
let that = this
uni.getNetworkType({
success(res) {
if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({
success(res) {
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData: "11close"
})
that.kgflag = false
},1500)
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
}
}
})
},
//
btngb() {
this.sdjsflag = true
},
@ -327,9 +418,6 @@
funListenDeviceMsgEvent: function(options) {
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
// that.setData({
// connected: options.result
// })
if (!options.result) {
uni.showModal({
title: '很抱歉提醒你!',
@ -337,7 +425,8 @@
showCancel: false,
//
success: function(res) {
uni.hideLoading()
uni.removeStorage({key:'device_key'})
}
})
}
@ -351,7 +440,7 @@
if (device.name.slice(5, 17) == this.mac) {
this.deviceId = device.deviceId
this.name = device.name
console.log(device.name,this.mac,'222');
// console.log(device.name,this.mac,'222');
this.devicesList.push(device);
let uniqueDevicesList = Array.from(new Set(this.devicesList));
this.devicesList = uniqueDevicesList;
@ -361,6 +450,7 @@
break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
console.log("连接回调:" + JSON.stringify(options));
uni.setStorageSync('device_key', 'true')
if (options.result) {
{
xBlufi.notifyInitBleEsp32({
@ -375,7 +465,7 @@
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);
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
if (options.result) {
@ -911,4 +1001,5 @@
}
}
}
</style>

View File

@ -57,6 +57,22 @@
mobileCode:''
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -19,6 +19,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -73,6 +73,22 @@
timer: null
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -78,6 +78,22 @@
timer: null
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -68,6 +68,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
this.getinfo()
this.gettiken()
@ -105,7 +121,10 @@
success: (res) => {
that.imageSrc = that.picdomain + '/' + JSON.parse(res.data).key
console.log(that.imageSrc);
that.$u.get(`/app/avatar?img=${that.imageSrc}`).then(res => {
let data = {
img:that.imageSrc
}
that.$u.get(`/appVerify/avatar?img=${that.imageSrc}`,data).then(res => {
})
}

View File

@ -39,6 +39,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -85,6 +85,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},

View File

@ -52,6 +52,22 @@
},
onLoad() {
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
methods: {
mapFun() {

View File

@ -15,6 +15,22 @@
}
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
onLoad() {
},