浇花器
This commit is contained in:
parent
3570f4d736
commit
08a9c27934
|
@ -21,7 +21,7 @@ const install = (Vue, vm) => {
|
||||||
// });
|
// });
|
||||||
Vue.prototype.$u.http.setConfig({
|
Vue.prototype.$u.http.setConfig({
|
||||||
baseUrl: 'https://yxd.ccttiot.com/prod-api',
|
baseUrl: 'https://yxd.ccttiot.com/prod-api',
|
||||||
// baseUrl: 'http://192.168.0.107:8081',
|
// baseUrl: 'http://192.168.0.101:8081',
|
||||||
loadingText: '努力加载中~',
|
loadingText: '努力加载中~',
|
||||||
loadingTime: 800,
|
loadingTime: 800,
|
||||||
// 设置自定义头部content-type
|
// 设置自定义头部content-type
|
||||||
|
|
|
@ -1,30 +1,37 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<u-navbar :is-back="true" title='添加设备' title-color="#000" :border-bottom="false" :background="bgc"
|
<u-navbar :is-back="true" title='添加设备' title-color="#000" :border-bottom="false" :background="bgc" id="navbar">
|
||||||
id="navbar">
|
|
||||||
</u-navbar>
|
</u-navbar>
|
||||||
|
<view class="page">
|
||||||
<!-- 有搜索到设备 -->
|
<!-- 有搜索到设备 -->
|
||||||
<view class="you" v-if="flags">
|
<view class="you" v-if="flags">
|
||||||
<view class="topone">
|
<view class="topone">
|
||||||
<image src="https://api.ccttiot.com/smartmeter/img/static/ubrPcpGQEXTadkBa1gKh" mode=""></image> 扫描到以下设备,点击添加!
|
<image src="https://api.ccttiot.com/smartmeter/img/static/ubrPcpGQEXTadkBa1gKh" mode=""></image>
|
||||||
|
扫描到以下设备,点击添加!
|
||||||
</view>
|
</view>
|
||||||
<view class="toptwo">
|
<view class="toptwo">
|
||||||
如未找到想添加的设备,点击重新搜索
|
如未找到想添加的设备,点击重新搜索
|
||||||
</view>
|
</view>
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="list_item" v-for="(item,index) in jiaohuaqi" :key="index">
|
<view class="list_item" v-for="(item,index) in jiaohuaqi" :key="index">
|
||||||
<image src="https://api.ccttiot.com/smartmeter/img/static/ufPWKlVzDbHNflX0jUIv" mode=""></image>
|
<image :src="item.modelPicture" mode=""></image>
|
||||||
<view class="cen">
|
<view class="cen">
|
||||||
<view class="name">
|
<view class="name" style="color: #ccc;" v-if="item.userId && item.userId != userid">
|
||||||
丁丁浇花器
|
{{item.modelName == undefined ? '' : item.modelName}}
|
||||||
|
</view>
|
||||||
|
<view class="name" v-else>
|
||||||
|
{{item.modelName == undefined ? '' : item.modelName}}
|
||||||
</view>
|
</view>
|
||||||
<view class="devmac">
|
<view class="devmac">
|
||||||
MAC:{{item}}
|
MAC:{{item.mac == undefined ? item.name.slice(-12) : item.mac}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="add" @click="btnadd(item)">
|
<view class="add" @click="btnadd(item)" v-if="item.userId == undefined">
|
||||||
添加
|
添加
|
||||||
</view>
|
</view>
|
||||||
|
<view class="add" style="color: #ccc;border: 1px solid #ccc;" v-else>
|
||||||
|
已添加
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -47,6 +54,7 @@
|
||||||
<view class="btnss" v-else>
|
<view class="btnss" v-else>
|
||||||
重新搜索
|
重新搜索
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
@ -68,7 +76,8 @@
|
||||||
flags: true,
|
flags: true,
|
||||||
userid: '',
|
userid: '',
|
||||||
arr: '',
|
arr: '',
|
||||||
jiaohuaqi:[]
|
jiaohuaqi: [],
|
||||||
|
getpre:[]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 分享到好友(会话)
|
// 分享到好友(会话)
|
||||||
|
@ -91,6 +100,7 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
this.getmodel()
|
||||||
this.getinfo()
|
this.getinfo()
|
||||||
this.btnss()
|
this.btnss()
|
||||||
},
|
},
|
||||||
|
@ -146,44 +156,74 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getmodel() {
|
||||||
|
this.$u.get(`/app/getAllModelList`).then(res => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.getpre = res.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getpipei(pre) {
|
||||||
|
// 添加默认返回值防止undefined
|
||||||
|
return this.getpre.find(item => item.pre == pre) || {
|
||||||
|
modelName: '未知型号',
|
||||||
|
picture: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
btnss() {
|
btnss() {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '搜索中...'
|
title: '搜索中...',
|
||||||
})
|
mask: true
|
||||||
this.jiaohuaqi = []
|
});
|
||||||
this.flag = false
|
|
||||||
let that = this
|
this.jiaohuaqi = [];
|
||||||
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
|
this.flag = false;
|
||||||
xBlufi.notifyStartDiscoverBle({
|
const that = this;
|
||||||
'isStart': true
|
|
||||||
})
|
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
|
||||||
|
xBlufi.notifyStartDiscoverBle({ 'isStart': true });
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({ 'isStart': false });
|
||||||
'isStart': false
|
|
||||||
})
|
|
||||||
if (that.devicesList.length > 0) {
|
if (that.devicesList.length > 0) {
|
||||||
// that.flags = true
|
const data = { mac: that.arr };
|
||||||
this.$u.get(`/app/device/isBand/${this.arr}`).then(res =>{
|
|
||||||
|
this.$u.post(`/app/getExistListByMacs`, data).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
res.data.forEach(item =>{
|
// 创建MAC地址映射表
|
||||||
if(item.isBand == false){
|
const macMap = new Map(res.data.map(item => [item.mac, item]));
|
||||||
|
|
||||||
that.devicesList.forEach(val => {
|
that.devicesList.forEach(val => {
|
||||||
if(val.name.slice(-12) == item.mac){
|
const mac = val.name.slice(-12);
|
||||||
that.jiaohuaqi.push(val.name)
|
if (macMap.has(mac)) {
|
||||||
console.log(that.jiaohuaqi);
|
that.jiaohuaqi.push(macMap.get(mac));
|
||||||
}
|
console.log(that.jiaohuaqi,'1111');
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
// that.flags = false
|
const pre = val.name.slice(0, 5);
|
||||||
|
const matched = that.getpipei(pre);
|
||||||
|
that.jiaohuaqi.push({
|
||||||
|
name: mac,
|
||||||
|
modelName: matched.modelName,
|
||||||
|
modelPicture: matched.picture
|
||||||
|
});
|
||||||
|
console.log(that.jiaohuaqi,'2222');
|
||||||
}
|
}
|
||||||
uni.hideLoading()
|
});
|
||||||
that.flag = true
|
|
||||||
}, 3000)
|
uni.hideLoading();
|
||||||
|
} else {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
that.flag = true;
|
||||||
|
}, 3000);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取附近蓝牙设备列表
|
// 获取附近蓝牙设备列表
|
||||||
|
@ -244,15 +284,24 @@
|
||||||
/deep/ .u-title {
|
/deep/ .u-title {
|
||||||
margin-bottom: 22rpx;
|
margin-bottom: 22rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .uicon-nav-back {
|
/deep/ .uicon-nav-back {
|
||||||
margin-bottom: 22rpx;
|
margin-bottom: 22rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page {
|
||||||
|
padding-bottom: 300rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
.wei {
|
.wei {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 380rpx;
|
width: 380rpx;
|
||||||
height: 394rpx;
|
height: 394rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sbname {
|
.sbname {
|
||||||
font-size: 40rpx;
|
font-size: 40rpx;
|
||||||
color: #3D3D3D;
|
color: #3D3D3D;
|
||||||
|
@ -260,6 +309,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sbwz {
|
.sbwz {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #737B80;
|
color: #737B80;
|
||||||
|
@ -268,6 +318,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.btnss {
|
.btnss {
|
||||||
width: 512rpx;
|
width: 512rpx;
|
||||||
height: 92rpx;
|
height: 92rpx;
|
||||||
|
@ -284,11 +335,13 @@
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
bottom: 106rpx;
|
bottom: 106rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list {
|
.list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
margin-top: 72rpx;
|
margin-top: 72rpx;
|
||||||
|
|
||||||
.list_item {
|
.list_item {
|
||||||
margin-top: 18rpx;
|
margin-top: 18rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -301,21 +354,25 @@
|
||||||
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08);
|
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08);
|
||||||
padding: 18rpx 30rpx;
|
padding: 18rpx 30rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 96rpx;
|
width: 94rpx;
|
||||||
height: 94rpx;
|
height: 94rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cen {
|
.cen {
|
||||||
.name {
|
.name {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #50565A;
|
color: #50565A;
|
||||||
}
|
}
|
||||||
|
|
||||||
.devmac {
|
.devmac {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #BDBCBC;
|
color: #BDBCBC;
|
||||||
margin-top: 6rpx;
|
margin-top: 6rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.add {
|
.add {
|
||||||
width: 108rpx;
|
width: 108rpx;
|
||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
|
@ -330,21 +387,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
page {
|
page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20rpx 64rpx;
|
padding: 20rpx 64rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topone {
|
.topone {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #3D3D3D;
|
color: #3D3D3D;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 48rpx;
|
width: 48rpx;
|
||||||
height: 48rpx;
|
height: 48rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.toptwo {
|
.toptwo {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #737B7F;
|
color: #737B7F;
|
||||||
|
@ -353,5 +414,4 @@
|
||||||
padding-left: 48rpx;
|
padding-left: 48rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -25,8 +25,9 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="wifi" style="margin-top: 24rpx;" @click="gjconfirm" >
|
<view class="wifi" style="margin-top: 24rpx;" @click="gjconfirm" >
|
||||||
<view class="">固件更新</view>
|
<view class="">固件更新</view>
|
||||||
<view class="flex">
|
<view class="flex" style="color: red;font-size: 20rpx;" v-if=" ver != null && ver != version">
|
||||||
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uiTIUYnR3ClrmqOTyF8F" mode=""></image> -->
|
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uiTIUYnR3ClrmqOTyF8F" mode=""></image> -->
|
||||||
|
<text style="display: inline-block;width: 10rpx;height: 10rpx;border-radius: 50%;background-color: red;margin-right: 10rpx;"></text>可更新
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 息屏选择器 -->
|
<!-- 息屏选择器 -->
|
||||||
|
@ -72,7 +73,6 @@
|
||||||
切记在蓝牙范围内,以防升级失败
|
切记在蓝牙范围内,以防升级失败
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@
|
||||||
xpshow: false,
|
xpshow: false,
|
||||||
gjshow: false,
|
gjshow: false,
|
||||||
xptxt: '',
|
xptxt: '',
|
||||||
gjtxt: 'v2.1.2',
|
|
||||||
nameflag: false,
|
nameflag: false,
|
||||||
xplist: [{
|
xplist: [{
|
||||||
value: '1',
|
value: '1',
|
||||||
|
@ -119,7 +118,8 @@
|
||||||
intervalId: null,
|
intervalId: null,
|
||||||
progress:0,
|
progress:0,
|
||||||
shengjiflag:false,
|
shengjiflag:false,
|
||||||
xctime:'--'
|
xctime:'--',
|
||||||
|
version:''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 分享到好友(会话)
|
// 分享到好友(会话)
|
||||||
|
@ -140,16 +140,18 @@
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
this.deviceid = option.deviceid
|
this.deviceid = option.deviceid
|
||||||
if(option.xctime){
|
if(option.xctime != '--'){
|
||||||
if(option.xctime != '--' && option.ver){
|
if(option.xctime != '--' && option.ver){
|
||||||
this.ver = option.ver
|
this.ver = 'V' + option.ver.slice(3)
|
||||||
this.xctime = option.xctime
|
this.xctime = option.xctime
|
||||||
console.log(11);
|
console.log(11);
|
||||||
}else{
|
}else{
|
||||||
this.ver = 1
|
this.ver = 'V1'
|
||||||
this.xctime = option.xctime
|
this.xctime = option.xctime
|
||||||
console.log(22);
|
console.log(22);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
this.ver = null
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getshebxq()
|
this.getshebxq()
|
||||||
|
@ -207,18 +209,11 @@
|
||||||
xpconfirm(e) {
|
xpconfirm(e) {
|
||||||
this.xptxt = e[0].label
|
this.xptxt = e[0].label
|
||||||
},
|
},
|
||||||
getbanben(){
|
|
||||||
this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
this.file = res.data.asDeviceVersion.file
|
|
||||||
console.log(this.file)
|
|
||||||
// this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getbanbens(){
|
getbanbens(){
|
||||||
this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
|
this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
|
this.version = res.data.version
|
||||||
|
console.log(this.ver,'当前蓝牙版本号',this.version,'最新蓝牙版本号');
|
||||||
this.file = res.data.asDeviceVersion.file
|
this.file = res.data.asDeviceVersion.file
|
||||||
console.log(this.file)
|
console.log(this.file)
|
||||||
// this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
|
// this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
|
||||||
|
@ -237,8 +232,7 @@
|
||||||
},
|
},
|
||||||
// 选择固件版本
|
// 选择固件版本
|
||||||
gjconfirm(e) {
|
gjconfirm(e) {
|
||||||
// this.gjtxt = e[0].label
|
if(this.ver != null && this.ver != this.version){
|
||||||
// if(this.ver != ''){
|
|
||||||
if(this.file == '' || this.file == null){
|
if(this.file == '' || this.file == null){
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '暂无新版本',
|
title: '暂无新版本',
|
||||||
|
@ -257,13 +251,13 @@
|
||||||
this.shengjiflag = true
|
this.shengjiflag = true
|
||||||
this.startProgress()
|
this.startProgress()
|
||||||
}
|
}
|
||||||
// }else{
|
}else{
|
||||||
// uni.showToast({
|
uni.showToast({
|
||||||
// title: '请连接蓝牙获取版本号',
|
title: '已是最新版本',
|
||||||
// icon: 'none',
|
icon: 'none',
|
||||||
// duration: 2000
|
duration: 2000
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
},
|
},
|
||||||
// 点击取消修改设备名称
|
// 点击取消修改设备名称
|
||||||
btnqx() {
|
btnqx() {
|
||||||
|
|
|
@ -894,6 +894,48 @@
|
||||||
break
|
break
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||||
console.log("1收到设备发来的自定义数据结果:", options.data,options.data.length)
|
console.log("1收到设备发来的自定义数据结果:", options.data,options.data.length)
|
||||||
|
if (options.data.indexOf("prom:") !== -1) {
|
||||||
|
console.log('固件升级中')
|
||||||
|
var indexOld = options.data.substring(options.data.indexOf('prom:'))
|
||||||
|
console.log("indexOld", indexOld);
|
||||||
|
var load_num = indexOld.substring(
|
||||||
|
indexOld.indexOf("prom:") + 5,
|
||||||
|
indexOld.indexOf("@")
|
||||||
|
)
|
||||||
|
this.progress = Number(load_num);
|
||||||
|
console.log("load_num", load_num);
|
||||||
|
console.log("升级进度:", this.progress)
|
||||||
|
if (this.progress === 6000) {
|
||||||
|
console.log('固件成功')
|
||||||
|
this.progress = 100
|
||||||
|
uni.showToast({
|
||||||
|
title: '固件升级成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.shengjiflag = false
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pages/index/index'
|
||||||
|
})
|
||||||
|
},2000)
|
||||||
|
}
|
||||||
|
if (this.progress === 9000) {
|
||||||
|
console.log('固件升级失败')
|
||||||
|
this.progress = 99
|
||||||
|
uni.showToast({
|
||||||
|
title: '固件升级失败',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.shengjiflag = false
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pages/index/index'
|
||||||
|
})
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
this.datalist = options.data.slice(0, -1) + ";"
|
this.datalist = options.data.slice(0, -1) + ";"
|
||||||
this.vardataflag = 3
|
this.vardataflag = 3
|
||||||
if(this.pre == 'WATER'){
|
if(this.pre == 'WATER'){
|
||||||
|
@ -901,6 +943,7 @@
|
||||||
}else{
|
}else{
|
||||||
this.getcsbshuju()
|
this.getcsbshuju()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||||
if (!options.result) {
|
if (!options.result) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user