From 66d2c8d8c97e19fdbd969f97dd3d6a28f27c415f Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Wed, 01 Nov 2023 16:07:03 +0800 Subject: [PATCH] fix:小程序分享功能和秒级数据 --- pages/actionChange/secondLevelData/index.vue | 189 +++++++++++++++++++++++------------------------ 1 files changed, 92 insertions(+), 97 deletions(-) diff --git a/pages/actionChange/secondLevelData/index.vue b/pages/actionChange/secondLevelData/index.vue index e6b8a30..69fc5ea 100644 --- a/pages/actionChange/secondLevelData/index.vue +++ b/pages/actionChange/secondLevelData/index.vue @@ -1,31 +1,44 @@ <template> <view class="rootBg"> <view class=""> - <view class="ridoa"> + <view class="ridoaBox"> <u-radio-group v-model="value" placement="row" :size='radioOption.size' :labelColor='radioOption.labelColor' :labelSize='radioOption.labelSize' @change='changeSearchType'> - <u-radio activeColor="#19be6b" label="������������������" name="0" :labelSize='radioOption.labelSize' + <u-radio activeColor="#19be6b" label="Mac������" name="1" :labelSize='radioOption.labelSize' :labelColor='radioOption.labelColor'></u-radio> - <u-radio activeColor="#19be6b" label="������������������" name="1" :labelSize='radioOption.labelSize' + <u-radio activeColor="#19be6b" label="������������" name="0" :labelSize='radioOption.labelSize' + :labelColor='radioOption.labelColor'></u-radio> + <u-radio activeColor="#19be6b" label="������������������" name="2" :labelSize='radioOption.labelSize' :labelColor='radioOption.labelColor'></u-radio> </u-radio-group> </view> <view class="" v-if="value==='1'"> - <u-input placeholder="���������Mac���" :placeholderStyle='placeholderStyle' color="#fff" v-model='macName'> + <u-input placeholder="���������Mac���" :placeholderStyle='placeholderStyle' color="#fff" + customStyle="margin: 0 5px;" v-model='macName'> <template slot="suffix"> <u-button @tap="searchMacList" text="������" type="success" size="small"></u-button> </template> </u-input> </view> - <view class="" v-else> + <view class="orgSearch" v-else-if="value==='0'"> <u-form ref="uForm" label-width="80" :model="form"> <u-form-item border-bottom @click="showeEscalationTime = true ;hideKeyboard('orgName','orgId')"> - <u-input v-model="form.orgName" disabled disabled-color="#ffffff" placeholder="���������������" - type="select" /> + <u-input v-model="form.orgName" disabled disabled-color="#ffffff" customStyle="margin: 0 5px;" + placeholder="���������������" type="select" /> </u-form-item> <u-form-item border-bottom @click="selectSite"> - <u-input v-model="form.siteName" disabled disabled-color="#ffffff" placeholder="���������������" - type="select" /> + <u-input v-model="form.siteName" disabled disabled-color="#ffffff" customStyle="margin: 0 5px;" + placeholder="���������������" type="select" /> + </u-form-item> + </u-form> + <u-picker :show="showeEscalationTime" :columns="columns" @confirm="selectBack" keyName="name" + @cancel="showeEscalationTime = false"></u-picker> + </view> + <view class="" v-else-if="value==='2'"> + <u-form ref="uForm" label-width="80" :model="form"> + <u-form-item border-bottom @click="selecSpecial"> + <u-input v-model="form.specialName" disabled disabled-color="#ffffff" + customStyle="margin: 0 5px;" placeholder="���������������" type="select" /> </u-form-item> </u-form> <u-picker :show="showeEscalationTime" :columns="columns" @confirm="selectBack" keyName="name" @@ -55,9 +68,11 @@ <u-toast ref="uToast"></u-toast> <u-modal :show="showModel" title='���������Mac���' showCancelButton @cancel='showModel=false' @confirm='selectMac'> <view class="slot-content"> - <u-radio-group v-model="modeleMacSelect" iconPlacement="right" placement='column' borderBottom='true'> + <u-radio-group v-model="modeleMacSelect" iconPlacement="right" placement='column' borderBottom='true' + @change='clickMac'> <view v-for="(item,index) in macList" :key="index" class="ridioBox"> - <u-radio activeColor="#19be6b" :label="item.mac" :name="item.mac"></u-radio> + <u-radio activeColor="#19be6b" :label="`${item.typeName}: ${item.mac}`" + :name="item.mac"></u-radio> </view> </u-radio-group> </view> @@ -71,7 +86,7 @@ data() { return { modeleMacSelect: '', - value: '0', + value: '1', showModel: false, showeEscalationTime: false, columns: [], @@ -79,7 +94,9 @@ orgName: '', orgId: '', siteName: '', - siteId: '' + siteId: '', + specialName: '', + specialid: '' }, selectForm: { name: '', @@ -89,7 +106,7 @@ radioOption: { size: '20px', labelColor: '#fff', - labelSize: '18px' + labelSize: '18px', }, placeholderStyle: 'color: #fff', macName: '', @@ -111,7 +128,8 @@ // ������������������ alarmBg: {}, timer: '', - isLoading: true + isLoading: true, + specialType: '3' } }, filters: { @@ -124,14 +142,13 @@ computed: { windDirData() { if (this.wsData2) { - console.log('this.windDir', this.windDir) return `${this.windDir} (${this.wsData2.a01008})` } else { return '' } }, showData() { - return [...this.defaultMonitorItems, ...this.coreMonitorItems] + return [...this.coreMonitorItems, ...this.defaultMonitorItems] } }, created() { @@ -144,6 +161,10 @@ that.timer = '' }, methods: { + clickMac(e) { + this.specialType = this.macList.find(item => item.mac === e).specialType + console.log('specialType', this.specialType) + }, getData() { this.queryAlarmByMac() this.getHourlyAqi() @@ -151,12 +172,18 @@ }, changeSearchType() { this.macName = '' + if (this.value === '2') { + this.getSpeciallist() + } + if (this.value === '0') { + this.getOrgs() + } }, selectMac() { this.macName = this.modeleMacSelect this.showModel = false if (this.socketTask) { - this.socketTask.onClose() + this.socketTask.close() } this.getData() }, @@ -164,9 +191,12 @@ this.$http.httpGet('/AppDevice/fuzzySearch', { mac: this.macName }).then(res => { - this.showModel = true - if (res.data && res.data.length > 10) { - this.macList = res.data.slice(0, 10) + this.macList = [] + if (res.data && res.data.length > 0) { + this.macList = res.data + this.showModel = true + } else { + uni.$u.toast('������������') } }).catch(res => { uni.$u.toast(res) @@ -186,12 +216,18 @@ this.getSites() } }, + selecSpecial() { + this.selectForm = { + name: 'specialName', + id: 'specialId' + } + this.showeEscalationTime = true + }, hideKeyboard(name, id) { this.selectForm = { 'name': name, 'id': id } - this.getOrgs() }, selectBack(e) { if (this.selectForm.name === 'orgName') { @@ -204,12 +240,13 @@ } else { this.macName = e.value[0].mac if (this.socketTask) { - this.socketTask.onClose() + this.socketTask.close() } this.getData() } this.form[this.selectForm.name] = e.value[0].name this.form[this.selectForm.id] = e.value[0].id + this.specialType = e.value[0].specialType this.showeEscalationTime = false }, getOrgs() { @@ -222,16 +259,14 @@ }, getSites() { let params = { - organizationId: this.form.orgId + monitorPointId: this.form.orgId } this.$http.httpGet('/AppDevice/selectDevice', params).then(res => { - console.log(res) this.columns = [] this.columns.push(res.data) this.showeEscalationTime = true }).catch(res => { uni.$u.toast(res) - console.log(res) }) }, sensorLayout() { @@ -245,8 +280,21 @@ this.fixedMonitorItems = res.data.fixedMonitorItems this.totalArray.push(...this.coreMonitorItems, ...this.defaultMonitorItems, ...this .fixedMonitorItems) - this.getSensorMonthAvg() - this.connectSocket() + if (this.chartSensorKey.length > 0) { + this.getSensorMonthAvg() + this.connectSocket() + } else { + uni.$u.toast('������������') + } + }).catch(res => { + uni.$u.toast(res) + }) + }, + // ������������������ + getSpeciallist() { + this.$http.httpGet('/AppDevice/specialDevice').then(res => { + this.columns = [] + this.columns.push(res.data) }).catch(res => { uni.$u.toast(res) console.log(res) @@ -418,8 +466,6 @@ this.totalArray[i].alarm = this.alarmProgress[key] } } - console.log('this.totalArray', this.totalArray) - console.log('this.alarmColour', this.alarmColour) for (const key in this.alarmColour) { if (this.totalArray[i].sensorCode === key) { this.totalArray[i].colour = this.alarmColour[key] @@ -434,15 +480,18 @@ }, //������websocket connectSocket() { - if (!this.isLoading) { + if (this.socketTask) { this.socketTask.close() this.socketTask = null } this.baseUrl = this.$storage.get('baseUrl') let that = this let socketUrl = this.baseUrl + '/singleDevice/' + this.macName + if (this.specialType === '0') { + socketUrl = this.baseUrl + '/cruiserWebsocket/' + this.macName + } socketUrl = socketUrl.replace('https', 'wss').replace('http', 'ws') - console.log('������������websocket') + console.log('������������websocket', socketUrl) this.socketTask = uni.connectSocket({ url: socketUrl, success(res) { @@ -463,77 +512,16 @@ console.log('������������������������' + res.data) that.handlerMsg(res) //������������������������������������������ }) - this.socketTask.onError(function(res) { - console.log('WebSocket���������������������������������') - console.log(res) - // this.isSuccess = false - // that.connectSocket() - //������������������ - that.reconnect() - }) // // ������������������ - this.socketTask.onClose(e => { console.log('WebSocket���������������') - clearInterval(that.timer) - that.timer = '' - if (!that.isClose) { - that.reconnect() - } }) console.log(this.socketTask) - }, - //������������������ - reconnect() { - console.log('������������������') - this.socketTask.close() - this.socketTask = null - if (this.isLoading) { - this.connectSocket() - } - }, - //������������ - sendSocketMessage(msg) { - console.log('������������') - console.log(msg) - return new Promise((reslove, reject) => { - this.socketTask.send({ - data: msg, - success(res) { - console.log('������������') - reslove(res) - }, - fail(res) { - console.log('������������') - console.log(res) - reject(res) - } - }) - }) - }, - //������ - heart() { - let that = this - clearInterval(this.timer) - this.timer = '' - let msg = { - 'type': 'heartbeat', - } - this.timer = setInterval(() => { - that.sendSocketMessage(JSON.stringify(msg)).then(res => { - console.log('������������') - }).catch(res => { - console.log('������������') - console.log((res)) - }) - }, 2000) }, beforeDestroy() { if (this.socketTask) { this.socketTask.close() this.socketTask = null - } - if (this.timer) { - clearInterval(this.timer) // ���Vue������������������������������������������ } }, } @@ -566,7 +554,7 @@ justify-content: center; } - .ridoa { + .ridoaBox { text-align: center; padding: 10px 0px; } @@ -575,9 +563,11 @@ color: #fff; } - /deep/.u-form { - display: flex; - justify-content: space-evenly; + .orgSearch { + /deep/.u-form { + display: flex; + justify-content: space-evenly; + } } .slot-content { @@ -593,4 +583,9 @@ .ridioBox { margin-bottom: 10px; } + + /deep/.u-modal__content { + max-height: 300px; + overflow: auto; + } </style> \ No newline at end of file -- Gitblit v1.8.0