|
@@ -1,6 +1,9 @@
|
|
|
<template>
|
|
|
<view class="u-page">
|
|
|
-
|
|
|
+ <view class="" style="height: 44px;margin-bottom: 88rpx;">
|
|
|
+ <u-navbar bgColor="#3c9cff" title="门锁测试" @leftClick="leftClick">
|
|
|
+ </u-navbar>
|
|
|
+ </view>
|
|
|
<view class="u-demo-block">
|
|
|
<view class="u-demo-block__content steps">
|
|
|
<u-steps :current="current1" direction="column">
|
|
@@ -18,8 +21,27 @@
|
|
|
|
|
|
</view>
|
|
|
<view class="upload">
|
|
|
- <u-button type="primary" size="large" :disabled="btnShow">完成测试并上传信息</u-button>
|
|
|
+ <u-button type="primary" size="large" @click="uploadTestMsg">完成测试并上传信息</u-button>
|
|
|
</view>
|
|
|
+ <u-popup customStyle="width: 70vw" :round="10" mode="center" :show="show7" @close="close">
|
|
|
+ <view class="popupView" style="height: 150px;">
|
|
|
+ <view class="power">
|
|
|
+ 功耗选择
|
|
|
+ </view>
|
|
|
+ <view class="inputNum" style="">
|
|
|
+ <view class="">
|
|
|
+ 功耗:
|
|
|
+ </view>
|
|
|
+ <u--input placeholder="请输入功耗" border="surround" v-model="value" @change="changeInput"></u--input>
|
|
|
+ </view>
|
|
|
+ <u-radio-group placement="row">
|
|
|
+ <u-radio :customStyle="{margin: '15px 30px'}" v-for="(item, index) in radiolist1" :key="index"
|
|
|
+ :label="item.value" :name="item.powerRefs" @change="radioChange" iconPlacement="right">
|
|
|
+ </u-radio>
|
|
|
+ </u-radio-group>
|
|
|
+
|
|
|
+ </view>
|
|
|
+ </u-popup>
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
@@ -28,188 +50,346 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ value: '',
|
|
|
+ uploadMsg: {
|
|
|
+ testProjectId: uni.getStorageSync('testProjectId'),
|
|
|
+ deviceId: "",
|
|
|
+ type: null
|
|
|
+ },
|
|
|
+ radiolist1: [{
|
|
|
+ value: '通过',
|
|
|
+ disabled: false,
|
|
|
+ powerRefs: true
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '不通过',
|
|
|
+ disabled: false,
|
|
|
+ powerRefs: false
|
|
|
+ }
|
|
|
+
|
|
|
+ ],
|
|
|
+ show7: false,
|
|
|
+ flag: 0,
|
|
|
timer: null,
|
|
|
+ cardPass: false,
|
|
|
room: {
|
|
|
- deviceId: "b44f96f00ff0",
|
|
|
+ deviceId: "",
|
|
|
hotelId: 3,
|
|
|
building: 2,
|
|
|
floor: 7,
|
|
|
room: "7728"
|
|
|
},
|
|
|
- deviceId: '',
|
|
|
- btnShow: true,
|
|
|
+ gatewayDeviceId: uni.getStorageSync('gatewayDeviceId'),
|
|
|
+
|
|
|
show: false,
|
|
|
current1: null,
|
|
|
- timer: null,
|
|
|
stepList: [{
|
|
|
id: 0,
|
|
|
title: '测试信号',
|
|
|
- desc: '20022-09-08',
|
|
|
+ desc: '测试蓝牙设备信号值是否通过',
|
|
|
error: false
|
|
|
}, {
|
|
|
id: 1,
|
|
|
title: '蓝牙测试开门',
|
|
|
- desc: '20022-09-08',
|
|
|
+ desc: '测试蓝牙进行门锁开门',
|
|
|
error: false
|
|
|
},
|
|
|
{
|
|
|
id: 2,
|
|
|
title: '测试刷卡',
|
|
|
- desc: '20022-09-08',
|
|
|
+ desc: '房间信息已经植入,请进行刷卡验证',
|
|
|
error: false
|
|
|
},
|
|
|
|
|
|
{
|
|
|
id: 3,
|
|
|
title: '测试功率',
|
|
|
- desc: '20022-09-08',
|
|
|
+ desc: '验证功耗是否通过',
|
|
|
error: false
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
methods: {
|
|
|
- // 得到网关的id
|
|
|
- async getGatewayDeviceId() {
|
|
|
- let msg = {
|
|
|
- userId: uni.getStorageSync('userId'),
|
|
|
- pageNo: 1,
|
|
|
- pageSize: 10
|
|
|
- }
|
|
|
- const {
|
|
|
- data: res
|
|
|
- } = await uni.$http.post('/api/v1/test/testProject/queryByCondition', msg)
|
|
|
- if (res.code === 200) {
|
|
|
+ changeInput(e) {
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
+
|
|
|
+ leftClick() {
|
|
|
+ console.log('模态框');
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showModal({
|
|
|
+ title: '温馨提示',
|
|
|
+ content: '确定取消上传本次测试信息吗?',
|
|
|
+ success: res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ // this.show1 = false
|
|
|
+ this.$u.toast(`点击了确定`)
|
|
|
+ this.flag = 99
|
|
|
+ // console.log(this.flag);
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
|
|
|
- this.deviceId = res.data.records[0].gatewayDeviceId
|
|
|
- } else {
|
|
|
- console.log(111111111111);
|
|
|
- }
|
|
|
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$u.toast(`点击了取消`)
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
+
|
|
|
// 测试网关连接
|
|
|
async testGateway() {
|
|
|
- console.log(this.deviceId);
|
|
|
uni.showLoading({
|
|
|
- title: '网关测试连接中',
|
|
|
+ mask: true,
|
|
|
+ title: '正在测试网关连接',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
const {
|
|
|
data: res
|
|
|
- } = await uni.$http.get(`/api/v1/test/gateway/connection/${this.deviceId}`)
|
|
|
+ } = await uni.$http.get(`/api/v1/test/gateway/connection/${this.gatewayDeviceId}`)
|
|
|
+ uni.hideLoading()
|
|
|
if (res.data.isConnect == true) {
|
|
|
- uni.hideLoading()
|
|
|
- uni.showToast({
|
|
|
- duration: 1500,
|
|
|
- title: '网关连接成功',
|
|
|
- icon: 'success'
|
|
|
- })
|
|
|
+ this.flag = 1
|
|
|
+ console.log('网关连接成功');
|
|
|
} else {
|
|
|
console.log('网关连接失败');
|
|
|
+ this.$u.toast(`网关连接失败`)
|
|
|
}
|
|
|
},
|
|
|
// 测试信号
|
|
|
async testSignal(obj) {
|
|
|
uni.showLoading({
|
|
|
- title: '信号测试中',
|
|
|
+ mask: true,
|
|
|
+ title: '正在测试信号',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
const {
|
|
|
data: res
|
|
|
} = await uni.$http.post('/api/v1/test/bluetooth/checkSignal', obj)
|
|
|
- console.log(res);
|
|
|
+ uni.hideLoading()
|
|
|
if (res.data.isNormal == true) {
|
|
|
- uni.hideLoading()
|
|
|
- this.current1 = 0
|
|
|
- console.log('信号测试');
|
|
|
+ this.current1 = 1
|
|
|
+ this.flag = 2
|
|
|
+ console.log('信号测试成功');
|
|
|
} else {
|
|
|
+ this.stepList[0].error = true
|
|
|
console.log('信号测试失败');
|
|
|
- console.log(11111111111111);
|
|
|
+ this.$u.toast(`信号测试失败`)
|
|
|
}
|
|
|
- },
|
|
|
+ },
|
|
|
// 下发房间号
|
|
|
async updataTime() {
|
|
|
uni.showLoading({
|
|
|
+ mask: true,
|
|
|
icon: 'none',
|
|
|
- title: "正在加载中",
|
|
|
-
|
|
|
+ title: "正在下发房间号"
|
|
|
})
|
|
|
const {
|
|
|
data: res
|
|
|
} = await uni.$http.post('/api/v1/test/bluetooth/setRoom', this.room)
|
|
|
- console.log(res);
|
|
|
+ uni.hideLoading()
|
|
|
if (res.code == 200) {
|
|
|
- uni.hideLoading()
|
|
|
+ this.flag = 4
|
|
|
+ console.log('时间更新成功');
|
|
|
} else {
|
|
|
+ this.$u.toast(`时间更新失败`)
|
|
|
console.log('时间更新失败');
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
// 测试开门
|
|
|
async openDoor() {
|
|
|
uni.showLoading({
|
|
|
- title: '测试开门中',
|
|
|
+ mask: true,
|
|
|
+ title: '蓝牙开门测试中',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
const {
|
|
|
data: res
|
|
|
} = await uni.$http.post('/api/v1/test/bluetooth/openDoor', {
|
|
|
- deviceId: "b44f96f00ff0"
|
|
|
+ deviceId: this.room.deviceId
|
|
|
})
|
|
|
- console.log(res);
|
|
|
+ uni.hideLoading()
|
|
|
if (res.code == 200) {
|
|
|
- this.current1 = 1
|
|
|
+ this.current1 = 2
|
|
|
+ this.flag = 3
|
|
|
uni.$u.toast(`开门成功`)
|
|
|
- uni.hideLoading()
|
|
|
-
|
|
|
-
|
|
|
+ console.log('开门成功');
|
|
|
+ } else {
|
|
|
+ this.stepList[1].error = true
|
|
|
+ console.log('开门失败');
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
// 测试刷卡
|
|
|
async swipe() {
|
|
|
- uni.showLoading({
|
|
|
- title: '请刷卡',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
const {
|
|
|
data: res
|
|
|
} = await uni.$http.post('/api/v1/test/bluetooth/queryOpenDoorRes', {
|
|
|
- deviceId: "b44f96f00ff0"
|
|
|
+ deviceId: this.room.deviceId,
|
|
|
+ type: 5,
|
|
|
+
|
|
|
})
|
|
|
- console.log(res);
|
|
|
+ // console.log(res);
|
|
|
if (res.data.cardOpenDoorRes === true) {
|
|
|
- uni.hideLoading()
|
|
|
- this.current1 = 2
|
|
|
+ this.current1 = 3
|
|
|
+ this.cardPass = true
|
|
|
+ this.flag = 5
|
|
|
+ console.log('开门记录');
|
|
|
uni.$u.toast(`刷卡开门成功`)
|
|
|
} else {
|
|
|
- this.$u.toast(`刷卡失败`)
|
|
|
+ // this.stepList[2].error = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ radioChange(n) {
|
|
|
+ console.log(n);
|
|
|
+ if (n) {
|
|
|
+ this.current1 = 4
|
|
|
+ this.show7 = false
|
|
|
+ this.flag = 6
|
|
|
+ } else {
|
|
|
+ this.stepList[3].error = true
|
|
|
+ this.show7 = false
|
|
|
+ }
|
|
|
+ // this.show7 = false
|
|
|
+
|
|
|
+ },
|
|
|
+ async uploadTest() {
|
|
|
+ uni.showLoading({
|
|
|
+ mask: true,
|
|
|
+ title: "正在上传本次测试结果",
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ let {
|
|
|
+ data: res
|
|
|
+ } = await uni.$http.post('/api/v1/test/testResult', this.uploadMsg)
|
|
|
+ uni.hideLoading()
|
|
|
+ console.log(res);
|
|
|
+ if (res.code == 200) {
|
|
|
+ uni.$showMsg('上传成功')
|
|
|
+ // uni.switchTab({
|
|
|
+ // url: "/pages/bluetooth/bluetooth"
|
|
|
+ // })
|
|
|
+ } else {
|
|
|
+ uni.$showMsg('上传失败')
|
|
|
}
|
|
|
},
|
|
|
+ uploadTestMsg() {
|
|
|
+
|
|
|
+ if (this.flag == 1 || this.flag == 0) {
|
|
|
+ console.log('失败的案例');
|
|
|
+ console.log(this.uploadMsg);
|
|
|
+ this.$set(this.uploadMsg, 'status', 0)
|
|
|
+ // this.$set(this.uploadMsg, 'signlRes', false)
|
|
|
+ // this.$set(this.uploadMsg, 'doorOpenRes', false)
|
|
|
+ // this.$set(this.uploadMsg, 'powerRes', false)
|
|
|
+ // this.$set(this.uploadMsg, 'cardOpenRes', false)
|
|
|
+ this.uploadTest()
|
|
|
+ }
|
|
|
+ if (this.flag == 2) {
|
|
|
+ this.$set(this.uploadMsg, 'status', 0)
|
|
|
+ this.$set(this.uploadMsg, 'signlRes', true)
|
|
|
+ // this.$set(this.uploadMsg, 'doorOpenRes', false)
|
|
|
+ // this.$set(this.uploadMsg, 'powerRes', false)
|
|
|
+ // this.$set(this.uploadMsg, 'cardOpenRes', false)
|
|
|
+ this.uploadTest()
|
|
|
+ }
|
|
|
+ if (this.flag == 3 || this.flag == 4) {
|
|
|
+ this.$set(this.uploadMsg, 'status', 0)
|
|
|
+ this.$set(this.uploadMsg, 'signlRes', true)
|
|
|
+ this.$set(this.uploadMsg, 'doorOpenRes', true)
|
|
|
+ // this.$set(this.uploadMsg, 'powerRes', false)
|
|
|
+ // this.$set(this.uploadMsg, 'cardOpenRes', false)
|
|
|
+ this.uploadTest()
|
|
|
+ }
|
|
|
+ if (this.flag == 5) {
|
|
|
+ this.$set(this.uploadMsg, 'status', 0)
|
|
|
+ this.$set(this.uploadMsg, 'signlRes', true)
|
|
|
+ this.$set(this.uploadMsg, 'doorOpenRes', true)
|
|
|
+ // this.$set(this.uploadMsg, 'powerRes', false)
|
|
|
+ this.$set(this.uploadMsg, 'cardOpenRes', true)
|
|
|
+ this.uploadTest()
|
|
|
+ }
|
|
|
+ if (this.flag == 6) {
|
|
|
+ this.$set(this.uploadMsg, 'status', 1)
|
|
|
+ this.$set(this.uploadMsg, 'signlRes', true)
|
|
|
+ this.$set(this.uploadMsg, 'doorOpenRes', true)
|
|
|
+ this.$set(this.uploadMsg, 'powerRes', true)
|
|
|
+ this.$set(this.uploadMsg, 'cardOpenRes', true)
|
|
|
+ this.uploadTest()
|
|
|
+ }
|
|
|
+ // else {
|
|
|
+ // console.log('失败的案例');
|
|
|
+ // console.log(this.uploadMsg);
|
|
|
+ // this.$set(this.uploadMsg, 'status', 0)
|
|
|
+
|
|
|
+ // this.uploadTest()
|
|
|
+ // }
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
let item = JSON.parse(option.item)
|
|
|
- console.log(item);
|
|
|
+ // console.log(item);
|
|
|
+ this.uploadMsg.deviceId = item.deviceId
|
|
|
+ this.uploadMsg.type = item.type
|
|
|
+ this.room.deviceId = item.deviceId
|
|
|
const obj = {
|
|
|
- testProjectId: 26,
|
|
|
- deviceId: "b44f96f00ff0"
|
|
|
+ testProjectId: uni.getStorageSync('testProjectId'),
|
|
|
+ deviceId: item.deviceId
|
|
|
}
|
|
|
- this.getGatewayDeviceId().then(() => {
|
|
|
- this.testGateway().then(() => {
|
|
|
- this.testSignal(obj).then(() => {
|
|
|
+
|
|
|
+ this.testGateway().then(() => {
|
|
|
+ if (this.flag != 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.testSignal(obj).then(() => {
|
|
|
+ if (this.flag != 2) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.openDoor().then(() => {
|
|
|
+ if (this.flag != 3) {
|
|
|
+ return
|
|
|
+ }
|
|
|
this.updataTime().then(() => {
|
|
|
- this.swipe().then(() => {
|
|
|
- console.log('刷卡开门成功了');
|
|
|
+ if (this.flag != 4) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.showLoading({
|
|
|
+ mask: true,
|
|
|
+ title: "请刷卡",
|
|
|
+ icon: "none"
|
|
|
})
|
|
|
+ let counter = 0
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ console.log(counter);
|
|
|
+ // 一分钟之后不再自动调取接口
|
|
|
+ if (counter == 11) {
|
|
|
+ uni.hideLoading()
|
|
|
+ clearInterval(this.timer)
|
|
|
+ this.stepList[2].error = true
|
|
|
+ this.$u.toast(`检测到未刷卡`)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.cardPass == true) {
|
|
|
+ this.show7 = true
|
|
|
+ uni.hideLoading()
|
|
|
+ clearInterval(this.timer)
|
|
|
+ }
|
|
|
+ counter++
|
|
|
+ this.swipe()
|
|
|
+ }, 5000)
|
|
|
})
|
|
|
-
|
|
|
})
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
|
|
|
+
|
|
|
+ })
|
|
|
})
|
|
|
+
|
|
|
},
|
|
|
|
|
|
}
|
|
@@ -246,6 +426,22 @@
|
|
|
bottom: 0;
|
|
|
width: 100vw;
|
|
|
}
|
|
|
+
|
|
|
+ .power {
|
|
|
+ text-align: center;
|
|
|
+ margin: 13px 0 20px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .inputNum {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ padding: 0 20rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .u-radio-group {
|
|
|
+ margin-top: 20rpx;
|
|
|
+ }
|
|
|
</style>
|
|
|
<!-- this.timer = setInterval(() => {
|
|
|
this.current1++
|