123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590 |
- <template>
- <view class="content">
- <view class="tabs">
- <u-tabs :list="tabList" @click="change" lineWidth="30" lineColor="#02A7F0" :activeStyle="{
- color: '#02A7F0',
- fontWeight: 'bold',
- transform:'scale(1.05)'
- }" :inactiveStyle="{
- color: '#000000',
- transform:'scale(1)'}" itemStyle="height: 50px; width: 33.3%;padding:0;border-bottom:1px solid #a0a0a0"></u-tabs>
- </view>
- <u-skeleton :animate="true" rows="17" title :loading='loading_skeleton'> <scroll-view scroll-y="true"
- :style="'height:'+wh+'px;'" @scrolltolower="scrolltolower">
- <u-swipe-action btn-width="500">
- <u-swipe-action-item v-if="show1" :options="options1" @click="click(item.id)"
- v-for="(item,index) in productList" :key="index">
- <view v-if="productList.length!==0" class="list-items">
- <view class="list-item" @click="toText(item)">
- <view class="left">
- <!-- 左 -->
- <view class="icon">
- <u-icon v-if="item.type!==0" name="lock-opened-fill" color="#3c9cff"
- size="25"></u-icon>
- <u-icon v-else name="eye-fill" color="#3c9cff" size="25"></u-icon>
- </view>
- <!-- 中 -->
- <view class="msg">
- <view class="id">
- {{item.deviceId}}
- </view>
- <view class="type">
- <text style="margin-right: 5px;">{{item.testTime|date}}</text>
- <text>信号值:{{item.signalNum}}</text>
- </view>
- </view>
- </view>
- <!-- 后 -->
- <view class="button" @click.stop="textBtn(item)">
- <u-button v-if="item.type==0" type="primary" size="small">风鸣</u-button>
- <u-button v-else type="primary" size="small">开门</u-button>
- </view>
- </view>
- </view>
- <view v-else class="noData" style="text-align: center;">
- 无数据
- </view>
- </u-swipe-action-item>
- </u-swipe-action>
- </scroll-view></u-skeleton>
- <view class="btn">
- <u-button size="large" type="primary" @click="search"> 点击进行蓝牙设备搜索</u-button>
- </view>
- <view class="scan" @click="scan">
- <img src="@/static/scan.png" alt="" style="width: 100rpx;height: 80rpx;">
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- loading_skeleton: false,
- gatewayFlag: 0,
- show1: true,
- options1: [{
- text: '删除',
- style: {
- backgroundColor: '#f56c6c'
- }
- }],
- wh: '',
- active: 0,
- tabList: [{
- name: '未检测',
- badge: {
- value: null,
- }
- }, {
- name: '检测失败',
- badge: {
- value: null,
- }
- }, {
- name: '检测成功',
- badge: {
- value: null,
- }
- },
- ],
- parameter: {
- testProjectId: uni.getStorageSync("testProjectId"),
- pageSize: 100,
- pageNo: 1,
- status: 2
- },
- total: 0,
- productList: [
- // {
- // deviceId:'b44f96f00ff0',
- // id:142,
- // signalNum:-65,
- // status:0,
- // type:1,
- // subType:1,
- // testProjectId:26,
- // testTime:'2023-11-02'
- // }
- ]
- }
- },
- methods: {
- scrolltolower() {
- // console.log('触底了');
- if (this.parameter.pageNo * this.parameter.pageSize >= this.total) {
- return uni.$showMsg('数据加载完毕')
- }
- this.parameter.pageNo++
- this.getBluetoothList()
- },
- toText(item) {
- console.log(item);
- uni.showModal({
- title: '温馨提示',
- content: "点击确定进入测试阶段",
- success: res => {
- if (res.confirm) {
- // this.show1 = false
- // this.$u.toast(`点击了确定`)
- let currentSite = JSON.stringify(item)
- // console.log(item);
- if (item.type === 0) {
- console.log('猫眼');
- console.log(item);
- uni.navigateTo({
- url: "/pages/cat-eye-test/cat-eye-test?item=" + currentSite
- })
- } else if (item.type == 1 && item.subType == 0 || item.subType == null) {
- uni.navigateTo({
- url: "/pages/lock-test/lock-test?item=" + currentSite
- })
- } else {
- uni.navigateTo({
- url: "/pages/door-lock-module/door-lock-module?item=" +
- currentSite
- })
- }
- } else {
- // this.$u.toast(`点击了取消`)
- }
- }
- })
- },
- async textBtn(item) {
- uni.showLoading({
- mask: true,
- title: '命令执行中',
- })
- if (item.type === 0) {
- console.log('我是猫眼');
- const {
- data: res
- } = await uni.$http.post('/api/v1/test/bluetooth/testCam', {
- deviceId: item.deviceId
- })
- if (res.code === 200) {
- uni.$showMsg('风鸣测试成功')
- } else {
- uni.$showMsg('测试失败')
- }
- } else {
- const {
- data: res
- } = await uni.$http.post('/api/v1/test/bluetooth/openDoor', {
- deviceId: item.deviceId
- })
- if (res.code === 200) {
- this.$u.toast(`开门测试成功`)
- } else {
- uni.$showMsg('测试失败')
- }
- }
- },
- change(index) {
- // this.current = index;
- // console.log(index.index);
- let current = index.index
- if (current == 0) {
- this.productList = []
- this.parameter.pageNo = 1
- this.parameter.status = 2
- this.getBluetoothList()
- } else if (current == 1) {
- this.productList = []
- this.parameter.pageNo = 1
- this.parameter.status = 0
- this.getBluetoothList()
- } else {
- this.productList = []
- this.parameter.pageNo = 1
- this.parameter.status = 1
- this.getBluetoothList()
- }
- },
- async scan() {
- uni.showLoading({
- title: "正在获取蓝牙设备",
- icon: 'none'
- })
- console.log('扫一扫');
- let arr = []
- const {
- data: res
- } = await uni.$http.post('/api/v1/test/testResult/queryByCondition', {
- testProjectId: uni.getStorageSync("testProjectId"),
- pageSize: 100,
- pageNo: 1,
- status: 2
- }, )
- uni.hideLoading()
- let that = this
- if (res.code == 200) {
- arr = res.data.records
- console.log(arr);
- uni.scanCode({
- scanType: ['barCode', 'qrCode'],
- success: function(res) {
- console.log('条码类型:' + res.scanType);
- console.log('条码内容:' + res.result);
- console.log(arr, 'arr的数据');
- let arr1 = arr.find((item) => {
- return item.deviceId == res.result.toLowerCase()
- })
- console.log(arr1, 'arr1的msg');
- let scanDeviced = JSON.stringify(arr1)
- if (!arr1) {
- return that.$u.toast(`未获取到设备信息`)
- } else {
- if (arr1.type == 0) {
- console.log('我是猫眼');
- uni.navigateTo({
- url: "/pages/cat-eye-test/cat-eye-test?item=" +
- scanDeviced
- })
- } else if (arr1.type == 1 && arr1.subType == 0 || arr1.subType ==
- null) {
- console.log('我是门锁');
- uni.navigateTo({
- url: "/pages/lock-test/lock-test?item=" + scanDeviced
- })
- } else {
- console.log('我是模块');
- uni.navigateTo({
- url: "/pages/door-lock-module/door-lock-module?item=" +
- scanDeviced
- })
- }
- }
- // if (arr1) {
- // uni.showToast({
- // icon: "error",
- // title: "未找到该设备"
- // })
- // } else {
- // if (arr1.type == 0) {
- // console.log(2);
- // uni.navigateTo({
- // url: "/pages/cat-eye-test/cat-eye-test?item=" +
- // scanDeviced
- // })
- // } else if (arr1.type == 1 && arr1.subType == 0 || arr1.subType ==
- // null) {
- // uni.navigateTo({
- // url: "/pages/lock-test/lock-test?item=" + scanDeviced
- // })
- // } else {
- // uni.navigateTo({
- // url: "/pages/door-lock-module/door-lock-module?item=" +
- // scanDeviced
- // })
- // }
- // }
- }
- });
- } else {
- this.$u.toast(`请重新获取蓝牙设备`)
- }
- },
- search() {
- this.searchBluetooth().then(() => {
- this.parameter.pageNo = 1
- this.productList = []
- this.getBluetoothList()
- })
- // console.log('点击了搜索');
- // this.productList = []
- // this.parameter.pageNo = 1
- // this.getBluetoothList()
- },
- // 右滑删除
- click(index) {
- console.log('click', index);
- uni.showModal({
- title: '温馨提示',
- content: '确定要删除吗?',
- success: async res => {
- if (res.confirm) {
- // this.show1 = false
- // this.$u.toast(`点击了确定`)
- uni.showLoading({
- mask: true,
- title: '正在删除中'
- })
- let {
- data: res
- } = await uni.$http.delete(`/api/v1/test/testResult/${index}`)
- console.log(res);
- if (res.code == 200) {
- this.productList = []
- this.getBluetoothList()
- } else {
- this.$u.toast(`删除失败`)
- }
- } else {
- // this.$u.toast(`点击了取消`)
- }
- }
- })
- },
- async getBluetoothList() {
-
- if (!uni.getStorageSync('testProjectId')) {
- return this.$u.toast(`未查询到测试项目,请前往后台添加测试项目`)
- }
- this.loading_skeleton=true
- console.log(11);
- this.gatewayFlag = 0
- // uni.showLoading({
- // mask: true,
- // title: '数据加载中'
- // })
- const {
- data: res
- } = await uni.$http.post('/api/v1/test/testResult/queryByCondition', this.parameter)
- uni.hideLoading()
- console.log(res);
- if (res.code === 200) {
- // let badge1 = res.data.records.filter((item) => {
- // return item.status = 2
- // })
- // console.log(badge1);
- this.total = res.data.total
- if (this.parameter.status == 2) {
- this.tabList[0].badge.value = res.data.total
- } else if (this.parameter.status == 0) {
- this.tabList[1].badge.value = res.data.total
- } else if (this.parameter.status == 1) {
- this.tabList[2].badge.value = res.data.total
- }
-
- uni.$showMsg('数据加载成功')
- this.loading_skeleton=false
- this.productList=[]
- this.productList = [
- ...this.productList,
- ...res.data.records
- ]
- } else {
- // uni.$showMsg('数据加载失败')
- console.log('数据加载失败');
- this.loading_skeleton=false
- }
- // console.log(this.productList);
- },
- async searchBluetooth() {
- this.productList = []
- uni.showLoading({
- mask: true,
- title: "网关扫描中",
- icon: 'none'
- })
- console.log(this.parameter.testProjectId);
- const {
- data: res
- } = await uni.$http.post('/api/v1/test/testProject/bluetooth/search', {
- testProjectId: this.parameter.testProjectId
- })
- if (res.code == 200) {
- this.gatewayFlag = 1
- uni.hideLoading()
- // this.$u.toast(`网关扫描成功`)
- } else {
- this.$u.toast(`网关失败,点击按钮重新扫描`)
- }
- console.log(res);
- },
- async getNum() {
- if (!uni.getStorageSync('testProjectId')) {
- return this.$u.toast(`未查询到测试项目,请前往后台添加测试项目`)
- }
- const {
- data: res
- } = await uni.$http.post('/api/v1/test/testResult/queryByCondition', {
- testProjectId: uni.getStorageSync("testProjectId"),
- pageSize: 100,
- pageNo: 1
- }, )
- let badge1 = res.data.records.filter((item) => {
- return item.status == 2
- })
- console.log(badge1.length);
- let badge2 = res.data.records.filter((item) => {
- return item.status == 1
- })
- let badge3 = res.data.records.filter((item) => {
- return item.status == 0
- })
- this.tabList[0].badge.value = badge1.length
- this.tabList[1].badge.value = badge3.length
- this.tabList[2].badge.value = badge2.length
- }
- },
- onShow() {
- this.getNum().then(() => {
- if (this.gatewayFlag = 1) {
- this.getBluetoothList()
- }
- })
- },
- onLoad() {
- let btn = uni.createSelectorQuery().in(this).select('.btn')
- btn.boundingClientRect(data => {
- let btnH = data.height
- // console.log(this.searchH)
- console.log(sysInfo.windowHeight - btnH - 50);
- this.wh = sysInfo.windowHeight - btnH - 50
- // console.log(this.wh);
- }).exec()
- const sysInfo = uni.getSystemInfoSync()
- this.parameter.testProjectId = uni.getStorageSync('testProjectId')
- console.log(this.parameter.testProjectId);
- this.getNum()
- this.searchBluetooth().then(() => {
- if (this.gatewayFlag = 1) {
- this.getBluetoothList()
- }
- })
- },
- }
- </script>
- <style lang="scss">
- // .tabs {
- // height: 100rpx;
- // display: flex;
- // justify-content: space-around;
- // align-items: center;
- // border-bottom: 1px solid #a0a0a0;
- // // background-color: red;
- // .tab-item {
- // border: 3px solid transparent;
- // padding-bottom: 10rpx;
- // // background-color: red;
- // &.active {
- // border-bottom: 3px solid #24acf2;
- // color: #1296db;
- // }
- // }
- // }
- .tabs {
- .u-tabs__wrapper__nav__line {
- margin-left: -12px;
- }
- }
- .btn {
- position: fixed;
- bottom: 0;
- width: 100%;
- }
- .scan {
- z-index: 9999;
- position: fixed;
- width: 120rpx;
- height: 120rpx;
- background-color: #3c9cff;
- bottom: 200rpx;
- right: 20vw;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .u-page__tag-item {
- margin-right: 40px;
- margin-top: 10px;
- }
- .u-demo-block__content {
- flex-direction: row;
- flex-wrap: wrap;
- align-items: center;
- }
- .list-item {
- width: calc(100vw - 20px);
- // margin: 28rpx 10px;
- // padding-bottom: 10rpx;
- padding: 28rpx 10px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid #a0a0a0;
- .left {
- display: flex;
- justify-content: center;
- align-items: center;
- .id {
- font-size: 14px
- }
- .type {
- text {
- margin-right: 5rpx;
- color: #a0a0a0;
- font-size: 12px
- }
- }
- .icon {
- margin-right: 10rpx;
- }
- }
- }
- </style>
|