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/workOrderDetails/index.vue | 64 ++++++- pages/actionChange/agencyPage/index.vue | 2 utils/permission.js | 55 ++++++ pages/actionChange/secondLevelData/index.vue | 189 +++++++++++------------ manifest.json | 8 - pages.json | 135 ++++++---------- utils/share.js | 2 App.vue | 12 + 8 files changed, 263 insertions(+), 204 deletions(-) diff --git a/App.vue b/App.vue index 1e09fad..3380106 100644 --- a/App.vue +++ b/App.vue @@ -3,6 +3,7 @@ getDic } from '@/utils/login.js' // ������������ import store from '@/store/index.js' + import routingIntercept from '@/utils/permission.js' import { httpPost, httpGet @@ -20,6 +21,7 @@ httpGet('/AppUser/wx/login', { 'code': loginRes.code }).then(result => { + routingIntercept() try { if (result.data.code === 0) { uni.clearStorageSync() @@ -55,6 +57,7 @@ title: errors, icon: 'none', }) + this.$isResolve() }) } }) @@ -149,4 +152,13 @@ line-height: 30px !important; } } + + .ridoaBox { + text-align: center; + padding: 10px 0px; + + /deep/.u-radio { + padding-right: 10px; + } + } </style> \ No newline at end of file diff --git a/manifest.json b/manifest.json index e69eee1..3c45bf9 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,6 @@ "versionName": "1.0.0", "versionCode": "100", "transformPx": false, - /* 5+App������������ */ "app-plus": { "usingComponents": true, "nvueStyleCompiler": "uni-app", @@ -16,11 +15,8 @@ "autoclose": true, "delay": 0 }, - /* ������������ */ "modules": {}, - /* ������������������ */ "distribute": { - /* android������������ */ "android": { "permissions": ["<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", @@ -39,15 +35,11 @@ "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" ] }, - /* ios������������ */ "ios": {}, - /* SDK������ */ "sdkConfigs": {} } }, - /* ��������������������� */ "quickapp": {}, - /* ��������������������� */ "mp-weixin": { "appid": "wxf95fb77e0b1f8c09", "__usePrivacyCheck__": true, diff --git a/pages.json b/pages.json index 395274f..4db1e4e 100644 --- a/pages.json +++ b/pages.json @@ -1,88 +1,53 @@ { - "pages": [ - //pages���������������������������������������������������https://uniapp.dcloud.io/collocation/pages - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "������", - "enablePullDownRefresh": false, - "disableSwipeBack": true, - "navigationStyle": "custom" - } - }, { - "path": "pages/actionChange/agencyPage/index", - "style": { - "navigationBarTitleText": "������", - "navigationStyle": "custom", - "enablePullDownRefresh": false - } - }, { - "path": "pages/login/login" - }, { - "path": "pages/login/register/register", - "style": { - "navigationBarTitleText": "������", - "enablePullDownRefresh": false - } - }, { - "path": "pages/actionChange/newPage/index", //��������������������������� - "style": { - "navigationBarTitleText": "���������������", - "enablePullDownRefresh": false - } - }, { - "path": "pages/actionChange/workOrderDetails/index", //��������������������������� - "style": { - "navigationBarTitleText": "���������������", - "enablePullDownRefresh": false - } - }, { - "path": "pages/actionChange/myInfor/index", - "style": { - "navigationBarTitleText": "������", - "enablePullDownRefresh": false, - "disableSwipeBack": true, - "navigationStyle": "custom" - } - }, { - "path": "pages/actionChange/secondLevelData/index", - "style": { - "navigationBarTitleText": "������������", - "enablePullDownRefresh": false, - "disableSwipeBack": true - } + "pages": [{ + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "������", + "enablePullDownRefresh": false, + "disableSwipeBack": true, + "navigationStyle": "custom" } - ] - // "tabBar": { - // "color": "#515151", - // "height": "60px", - // "fontSize": "60px", - // "selectedFontSize": 20, - // "selectedColor": "#3875C5", - // "list": [{ - // "text": "������", - // "pagePath": "pages/actionChange/agencyPage/index", - // "iconPath": "static/img/shouye.png", - // "selectedIconPath": "static/img/shouyeClick.png", - // "textStyle": { - // "fontSize": "60px" - // } - // }, { - // "text": "���������������", - // "pagePath": "pages/actionChange/newPage/index", - // "iconPath": "static/img/xinjian.png", - // "selectedIconPath": "static/img/xinjianClick.png", - // "textStyle": { - // "fontSize": "20px" - // } - // }, { - // "text": "������", - // "iconPath": "static/img/wode-.png", - // "selectedIconPath": "static/img/wodeClick.png", - // "pagePath": "pages/actionChange/myInfor/index", - // "textStyle": { - // "fontSize": "20px" - // } - // }] - // } + }, { + "path": "pages/actionChange/agencyPage/index", + "style": { + "navigationBarTitleText": "������", + "navigationStyle": "custom", + "enablePullDownRefresh": false + } + }, { + "path": "pages/login/login" + }, { + "path": "pages/login/register/register", + "style": { + "navigationBarTitleText": "������", + "enablePullDownRefresh": false + } + }, { + "path": "pages/actionChange/newPage/index", + "style": { + "navigationBarTitleText": "���������������", + "enablePullDownRefresh": false + } + }, { + "path": "pages/actionChange/workOrderDetails/index", + "style": { + "navigationBarTitleText": "���������������", + "enablePullDownRefresh": false + } + }, { + "path": "pages/actionChange/myInfor/index", + "style": { + "navigationBarTitleText": "������", + "enablePullDownRefresh": false, + "disableSwipeBack": true, + "navigationStyle": "custom" + } + }, { + "path": "pages/actionChange/secondLevelData/index", + "style": { + "navigationBarTitleText": "������������", + "enablePullDownRefresh": false, + "disableSwipeBack": true + } + }] } \ No newline at end of file diff --git a/pages/actionChange/agencyPage/index.vue b/pages/actionChange/agencyPage/index.vue index 68b842e..1313d84 100644 --- a/pages/actionChange/agencyPage/index.vue +++ b/pages/actionChange/agencyPage/index.vue @@ -352,7 +352,7 @@ data.pageState = e.stateName === '���������' ? pageState : 'view' let myData = JSON.stringify(data) uni.navigateTo({ - url: '/pages/actionChange/workOrderDetails/index?infor=' + myData, + url: '/pages/actionChange/workOrderDetails/index?infor=' + myData + '&type=jump', }) }) }, 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 diff --git a/pages/actionChange/workOrderDetails/index.vue b/pages/actionChange/workOrderDetails/index.vue index 2520f8d..3bfbe07 100644 --- a/pages/actionChange/workOrderDetails/index.vue +++ b/pages/actionChange/workOrderDetails/index.vue @@ -14,6 +14,8 @@ <u-button shape="square" type="primary" @click="submit"> ������ </u-button> </view> </view> + <u-overlay :show="show" :mask-click-able='false' opacity='0.8'> + </u-overlay> </view> </template> <script> @@ -28,27 +30,65 @@ }, data() { return { - basicInfor: {} + basicInfor: {}, + unitListL: [], + userInfor: null, + show: false } }, computed: { pageState() { return this.basicInfor.pageState - } + }, + }, + created() { + this.getUnitList() }, onLoad: function(option) { - console.log('option', option) //option���object������������������������������������������������ this.basicInfor = JSON.parse(option.infor) - this.share.title = '���������������' - }, - onBackPress(e) { - uni.navigateBack({ - delta: 1, //������������������������������������������2 - }) - return false + // let type = JSON.parse(option.type) + console.log('option', option) + this.userInfor = JSON.parse(uni.getStorageSync('userInfor') || 'null') + if (option.type === 'share' && this.userInfor) { + let params = { + allocationNum: this.basicInfor.allocationNum, + userId: this.userInfor.userId + } + this.$http.httpGet('/allocationApp/authority', params).then(res => { + res.data = false + if (!res.data) { + uni.showModal({ + content: '���������������������������������������������', + showCancel: false, + confirmText: '������', + success: res => { + if (res.confirm) { + uni.reLaunch({ + url: '/pages/index/index', + }) + } + }, + }) + } + }) + } + console.log('this.basicInfor ', this.basicInfor) }, methods: { + closePop() {}, + getUnitList() { + this.$http.httpGet('/allocation/unit').then(res => { + this.unitList = res.data + let data = '' + if (this.basicInfor.unitId && this.unitList.length > 0) { + data = this.unitList && this.unitList.find(a => Number(a.unitId) === Number(this.basicInfor + .unitId)).unitName + let time = this.basicInfor.time.slice(5) + this.share.title = `${data}-${time}������������` + } + }) + }, radioGroupChange(e) { console.log('radioGroupe���e', this.workForme.isChange) }, @@ -59,8 +99,8 @@ showTabBar: true } }) - uni.navigateBack({ - delta: 1, //������������������������������������������2 + uni.redirectTo({ + url: '/pages/index/index', }) }, refuse() { diff --git a/utils/permission.js b/utils/permission.js new file mode 100644 index 0000000..3470425 --- /dev/null +++ b/utils/permission.js @@ -0,0 +1,55 @@ +// ��������� +const whiteList = [, // ������������������������������ '/' + '/pages/login/login' +] +export default async function() { + const list = ['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'] + // ������������������������ + list.forEach(item => { + uni.addInterceptor(item, { + // ��������������� + invoke(args) { + console.log('navigateTo������������������', args) + const token = uni.getStorageSync('tonken') + const url = args.url.split('?')[0] + if (token) { + if (args.url.includes('/pages/login/login')) { + //��������������� + uni.navigateTo({ url: '/pages/index/index', }) + return false + } + return args + } else { + let pass + if (whiteList) { + pass = whiteList.some(whiteItem => { + if (typeof(whiteItem) === 'object' && whiteItem.pattern) { + return whiteItem.pattern.test(url) + } + return url === whiteItem + }) + } + console.log('pass', pass) + if (!pass) { + uni.showModal({ + title: '���������', + content: '������������������������������������������', + showCancel: false, + confirmText: '������', + success: res => { + if (res.confirm) { + uni.reLaunch({ url: '/pages/login/login', }) + } + }, + }) + return false + } + return args + } + }, + // ��������������� + success(res) {}, + fail(err) {} + }) + }) +} \ No newline at end of file diff --git a/utils/share.js b/utils/share.js index 721afd2..85d74d5 100644 --- a/utils/share.js +++ b/utils/share.js @@ -19,7 +19,7 @@ // console.log("���������������������", pages); this.share.path = `/${page.route}` if (page.options.infor) { - this.share.path = `/${page.route}?infor=${page.options.infor}` + this.share.path = `/${page.route}?infor=${page.options.infor}&type=share` } console.log('page.options', page.options) return { -- Gitblit v1.8.0