869 lines
21 KiB
Vue
Raw Normal View History

<template>
<view class="qualitySpringback">
<view class="fixedheader">
<headers :showBack="true">
<view class="headerName">
测量情况
<!-- <text class="right_btn" @click="goHasMeasure">测量记录</text> -->
</view>
</headers>
</view>
<view class="content">
<view class="info_box">
<view class="chart_wrap">
<view class="title" style="color: #488dec">·测量情况·</view>
<view class="flex">
<view class="chart">
<image class="chart_img" src="/static/measure1.png"></image>
<view class="chart_text">
<view class="value"
>{{ form.horizontalMeasureNum }}/{{
form.horizontalMemberNum
}}</view
>
<view class="name">水平构件</view>
</view>
</view>
<view class="chart">
<image
class="chart_img"
src="/static/measure2.png"
style="height: 257rpx"
></image>
<view class="chart_text">
<view class="value"
>{{ form.verticalMeasureNum }}/{{
form.verticalMemberNum
}}</view
>
<view class="name">竖向构件</view>
</view>
</view>
</view>
</view>
</view>
<view
class="nav_list"
:style="{
'border-radius':
activeIndex == 1
? '24rpx 0 0 0'
: activeIndex == 2
? '0 24rpx 0 0'
: '0',
}"
>
<view
class="nav_item"
:class="{ active_item: activeIndex == 1 }"
@click="changeTab(1)"
>
<view class="text">设备列表</view>
<view class="bottom_box"></view>
</view>
<view
class="nav_item"
:class="{ active_item: activeIndex == 2 }"
@click="changeTab(2)"
>
<view class="text">测量记录</view>
<view class="bottom_box"></view>
</view>
</view>
<view class="page1" v-if="activeIndex == 1">
<view class="title">
<text style="color: #2a2b5b; opacity: 0.4">·设备列表·</text>
<button
type="primary"
plain
@click="getList()"
size="mini"
class="searchBluetooth"
>
<icon
v-show="!isSearching"
class="searchIcon"
color="#007aff"
type="search"
size="15"
/>
<loadingGig v-show="isSearching"></loadingGig>
<!-- <image src="/static/loading.png" class="loadingIcon"></image> -->
{{ isSearching ? "搜索蓝牙中" : "搜索蓝牙" }}
</button>
</view>
<!-- <input type="text" v-model="sendData" placeholder="" style="border:1px solid red;padding: 10rpx 20rpx;margin-bottom: 20rpx;" />
<button type="default" @click="send()">发送数据</button> -->
<view
class="listItem"
:class="
bleDeviceId == item.deviceId && isLinkFinished == '连接成功'
? 'linkFinishedItem'
: 'value'
"
v-for="(item, index) in bluetooth"
@click="conn(item)"
:key="index"
>
<view class="item_name"
>蓝牙编码<text class="value">{{
item.name ? item.name : item.deviceId
}}</text></view
>
<view class="item_name"
>信号强度<text class="value">{{ item.RSSI }}</text></view
>
<!-- <view class="item_name">边接状态<text class="value">{{isLink[index]==0?'未连接':isLink[index]==1?'连接中...':isLink[index]==2?'连接成功':
isLink[index]==3?'连接失败':isLink[index]==4?'已断开':''
}}</text></view> -->
<view class="item_name"
>连接状态<text
:class="bleDeviceId == item.deviceId ? 'primaryText' : 'value'"
>{{
bleDeviceId == item.deviceId ? isLinkFinished : "未连接"
}}</text
>
</view>
<view
class="animateBox"
v-show="
bleDeviceId == item.deviceId && isLinkFinished == '连接中...'
"
>
</view>
</view>
<view class="placeholderBox" v-if="bluetooth.length == 0">
<image class="noDataImg" src="/static/noData.png"></image>
<view class="text">暂未搜到蓝牙设备</view>
</view>
<view class="start_wrap">
<view class="start_btn" @click="measureBtn">开始测量</view>
<!-- <view class="start_btn" style="margin-top: 20rpx" @click="measureBtn(1)">开始测试</view> -->
</view>
</view>
<view class="page2" v-if="activeIndex == 2">
<selectPage :dataId="detailId"></selectPage>
</view>
</view>
<!-- <view class="tabBarBox">
<view class="item active">
<image src="/static/personManage/index.png" class="img"></image>
<view class="txt">
首页
</view>
</view>
<view class="item" @click="goHasMeasure">
<image src="/static/personManage/location.png" class="img"></image>
<view class="txt">
已测量
</view>
</view>
<view class="item" @click="queryStaff">
<image src="/static/personManage/search.png" class="img"></image>
<view class="txt">
浇筑令
</view>
</view>
</view> -->
</view>
</template>
<script>
import selectPage from "./selectPage.vue";
var times = 0;
import { getBlooth, createBLE, DeviceFound } from "@/static/js/BLEConn.js";
import loadingGig from "@/components/loadingGig.vue";
export default {
components: {
loadingGig,
selectPage,
},
data() {
return {
activeIndex: 1,
projectDetail: "",
bluetooth: [],
isLink: [],
totalSurveyNum: 0,
abnormalSurveyNum: 0,
sendData: "24535253F8230D0A",
bleDeviceId: "",
bleName: "",
isLinkFinished: "未连接", // 未连接 连接中... 连接成功 连接失败
isSearching: false,
platform: "",
detailId: "",
form: {
horizontalMeasureNum: 0,
horizontalMemberNum: 0,
verticalMeasureNum: 0,
verticalMemberNum: 0,
},
};
},
onLoad(options) {
this.detailId = options.id;
//24535253F8230D0A 正在回弹采集命令
//2445525396230D0A 停止回弹采集命令
//24524449DF230D0A 获取设备信息命令
this.projectDetail = JSON.parse(uni.getStorageSync("projectDetail"));
if (uni.getStorageSync("measureDevType")) {
uni.removeStorageSync("measureDevType");
}
this.getDevTotal();
// this.bluetooth=[
// {
// name:'aaaa',deviceId:'11111111',RSSI:'12'
// }
// ]
this.platform = uni.getStorageSync("systemInfo").platform;
// let that = this
// uni.getNetworkType({
// success: function (res) {
// console.log(res.networkType);
// if(res.networkType != 'none'){
// let outLineData = []
// if(uni.getStorageSync('outLineData')){
// outLineData = JSON.parse(uni.getStorageSync('outLineData'))
// that.uploadData(outLineData)
// }
// console.log(outLineData)
// }
// }
// });
},
methods: {
changeTab(val) {
this.activeIndex = val;
},
// uploadData(data){
// console.log(data)
// this.sendRequest({
// url: 'xmgl/massReboundSurveyArea/saveBatch',
// method: 'post',
// data: data,
// success: (res) => {
// if (res.code == 200) {
// console.log('res.result', res.result)
// uni.showToast({
// title: '离线数据上传成功!'
// })
// uni.removeStorageSync('outLineData');
// }
// }
// })
// },
// 搜索蓝牙列表
async getList() {
// uni.showLoading({
// title: '蓝牙搜索中...',
// icon: 'none'
// })
this.isSearching = true;
var flag = false; // 标记是否进入了getBLooth
this.closeDevConnect();
await getBlooth()
.then((res) => {
// console.log(res)
flag = true;
this.isSearching = false;
uni.showToast({
title: "蓝牙搜索完成",
icon: "none",
});
// console.log('第' + times + '次')
// if (res.devices.length == 0 && times <= 3) {
// times++
// this.getList()
// } else {
this.bluetooth = res.devices;
if (res.devices.length == 0) {
// uni.showToast({
// title: '请先开启手机定位',
// icon: 'none',
// mask: true
// })
this.checkOpenGPSServiceByAndroid();
}
console.log("蓝牙设备列表");
console.log(this.bluetooth);
// uni.hideLoading()
// times = 1
// // 打开弹框
// this.$refs.popup.open()
// this.scanBLE = true
// }
})
.catch((err) => {
flag = false;
// times = 1
});
// console.log(flag)
if (!flag) {
this.isSearching = false;
// uni.hideLoading()
let txt = "";
if (this.platform == "android") {
txt = "和定位";
}
uni.showToast({
title: "请先开启手机蓝牙" + txt,
icon: "none",
mask: true,
});
console.log("没有进入getBlooth");
}
},
checkOpenGPSServiceByAndroid() {
let system = uni.getSystemInfoSync(); // 获取系统信息
// console.log(system);
if (system.platform === "android") {
// 判断平台
var context = plus.android.importClass("android.content.Context");
var locationManager = plus.android.importClass(
"android.location.LocationManager"
);
var main = plus.android.runtimeMainActivity();
var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
uni.showModal({
title: "提示",
content: "请打开定位服务功能",
showCancel: false, // 不显示取消按钮
success() {
if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass(
"android.provider.Settings"
);
var intent = new Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS
);
main.startActivity(intent); // 打开系统设置GPS服务页面
} else {
console.log("GPS功能已开启");
}
},
});
}
}
},
addDevice(devName, devNo) {
this.sendRequest({
url: "xmgl/massReboundMeasureDev/add",
method: "post",
hideLoading: "true",
data: {
projectSn: this.projectDetail.projectSn,
devName: devName,
devNo: devNo,
},
success: (res) => {},
});
},
async closeDevConnect(id) {
if (this.bleDeviceId) {
let that = this;
uni.closeBLEConnection({
deviceId: this.bleDeviceId,
success(res) {
console.log("断开上一个连接的蓝牙");
that.bleDeviceId = "";
that.bleName = "";
that.isLinkFinished = "未连接";
},
});
}
},
// 2. 选中蓝牙并连接
async conn(item) {
// console.log(item)
// uni.showLoading({
// title: "正在连接...",
// icon: "loading",
// mask: true
// })
// await this.closeDevConnect(item.deviceId)
if (this.bleDeviceId) {
let that = this;
// that.closeBle().then(res => {
// // this.closeDiv = false
// // this.clear()
// // uni.hideLoading()
// console.log('断开蓝牙成功')
// }).catch(err => {
// // uni.hideLoading()
// console.log('断开蓝牙失败')
// })
// return new Promise((resolve, reject) => {
uni.closeBLEConnection({
deviceId: this.bleDeviceId,
success(res) {
console.log("断开上一个连接的蓝牙");
if (
that.bleDeviceId == item.deviceId &&
that.isLinkFinished == "连接成功"
) {
that.bleDeviceId = "";
that.bleName = "";
that.isLinkFinished = "未连接";
uni.showToast({
title: "已断开连接",
});
}
},
});
// })
if (
this.bleDeviceId == item.deviceId &&
that.isLinkFinished != "连接失败"
) {
console.log("停止接下来的操作");
return false;
}
}
// console.log('执行完closeDevConnect')
this.bleDeviceId = item.deviceId;
this.bleName = item.name;
this.isLinkFinished = "连接中...";
// connBLESuc++
let create = true; // 判断有没有进入createBLE
// '49535343-FE7D-4AE5-8FA9-9FAFD205E455'
await createBLE(item, "00001800-0000-1000-8000-00805F9B34FB")
.then((res) => {
console.log("createBLE " + res);
create = false;
this.isLinkFinished = "连接成功";
this.addDevice(item.name, item.deviceId);
})
.catch((err) => {
console.log("createBLE error");
// this.isLinkFinished = '连接失败'
create = false;
});
// setTimeout(() => {
// if (create) {
// console.log('没有进入回调')
// this.isLinkFinished = '连接失败'
// uni.hideLoading()
// setTimeout(() => {
// uni.showToast({
// // title: this.other.fail,
// title: "连接失败",
// icon: "none"
// })
// }, 500)
// }
// }, 3000)
},
getDevTotal() {
let that = this;
this.sendRequest({
url: "xmgl/massReboundMainMeasureRecord/selectPouringMeasureCount",
method: "post",
data: {
pouringId: that.detailId,
},
success: (res) => {
// that.totalSurveyNum = res.result.totalSurveyNum;
// that.abnormalSurveyNum = res.result.abnormalSurveyNum;
that.form = res.result;
setTimeout(() => {
this.getList();
}, 200);
},
});
},
measureBtn(val) {
uni.navigateTo({
url: "./detail?id=" + this.detailId + "&isAdd=true",
});
// if (this.isLinkFinished != '连接成功') {
// uni.showToast({
// title: '请先连接蓝牙'
// })
// } else {
// uni.navigateTo({
// url: './detail?id='+this.detailId + '&isAdd=true'
// });
// if(uni.getStorageSync('oldObj')){
// uni.removeStorageSync('oldObj');
// }
// if(val == 1){
// uni.navigateTo({
// url: './selectPage?isAdd=true&isTest=true'
// });
// } else {
// uni.navigateTo({
// url: './selectPage?isAdd=true'
// });
// }
// }
},
goHasMeasure() {
uni.navigateTo({
url: "./selectPage?isAdd=false",
});
},
queryStaff() {
uni.navigateTo({
url: "./pouringOrderManage",
});
},
},
};
</script>
<style scoped lang="scss">
.flex {
display: flex;
align-items: center;
justify-content: space-around;
}
.flex2 {
display: flex;
align-items: center;
}
.flex3 {
display: flex;
align-items: center;
justify-content: space-between;
}
.title {
text-align: center;
font-size: 30rpx;
letter-spacing: 1.4px;
line-height: 21px;
margin-bottom: 16rpx;
position: relative;
}
.content {
padding: 0px 0rpx 64rpx;
box-sizing: border-box;
width: 100%;
}
.info_box {
background: #5181f6;
padding: 0 30rpx;
padding-top: 20rpx;
padding-bottom: 40rpx;
}
.chart_wrap {
width: 100%;
// box-shadow: 0 4rpx 20rpx 0 rgba(212, 220, 236, 0.65);
box-shadow: 0px 11px 8px -3px rgba(36, 69, 150, 0.34);
border-radius: 16rpx;
background-color: #fff;
box-sizing: border-box;
padding: 20rpx 0 40rpx;
margin-top: 20rpx;
// margin-bottom: 40rpx;
}
.chart {
position: relative;
width: 266rpx;
height: 269rpx;
}
.chart_img {
width: 266rpx;
height: 269rpx;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 2;
}
.chart_text {
z-index: 999;
text-align: center;
position: relative;
top: 50%;
/*偏移*/
margin-top: -38px;
}
.chart_text .value {
font-size: 60rpx;
font-weight: 700;
margin-bottom: 10rpx;
}
.chart_text .name {
color: #54547c;
font-size: 30rpx;
line-height: 36rpx;
}
.listItem {
line-height: 52rpx;
margin-top: 30rpx;
box-shadow: 0 4rpx 20rpx 0 rgba(212, 220, 236, 0.65);
border-radius: 10rpx;
padding: 20rpx 30rpx;
font-size: 28rpx;
position: relative;
}
.linkFinishedItem {
background-color: rgba(219, 231, 243, 0.2);
}
.animateBox {
position: absolute;
left: 0;
top: 5%;
width: 80px;
height: 90%;
background: linear-gradient(
to right,
rgba(219, 231, 243, 0.2),
rgba(219, 231, 243, 0.8),
#dbe7f3
);
filter: blur(4px);
animation: mymove 1s infinite;
}
@keyframes mymove {
from {
left: 0px;
}
to {
left: 80%;
}
}
@-webkit-keyframes mymove
/*Safari and Chrome*/ {
from {
left: 0px;
}
to {
left: 80%;
}
}
.item_name {
color: rgba(42, 43, 91, 0.6);
}
.item .value {
color: #2a2b5b;
}
.item .active {
color: $uni-color-primary;
}
.start_wrap {
margin-top: 80rpx;
margin-bottom: 80rpx;
}
.start_btn {
text-align: center;
pos-bottom: 40rpx;
line-height: 90rpx;
width: 60%;
margin: 0 auto;
background-color: rgba(72, 141, 236, 1);
color: #fff;
border-radius: 70rpx;
box-shadow: 0 4rpx 4px 0 rgba(43, 141, 243, 0.42);
}
.start_btn:active {
background-color: rgba(65, 129, 254, 0.8);
}
.searchBluetooth {
position: absolute;
right: 0px;
top: -10rpx;
padding: 0 16rpx;
}
.tabBarBox {
display: flex;
align-items: center;
font-size: 24rpx;
border-top: 1px solid rgba(151, 151, 151, 0.2);
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 64rpx;
background-color: white;
z-index: 22;
.item {
flex: 1;
// display: inline-flex;
text-align: center;
color: rgba(148, 149, 173, 1);
.img {
width: 70rpx;
height: 70rpx;
}
&.active {
color: rgba(72, 141, 236, 1);
}
}
}
.placeholderBox {
margin: 100rpx auto;
}
.searchIcon {
vertical-align: middle;
margin-right: 6rpx;
}
.loadingIcon {
width: 30rpx;
height: 30rpx;
vertical-align: middle;
margin-right: 6rpx;
animation: mymove2 0.5s infinite;
}
@keyframes mymove2 {
from {
transform: rotate(0deg);
}
to {
transform: rotate(180deg);
}
}
@-webkit-keyframes mymove2
/*Safari and Chrome*/ {
from {
transform: rotate(0deg);
}
to {
transform: rotate(180deg);
}
}
.right_btn {
position: absolute;
right: 20rpx;
top: 50%;
font-size: 28rpx;
transform: translateY(-50%);
}
.headerName {
width: 100%;
box-sizing: border-box;
}
.nav_list {
display: flex;
height: 68rpx;
background: #7097f7;
.nav_item {
flex: 1;
// padding-left: 24rpx;
// margin-left: -24rpx;
z-index: 1;
height: 68rpx;
text-align: center;
position: relative;
line-height: 68rpx;
color: rgba(255, 255, 255, 0.68);
.bottom_box {
display: none;
}
}
.active_item {
background: #fff;
color: rgba(81, 129, 246, 1);
// margin-left: 0;
border-radius: 24rpx;
z-index: 2;
.text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 3;
}
.bottom_box {
display: block;
height: 20rpx;
position: absolute;
left: -20rpx;
bottom: 0;
z-index: 2;
width: calc(100% + 40rpx);
background: #fff;
}
.bottom_box::after {
content: "";
position: absolute;
width: 48rpx;
height: 68rpx;
right: -29rpx;
bottom: 0;
border-radius: 24rpx;
background: #7097f7;
}
.bottom_box::before {
content: "";
position: absolute;
width: 48rpx;
height: 48rpx;
left: -29rpx;
bottom: 0;
border-radius: 50%;
background: #7097f7;
}
}
}
.fixedHeader {
:deep(.headerBox) {
background: #5181f6;
color: #fff;
border: 0;
.backImg {
color: #fff !important;
}
.headerName {
padding-left: 0;
}
}
}
.page1 {
padding: 30rpx 30rpx 0;
}
</style>