电动车

This commit is contained in:
吴鹏 2025-06-13 17:00:24 +08:00
parent 1251d00722
commit b3872e12bd
9 changed files with 805 additions and 687 deletions

View File

@ -84,6 +84,8 @@
permissionConfig: { permissionConfig: {
'查看运营区': 'area:view', '查看运营区': 'area:view',
'操作运营区': 'area:edit', '操作运营区': 'area:edit',
'查看子区域': 'areaSub:view',
'操作子区域': 'areaSub:edit',
'查看故障': 'fault:view', '查看故障': 'fault:view',
'故障审核': 'fault:edit', '故障审核': 'fault:edit',
'查看订单': 'order:view', '查看订单': 'order:view',
@ -113,84 +115,96 @@
txt: 2 txt: 2
}, },
{ {
name: '查看故障', name: '查看子区域',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 3 txt: 3
}, },
{ {
name: '故障审核', name: '操作子区域',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 4 txt: 4
}, },
{ {
name: '查看订单', name: '查看故障',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 5 txt: 5
}, },
{ {
name: '操作订单', name: '故障审核',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 6 txt: 6
}, },
{ {
name: '查看车辆', name: '查看订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 7 txt: 7
}, },
{ {
name: '操作车辆', name: '操作订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 8 txt: 8
}, },
{ {
name: '查看客服', name: '查看车辆',
tit: '是否允许',
checked: false,
txt: 9
},
{
name: '操作车辆',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 10 txt: 10
}, },
{ {
name: '操作客服', name: '查看客服',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 11 txt: 11
}, },
{
name: '操作客服',
tit: '是否允许',
checked: false,
txt: 12
},
{ {
name: '查看卡券', name: '查看卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 12 txt: 13
},{ },{
name: '操作卡券', name: '操作卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 13 txt: 14
},{ },{
name: '查看卡券订单', name: '查看卡券订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 14 txt: 15
},{ },{
name: '操作卡券订单', name: '操作卡券订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 15 txt: 16
},{ },{
name: '查看用户卡券', name: '查看用户卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 16 txt: 17
},{ },{
name: '操作用户卡券', name: '操作用户卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 17 txt: 18
}, },
], ],
} }
@ -228,20 +242,22 @@
const permissionMap = { const permissionMap = {
'area:view': 0, 'area:view': 0,
'area:edit': 1, 'area:edit': 1,
'fault:view': 2, 'areaSub:view':2,
'fault:edit': 3, 'areaSub:edit':3,
'order:view': 4, 'fault:view': 4,
'order:edit': 5, 'fault:edit': 5,
'device:view': 6, 'order:view': 6,
'device:edit': 7, 'order:edit': 7,
'customerService:view': 8, 'device:view': 8,
'customerService:edit': 9, 'device:edit': 9,
'vip:view': 10, 'customerService:view': 10,
'vip:edit': 11, 'customerService:edit': 11,
'vipOrder:view': 12, 'vip:view': 12,
'vipOrder:edit': 13, 'vip:edit': 13,
'vipUser:view': 14, 'vipOrder:view': 14,
'vipUser:edit': 15 'vipOrder:edit': 15,
'vipUser:view': 16,
'vipUser:edit': 17
} }
permissions.forEach(permission => { permissions.forEach(permission => {

View File

@ -81,6 +81,8 @@
permissionConfig: { permissionConfig: {
'查看运营区': 'area:view', '查看运营区': 'area:view',
'操作运营区': 'area:edit', '操作运营区': 'area:edit',
'查看子区域': 'areaSub:view',
'操作子区域': 'areaSub:edit',
'查看故障': 'fault:view', '查看故障': 'fault:view',
'故障审核': 'fault:edit', '故障审核': 'fault:edit',
'查看订单': 'order:view', '查看订单': 'order:view',
@ -110,82 +112,96 @@
txt: 2 txt: 2
}, },
{ {
name: '查看故障', name: '查看子区域',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 3 txt: 3
}, },
{ {
name: '故障审核', name: '操作子区域',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 4 txt: 4
}, },
{ {
name: '查看订单', name: '查看故障',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 5 txt: 5
}, },
{ {
name: '操作订单', name: '故障审核',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 6 txt: 6
}, },
{ {
name: '查看车辆', name: '查看订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 7 txt: 7
}, },
{ {
name: '操作车辆', name: '操作订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 8 txt: 8
}, },
{ {
name: '查看客服', name: '查看车辆',
tit: '是否允许',
checked: false,
txt: 9
},
{
name: '操作车辆',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 10 txt: 10
}, },
{ {
name: '操作客服', name: '查看客服',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 11 txt: 11
},{ },
name: '查看卡券', {
name: '操作客服',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 12 txt: 12
},{ },
name: '操作卡券',
{
name: '查看卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 13 txt: 13
},{ },{
name: '查看卡券订单', name: '操作卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 14 txt: 14
},{ },{
name: '操作卡券订单', name: '查看卡券订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 15 txt: 15
},{ },{
name: '查看用户卡券', name: '操作卡券订单',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 16 txt: 16
},{ },{
name: '操作用户卡券', name: '查看用户卡券',
tit: '是否允许', tit: '是否允许',
checked: false, checked: false,
txt: 17 txt: 17
},{
name: '操作用户卡券',
tit: '是否允许',
checked: false,
txt: 18
}, },
], ],
} }
@ -222,20 +238,22 @@
const permissionMap = { const permissionMap = {
'area:view': 0, 'area:view': 0,
'area:edit': 1, 'area:edit': 1,
'fault:view': 2, 'areaSub:view':2,
'fault:edit': 3, 'areaSub:edit':3,
'order:view': 4, 'fault:view': 4,
'order:edit': 5, 'fault:edit': 5,
'device:view': 6, 'order:view': 6,
'device:edit': 7, 'order:edit': 7,
'customerService:view': 8, 'device:view': 8,
'customerService:edit': 9, 'device:edit': 9,
'vip:view': 10, 'customerService:view': 10,
'vip:edit': 11, 'customerService:edit': 11,
'vipOrder:view': 12, 'vip:view': 12,
'vipOrder:edit': 13, 'vip:edit': 13,
'vipUser:view': 14, 'vipOrder:view': 14,
'vipUser:edit': 15 'vipOrder:edit': 15,
'vipUser:view': 16,
'vipUser:edit': 17
} }
permissions.forEach(permission => { permissions.forEach(permission => {

View File

@ -30,6 +30,9 @@
<view class="park" @click="showdevList=!showdevList" style="bottom: 600rpx;"> <view class="park" @click="showdevList=!showdevList" style="bottom: 600rpx;">
<image src="https://api.ccttiot.com/smartmeter/img/static/uP0Jd1XAgfjBj4NM9a8g" mode=""></image> <image src="https://api.ccttiot.com/smartmeter/img/static/uP0Jd1XAgfjBj4NM9a8g" mode=""></image>
</view> </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 @touchmove.stop.prevent="() => {}">
<view class="btn_box"> <view class="btn_box">
@ -236,6 +239,10 @@
}, },
}, },
methods: { methods: {
btnshuaixn(){
this.getqb()
this.getmarks()
},
// //
getqb() { getqb() {
let StatKeys = 'device_status_count,device_online_status_count,device_count' let StatKeys = 'device_status_count,device_online_status_count,device_count'
@ -787,10 +794,10 @@
this.status9 = [] this.status9 = []
this.status6 = [] this.status6 = []
// 使 // 使
if (this.allDeviceData.length > 0) { // if (this.allDeviceData.length > 0) {
this.filterDevicesByPowerRange() // this.filterDevicesByPowerRange()
return // return
} // }
if (this.statusidx != 7 && this.statusidx != 20 && this.statusidx != 10) { 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) => { 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) { if (res.code == 200) {
@ -931,6 +938,7 @@
const type2Data = [] const type2Data = []
const type3Data = [] const type3Data = []
res.data.forEach(row => { res.data.forEach(row => {
if(row.status == 0){
if (row.type == 1) { if (row.type == 1) {
type1Data.push(row) type1Data.push(row)
} else if (row.type == 2) { } else if (row.type == 2) {
@ -958,6 +966,8 @@
isParking: true isParking: true
}) })
console.log(newMarkers,'newMarkersnewMarkersnewMarkers') console.log(newMarkers,'newMarkersnewMarkersnewMarkers')
}
}) })
this.$set(this, 'markers', [...this.markers, ...newMarkers]) this.$set(this, 'markers', [...this.markers, ...newMarkers])
const validBoundaries1 = type1Data.map(row => row.boundaryStr).filter(boundary => const validBoundaries1 = type1Data.map(row => row.boundaryStr).filter(boundary =>

View File

@ -237,15 +237,15 @@
<view class="card_li"> <view class="card_li">
<view class="tops"> <view class="tops">
<view class="card_left"> <view class="card_left">
运营区外调度 运营区外管理
</view> </view>
<view class="card_right"> <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;"> placeholder-style="color:#C7CDD3" style="width: 100rpx;">
</view> </view>
</view> </view>
<view class="tips" style="text-align: left;"> <view class="tips" style="text-align: left;">
设置车辆超出运营区外产生的调度费用 设置车辆超出运营区外产生的管理费用
</view> </view>
</view> </view>
<view class="card_li"> <view class="card_li">
@ -254,7 +254,7 @@
停车点外调度费 停车点外调度费
</view> </view>
<view class="card_right"> <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;"> placeholder-style="color:#C7CDD3" style="width: 100rpx;">
</view> </view>
</view> </view>

View File

@ -307,11 +307,11 @@ export default {
} }
this.selectedItems = [] 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) { if (res.code == 200) {
this.total = res.total this.total = res.data.length
this.deviceList = res.rows this.deviceList = res.data
this.filteredList = res.rows this.filteredList = res.data
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
@ -322,32 +322,6 @@ 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) { todetail(item) {
if (this.stepindex == 0) { if (this.stepindex == 0) {
console.log(item.id,item); console.log(item.id,item);
@ -368,7 +342,7 @@ export default {
key: 'typeSortLabel', key: 'typeSortLabel',
data: e[0].label, data: e[0].label,
}) })
this.pageNum = 1 // this.pageNum = 1
this.getDevice() this.getDevice()
}, },
// //
@ -558,25 +532,59 @@ export default {
getDevice() { getDevice() {
console.log(this.typeSort) console.log(this.typeSort)
let data = { let data = {
isAsc: this.scidx, // isAsc: this.scidx,
status: this.typeidx, status: this.typeidx,
areaId: this.areaId, areaId: this.areaId,
orderByColumn: this.typeSort, // orderByColumn: this.typeSort,
// refresh:true, // refresh:true,
Keyword:this.searchKeyword Keyword:this.searchKeyword
} }
this.selectedItems = [] 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) { if (res.code == 200) {
this.total = res.total this.total = res.data.length
if(this.pageNum == 1){ this.deviceList = res.data
this.deviceList = res.rows this.filteredList = res.data
this.filteredList = res.rows if (!this.filteredList || this.filteredList.length === 0) return;
}else{
this.deviceList = this.deviceList.concat(res.rows) // 使
this.filteredList = this.filteredList.concat(res.rows) 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;
} }
this.pageNum++
//
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 { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,

View File

@ -33,8 +33,8 @@
<view class="tap_cont" :class="zhuangtai=='PROCESSING'?'act1':''" @click="changeidx('PROCESSING')"> <view class="tap_cont" :class="zhuangtai=='PROCESSING'?'act1':''" @click="changeidx('PROCESSING')">
进行中 进行中
</view> </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>
<view class="tap_cont" :class="zhuangtai=='FINISHED'?'act1':''" @click="changeidx('FINISHED')"> <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'" <view class="top_info_right" v-if="item.status== 'WAIT_PAY'"
style="color: orangered;"> style="color: orangered;">
<view class="yuan" style="background: orangered;"></view> <view class="yuan" style="background: orangered;"></view>
待支付 押金待支付
</view> </view>
<view class="top_info_right" v-if="item.status=='FINISHED'" style="color: green;"> <view class="top_info_right" v-if="item.status=='FINISHED'" style="color: green;">
<view class="yuan" style="background: green;"></view> <view class="yuan" style="background: green;"></view>

View File

@ -8,10 +8,10 @@
<cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/uRiYQZQEb3l2LsltEsyW" <cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/uRiYQZQEb3l2LsltEsyW"
mode=""></cover-image> mode=""></cover-image>
</cover-view> </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" <cover-image class="img" src="https://api.ccttiot.com/smartmeter/img/static/uBluMsnJyV5Judyx7SYx"
mode=""></cover-image> mode=""></cover-image>
</cover-view> </cover-view> -->
<!-- <cover-view class="track" @click="toTrack"> <!-- <cover-view class="track" @click="toTrack">
<cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/ufaAAtlirJYs1QwJF25P" <cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/ufaAAtlirJYs1QwJF25P"
mode=""></cover-image> mode=""></cover-image>
@ -27,13 +27,6 @@
</view> </view>
<view class="" style="display: flex;justify-content: space-between;"> <view class="" style="display: flex;justify-content: space-between;">
<view class="cent"> <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"> <view class="lypic" v-if="deviceInfos.music == 0" @click="btnsy">
<image src="https://api.ccttiot.com/smartmeter/img/static/uDORYeTuc2EQ1lSI2dbe" mode=""></image> <image src="https://api.ccttiot.com/smartmeter/img/static/uDORYeTuc2EQ1lSI2dbe" mode=""></image>
</view> </view>
@ -43,6 +36,21 @@
<view class="lypic" v-if="deviceInfos.music == 2" @click="btnsy"> <view class="lypic" v-if="deviceInfos.music == 2" @click="btnsy">
<image src="https://api.ccttiot.com/smartmeter/img/static/uP7BOVsjvWaGItgHtoKV" mode=""></image> <image src="https://api.ccttiot.com/smartmeter/img/static/uP7BOVsjvWaGItgHtoKV" mode=""></image>
</view> </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> </view>
<view class="rt"> <view class="rt">
@ -362,6 +370,8 @@
</template> </template>
<script> <script>
import { showLoading } from "../../components/blufi/util"
const app = getApp() const app = getApp()
var xBlufi = require("@/components/blufi/xBlufi.js") var xBlufi = require("@/components/blufi/xBlufi.js")
let _this = null let _this = null
@ -444,7 +454,10 @@
findDeviceTimer: null, findDeviceTimer: null,
jieliuflag:true, jieliuflag:true,
isMarkerVisible: true isMarkerVisible: true,
isVisible: true,
glowInterval: null
} }
}, },
onLoad(e) { onLoad(e) {
@ -456,6 +469,14 @@
this.getyunying() this.getyunying()
}, },
mounted() {
//
this.startGlowEffect();
},
beforeDestroy() {
//
clearInterval(this.glowInterval);
},
onUnload: function() { onUnload: function() {
xBlufi.notifyConnectBle({ xBlufi.notifyConnectBle({
isStart: false, isStart: false,
@ -468,6 +489,12 @@
} }
}, },
methods: { methods: {
startGlowEffect() {
// 1.5
this.glowInterval = setInterval(() => {
this.isVisible = !this.isVisible;
}, 1500);
},
// //
btnsjyc() { btnsjyc() {
this.isMarkerVisible = !this.isMarkerVisible; this.isMarkerVisible = !this.isMarkerVisible;
@ -603,7 +630,7 @@
this.getlanya() this.getlanya()
}else if (num == 1) { }else if (num == 1) {
xBlufi.notifySendCustomData({ xBlufi.notifySendCustomData({
customData: "11open@" customData: "11opensub5@"
}) })
uni.showToast({ uni.showToast({
title: '发送成功', title: '发送成功',
@ -612,7 +639,7 @@
}) })
} else if (num == 2) { } else if (num == 2) {
xBlufi.notifySendCustomData({ xBlufi.notifySendCustomData({
customData: "11close@" customData: "11closesub200@"
}) })
uni.showToast({ uni.showToast({
title: '发送成功', title: '发送成功',
@ -649,7 +676,7 @@
} }
setTimeout(()=>{ setTimeout(()=>{
this.jieliuflag = true this.jieliuflag = true
},1000) },3000)
} }
}, },
getlanya() { getlanya() {
@ -706,12 +733,6 @@
if (options.result == true) { if (options.result == true) {
setTimeout(() => { setTimeout(() => {
this.ver_dataflag = 3 this.ver_dataflag = 3
uni.hideLoading()
uni.showToast({
title: '连接成功',
icon: 'none',
duration: 2000
})
}, 2000) }, 2000)
xBlufi.notifyInitBleEsp32({ xBlufi.notifyInitBleEsp32({
deviceId: this.deviceid deviceId: this.deviceid
@ -719,12 +740,7 @@
this.deviceid = options.data.deviceId this.deviceid = options.data.deviceId
this.name = this.name this.name = this.name
}else{ }else{
uni.hideLoading()
uni.showToast({
title: '连接失败',
icon: 'none',
duration: 2000
})
} }
break; break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
@ -935,31 +951,33 @@
if (res.code == 200) { if (res.code == 200) {
// 线 // 线
this.deviceInfo() this.deviceInfo()
uni.showToast({
title: '操作成功',
icon: 'success',
duration: 2000
})
setTimeout(()=>{ setTimeout(()=>{
this.jieliuflag = true this.jieliuflag = true
},2000) },2000)
} else if(res.code == 20001){ } else if(res.code == 20001){
setTimeout(()=>{ if(this.ver_dataflag == 3){
this.jieliuflag = true xBlufi.notifySendCustomData({
},2000) customData: "11opensub5@"
})
}else{
this.lanya(0)
let that = this let that = this
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '正在尝试使用蓝牙控制,蓝牙连接需尽可能靠近车辆!', content: res.msg,
showCancel: true, showCancel: false,
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
that.lanya(0)
} else if (res.cancel) { } else if (res.cancel) {
} }
} }
}) })
}
setTimeout(()=>{
this.jieliuflag = true
},2000)
}else { }else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
@ -984,28 +1002,47 @@
uni.showToast({ uni.showToast({
title: '操作成功', title: '操作成功',
icon: 'success', icon: 'success',
duration: 2000 duration: 3000
}) })
setTimeout(()=>{ setTimeout(()=>{
this.jieliuflag = true this.jieliuflag = true
},2000) },2000)
}else if(res.code == 20001){ }else if(res.code == 20001){
setTimeout(()=>{ if(this.ver_dataflag == 3){
this.jieliuflag = true xBlufi.notifySendCustomData({
},2000) customData: "11closesub200@"
})
}else{
this.lanya(0)
let that = this let that = this
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '正在尝试使用蓝牙控制,蓝牙连接需尽可能靠近车辆!', content: res.msg,
showCancel: true, showCancel: false,
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
that.lanya(0)
} else if (res.cancel) { } 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{ }else{
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
@ -1062,6 +1099,7 @@
this.jieliuflag = true this.jieliuflag = true
},2000) },2000)
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: 'none', icon: 'none',
@ -1087,6 +1125,8 @@
setTimeout(()=>{ setTimeout(()=>{
this.jieliuflag = true this.jieliuflag = true
},2000) },2000)
} else if(res.code == 200001){
} else{ } else{
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
@ -1255,6 +1295,9 @@
} }
this.deviceInfos = res.data this.deviceInfos = res.data
this.mac = res.data.mac this.mac = res.data.mac
if(this.ver_dataflag != 3){
this.getlanya()
}
if (this.getnum == 0) { if (this.getnum == 0) {
this.getArea() this.getArea()
} }
@ -1263,23 +1306,23 @@
this.getModelList() this.getModelList()
this.latitude = this.deviceInfos.latitude this.latitude = this.deviceInfos.latitude
this.longitude = this.deviceInfos.longitude this.longitude = this.deviceInfos.longitude
this.markers.push({ // this.markers.push({
id: 0.1, // id: 0.1,
latitude: this.deviceInfos.mobileLat, // latitude: this.deviceInfos.mobileLat,
longitude: this.deviceInfos.mobileLon, // longitude: this.deviceInfos.mobileLon,
width: 40, // width: 40,
height: 47, // height: 47,
iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uvMzjOvKi58e8VAAS8t6', // iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uvMzjOvKi58e8VAAS8t6',
callout: { // callout: {
content: '手机定位', // // content: '', //
color: '#ffffff', // // color: '#ffffff', //
fontSize: 10, // // fontSize: 10, //
borderRadius: 10, // // borderRadius: 10, //
bgColor: '#000000', // // bgColor: '#000000', //
padding: 2, // // padding: 2, //
display: 'ALWAYS', // // display: 'ALWAYS', //
} // }
}) // })
if (this.deviceInfos.status == 0) { if (this.deviceInfos.status == 0) {
this.markers.push({ this.markers.push({
id: parseFloat(this.deviceInfos.sn), id: parseFloat(this.deviceInfos.sn),
@ -1638,7 +1681,7 @@
<style lang="scss"> <style lang="scss">
page { page {
overflow-x: hidden; overflow-x: hidden;
background-color: #F6F8FA; // background-color: #F6F8FA;
} }
.page { .page {
@ -1648,8 +1691,6 @@
.new_infocard{ .new_infocard{
width: 750rpx; width: 750rpx;
height: 80vh; height: 80vh;
// overflow: scroll;
// padding-bottom: 100rpx;
background: #FFFFFF; background: #FFFFFF;
border-radius: 30rpx; border-radius: 30rpx;
padding: 30rpx; padding: 30rpx;
@ -1776,19 +1817,47 @@
} }
.cent{ .cent{
display: flex; display: flex;
.lypic { .lypic {
display: flex; display: flex;
justify-content: center;
align-items: center; align-items: center;
font-size: 24rpx; }
color: #3D3D3D;
margin-right: 22rpx;
image{ image{
width: 36rpx; width: 36rpx;
height: 36rpx; height: 36rpx;
margin-right: 8rpx; 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{ .bikexx{
margin-top: 26rpx; margin-top: 26rpx;
@ -1833,7 +1902,6 @@
} }
} }
} }
.topsn{ .topsn{
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -1875,8 +1943,6 @@
} }
} }
} }
.tip_box { .tip_box {
position: fixed; position: fixed;
left: 72rpx; left: 72rpx;
@ -1886,7 +1952,6 @@
border-radius: 30rpx 30rpx 30rpx 30rpx; border-radius: 30rpx 30rpx 30rpx 30rpx;
z-index: 110; z-index: 110;
padding-bottom: 100rpx; padding-bottom: 100rpx;
.saveQr { .saveQr {
margin: 0 auto; margin: 0 auto;
margin-top: 30rpx; margin-top: 30rpx;
@ -1901,10 +1966,8 @@
font-size: 36rpx; font-size: 36rpx;
color: #FFFFFF; color: #FFFFFF;
} }
.top { .top {
padding: 52rpx 38rpx 42rpx 36rpx; padding: 52rpx 38rpx 42rpx 36rpx;
.ipt_box { .ipt_box {
margin-top: 22rpx; margin-top: 22rpx;
display: flex; display: flex;

View File

@ -21,7 +21,7 @@
</view> </view>
<view class="iptbox" @click="show=true"> <view class="iptbox" @click="show=true">
<view class="" v-if="hardwareInfo.version"> <view class="" v-if="hardwareInfo.version">
版本{{hardwareInfo.version}} 版本id:{{hardwareInfo.id}} 版本{{hardwareInfo.version}}
</view> </view>
<view class="" v-else> <view class="" v-else>
请点击选择版本 请点击选择版本
@ -42,7 +42,7 @@
<!-- <view class="btn1" @click="btngx()"> <!-- <view class="btn1" @click="btngx()">
设备更新 设备更新
</view> --> </view> -->
<view class="btn1" @click="Binddevice()"> <view class="btn1" @click="findDevice()">
蓝牙链接 蓝牙链接
</view> </view>
<view class="btn1" @click="ring()" v-if="carstause"> <view class="btn1" @click="ring()" v-if="carstause">
@ -104,6 +104,7 @@
export default { export default {
data() { data() {
return { return {
devicesarr:[],
devicesList: [ devicesList: [
// {name:'110000', // {name:'110000',
// mac:'11111'} // mac:'11111'}
@ -139,39 +140,43 @@
show: false, show: false,
list: [], list: [],
hardwareInfo: {}, hardwareInfo: {},
showbind:false showbind:false,
deviceid:''
} }
}, },
onLoad(e) { onLoad(e) {
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
this.mac = e.mac this.mac = e.mac
this.Binddevice() this.findDevice()
this.isbands = false this.isbands = false
this.carstause = false this.carstause = false
}, },
onShow() { onShow() {
this.getlist() this.getlist()
}, },
onUnload: function() { // onUnload: function() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); // xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({ // xBlufi.notifyStartDiscoverBle({
'isStart': false // 'isStart': false
}); // });
}, // },
onHide() { // onHide() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); // xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({ // xBlufi.notifyStartDiscoverBle({
'isStart': false // 'isStart': false
}); // });
}, // },
onBeforeUnmount() { // onBeforeUnmount() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); // xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({ // xBlufi.notifyStartDiscoverBle({
'isStart': false // 'isStart': false
}); // });
}, // },
watch: { watch: {
}, },
@ -209,7 +214,8 @@
getlist() { getlist() {
this.$u.get('/bst/hardwareVersion/all').then((res) => { this.$u.get('/bst/hardwareVersion/all').then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.Versionlist = res.data this.Versionlist = res.data.filter(item => item.parentId !== 0);
const hardwareVersionId = uni.getStorageSync('hardwareVersionId'); const hardwareVersionId = uni.getStorageSync('hardwareVersionId');
if (hardwareVersionId) { if (hardwareVersionId) {
@ -220,10 +226,13 @@
this.hardwareInfo = matchedVersion; this.hardwareInfo = matchedVersion;
} }
} }
this.list = res.data.map(item => ({ this.list = res.data
.filter(item => item.parentId != 0) // != "0"
.map(item => ({
value: item.id, value: item.id,
label: item.version label: item.version
})) }));
console.log(JSON.stringify(this.list, null, 2));
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
@ -349,50 +358,110 @@
} }
}) })
}, },
Binddevice() { findDevice() {
uni.showLoading({ // 使 find
title: '连接中..' 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) if (matchedDevice) {
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) //
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
//
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({ xBlufi.notifyStartDiscoverBle({
'isStart': false 'isStart': false
}) })
setTimeout(() => { xBlufi.notifyConnectBle({
uni.hideLoading() isStart: true,
if (this.devicesList.length == 0) { deviceId: matchedDevice.deviceId,
uni.showToast({ name: matchedDevice.name
title: '暂无发现对应设备,请靠近设备',
icon: 'none'
}) })
this.deviceid = matchedDevice.deviceId
} else { } else {
let uniqueDevicesList = Array.from(new Set(this.devicesList)) this.findDeviceTimer = setTimeout(this.findDevice.bind(this), 1000) // 使 bind this
// 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)
}, },
//
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() { reboot() {
let vm = this // this vm let vm = this // this vm
uni.getNetworkType({ uni.getNetworkType({
@ -511,90 +580,90 @@
btnyc() { btnyc() {
this.titleflag = false this.titleflag = false
}, },
// // //
funListenDeviceMsgEvent: function(options) { // funListenDeviceMsgEvent: function(options) {
switch (options.type) { // switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: // case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) { // if (options.result) {
let devicesarr = options.data // this.devicesarr = options.data
devicesarr.forEach(device => { // // devicesarr.forEach(device => {
this.devicesList.push(device) // // this.devicesList.push(device)
let uniqueDevicesList = Array.from(new Set(this.devicesList)) // // let uniqueDevicesList = Array.from(new Set(this.devicesList))
// this.devicesList // // // this.devicesList
this.devicesList = uniqueDevicesList // // 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'
}); {
xBlufi.notifyInitBleEsp32({
deviceId: options.data.deviceId
});
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(); // break;
if (systemInfo.platform === 'android') {
// Android
} else if (systemInfo.platform === 'ios') { // case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
// iOS // console.log("" + JSON.stringify(options));
// uni.navigateTo({ // if (options.result) {
// url: '/pages/wifilist/index?deviceId=' + options // uni.hideLoading();
// .data.deviceId + '&name=' + options.data.name // uni.showToast({
// }) // title: '',
} // icon: 'none'
} // }); {
}
break; // xBlufi.notifyInitBleEsp32({
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: // deviceId: options.data.deviceId
// 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");
// this.devicesList
this.devicesList = filteredDevices;
// console.log('ok',this.devicesList);
} else {
//
// console.log('');
}
this.searching = false
// _this.setData({
// searching: false
// }); // });
break; // 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
// } 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:
// // 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");
// // this.devicesList
// this.devicesList = filteredDevices;
// // console.log('ok',this.devicesList);
// } else {
// //
// // console.log('');
// }
// this.searching = false
// // _this.setData({
// // searching: false
// // });
// break;
// }
// },
//4 //4
@ -663,59 +732,59 @@
}, },
funListenDeviceMsgEvents: function(options) { // funListenDeviceMsgEvents: function(options) {
let that = this; // let that = this;
switch (options.type) { // switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: { // case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
console.log('状态', options.result) // console.log('', options.result)
if (options.result == false) { // if (options.result == false) {
this.carstause = false // this.carstause = false
uni.showToast({ // uni.showToast({
title: '设备断开链接,请重新点击蓝牙链接', // title: '',
icon: 'none' // icon: 'none'
});
// uni.showModal({
// title: '',
// content: '',
// showCancel: false,
// success: function(res) {
// // uni.navigateBack({
// // url: '../search/search'
// // });
// }
// }); // });
// this.statusflag = false // // uni.showModal({
uni.hideLoading(); // // title: '',
} // // content: '',
} // // showCancel: false,
break; // // success: function(res) {
// // // uni.navigateBack({
// // // url: '../search/search'
// // // });
// // }
// // });
// // this.statusflag = false
// uni.hideLoading();
// }
// }
// break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA: // case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
this.loadPercent = options.data; // this.loadPercent = options.data;
this.loadText = '文件读取中' // this.loadText = ''
console.log("文件读取中", options.data); // console.log("", options.data);
break; // break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: // case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
// this.isband = true // // this.isband = true
// this.ver_data = this.parseCustomData(options.data) // // this.ver_data = this.parseCustomData(options.data)
console.log("1收到设备发来的自定义数据结果", options.data); // console.log("1", options.data);
if (options.data) { // if (options.data) {
this.carstause = true // this.carstause = true
} // }
break; // break;
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT: // case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
uni.hideLoading(); // uni.hideLoading();
if (options.result) { // if (options.result) {
console.log('初始化成功'); // console.log('');
} else { // } else {
console.log('初始化失败'); // console.log('');
} // }
break; // break;
} // }
}, // },
// //
btnhd() { btnhd() {
this.tishiflag = false this.tishiflag = false

View File

@ -12,16 +12,10 @@
重置页面 重置页面
</view> </view>
</view> </view>
<image src="https://api.ccttiot.com/smartmeter/img/static/uCfe9273aC89tGOT7n1G" mode="widthFix"></image> <image src="https://api.ccttiot.com/smartmeter/img/static/uCfe9273aC89tGOT7n1G" mode="widthFix"></image>
<text class="sm">{{texts}}</text> <text class="sm">{{texts}}</text>
</view> </view>
<view class="dblist" v-for="(item, index) in devicesList" :key="index" @tap="choose(item)"> <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="cen">
<view class="name"> <view class="name">
MAC{{item.localName.substring(5)}} MAC{{item.localName.substring(5)}}
@ -35,22 +29,13 @@
蓝牙信号{{item.RSSI}} <span style="margin-left: 20rpx;" v-if="item.isBand "> SN:{{item.sn}}</span> 蓝牙信号{{item.RSSI}} <span style="margin-left: 20rpx;" v-if="item.isBand "> SN:{{item.sn}}</span>
</view> </view>
</view> </view>
<!-- <view class="rt">
<text :id="item.deviceId" @tap="openConfirmModal(item)">绑定</text>
</view> -->
<view class="rt" style="margin-right: 10rpx;"> <view class="rt" style="margin-right: 10rpx;">
<text :id="item.deviceId">选择</text> <text :id="item.deviceId">选择</text>
</view> </view>
</view> </view>
<view class="anniu" @click="Search"> <view class="anniu" @click="Search">
<button>重新扫描</button> <button>重新扫描</button>
</view> </view>
<!-- <view class="anniu2 " @click="send">
响铃
</view> -->
<view v-if="showConfirmModal" class="modal-overlay"> <view v-if="showConfirmModal" class="modal-overlay">
<view class="modal"> <view class="modal">
<view class="modal-content"> <view class="modal-content">
@ -83,10 +68,7 @@
bgc: { bgc: {
backgroundColor: "#F7FAFE", backgroundColor: "#F7FAFE",
}, },
devicesList: [ devicesList: [],
// {name:'110000',
// mac:'11111'}
],
devicesLists: [], devicesLists: [],
searching: false, searching: false,
texts: '正在扫描蓝牙设备...', texts: '正在扫描蓝牙设备...',
@ -112,55 +94,47 @@
xBlufi.initXBlufi(1) xBlufi.initXBlufi(1)
}, },
onShow: function() { onShow: function() {
this.bluthlist = []; this.bluthlist = []
this.devicesList = []; this.devicesList = []
this.devicesLists = []; this.devicesLists = []
// //
this.$forceUpdate(); this.$forceUpdate()
// //
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); xBlufi.notifyStartDiscoverBle({ 'isStart': true })
xBlufi.notifyStartDiscoverBle({ 'isStart': true });
setTimeout(() => { setTimeout(() => {
xBlufi.notifyStartDiscoverBle({ 'isStart': false }); xBlufi.notifyStartDiscoverBle({ 'isStart': false })
if (this.devicesList.length == 0) { if (this.devicesList.length == 0) {
this.tishiflag = true; this.tishiflag = true
this.texts = '扫描完毕,暂无发现电动车设备'; this.texts = '扫描完毕,请操作'
} else { } else {
this.texts = '扫描到以下设备,请点击连接!'; this.texts = '扫描到以下设备,请点击连接!'
} }
this.status = true; this.status = true
// //
this.$forceUpdate(); this.$forceUpdate();
}, 2000); }, 2000)
}, },
onUnload: function() { onUnload: function() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({ xBlufi.notifyStartDiscoverBle({
'isStart': false 'isStart': false
}); })
}, },
onHide() { onHide() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({ xBlufi.notifyStartDiscoverBle({
'isStart': false 'isStart': false
}); })
}, },
onBeforeUnmount() { onBeforeUnmount() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({ xBlufi.notifyStartDiscoverBle({
'isStart': false 'isStart': false
}); })
}, },
mounted() { mounted() {
// this.videoContext = uni.createVideoContext('myVideo', this)
}, },
methods: { methods: {
replay(){ replay(){
@ -180,48 +154,41 @@
}, },
fetchDevicesBoundStatus() { fetchDevicesBoundStatus() {
// MAC Set // 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 // devicesList
this.devicesList = uniqueDevices.map(mac => { 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 let data = macs
this.$u.post(`/bst/device/listSnByMac`,data).then((res) => { this.$u.post(`/bst/device/listSnByMac`,data).then((res) => {
const resultList = res.data; // const resultList = res.data //
console.log(res,'请求'); console.log(res,'请求')
// devicesList mac // devicesList mac
this.devicesList.forEach(device => { this.devicesList.forEach(device => {
const mac = device.localName.substring(5); const mac = device.localName.substring(5)
// MAC // MAC
const matchingResult = resultList.find(result => result.mac === mac); const matchingResult = resultList.find(result => result.mac === mac)
// MAC sn isBand // MAC sn isBand
if (matchingResult) { if (matchingResult) {
device.sn = matchingResult.sn; device.sn = matchingResult.sn
device.isBand = true device.isBand = true
} }
}); })
// devicesList isBand false // devicesList isBand false
this.devicesList.sort((a, b) => { this.devicesList.sort((a, b) => {
return (a.isBand === false ? -1 : 1) - (b.isBand === false ? -1 : 1); return (a.isBand === false ? -1 : 1) - (b.isBand === false ? -1 : 1)
}); })
this.$forceUpdate() //
this.$forceUpdate(); // console.log(this.devicesList, 'Updated devicesList')
console.log(this.devicesList, 'Updated devicesList');
}).catch((error) => { }).catch((error) => {
console.error('批量获取设备录入状态失败', error); console.error('批量获取设备录入状态失败', error)
}); })
}, },
choose(e) { choose(e) {
console.log(e); console.log(e)
let Bluetoothmac = e.name.substring(5) let Bluetoothmac = e.name.substring(5)
uni.redirectTo({ uni.redirectTo({
url: '/page_user/luru/bind_mac?mac=' + Bluetoothmac url: '/page_user/luru/bind_mac?mac=' + Bluetoothmac
@ -236,17 +203,16 @@
title: res.msg, title: res.msg,
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}); })
} }
}) })
}, },
openConfirmModal(e) { openConfirmModal(e) {
this.deviceinfo = e this.deviceinfo = e
this.showConfirmModal = true; this.showConfirmModal = true
}, },
closeConfirmModal() { closeConfirmModal() {
this.showConfirmModal = false; this.showConfirmModal = false
}, },
confirmBind() { confirmBind() {
this.closeConfirmModal(); this.closeConfirmModal();
@ -256,131 +222,113 @@
this.titleflag = false this.titleflag = false
}, },
sing() { sing() {
let vm = this; // this vm let vm = this // this vm
uni.getNetworkType({ uni.getNetworkType({
success(res) { success(res) {
if (res.networkType !== 'none') { if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({ uni.getConnectedBluetoothDevices({
success(res) { success(res) {
console.log('已连接的蓝牙设备信息:', res); console.log('已连接的蓝牙设备信息:', res)
// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使 vm 访 Vue
xBlufi.notifySendCustomData({ xBlufi.notifySendCustomData({
customData: "11play1@" customData: "11play1@"
}); })
uni.hideLoading() uni.hideLoading()
vm.remakr() vm.remakr()
}, },
fail(err) { fail(err) {
uni.hideLoading() uni.hideLoading()
console.error('获取已连接蓝牙设备信息失败:', err); console.error('获取已连接蓝牙设备信息失败:', err)
} }
}); })
} else { } else {
console.log('手机未连接网络'); console.log('手机未连接网络')
} }
} }
}); })
}, },
remakr() { remakr() {
let vm = this; // this vm let vm = this // this vm
uni.getNetworkType({ uni.getNetworkType({
success(res) { success(res) {
if (res.networkType !== 'none') { if (res.networkType !== 'none') {
uni.getConnectedBluetoothDevices({ uni.getConnectedBluetoothDevices({
success(res) { success(res) {
console.log('已连接的蓝牙设备信息:', res); console.log('已连接的蓝牙设备信息:', res)
// vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使 vm 访 Vue
xBlufi.notifySendCustomData({ xBlufi.notifySendCustomData({
customData: "11reboot" customData: "11reboot"
}); })
uni.navigateBack({ uni.navigateBack({
delta: 1 // delta1 delta: 1 // delta1
}); })
}, },
fail(err) { fail(err) {
console.error('获取已连接蓝牙设备信息失败:', err); console.error('获取已连接蓝牙设备信息失败:', err)
} }
}); })
} else { } else {
console.log('手机未连接网络'); console.log('手机未连接网络')
} }
} }
}); })
}, },
funListenDeviceMsgEvent: function(options) { funListenDeviceMsgEvent: function(options) {
switch (options.type) { switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) { if (options.result) {
let devicesarr = options.data this.devicesLists = options.data
// this.devicesList = options.data // let devicesarr = options.data
// console.log(devicesarr, 'devicesarrdevicesarr'); // // this.devicesList = options.data
devicesarr.forEach(device => { // // console.log(devicesarr, 'devicesarrdevicesarr');
const mac = device.name.substring(6); // devicesarr.forEach(device => {
// const mac = device.name.substring(6);
if (device.name.indexOf("BBLE") != -1) { // if (device.name.indexOf("BBLE") != -1) {
// this.$u.get(`/app/device/${mac}/isBind`).then((res) => { // // this.$u.get(`/app/device/${mac}/isBind`).then((res) => {
// if (res.data == false) { // // if (res.data == false) {
this.devicesLists.push(device); // this.devicesLists.push(device);
let uniqueDevicesList = Array.from(new Set(this.devicesLists)); // 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) {
// getisband(mac).then(res => { // // console.log(`MAC ${mac} `);
// console.log(res); // // } else {
// if (res.data == true) { // // this.devicesList.push(device)
// console.log(`MAC ${mac} `); // // }
// } else { // // }).catch(error => {
// this.devicesList.push(device) // // console.error(` MAC ${mac} :`, error);
// } // // });
// }).catch(error => {
// console.error(` MAC ${mac} :`, error);
// }); // });
});
} }
break; break
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED: case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
console.log("连接回调:" + JSON.stringify(options)); console.log("连接回调:" + JSON.stringify(options))
if (options.result) { if (options.result) {
uni.hideLoading(); uni.hideLoading()
uni.showToast({ uni.showToast({
title: '连接成功', title: '连接成功',
icon: 'none' icon: 'none'
}); { }); {
console.log("连接回调options.data.deviceId" + options.data.deviceId, console.log("连接回调options.data.deviceId" + options.data.deviceId,
"连接回调options.data.name" + options.data.name); "连接回调options.data.name" + options.data.name);
//
// let params = {
// mac: this.Bluetoothmac,
// userId: this.$store.state.user.userId
// }
xBlufi.notifyInitBleEsp32({ xBlufi.notifyInitBleEsp32({
deviceId: options.data.deviceId deviceId: options.data.deviceId
}); })
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);
// setTimeout(() => {
// this.sing()
// }, 3000)
let systemInfo = uni.getSystemInfoSync(); let systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform === 'android') { if (systemInfo.platform === 'android') {
// Android // Android
} else if (systemInfo.platform === 'ios') { } else if (systemInfo.platform === 'ios') {
// iOS // iOS
} }
} }
} }
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) {
console.log("蓝牙未开启", options); console.log("蓝牙未开启", options);
@ -397,18 +345,12 @@
} }
} else { } else {
this.searching = true this.searching = true
//
// _this.setData({
// searching: true
// });
} }
break; break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
if (options.result) { if (options.result) {
let uniqueDevicesList = Array.from(new Set(this.devicesLists)); let uniqueDevicesList = Array.from(new Set(this.devicesLists));
// this.devicesList // this.devicesList
this.devicesLists = uniqueDevicesList; this.devicesLists = uniqueDevicesList;
let list = [] let list = []
@ -418,19 +360,10 @@
// console.log(macFromName); // console.log(macFromName);
// this.mac // this.mac
list.push(device) list.push(device)
// this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => {
// if (res.data == false) {
// list.push(device)
// } else {
// }
// })
}); });
setTimeout(() => { setTimeout(() => {
this.devicesList = list this.devicesList = list
let uniqueDevicesList = Array.from(new Set(this.devicesList)); let uniqueDevicesList = Array.from(new Set(this.devicesList));
// this.devicesList // this.devicesList
this.devicesList = uniqueDevicesList; this.devicesList = uniqueDevicesList;
this.fetchDevicesBoundStatus(); this.fetchDevicesBoundStatus();
@ -552,7 +485,7 @@
// //
if (this.devicesList.length == 0) { if (this.devicesList.length == 0) {
this.tishiflag = true this.tishiflag = true
this.texts = '扫描完毕,暂无发现电动车设备' this.texts = '扫描完毕,请操作'
} else { } else {
this.texts = '扫描到以下设备,请点击连接!' this.texts = '扫描到以下设备,请点击连接!'
} }
@ -619,6 +552,8 @@
// padding-top: 136rpx !important; // padding-top: 136rpx !important;
padding: 0 66rpx; padding: 0 66rpx;
box-sizing: border-box; box-sizing: border-box;
padding-bottom: 200rpx;
box-sizing: border-box;
} }
.modal-overlay { .modal-overlay {
@ -752,7 +687,6 @@
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;
border-radius: 10rpx; border-radius: 10rpx;
.lt { .lt {
padding-left: 10rpx; padding-left: 10rpx;
box-sizing: border-box; box-sizing: border-box;