电动车
This commit is contained in:
parent
1251d00722
commit
b3872e12bd
|
|
@ -84,6 +84,8 @@
|
|||
permissionConfig: {
|
||||
'查看运营区': 'area:view',
|
||||
'操作运营区': 'area:edit',
|
||||
'查看子区域': 'areaSub:view',
|
||||
'操作子区域': 'areaSub:edit',
|
||||
'查看故障': 'fault:view',
|
||||
'故障审核': 'fault:edit',
|
||||
'查看订单': 'order:view',
|
||||
|
|
@ -112,85 +114,97 @@
|
|||
checked: false,
|
||||
txt: 2
|
||||
},
|
||||
{
|
||||
name: '查看子区域',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 3
|
||||
},
|
||||
{
|
||||
name: '操作子区域',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 4
|
||||
},
|
||||
{
|
||||
name: '查看故障',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 3
|
||||
},
|
||||
{
|
||||
name: '故障审核',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 4
|
||||
},
|
||||
{
|
||||
name: '查看订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 5
|
||||
},
|
||||
{
|
||||
name: '操作订单',
|
||||
name: '故障审核',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 6
|
||||
},
|
||||
{
|
||||
name: '查看车辆',
|
||||
name: '查看订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 7
|
||||
},
|
||||
{
|
||||
name: '操作车辆',
|
||||
name: '操作订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 8
|
||||
},
|
||||
{
|
||||
name: '查看客服',
|
||||
name: '查看车辆',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 9
|
||||
},
|
||||
{
|
||||
name: '操作车辆',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 10
|
||||
},
|
||||
{
|
||||
name: '操作客服',
|
||||
name: '查看客服',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 11
|
||||
},
|
||||
{
|
||||
name: '操作客服',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 12
|
||||
},
|
||||
|
||||
{
|
||||
name: '查看卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 12
|
||||
txt: 13
|
||||
},{
|
||||
name: '操作卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 13
|
||||
txt: 14
|
||||
},{
|
||||
name: '查看卡券订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 14
|
||||
txt: 15
|
||||
},{
|
||||
name: '操作卡券订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 15
|
||||
txt: 16
|
||||
},{
|
||||
name: '查看用户卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 16
|
||||
txt: 17
|
||||
},{
|
||||
name: '操作用户卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 17
|
||||
txt: 18
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -228,20 +242,22 @@
|
|||
const permissionMap = {
|
||||
'area:view': 0,
|
||||
'area:edit': 1,
|
||||
'fault:view': 2,
|
||||
'fault:edit': 3,
|
||||
'order:view': 4,
|
||||
'order:edit': 5,
|
||||
'device:view': 6,
|
||||
'device:edit': 7,
|
||||
'customerService:view': 8,
|
||||
'customerService:edit': 9,
|
||||
'vip:view': 10,
|
||||
'vip:edit': 11,
|
||||
'vipOrder:view': 12,
|
||||
'vipOrder:edit': 13,
|
||||
'vipUser:view': 14,
|
||||
'vipUser:edit': 15
|
||||
'areaSub:view':2,
|
||||
'areaSub:edit':3,
|
||||
'fault:view': 4,
|
||||
'fault:edit': 5,
|
||||
'order:view': 6,
|
||||
'order:edit': 7,
|
||||
'device:view': 8,
|
||||
'device:edit': 9,
|
||||
'customerService:view': 10,
|
||||
'customerService:edit': 11,
|
||||
'vip:view': 12,
|
||||
'vip:edit': 13,
|
||||
'vipOrder:view': 14,
|
||||
'vipOrder:edit': 15,
|
||||
'vipUser:view': 16,
|
||||
'vipUser:edit': 17
|
||||
}
|
||||
|
||||
permissions.forEach(permission => {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@
|
|||
permissionConfig: {
|
||||
'查看运营区': 'area:view',
|
||||
'操作运营区': 'area:edit',
|
||||
'查看子区域': 'areaSub:view',
|
||||
'操作子区域': 'areaSub:edit',
|
||||
'查看故障': 'fault:view',
|
||||
'故障审核': 'fault:edit',
|
||||
'查看订单': 'order:view',
|
||||
|
|
@ -109,83 +111,97 @@
|
|||
checked: false,
|
||||
txt: 2
|
||||
},
|
||||
{
|
||||
name: '查看子区域',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 3
|
||||
},
|
||||
{
|
||||
name: '操作子区域',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 4
|
||||
},
|
||||
{
|
||||
name: '查看故障',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 3
|
||||
},
|
||||
{
|
||||
name: '故障审核',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 4
|
||||
},
|
||||
{
|
||||
name: '查看订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 5
|
||||
},
|
||||
{
|
||||
name: '操作订单',
|
||||
name: '故障审核',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 6
|
||||
},
|
||||
{
|
||||
name: '查看车辆',
|
||||
name: '查看订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 7
|
||||
},
|
||||
{
|
||||
name: '操作车辆',
|
||||
name: '操作订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 8
|
||||
},
|
||||
{
|
||||
name: '查看客服',
|
||||
name: '查看车辆',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 9
|
||||
},
|
||||
{
|
||||
name: '操作车辆',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 10
|
||||
},
|
||||
{
|
||||
name: '操作客服',
|
||||
name: '查看客服',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 11
|
||||
},{
|
||||
name: '查看卡券',
|
||||
},
|
||||
{
|
||||
name: '操作客服',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 12
|
||||
},{
|
||||
name: '操作卡券',
|
||||
},
|
||||
|
||||
{
|
||||
name: '查看卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 13
|
||||
},{
|
||||
name: '查看卡券订单',
|
||||
name: '操作卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 14
|
||||
},{
|
||||
name: '操作卡券订单',
|
||||
name: '查看卡券订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 15
|
||||
},{
|
||||
name: '查看用户卡券',
|
||||
name: '操作卡券订单',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 16
|
||||
},{
|
||||
name: '操作用户卡券',
|
||||
name: '查看用户卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 17
|
||||
},{
|
||||
name: '操作用户卡券',
|
||||
tit: '是否允许',
|
||||
checked: false,
|
||||
txt: 18
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -222,20 +238,22 @@
|
|||
const permissionMap = {
|
||||
'area:view': 0,
|
||||
'area:edit': 1,
|
||||
'fault:view': 2,
|
||||
'fault:edit': 3,
|
||||
'order:view': 4,
|
||||
'order:edit': 5,
|
||||
'device:view': 6,
|
||||
'device:edit': 7,
|
||||
'customerService:view': 8,
|
||||
'customerService:edit': 9,
|
||||
'vip:view': 10,
|
||||
'vip:edit': 11,
|
||||
'vipOrder:view': 12,
|
||||
'vipOrder:edit': 13,
|
||||
'vipUser:view': 14,
|
||||
'vipUser:edit': 15
|
||||
'areaSub:view':2,
|
||||
'areaSub:edit':3,
|
||||
'fault:view': 4,
|
||||
'fault:edit': 5,
|
||||
'order:view': 6,
|
||||
'order:edit': 7,
|
||||
'device:view': 8,
|
||||
'device:edit': 9,
|
||||
'customerService:view': 10,
|
||||
'customerService:edit': 11,
|
||||
'vip:view': 12,
|
||||
'vip:edit': 13,
|
||||
'vipOrder:view': 14,
|
||||
'vipOrder:edit': 15,
|
||||
'vipUser:view': 16,
|
||||
'vipUser:edit': 17
|
||||
}
|
||||
|
||||
permissions.forEach(permission => {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@
|
|||
<view class="park" @click="showdevList=!showdevList" style="bottom: 600rpx;">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uP0Jd1XAgfjBj4NM9a8g" mode=""></image>
|
||||
</view>
|
||||
<view class="park" @click="btnshuaixn" style="bottom: 700rpx;width: 82rpx;height: 82rpx;border-radius: 50%;background-color: #fff;text-align: center;line-height: 82rpx;">
|
||||
刷新
|
||||
</view>
|
||||
|
||||
<view @touchmove.stop.prevent="() => {}">
|
||||
<view class="btn_box">
|
||||
|
|
@ -236,6 +239,10 @@
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
btnshuaixn(){
|
||||
this.getqb()
|
||||
this.getmarks()
|
||||
},
|
||||
// 请求全部运营统计数据
|
||||
getqb() {
|
||||
let StatKeys = 'device_status_count,device_online_status_count,device_count'
|
||||
|
|
@ -787,10 +794,10 @@
|
|||
this.status9 = []
|
||||
this.status6 = []
|
||||
// 如果已经有数据,直接使用本地筛选
|
||||
if (this.allDeviceData.length > 0) {
|
||||
this.filterDevicesByPowerRange()
|
||||
return
|
||||
}
|
||||
// if (this.allDeviceData.length > 0) {
|
||||
// this.filterDevicesByPowerRange()
|
||||
// return
|
||||
// }
|
||||
if (this.statusidx != 7 && this.statusidx != 20 && this.statusidx != 10) {
|
||||
this.$u.get(`/bst/device/all?areaId=${this.areaId}&status=${this.statusidx}&powerRange=${this.rangeValue[0] + ',' + this.rangeValue[1]}&refresh=true`).then((res) => {
|
||||
if (res.code == 200) {
|
||||
|
|
@ -931,33 +938,36 @@
|
|||
const type2Data = []
|
||||
const type3Data = []
|
||||
res.data.forEach(row => {
|
||||
if (row.type == 1) {
|
||||
type1Data.push(row)
|
||||
} else if (row.type == 2) {
|
||||
type2Data.push(row)
|
||||
} else if (row.type == 3) {
|
||||
type3Data.push(row)
|
||||
if(row.status == 0){
|
||||
if (row.type == 1) {
|
||||
type1Data.push(row)
|
||||
} else if (row.type == 2) {
|
||||
type2Data.push(row)
|
||||
} else if (row.type == 3) {
|
||||
type3Data.push(row)
|
||||
}
|
||||
console.log(row,'121212')
|
||||
newMarkers.push({
|
||||
id: row.id,
|
||||
latitude: row.latitude,
|
||||
longitude: row.longitude,
|
||||
width: 20,
|
||||
height: 29,
|
||||
iconPath: row.type == 1 ? 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : row.type == 2 ? 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t',
|
||||
callout: {
|
||||
content: row.name,
|
||||
color: '#ffffff',
|
||||
fontSize: 14,
|
||||
borderRadius: 10,
|
||||
bgColor: row.type == 1 ? '#3A7EDB' : row.type == 2 ? '#FF473E' : '#FFC107',
|
||||
padding: 6,
|
||||
display: 'BYCLICK'
|
||||
},
|
||||
isParking: true
|
||||
})
|
||||
console.log(newMarkers,'newMarkersnewMarkersnewMarkers')
|
||||
}
|
||||
console.log(row,'121212')
|
||||
newMarkers.push({
|
||||
id: row.id,
|
||||
latitude: row.latitude,
|
||||
longitude: row.longitude,
|
||||
width: 20,
|
||||
height: 29,
|
||||
iconPath: row.type == 1 ? 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : row.type == 2 ? 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t',
|
||||
callout: {
|
||||
content: row.name,
|
||||
color: '#ffffff',
|
||||
fontSize: 14,
|
||||
borderRadius: 10,
|
||||
bgColor: row.type == 1 ? '#3A7EDB' : row.type == 2 ? '#FF473E' : '#FFC107',
|
||||
padding: 6,
|
||||
display: 'BYCLICK'
|
||||
},
|
||||
isParking: true
|
||||
})
|
||||
console.log(newMarkers,'newMarkersnewMarkersnewMarkers')
|
||||
|
||||
})
|
||||
this.$set(this, 'markers', [...this.markers, ...newMarkers])
|
||||
const validBoundaries1 = type1Data.map(row => row.boundaryStr).filter(boundary =>
|
||||
|
|
|
|||
|
|
@ -237,24 +237,24 @@
|
|||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
运营区外调度费
|
||||
运营区外管理费
|
||||
</view>
|
||||
<view class="card_right">
|
||||
<input type="number" v-model="form.dispatchFee" placeholder=" " class="input"
|
||||
<input type="number" v-model="form.vehicleManagementFee" placeholder=" " class="input"
|
||||
placeholder-style="color:#C7CDD3" style="width: 100rpx;">元
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips" style="text-align: left;">
|
||||
设置车辆超出运营区外产生的调度费用
|
||||
设置车辆超出运营区外产生的管理费用
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_li">
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
停车点外调度费
|
||||
</view>
|
||||
<view class="card_right">
|
||||
<input type="number" v-model="form.vehicleManagementFee" placeholder=" " class="input"
|
||||
<input type="number" v-model="form.dispatchFee" placeholder=" " class="input"
|
||||
placeholder-style="color:#C7CDD3" style="width: 100rpx;">元
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -307,11 +307,11 @@ export default {
|
|||
}
|
||||
|
||||
this.selectedItems = []
|
||||
this.$u.get(`/bst/device/list?pageNum=${this.pageNum}&pageSize=999`, data).then((res) => {
|
||||
this.$u.get(`//bst/device/all`, data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.total = res.total
|
||||
this.deviceList = res.rows
|
||||
this.filteredList = res.rows
|
||||
this.total = res.data.length
|
||||
this.deviceList = res.data
|
||||
this.filteredList = res.data
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
|
@ -321,33 +321,7 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
|
||||
// // 搜索
|
||||
// search() {
|
||||
// this.pageNum = 1
|
||||
// let data = {
|
||||
// isAsc: this.scidx,
|
||||
// status: this.typeidx,
|
||||
// areaId: this.areaId,
|
||||
// orderByColumn: this.typeSort,
|
||||
// refresh:true,
|
||||
// Keyword:this.searchKeyword
|
||||
// }
|
||||
// this.selectedItems = []
|
||||
// this.$u.get(`/bst/device/list?pageNum=${this.pageNum}&pageSize=999`, data).then((res) => {
|
||||
// if (res.code == 200) {
|
||||
// this.total = res.total
|
||||
// this.deviceList = res.rows
|
||||
// this.filteredList = res.rows
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// title: res.msg,
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
|
||||
todetail(item) {
|
||||
if (this.stepindex == 0) {
|
||||
console.log(item.id,item);
|
||||
|
|
@ -368,7 +342,7 @@ export default {
|
|||
key: 'typeSortLabel',
|
||||
data: e[0].label,
|
||||
})
|
||||
this.pageNum = 1
|
||||
// this.pageNum = 1
|
||||
this.getDevice()
|
||||
},
|
||||
// 车辆禁用
|
||||
|
|
@ -558,25 +532,59 @@ export default {
|
|||
getDevice() {
|
||||
console.log(this.typeSort)
|
||||
let data = {
|
||||
isAsc: this.scidx,
|
||||
// isAsc: this.scidx,
|
||||
status: this.typeidx,
|
||||
areaId: this.areaId,
|
||||
orderByColumn: this.typeSort,
|
||||
// orderByColumn: this.typeSort,
|
||||
// refresh:true,
|
||||
Keyword:this.searchKeyword
|
||||
}
|
||||
this.selectedItems = []
|
||||
this.$u.get(`/bst/device/list?pageNum=${this.pageNum}&pageSize=10`, data).then((res) => {
|
||||
this.$u.get(`/bst/device/all`, data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.total = res.total
|
||||
if(this.pageNum == 1){
|
||||
this.deviceList = res.rows
|
||||
this.filteredList = res.rows
|
||||
}else{
|
||||
this.deviceList = this.deviceList.concat(res.rows)
|
||||
this.filteredList = this.filteredList.concat(res.rows)
|
||||
}
|
||||
this.pageNum++
|
||||
this.total = res.data.length
|
||||
this.deviceList = res.data
|
||||
this.filteredList = res.data
|
||||
if (!this.filteredList || this.filteredList.length === 0) return;
|
||||
|
||||
// 如果没有设置排序字段或方向,使用默认值
|
||||
const sortField = this.typeSort || 'remainingPower';
|
||||
const isDesc = this.scidx === 'desc';
|
||||
|
||||
this.filteredList.sort((a, b) => {
|
||||
// 获取比较值(处理可能不存在的字段)
|
||||
let valueA = a[sortField] || '';
|
||||
let valueB = b[sortField] || '';
|
||||
|
||||
// 特殊处理数字类型(如电量)
|
||||
if (sortField === 'remainingPower') {
|
||||
valueA = parseFloat(valueA) || 0;
|
||||
valueB = parseFloat(valueB) || 0;
|
||||
}
|
||||
|
||||
// 执行比较
|
||||
if (isDesc) {
|
||||
// 降序排列
|
||||
if (valueA > valueB) return -1;
|
||||
if (valueA < valueB) return 1;
|
||||
} else {
|
||||
// 升序排列
|
||||
if (valueA < valueB) return -1;
|
||||
if (valueA > valueB) return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
// 更新视图
|
||||
this.$forceUpdate();
|
||||
// if(this.pageNum == 1){
|
||||
// this.deviceList = res.rows
|
||||
// this.filteredList = res.rows
|
||||
// }else{
|
||||
// this.deviceList = this.deviceList.concat(res.rows)
|
||||
// this.filteredList = this.filteredList.concat(res.rows)
|
||||
// }
|
||||
// this.pageNum++
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@
|
|||
<view class="tap_cont" :class="zhuangtai=='PROCESSING'?'act1':''" @click="changeidx('PROCESSING')">
|
||||
进行中
|
||||
</view>
|
||||
<view class="tap_cont" :class="zhuangtai=='WAIT_PAY'?'act1':''" @click="changeidx('WAIT_PAY')">
|
||||
待支付
|
||||
<view class="tap_cont" style="width: 200rpx;" :class="zhuangtai=='RIDE_WAIT_PAY'?'act1':''" @click="changeidx('RIDE_WAIT_PAY')">
|
||||
骑行待支付
|
||||
</view>
|
||||
<view class="tap_cont" :class="zhuangtai=='FINISHED'?'act1':''" @click="changeidx('FINISHED')">
|
||||
已完成
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
<view class="top_info_right" v-if="item.status== 'WAIT_PAY'"
|
||||
style="color: orangered;">
|
||||
<view class="yuan" style="background: orangered;"></view>
|
||||
待支付
|
||||
押金待支付
|
||||
</view>
|
||||
<view class="top_info_right" v-if="item.status=='FINISHED'" style="color: green;">
|
||||
<view class="yuan" style="background: green;"></view>
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
<cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/uRiYQZQEb3l2LsltEsyW"
|
||||
mode=""></cover-image>
|
||||
</cover-view>
|
||||
<cover-view class="park" style="bottom: 240rpx;width: 70rpx;height: 70rpx;right: 40rpx;" @click="btnsjyc">
|
||||
<!-- <cover-view class="park" style="bottom: 240rpx;width: 70rpx;height: 70rpx;right: 40rpx;" @click="btnsjyc">
|
||||
<cover-image class="img" src="https://api.ccttiot.com/smartmeter/img/static/uBluMsnJyV5Judyx7SYx"
|
||||
mode=""></cover-image>
|
||||
</cover-view>
|
||||
</cover-view> -->
|
||||
<!-- <cover-view class="track" @click="toTrack">
|
||||
<cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/ufaAAtlirJYs1QwJF25P"
|
||||
mode=""></cover-image>
|
||||
|
|
@ -27,13 +27,6 @@
|
|||
</view>
|
||||
<view class="" style="display: flex;justify-content: space-between;">
|
||||
<view class="cent">
|
||||
<view class="lypic" v-if="ver_dataflag == 3" @click="btnly">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uLw46jus4X9fposAvVD7" mode=""></image>
|
||||
</view>
|
||||
<view class="lypic" v-if="ver_dataflag == 1" @click="btnly">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uCdHjNaNfD9aikVg9Cuk" mode=""></image>
|
||||
</view>
|
||||
|
||||
<view class="lypic" v-if="deviceInfos.music == 0" @click="btnsy">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uDORYeTuc2EQ1lSI2dbe" mode=""></image>
|
||||
</view>
|
||||
|
|
@ -43,6 +36,21 @@
|
|||
<view class="lypic" v-if="deviceInfos.music == 2" @click="btnsy">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uP7BOVsjvWaGItgHtoKV" mode=""></image>
|
||||
</view>
|
||||
|
||||
<view class="lypic" v-if="ver_dataflag == 3" @click="btnly">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uLw46jus4X9fposAvVD7" mode=""></image>
|
||||
</view>
|
||||
<!-- <view class="lypic" v-if="ver_dataflag == 1" @click="btnly">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uCdHjNaNfD9aikVg9Cuk" mode=""></image>
|
||||
</view> -->
|
||||
<view class="lypic" v-if="ver_dataflag == 1" @click="btnly">
|
||||
<image
|
||||
class="glow-image"
|
||||
src="https://api.ccttiot.com/smartmeter/img/static/uCdHjNaNfD9aikVg9Cuk"
|
||||
mode="aspectFit"
|
||||
:class="{ 'visible': isVisible, 'hidden': !isVisible }"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="rt">
|
||||
|
|
@ -362,6 +370,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { showLoading } from "../../components/blufi/util"
|
||||
|
||||
const app = getApp()
|
||||
var xBlufi = require("@/components/blufi/xBlufi.js")
|
||||
let _this = null
|
||||
|
|
@ -444,7 +454,10 @@
|
|||
findDeviceTimer: null,
|
||||
jieliuflag:true,
|
||||
|
||||
isMarkerVisible: true
|
||||
isMarkerVisible: true,
|
||||
|
||||
isVisible: true,
|
||||
glowInterval: null
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
|
|
@ -456,6 +469,14 @@
|
|||
this.getyunying()
|
||||
|
||||
},
|
||||
mounted() {
|
||||
// 开启呼吸灯效果
|
||||
this.startGlowEffect();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 清除定时器
|
||||
clearInterval(this.glowInterval);
|
||||
},
|
||||
onUnload: function() {
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: false,
|
||||
|
|
@ -468,6 +489,12 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
startGlowEffect() {
|
||||
// 每1.5秒切换一次显隐状态
|
||||
this.glowInterval = setInterval(() => {
|
||||
this.isVisible = !this.isVisible;
|
||||
}, 1500);
|
||||
},
|
||||
// 点击隐藏手机定位
|
||||
btnsjyc() {
|
||||
this.isMarkerVisible = !this.isMarkerVisible;
|
||||
|
|
@ -603,7 +630,7 @@
|
|||
this.getlanya()
|
||||
}else if (num == 1) {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11open@"
|
||||
customData: "11opensub5@"
|
||||
})
|
||||
uni.showToast({
|
||||
title: '发送成功',
|
||||
|
|
@ -612,7 +639,7 @@
|
|||
})
|
||||
} else if (num == 2) {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11close@"
|
||||
customData: "11closesub200@"
|
||||
})
|
||||
uni.showToast({
|
||||
title: '发送成功',
|
||||
|
|
@ -649,7 +676,7 @@
|
|||
}
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},1000)
|
||||
},3000)
|
||||
}
|
||||
},
|
||||
getlanya() {
|
||||
|
|
@ -706,12 +733,6 @@
|
|||
if (options.result == true) {
|
||||
setTimeout(() => {
|
||||
this.ver_dataflag = 3
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}, 2000)
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceid
|
||||
|
|
@ -719,12 +740,7 @@
|
|||
this.deviceid = options.data.deviceId
|
||||
this.name = this.name
|
||||
}else{
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '连接失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
|
|
@ -935,31 +951,33 @@
|
|||
if (res.code == 200) {
|
||||
// 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else if(res.code == 20001){
|
||||
if(this.ver_dataflag == 3){
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11opensub5@"
|
||||
})
|
||||
}else{
|
||||
this.lanya(0)
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: res.msg,
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
} else if (res.cancel) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '正在尝试使用蓝牙控制,蓝牙连接需尽可能靠近车辆!',
|
||||
showCancel: true,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
that.lanya(0)
|
||||
} else if (res.cancel) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
|
|
@ -984,28 +1002,47 @@
|
|||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
duration: 3000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}else if(res.code == 20001){
|
||||
if(this.ver_dataflag == 3){
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11closesub200@"
|
||||
})
|
||||
}else{
|
||||
this.lanya(0)
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: res.msg,
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
} else if (res.cancel) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '正在尝试使用蓝牙控制,蓝牙连接需尽可能靠近车辆!',
|
||||
showCancel: true,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
that.lanya(0)
|
||||
} else if (res.cancel) {
|
||||
// let that = this
|
||||
// uni.showModal({
|
||||
// title: '提示',
|
||||
// content: '正在尝试使用蓝牙控制,蓝牙连接需尽可能靠近车辆!',
|
||||
// showCancel: true,
|
||||
// success: function(res) {
|
||||
// if (res.confirm) {
|
||||
// that.lanya(0)
|
||||
// } else if (res.cancel) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}else{
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
|
|
@ -1062,6 +1099,7 @@
|
|||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
|
|
@ -1087,7 +1125,9 @@
|
|||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
} else if(res.code == 200001){
|
||||
|
||||
} else{
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
|
@ -1103,97 +1143,97 @@
|
|||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/in', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: '回仓成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
this.deviceInfo()
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
} else if (num == 6) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/out', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '出仓成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
} else if (num == 7) {
|
||||
this.showvehicle = true
|
||||
} else if (num == 8) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/iot/reboot?id=' + this.sn).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
} else if (num == 9) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/iot/unlockSeat?id=' + this.sn).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
this.$u.put('/bst/device/in', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: '回仓成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
this.deviceInfo()
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
} else if (num == 6) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/out', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '出仓成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
} else if (num == 7) {
|
||||
this.showvehicle = true
|
||||
} else if (num == 8) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/iot/reboot?id=' + this.sn).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
} else if (num == 9) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.put('/bst/device/iot/unlockSeat?id=' + this.sn).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceInfo()
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.jieliuflag = true
|
||||
},2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
|
@ -1255,6 +1295,9 @@
|
|||
}
|
||||
this.deviceInfos = res.data
|
||||
this.mac = res.data.mac
|
||||
if(this.ver_dataflag != 3){
|
||||
this.getlanya()
|
||||
}
|
||||
if (this.getnum == 0) {
|
||||
this.getArea()
|
||||
}
|
||||
|
|
@ -1263,23 +1306,23 @@
|
|||
this.getModelList()
|
||||
this.latitude = this.deviceInfos.latitude
|
||||
this.longitude = this.deviceInfos.longitude
|
||||
this.markers.push({
|
||||
id: 0.1,
|
||||
latitude: this.deviceInfos.mobileLat,
|
||||
longitude: this.deviceInfos.mobileLon,
|
||||
width: 40,
|
||||
height: 47,
|
||||
iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uvMzjOvKi58e8VAAS8t6',
|
||||
callout: {
|
||||
content: '手机定位', // 修改为你想要显示的文字内容
|
||||
color: '#ffffff', // 修改为文字颜色
|
||||
fontSize: 10, // 修改为文字大小
|
||||
borderRadius: 10, // 修改为气泡圆角大小
|
||||
bgColor: '#000000', // 修改为气泡背景颜色
|
||||
padding: 2, // 修改为气泡内边距
|
||||
display: 'ALWAYS', // 修改为气泡的显示策略
|
||||
}
|
||||
})
|
||||
// this.markers.push({
|
||||
// id: 0.1,
|
||||
// latitude: this.deviceInfos.mobileLat,
|
||||
// longitude: this.deviceInfos.mobileLon,
|
||||
// width: 40,
|
||||
// height: 47,
|
||||
// iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uvMzjOvKi58e8VAAS8t6',
|
||||
// callout: {
|
||||
// content: '手机定位', // 修改为你想要显示的文字内容
|
||||
// color: '#ffffff', // 修改为文字颜色
|
||||
// fontSize: 10, // 修改为文字大小
|
||||
// borderRadius: 10, // 修改为气泡圆角大小
|
||||
// bgColor: '#000000', // 修改为气泡背景颜色
|
||||
// padding: 2, // 修改为气泡内边距
|
||||
// display: 'ALWAYS', // 修改为气泡的显示策略
|
||||
// }
|
||||
// })
|
||||
if (this.deviceInfos.status == 0) {
|
||||
this.markers.push({
|
||||
id: parseFloat(this.deviceInfos.sn),
|
||||
|
|
@ -1638,7 +1681,7 @@
|
|||
<style lang="scss">
|
||||
page {
|
||||
overflow-x: hidden;
|
||||
background-color: #F6F8FA; // 更改背景色为更柔和的色调
|
||||
background-color: #F6F8FA;
|
||||
}
|
||||
|
||||
.page {
|
||||
|
|
@ -1648,8 +1691,6 @@
|
|||
.new_infocard{
|
||||
width: 750rpx;
|
||||
height: 80vh;
|
||||
// overflow: scroll;
|
||||
// padding-bottom: 100rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 30rpx;
|
||||
padding: 30rpx;
|
||||
|
|
@ -1776,19 +1817,47 @@
|
|||
}
|
||||
.cent{
|
||||
display: flex;
|
||||
|
||||
.lypic{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 24rpx;
|
||||
color: #3D3D3D;
|
||||
margin-right: 22rpx;
|
||||
image{
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
.lypic {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
image{
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
.glow-image {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 8rpx;
|
||||
transition: all 1s ease-in-out;
|
||||
filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.7)); /* 青色外发光 */
|
||||
}
|
||||
|
||||
.visible {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
filter: drop-shadow(0 0 5px rgba(255, 50, 50, 1)); /* 增强发光 */
|
||||
}
|
||||
|
||||
.hidden {
|
||||
opacity: 0.3;
|
||||
transform: scale(0.95);
|
||||
filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.3)); /* 减弱发光 */
|
||||
}
|
||||
// .lypic{
|
||||
// display: flex;
|
||||
// align-items: center;
|
||||
// font-size: 24rpx;
|
||||
// color: #3D3D3D;
|
||||
// margin-right: 22rpx;
|
||||
// image{
|
||||
// width: 36rpx;
|
||||
// height: 36rpx;
|
||||
// margin-right: 8rpx;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
.bikexx{
|
||||
margin-top: 26rpx;
|
||||
|
|
@ -1833,7 +1902,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.topsn{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
@ -1875,8 +1943,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.tip_box {
|
||||
position: fixed;
|
||||
left: 72rpx;
|
||||
|
|
@ -1886,7 +1952,6 @@
|
|||
border-radius: 30rpx 30rpx 30rpx 30rpx;
|
||||
z-index: 110;
|
||||
padding-bottom: 100rpx;
|
||||
|
||||
.saveQr {
|
||||
margin: 0 auto;
|
||||
margin-top: 30rpx;
|
||||
|
|
@ -1901,10 +1966,8 @@
|
|||
font-size: 36rpx;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.top {
|
||||
padding: 52rpx 38rpx 42rpx 36rpx;
|
||||
|
||||
.ipt_box {
|
||||
margin-top: 22rpx;
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
</view>
|
||||
<view class="iptbox" @click="show=true">
|
||||
<view class="" v-if="hardwareInfo.version">
|
||||
版本:{{hardwareInfo.version}} 版本id:{{hardwareInfo.id}}
|
||||
版本:{{hardwareInfo.version}}
|
||||
</view>
|
||||
<view class="" v-else>
|
||||
请点击选择版本
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
<!-- <view class="btn1" @click="btngx()">
|
||||
设备更新
|
||||
</view> -->
|
||||
<view class="btn1" @click="Binddevice()">
|
||||
<view class="btn1" @click="findDevice()">
|
||||
蓝牙链接
|
||||
</view>
|
||||
<view class="btn1" @click="ring()" v-if="carstause">
|
||||
|
|
@ -104,6 +104,7 @@
|
|||
export default {
|
||||
data() {
|
||||
return {
|
||||
devicesarr:[],
|
||||
devicesList: [
|
||||
// {name:'110000',
|
||||
// mac:'11111'}
|
||||
|
|
@ -139,39 +140,43 @@
|
|||
show: false,
|
||||
list: [],
|
||||
hardwareInfo: {},
|
||||
showbind:false
|
||||
|
||||
showbind:false,
|
||||
deviceid:''
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
this.mac = e.mac
|
||||
this.Binddevice()
|
||||
this.findDevice()
|
||||
this.isbands = false
|
||||
this.carstause = false
|
||||
},
|
||||
onShow() {
|
||||
this.getlist()
|
||||
},
|
||||
onUnload: function() {
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
},
|
||||
onHide() {
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
},
|
||||
onBeforeUnmount() {
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
},
|
||||
// onUnload: function() {
|
||||
// xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// });
|
||||
// },
|
||||
// onHide() {
|
||||
// xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// });
|
||||
// },
|
||||
// onBeforeUnmount() {
|
||||
// xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// });
|
||||
// },
|
||||
watch: {
|
||||
|
||||
},
|
||||
|
|
@ -209,7 +214,8 @@
|
|||
getlist() {
|
||||
this.$u.get('/bst/hardwareVersion/all').then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.Versionlist = res.data
|
||||
this.Versionlist = res.data.filter(item => item.parentId !== 0);
|
||||
|
||||
const hardwareVersionId = uni.getStorageSync('hardwareVersionId');
|
||||
|
||||
if (hardwareVersionId) {
|
||||
|
|
@ -220,10 +226,13 @@
|
|||
this.hardwareInfo = matchedVersion;
|
||||
}
|
||||
}
|
||||
this.list = res.data.map(item => ({
|
||||
value: item.id,
|
||||
label: item.version
|
||||
}))
|
||||
this.list = res.data
|
||||
.filter(item => item.parentId != 0) // 改用 != 兼容字符串 "0"
|
||||
.map(item => ({
|
||||
value: item.id,
|
||||
label: item.version
|
||||
}));
|
||||
console.log(JSON.stringify(this.list, null, 2));
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
|
@ -349,50 +358,110 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
Binddevice() {
|
||||
uni.showLoading({
|
||||
title: '连接中..'
|
||||
findDevice() {
|
||||
// 使用 find 方法查找匹配的设备
|
||||
const matchedDevice = this.devicesarr.find(device => {
|
||||
console.log(this.mac, '111')
|
||||
return device.name.slice(-12) == this.mac.slice(-12)
|
||||
})
|
||||
console.log("xBlufi", xBlufi.XMQTT_SYSTEM)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 两秒后停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
if (matchedDevice) {
|
||||
// 找到匹配的设备
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
if (this.devicesList.length == 0) {
|
||||
uni.showToast({
|
||||
title: '暂无发现对应设备,请靠近设备',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList))
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList
|
||||
this.devicesList.forEach(device => {
|
||||
// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符)
|
||||
let macFromName = device.name.substring(device.name.length - 12)
|
||||
console.log(macFromName, 'macFromNamemacFromName')
|
||||
// 与 this.mac 进行比较
|
||||
if (macFromName == this.mac) {
|
||||
// 如果相同,则将 this.ishave 设置为 true
|
||||
console.log(device)
|
||||
this.deviceInfoss = device
|
||||
this.createBLEConnection(device)
|
||||
console.log('对比正确1111111111')
|
||||
} else {
|
||||
console.log('对比错误')
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 200)
|
||||
}, 2000)
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: matchedDevice.deviceId,
|
||||
name: matchedDevice.name
|
||||
})
|
||||
this.deviceid = matchedDevice.deviceId
|
||||
} else {
|
||||
this.findDeviceTimer = setTimeout(this.findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文
|
||||
}
|
||||
},
|
||||
// 获取附近蓝牙设备列表
|
||||
funListenDeviceMsgEvent: function(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||
if (!options.result) {
|
||||
this.carstause = false
|
||||
console.log('断开断开');
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
this.devicesarr = options.data
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options))
|
||||
if (options.result == true) {
|
||||
this.carstause = true
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceid
|
||||
})
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
console.log("1收到设备发来的自定义数据结果:", options.data)
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||
if (!options.result) {
|
||||
console.log('蓝牙未开启')
|
||||
return
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
// Binddevice() {
|
||||
// uni.showLoading({
|
||||
// title: '连接中..'
|
||||
// })
|
||||
// console.log("xBlufi", xBlufi.XMQTT_SYSTEM)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// // 两秒后停止蓝牙搜索
|
||||
// setTimeout(() => {
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// })
|
||||
// setTimeout(() => {
|
||||
// uni.hideLoading()
|
||||
// if (this.devicesList.length == 0) {
|
||||
// uni.showToast({
|
||||
// title: '暂无发现对应设备,请靠近设备',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// } else {
|
||||
// let uniqueDevicesList = Array.from(new Set(this.devicesList))
|
||||
// // 将去重后的数组重新赋值给 this.devicesList
|
||||
// this.devicesList = uniqueDevicesList
|
||||
// this.devicesList.forEach(device => {
|
||||
// // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符)
|
||||
// let macFromName = device.name.substring(device.name.length - 12)
|
||||
// console.log(macFromName, 'macFromNamemacFromName')
|
||||
// // 与 this.mac 进行比较
|
||||
// if (macFromName == this.mac) {
|
||||
// // 如果相同,则将 this.ishave 设置为 true
|
||||
// console.log(device)
|
||||
// this.deviceInfoss = device
|
||||
// this.createBLEConnection(device)
|
||||
// console.log('对比正确1111111111')
|
||||
// } else {
|
||||
// console.log('对比错误')
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }, 200)
|
||||
// }, 2000)
|
||||
// },
|
||||
reboot() {
|
||||
let vm = this // 将外部的 this 绑定到 vm 上
|
||||
uni.getNetworkType({
|
||||
|
|
@ -511,90 +580,90 @@
|
|||
btnyc() {
|
||||
this.titleflag = false
|
||||
},
|
||||
// 解析自定义数据
|
||||
funListenDeviceMsgEvent: function(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
let devicesarr = options.data
|
||||
devicesarr.forEach(device => {
|
||||
this.devicesList.push(device)
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList))
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList
|
||||
})
|
||||
}
|
||||
break;
|
||||
// // 解析自定义数据
|
||||
// funListenDeviceMsgEvent: function(options) {
|
||||
// switch (options.type) {
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
// if (options.result) {
|
||||
// this.devicesarr = options.data
|
||||
// // devicesarr.forEach(device => {
|
||||
// // this.devicesList.push(device)
|
||||
// // let uniqueDevicesList = Array.from(new Set(this.devicesList))
|
||||
// // // 将去重后的数组重新赋值给 this.devicesList
|
||||
// // this.devicesList = uniqueDevicesList
|
||||
// // })
|
||||
// }
|
||||
// break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
if (options.result) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'none'
|
||||
}); {
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
// console.log("连接回调:" + JSON.stringify(options));
|
||||
// if (options.result) {
|
||||
// uni.hideLoading();
|
||||
// uni.showToast({
|
||||
// title: '连接成功',
|
||||
// icon: 'none'
|
||||
// }); {
|
||||
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: options.data.deviceId
|
||||
});
|
||||
// xBlufi.notifyInitBleEsp32({
|
||||
// deviceId: options.data.deviceId
|
||||
// });
|
||||
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);
|
||||
|
||||
this.deviceIds = options.data.deviceId
|
||||
this.name = options.data.name
|
||||
// 连接成功绑定设备
|
||||
// let params = {
|
||||
// mac: this.Bluetoothmac,
|
||||
// userId: this.$store.state.user.userId
|
||||
// }
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
if (systemInfo.platform === 'android') {
|
||||
// 当前设备是 Android
|
||||
// this.deviceIds = options.data.deviceId
|
||||
// this.name = options.data.name
|
||||
// // 连接成功绑定设备
|
||||
// // let params = {
|
||||
// // mac: this.Bluetoothmac,
|
||||
// // userId: this.$store.state.user.userId
|
||||
// // }
|
||||
// let systemInfo = uni.getSystemInfoSync();
|
||||
// if (systemInfo.platform === 'android') {
|
||||
// // 当前设备是 Android
|
||||
|
||||
} else if (systemInfo.platform === 'ios') {
|
||||
// 当前设备是 iOS
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/wifilist/index?deviceId=' + options
|
||||
// .data.deviceId + '&name=' + options.data.name
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
// } else if (systemInfo.platform === 'ios') {
|
||||
// // 当前设备是 iOS
|
||||
// // uni.navigateTo({
|
||||
// // url: '/pages/wifilist/index?deviceId=' + options
|
||||
// // .data.deviceId + '&name=' + options.data.name
|
||||
// // })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
// break;
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
|
||||
// this.ver_data = this.parseCustomData(options.data)
|
||||
if (options.data) {
|
||||
this.carstause = true
|
||||
}
|
||||
// console.log("1收到设备发来的自定义数据结果:", this.ver_data);
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
if (options.result) {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
// // this.ver_data = this.parseCustomData(options.data)
|
||||
// if (options.data) {
|
||||
// this.carstause = true
|
||||
// }
|
||||
// // console.log("1收到设备发来的自定义数据结果:", this.ver_data);
|
||||
// break;
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
// if (options.result) {
|
||||
// let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
|
||||
// 过滤出名称字段的前五个字母为 "CTPOW" 的项
|
||||
let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) ===
|
||||
"BBLE");
|
||||
// // 过滤出名称字段的前五个字母为 "CTPOW" 的项
|
||||
// let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) ===
|
||||
// "BBLE");
|
||||
|
||||
// 将过滤后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = filteredDevices;
|
||||
// // 将过滤后的数组重新赋值给 this.devicesList
|
||||
// this.devicesList = filteredDevices;
|
||||
|
||||
// console.log('蓝牙停止搜索ok',this.devicesList);
|
||||
} else {
|
||||
//蓝牙停止搜索失败
|
||||
// console.log('蓝牙停止搜索失败');
|
||||
}
|
||||
this.searching = false
|
||||
// _this.setData({
|
||||
// searching: false
|
||||
// });
|
||||
// // console.log('蓝牙停止搜索ok',this.devicesList);
|
||||
// } else {
|
||||
// //蓝牙停止搜索失败
|
||||
// // console.log('蓝牙停止搜索失败');
|
||||
// }
|
||||
// this.searching = false
|
||||
// // _this.setData({
|
||||
// // searching: false
|
||||
// // });
|
||||
|
||||
break;
|
||||
}
|
||||
},
|
||||
// break;
|
||||
// }
|
||||
// },
|
||||
|
||||
|
||||
//4、建立连接
|
||||
|
|
@ -663,59 +732,59 @@
|
|||
|
||||
|
||||
},
|
||||
funListenDeviceMsgEvents: function(options) {
|
||||
let that = this;
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
|
||||
console.log('状态', options.result)
|
||||
if (options.result == false) {
|
||||
this.carstause = false
|
||||
uni.showToast({
|
||||
title: '设备断开链接,请重新点击蓝牙链接',
|
||||
icon: 'none'
|
||||
});
|
||||
// uni.showModal({
|
||||
// title: '很抱歉提醒你!',
|
||||
// content: '小程序与设备异常断开',
|
||||
// showCancel: false,
|
||||
// success: function(res) {
|
||||
// // uni.navigateBack({
|
||||
// // url: '../search/search'
|
||||
// // });
|
||||
// }
|
||||
// });
|
||||
// this.statusflag = false
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// funListenDeviceMsgEvents: function(options) {
|
||||
// let that = this;
|
||||
// switch (options.type) {
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
|
||||
// console.log('状态', options.result)
|
||||
// if (options.result == false) {
|
||||
// this.carstause = false
|
||||
// uni.showToast({
|
||||
// title: '设备断开链接,请重新点击蓝牙链接',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// // uni.showModal({
|
||||
// // title: '很抱歉提醒你!',
|
||||
// // content: '小程序与设备异常断开',
|
||||
// // showCancel: false,
|
||||
// // success: function(res) {
|
||||
// // // uni.navigateBack({
|
||||
// // // url: '../search/search'
|
||||
// // // });
|
||||
// // }
|
||||
// // });
|
||||
// // this.statusflag = false
|
||||
// uni.hideLoading();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
||||
this.loadPercent = options.data;
|
||||
this.loadText = '文件读取中'
|
||||
console.log("文件读取中", options.data);
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
// this.isband = true
|
||||
// this.ver_data = this.parseCustomData(options.data)
|
||||
console.log("1收到设备发来的自定义数据结果:", options.data);
|
||||
if (options.data) {
|
||||
this.carstause = true
|
||||
}
|
||||
break;
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
||||
// this.loadPercent = options.data;
|
||||
// this.loadText = '文件读取中'
|
||||
// console.log("文件读取中", options.data);
|
||||
// break;
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
// // this.isband = true
|
||||
// // this.ver_data = this.parseCustomData(options.data)
|
||||
// console.log("1收到设备发来的自定义数据结果:", options.data);
|
||||
// if (options.data) {
|
||||
// this.carstause = true
|
||||
// }
|
||||
// break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
|
||||
uni.hideLoading();
|
||||
if (options.result) {
|
||||
console.log('初始化成功');
|
||||
} else {
|
||||
console.log('初始化失败');
|
||||
// case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
|
||||
// uni.hideLoading();
|
||||
// if (options.result) {
|
||||
// console.log('初始化成功');
|
||||
// } else {
|
||||
// console.log('初始化失败');
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// },
|
||||
// 点击隐藏没有设备提示
|
||||
btnhd() {
|
||||
this.tishiflag = false
|
||||
|
|
|
|||
|
|
@ -12,16 +12,10 @@
|
|||
重置页面
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uCfe9273aC89tGOT7n1G" mode="widthFix"></image>
|
||||
<text class="sm">{{texts}}</text>
|
||||
</view>
|
||||
|
||||
<view class="dblist" v-for="(item, index) in devicesList" :key="index" @tap="choose(item)">
|
||||
<!-- <view class="lt">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uoQO0pUZ1UHcW5uVKkuR" mode=""></image>
|
||||
</view> -->
|
||||
<view class="cen">
|
||||
<view class="name">
|
||||
MAC:{{item.localName.substring(5)}}
|
||||
|
|
@ -35,22 +29,13 @@
|
|||
蓝牙信号:{{item.RSSI}} <span style="margin-left: 20rpx;" v-if="item.isBand "> SN:{{item.sn}}</span>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="rt">
|
||||
<text :id="item.deviceId" @tap="openConfirmModal(item)">绑定</text>
|
||||
</view> -->
|
||||
<view class="rt" style="margin-right: 10rpx;">
|
||||
<text :id="item.deviceId">选择</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="anniu" @click="Search">
|
||||
<button>重新扫描</button>
|
||||
|
||||
</view>
|
||||
<!-- <view class="anniu2 " @click="send">
|
||||
响铃
|
||||
</view> -->
|
||||
|
||||
<view v-if="showConfirmModal" class="modal-overlay">
|
||||
<view class="modal">
|
||||
<view class="modal-content">
|
||||
|
|
@ -83,10 +68,7 @@
|
|||
bgc: {
|
||||
backgroundColor: "#F7FAFE",
|
||||
},
|
||||
devicesList: [
|
||||
// {name:'110000',
|
||||
// mac:'11111'}
|
||||
],
|
||||
devicesList: [],
|
||||
devicesLists: [],
|
||||
searching: false,
|
||||
texts: '正在扫描蓝牙设备...',
|
||||
|
|
@ -112,55 +94,47 @@
|
|||
xBlufi.initXBlufi(1)
|
||||
},
|
||||
onShow: function() {
|
||||
this.bluthlist = [];
|
||||
this.devicesList = [];
|
||||
this.devicesLists = [];
|
||||
|
||||
this.bluthlist = []
|
||||
this.devicesList = []
|
||||
this.devicesLists = []
|
||||
// 强制视图更新
|
||||
this.$forceUpdate();
|
||||
|
||||
this.$forceUpdate()
|
||||
// 后续的蓝牙初始化和扫描逻辑
|
||||
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({ 'isStart': true });
|
||||
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({ 'isStart': true })
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({ 'isStart': false });
|
||||
xBlufi.notifyStartDiscoverBle({ 'isStart': false })
|
||||
if (this.devicesList.length == 0) {
|
||||
this.tishiflag = true;
|
||||
this.texts = '扫描完毕,暂无发现电动车设备';
|
||||
this.tishiflag = true
|
||||
this.texts = '扫描完毕,请操作'
|
||||
} else {
|
||||
this.texts = '扫描到以下设备,请点击连接!';
|
||||
this.texts = '扫描到以下设备,请点击连接!'
|
||||
}
|
||||
this.status = true;
|
||||
|
||||
this.status = true
|
||||
// 再次强制更新
|
||||
this.$forceUpdate();
|
||||
}, 2000);
|
||||
|
||||
}, 2000)
|
||||
},
|
||||
onUnload: function() {
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
|
||||
})
|
||||
},
|
||||
onHide() {
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
|
||||
})
|
||||
},
|
||||
onBeforeUnmount() {
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
// this.videoContext = uni.createVideoContext('myVideo', this)
|
||||
|
||||
},
|
||||
methods: {
|
||||
replay(){
|
||||
|
|
@ -180,48 +154,41 @@
|
|||
},
|
||||
fetchDevicesBoundStatus() {
|
||||
// 提取所有设备的 MAC 地址,并通过 Set 去重
|
||||
let uniqueDevices = Array.from(new Set(this.devicesList.map(item => item.localName.substring(5))));
|
||||
|
||||
let uniqueDevices = Array.from(new Set(this.devicesList.map(item => item.localName.substring(5))))
|
||||
// 重新构建去重后的 devicesList
|
||||
this.devicesList = uniqueDevices.map(mac => {
|
||||
return this.devicesList.find(item => item.localName.substring(5) === mac);
|
||||
});
|
||||
|
||||
return this.devicesList.find(item => item.localName.substring(5) === mac)
|
||||
})
|
||||
// 拼接成字符串
|
||||
const macs = uniqueDevices;
|
||||
|
||||
const macs = uniqueDevices
|
||||
// 向批量接口请求录入状态
|
||||
let data = macs
|
||||
this.$u.post(`/bst/device/listSnByMac`,data).then((res) => {
|
||||
const resultList = res.data; // 获取接口返回的数据数组
|
||||
console.log(res,'请求');
|
||||
const resultList = res.data // 获取接口返回的数据数组
|
||||
console.log(res,'请求')
|
||||
// 遍历 devicesList 并对比 mac 地址
|
||||
this.devicesList.forEach(device => {
|
||||
const mac = device.localName.substring(5);
|
||||
|
||||
const mac = device.localName.substring(5)
|
||||
// 查找返回结果中是否有与该设备 MAC 地址相同的项
|
||||
const matchingResult = resultList.find(result => result.mac === mac);
|
||||
|
||||
const matchingResult = resultList.find(result => result.mac === mac)
|
||||
// 如果找到了匹配的 MAC 地址项,则更新设备的 sn 和 isBand
|
||||
if (matchingResult) {
|
||||
device.sn = matchingResult.sn;
|
||||
device.sn = matchingResult.sn
|
||||
device.isBand = true
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
// 对 devicesList 进行排序,将 isBand 为 false 的设备排在前面
|
||||
this.devicesList.sort((a, b) => {
|
||||
return (a.isBand === false ? -1 : 1) - (b.isBand === false ? -1 : 1);
|
||||
});
|
||||
|
||||
this.$forceUpdate(); // 强制更新视图
|
||||
console.log(this.devicesList, 'Updated devicesList');
|
||||
return (a.isBand === false ? -1 : 1) - (b.isBand === false ? -1 : 1)
|
||||
})
|
||||
this.$forceUpdate() // 强制更新视图
|
||||
console.log(this.devicesList, 'Updated devicesList')
|
||||
}).catch((error) => {
|
||||
console.error('批量获取设备录入状态失败', error);
|
||||
});
|
||||
console.error('批量获取设备录入状态失败', error)
|
||||
})
|
||||
},
|
||||
choose(e) {
|
||||
console.log(e);
|
||||
console.log(e)
|
||||
let Bluetoothmac = e.name.substring(5)
|
||||
uni.redirectTo({
|
||||
url: '/page_user/luru/bind_mac?mac=' + Bluetoothmac
|
||||
|
|
@ -236,17 +203,16 @@
|
|||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
openConfirmModal(e) {
|
||||
this.deviceinfo = e
|
||||
this.showConfirmModal = true;
|
||||
this.showConfirmModal = true
|
||||
},
|
||||
|
||||
closeConfirmModal() {
|
||||
this.showConfirmModal = false;
|
||||
this.showConfirmModal = false
|
||||
},
|
||||
confirmBind() {
|
||||
this.closeConfirmModal();
|
||||
|
|
@ -256,131 +222,113 @@
|
|||
this.titleflag = false
|
||||
},
|
||||
sing() {
|
||||
let vm = this; // 将外部的 this 绑定到 vm 上
|
||||
let vm = this // 将外部的 this 绑定到 vm 上
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
console.log('已连接的蓝牙设备信息:', res);
|
||||
// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性
|
||||
console.log('已连接的蓝牙设备信息:', res)
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11play1@"
|
||||
});
|
||||
})
|
||||
uni.hideLoading()
|
||||
vm.remakr()
|
||||
},
|
||||
fail(err) {
|
||||
uni.hideLoading()
|
||||
console.error('获取已连接蓝牙设备信息失败:', err);
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络');
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
remakr() {
|
||||
let vm = this; // 将外部的 this 绑定到 vm 上
|
||||
let vm = this // 将外部的 this 绑定到 vm 上
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
console.log('已连接的蓝牙设备信息:', res);
|
||||
// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性
|
||||
console.log('已连接的蓝牙设备信息:', res)
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11reboot"
|
||||
});
|
||||
})
|
||||
uni.navigateBack({
|
||||
delta: 1 // delta值为1时表示返回的页面层数
|
||||
});
|
||||
|
||||
})
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err);
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络');
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
funListenDeviceMsgEvent: function(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
let devicesarr = options.data
|
||||
// this.devicesList = options.data
|
||||
// console.log(devicesarr, 'devicesarrdevicesarr');
|
||||
devicesarr.forEach(device => {
|
||||
const mac = device.name.substring(6);
|
||||
this.devicesLists = options.data
|
||||
// let devicesarr = options.data
|
||||
// // this.devicesList = options.data
|
||||
// // console.log(devicesarr, 'devicesarrdevicesarr');
|
||||
// devicesarr.forEach(device => {
|
||||
// const mac = device.name.substring(6);
|
||||
|
||||
if (device.name.indexOf("BBLE") != -1) {
|
||||
// this.$u.get(`/app/device/${mac}/isBind`).then((res) => {
|
||||
// if (res.data == false) {
|
||||
this.devicesLists.push(device);
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesLists));
|
||||
// if (device.name.indexOf("BBLE") != -1) {
|
||||
// // this.$u.get(`/app/device/${mac}/isBind`).then((res) => {
|
||||
// // if (res.data == false) {
|
||||
// this.devicesLists.push(device);
|
||||
// let uniqueDevicesList = Array.from(new Set(this.devicesLists));
|
||||
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesLists = uniqueDevicesList;
|
||||
// }
|
||||
// })
|
||||
// // 将去重后的数组重新赋值给 this.devicesList
|
||||
// this.devicesLists = uniqueDevicesList;
|
||||
// // }
|
||||
// // })
|
||||
|
||||
}
|
||||
// getisband(mac).then(res => {
|
||||
// console.log(res);
|
||||
// if (res.data == true) {
|
||||
// console.log(`MAC 地址 ${mac} 已经绑定`);
|
||||
// } else {
|
||||
// this.devicesList.push(device)
|
||||
// }
|
||||
// }).catch(error => {
|
||||
// console.error(`检查 MAC 地址 ${mac} 是否绑定的过程中出错:`, error);
|
||||
// });
|
||||
});
|
||||
// }
|
||||
// // getisband(mac).then(res => {
|
||||
// // console.log(res);
|
||||
// // if (res.data == true) {
|
||||
// // console.log(`MAC 地址 ${mac} 已经绑定`);
|
||||
// // } else {
|
||||
// // this.devicesList.push(device)
|
||||
// // }
|
||||
// // }).catch(error => {
|
||||
// // console.error(`检查 MAC 地址 ${mac} 是否绑定的过程中出错:`, error);
|
||||
// // });
|
||||
// });
|
||||
}
|
||||
break;
|
||||
|
||||
break
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
console.log("连接回调:" + JSON.stringify(options))
|
||||
if (options.result) {
|
||||
uni.hideLoading();
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'none'
|
||||
}); {
|
||||
console.log("连接回调options.data.deviceId:" + options.data.deviceId,
|
||||
"连接回调options.data.name:" + options.data.name);
|
||||
// 连接成功绑定设备
|
||||
// let params = {
|
||||
// mac: this.Bluetoothmac,
|
||||
// userId: this.$store.state.user.userId
|
||||
// }
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: options.data.deviceId
|
||||
});
|
||||
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);
|
||||
// setTimeout(() => {
|
||||
// this.sing()
|
||||
// }, 3000)
|
||||
|
||||
})
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
if (systemInfo.platform === 'android') {
|
||||
// 当前设备是 Android
|
||||
|
||||
} else if (systemInfo.platform === 'ios') {
|
||||
// 当前设备是 iOS
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||
if (!options.result) {
|
||||
console.log("蓝牙未开启", options);
|
||||
|
|
@ -397,18 +345,12 @@
|
|||
}
|
||||
} else {
|
||||
this.searching = true
|
||||
//蓝牙搜索开始
|
||||
// _this.setData({
|
||||
// searching: true
|
||||
// });
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
if (options.result) {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesLists));
|
||||
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesLists = uniqueDevicesList;
|
||||
let list = []
|
||||
|
|
@ -418,19 +360,10 @@
|
|||
// console.log(macFromName);
|
||||
// 与 this.mac 进行比较
|
||||
list.push(device)
|
||||
// this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => {
|
||||
// if (res.data == false) {
|
||||
// list.push(device)
|
||||
// } else {
|
||||
|
||||
// }
|
||||
// })
|
||||
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.devicesList = list
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList;
|
||||
this.fetchDevicesBoundStatus();
|
||||
|
|
@ -552,7 +485,7 @@
|
|||
// 判断是否存在浇花器设备
|
||||
if (this.devicesList.length == 0) {
|
||||
this.tishiflag = true
|
||||
this.texts = '扫描完毕,暂无发现电动车设备'
|
||||
this.texts = '扫描完毕,请操作'
|
||||
} else {
|
||||
this.texts = '扫描到以下设备,请点击连接!'
|
||||
}
|
||||
|
|
@ -619,6 +552,8 @@
|
|||
// padding-top: 136rpx !important;
|
||||
padding: 0 66rpx;
|
||||
box-sizing: border-box;
|
||||
padding-bottom: 200rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
|
|
@ -752,7 +687,6 @@
|
|||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
border-radius: 10rpx;
|
||||
|
||||
.lt {
|
||||
padding-left: 10rpx;
|
||||
box-sizing: border-box;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user