diff --git a/App.vue b/App.vue index e511dae..487d808 100644 --- a/App.vue +++ b/App.vue @@ -4,6 +4,7 @@ import { getImageUrl } from '@/common/api/basic' export default { onLaunch: function () { + // this.checkAppUpdate() // uni.onPushMessage((res) => { // console.log("收到推送消息:",res) //监听推送消息 // }) @@ -39,6 +40,209 @@ export default { onHide: function () { console.log('App Hide') }, + + methods: { + // 1. 检查应用更新(已分平台:安卓 + iOS) + checkAppUpdate() { + // 开发环境跳过检查 + const isDev = process.env.NODE_ENV === 'development' + if (isDev) { + return console.log('开发环境,不执行更新检查') + } + let isforce = 1 + // uni.showModal({ + // title: '更新提示', + // content: '发现新版本,是否立即更新?', + // showCancel: isforce == '0', // 强制更新隐藏取消按钮 + // confirmText: '去更新', + // success: (modalRes) => { + // if (modalRes.confirm) { + // this.downloadAndInstallApk('http://112.4.144.18:8040/shiningCloud/file/canneng_wulian.apk') + // } else { + // } + // }, + // }) + // 获取当前应用信息 + plus.runtime.getProperty(plus.runtime.appid, (info) => { + const currentVersion = info.version // 当前本地版本号 + + // 调用 API 获取服务器上的最新版本信息 + getLastestVersion() + .then((res) => { + if (!res.data) { + return + } + const { version, appFileList, iosUrl } = res?.data || {} + // let isforce = 1 + // 版本不一样才更新 + if (currentVersion != version) { + // ============================================== + // 🔴 关键:判断手机系统(安卓 / iOS) + // ============================================== + const isAndroid = plus.os.name === 'Android' + const isIos = plus.os.name === 'iOS' + + // ---------------------- + // ① iOS:跳 App Store + // ---------------------- + if (isIos) { + uni.showModal({ + title: '更新提示', + content: '发现新版本,请前往 App Store 更新', + showCancel: isforce === '0', // 强制更新隐藏取消按钮 + confirmText: '去更新', + success: (modalRes) => { + if (modalRes.confirm) { + // 跳转到 App Store 链接 + plus.runtime.openURL(iosUrl) + + // 强制更新:退出 App + if (isforce !== '0') { + plus.runtime.quit() + } + } else { + // 不更新直接退出 App(强制) + if (isforce !== '0') { + plus.runtime.quit() + } + } + }, + }) + return + } + + // ---------------------- + // ② Android:下载安装 + // ---------------------- + if (isAndroid) { + uni.showModal({ + title: '更新提示', + content: '发现新版本,是否立即更新?', + showCancel: isforce === '0', // 强制更新隐藏取消按钮 + confirmText: '去更新', + success: (modalRes) => { + if (modalRes.confirm) { + // 跳转到 App Store 链接 + this.downloadAndInstallApk(appFileList[0].filePath) + } + }, + }) + return + } + } + }) + .catch((err) => { + console.log('获取版本接口失败', err) + }) + }) + }, + + // 2. 安卓专用:下载并安装 APK + downloadAndInstallApk(url) { + // 防止重复点击下载 + if (this.downloadLoading) return + this.downloadLoading = true + + uni.showLoading({ + title: '正在下载更新...', + mask: true, // 加遮罩,防止重复点 + }) + + // 下载配置(修复路径、覆盖安装) + const options = { + filename: '_doc/update/canneng_wulian.apk', // 固定文件名,更稳定 + timeout: 120, // 超时时间 + } + + // 创建下载任务 + const downloadTask = plus.downloader.createDownload(url, options, (downloadedFile, status) => { + this.downloadLoading = false + uni.hideLoading() + + if (status === 200) { + // 开始安装 + plus.runtime.install( + downloadedFile.filename, + { + force: true, // 强制覆盖安装 + }, + () => { + uni.showModal({ + title: '安装成功', + content: '请重启APP', + showCancel: false, + confirmText: '确定', + success() { + plus.runtime.restart() + }, + }) + }, + (e) => { + console.error('安装失败', e) + uni.showModal({ + title: '安装失败', + content: '请开启安装权限后重试:' + e.message, + confirmText: '重试', + success: () => { + this.downloadAndInstallApk(url) + }, + }) + }, + ) + } else { + uni.showModal({ + title: '下载失败', + content: '网络异常或下载链接失效', + confirmText: '重试', + success: () => { + this.downloadAndInstallApk(url) + }, + }) + } + }) + + // 下载进度(优化体验) + downloadTask.addEventListener('statechanged', (task) => { + if (task.state === 3 && task.totalSize > 0) { + const percent = ((task.downloadedSize / task.totalSize) * 100).toFixed(0) + uni.showLoading({ + title: `正在下载更新 ${percent}%`, + mask: true, + }) + } + }) + + // 开始下载 + downloadTask.start() + }, + + // downloadAndInstallApk(url) { + // uni.showLoading({ title: '下载新版本...' }) + + // const downloadTask = plus.downloader.createDownload( + // url, + // { filename: '_doc/update/' }, + // (downloadedFile, status) => { + // uni.hideLoading() + // if (status === 200) { + // plus.runtime.install( + // downloadedFile.filename, + // { force: true }, + // () => { + // // 安装成功 + // }, + // (e) => { + // uni.showToast({ title: '安装失败: ' + e.message, icon: 'none' }) + // }, + // ) + // } else { + // uni.showToast({ title: '下载失败', icon: 'none' }) + // } + // }, + // ) + // downloadTask.start() + // }, + }, } diff --git a/common/api/project.js b/common/api/project.js index db8e099..fa398eb 100644 --- a/common/api/project.js +++ b/common/api/project.js @@ -1,128 +1,128 @@ -import request from '../js/request' -import config from '../js/config' - -export function addAppProject(params, files) { - if (files.length === 0) { - return request({ - url: '/cs-device-boot/project/addAppProject', - method: 'post', - data: params, - }) - } else { - return uni.uploadFile({ - url: config.domain + '/cs-device-boot/project/addAppProject', //仅为示例,非真实的接口地址 - files: files, - header: { - Authorization: uni.getStorageSync('access_token'), - }, - formData: params, - }) - } -} - -// 修改项目 -export function updateAppProject(params, files) { - if (files.length === 0) { - return request({ - url: '/cs-device-boot/project/auditAppProject', - method: 'post', - data: params, - }) - } else { - return uni.uploadFile({ - url: config.domain + '/cs-device-boot/project/auditAppProject', //仅为示例,非真实的接口地址 - files: files, - header: { - Authorization: uni.getStorageSync('access_token'), - }, - formData: params, - }) - } -} - -export function getProjectList(params) { - return request({ - url: '/cs-device-boot/project/queryProject', - method: 'post', - data: params, - header: { - 'Content-Type': 'application/json', - }, - }) -} - -// 删除项目 -export function deleteProject(id) { - return request({ - url: '/cs-device-boot/project/auditAppProject', - method: 'post', - data: { - id, - status: 0, - }, - }) -} - -// 查询拓扑图 - -export function queryTopologyDiagramPage(params) { - return request({ - url: '/cs-device-boot/topologyDiagram/queryTopologyDiagramPage', - method: 'post', - data: Object.assign( - { - pageNum: 1, - pageSize: 999, - projectId: '', - searchValue: '', - }, - params, - ), - header: { - 'Content-Type': 'application/json', - }, - }) -} - -// 删除拓扑图 -export function deleteAppTopologyDiagram(id) { - return request({ - url: '/cs-device-boot/topologyDiagram/AuditAppTopologyDiagram', - method: 'post', - data: { - id, - status: 0, - }, - }) -} - -// 删除拓扑图 -export function checkCanDelete(id) { - return request({ - url: '/cs-device-boot/topologyDiagram/checkCanDelete', - method: 'post', - data: { - id, - }, - }) -} - -// 新增拓扑图 - -export function addAppTopologyDiagram(params, filePath) { - return uni.uploadFile({ - url: config.domain + '/cs-device-boot/topologyDiagram/addAppTopologyDiagram', //仅为示例,非真实的接口地址 - filePath, - name: 'file', - header: { - Authorization: uni.getStorageSync('access_token'), - }, - formData: Object.assign( - { - topologyDiagramName: '', - projectId: '', - }, - params, - ), - }) -} +import request from '../js/request' +import config from '../js/config' + +export function addAppProject(params, files) { + if (files.length === 0) { + return request({ + url: '/cs-device-boot/project/addAppProject', + method: 'post', + data: params, + }) + } else { + return uni.uploadFile({ + url: config.domain + '/cs-device-boot/project/addAppProject', //仅为示例,非真实的接口地址 + files: files, + header: { + Authorization: uni.getStorageSync('access_token'), + }, + formData: params, + }) + } +} + +// 修改项目 +export function updateAppProject(params, files) { + if (files.length === 0) { + return request({ + url: '/cs-device-boot/project/auditAppProject', + method: 'post', + data: params, + }) + } else { + return uni.uploadFile({ + url: config.domain + '/cs-device-boot/project/auditAppProject', //仅为示例,非真实的接口地址 + files: files, + header: { + Authorization: uni.getStorageSync('access_token'), + }, + formData: params, + }) + } +} + +export function getProjectList(params) { + return request({ + url: '/cs-device-boot/project/queryProject', + method: 'post', + data: params, + header: { + 'Content-Type': 'application/json', + }, + }) +} + +// 删除项目 +export function deleteProject(id) { + return request({ + url: '/cs-device-boot/project/auditAppProject', + method: 'post', + data: { + id, + status: 0, + }, + }) +} + +// 查询拓扑图 + +export function queryTopologyDiagramPage(params) { + return request({ + url: '/cs-device-boot/topologyDiagram/queryTopologyDiagramPage', + method: 'post', + data: Object.assign( + { + pageNum: 1, + pageSize: 999, + projectId: '', + searchValue: '', + }, + params, + ), + header: { + 'Content-Type': 'application/json', + }, + }) +} + +// 删除拓扑图 +export function deleteAppTopologyDiagram(id) { + return request({ + url: '/cs-device-boot/topologyDiagram/AuditAppTopologyDiagram', + method: 'post', + data: { + id, + status: 0, + }, + }) +} + +// 删除拓扑图 +export function checkCanDelete(id) { + return request({ + url: '/cs-device-boot/topologyDiagram/checkCanDelete', + method: 'post', + data: { + id, + }, + }) +} + +// 新增拓扑图 + +export function addAppTopologyDiagram(params, filePath) { + return uni.uploadFile({ + url: config.domain + '/cs-device-boot/topologyDiagram/addAppTopologyDiagram', //仅为示例,非真实的接口地址 + filePath, + name: 'file', + header: { + Authorization: uni.getStorageSync('access_token'), + }, + formData: Object.assign( + { + topologyDiagramName: '', + projectId: '', + }, + params, + ), + }) +} diff --git a/common/js/config.js b/common/js/config.js index f346d07..ad3033a 100644 --- a/common/js/config.js +++ b/common/js/config.js @@ -1,7 +1,7 @@ const debug = true // true 是连地服务端本地,false 是连接线上 const development = { - domain: 'http://192.168.2.126:10215', + domain: 'http://192.168.1.103:10215', } const production = { diff --git a/components/Cn-device-card/Cn-device-card.vue b/components/Cn-device-card/Cn-device-card.vue index 4608369..2af202d 100644 --- a/components/Cn-device-card/Cn-device-card.vue +++ b/components/Cn-device-card/Cn-device-card.vue @@ -228,8 +228,8 @@ export default { // 在线 .zx-tag { - background-color: #67c23a20; - color: #67c23a; + background-color: #10b98120; + color: #10b981; } .lx-tag { background-color: #ff3b3020; diff --git a/components/Cn-qianTree/Cn-qianTree.vue b/components/Cn-qianTree/Cn-qianTree.vue index e1af55b..12974b1 100644 --- a/components/Cn-qianTree/Cn-qianTree.vue +++ b/components/Cn-qianTree/Cn-qianTree.vue @@ -20,7 +20,7 @@ class="uni-input" radius="5" placeholder="请输入关键字搜索" - clearButton="none" + clearButton="none" @input="input" /> @@ -212,6 +212,12 @@ export default { } }) this._hide() + console.log('🚀 ~ rt:', rt) + + if (rt.length == 0) return + if (this.singleChoice) { + if (rt[0].rank != 3) return + } this.$emit('confirm', rt) }, //扁平化树结构 diff --git a/manifest.json b/manifest.json index 70ba654..1aad8c1 100644 --- a/manifest.json +++ b/manifest.json @@ -139,7 +139,7 @@ "/api" : { "https" : true, // "target" : "https://pqmcn.com:8092/api", - "target" : "http://192.168.2.126:10215", + "target" : "http://192.168.1.103:10215", "changOrigin" : true, "pathRewrite" : { "/api" : "" diff --git a/pages.json b/pages.json index 643c880..d41fdfc 100644 --- a/pages.json +++ b/pages.json @@ -46,7 +46,13 @@ { "path": "pages/index/report", "style": { - "navigationBarTitleText": "报表" + "navigationBarTitleText": "报表", + "enablePullDownRefresh": true, // 开启下拉刷新 + "pullToRefresh": { + "support":true, + "style": "circle", + "color":"#007aff" + } } }, { @@ -161,7 +167,12 @@ "path": "pages/device/APF/detail", "style": { "navigationBarTitleText": "APF 设备名称 + 型号", - "enablePullDownRefresh": true + "enablePullDownRefresh": true, + "pullToRefresh": { + "support":true, + "style": "circle", + "color":"#007aff" + } } }, { diff --git a/pages/device/APF/comp/IO.vue b/pages/device/APF/comp/IO.vue index 954ad8a..a34c07d 100644 --- a/pages/device/APF/comp/IO.vue +++ b/pages/device/APF/comp/IO.vue @@ -1,151 +1,164 @@ - - - \ No newline at end of file + + + diff --git a/pages/device/APF/comp/basic.vue b/pages/device/APF/comp/basic.vue index 694c076..1b33bc6 100644 --- a/pages/device/APF/comp/basic.vue +++ b/pages/device/APF/comp/basic.vue @@ -1,172 +1,184 @@ - - - + + + diff --git a/pages/device/APF/comp/power.vue b/pages/device/APF/comp/power.vue index a2e035a..164192e 100644 --- a/pages/device/APF/comp/power.vue +++ b/pages/device/APF/comp/power.vue @@ -1,125 +1,135 @@ - - - + + + diff --git a/pages/device/APF/comp/xieBo.vue b/pages/device/APF/comp/xieBo.vue index 7b783d8..3412c4d 100644 --- a/pages/device/APF/comp/xieBo.vue +++ b/pages/device/APF/comp/xieBo.vue @@ -1,375 +1,385 @@ - - - - - + + + + + diff --git a/pages/device/APF/detail.vue b/pages/device/APF/detail.vue index ea14ec0..35fcb6a 100644 --- a/pages/device/APF/detail.vue +++ b/pages/device/APF/detail.vue @@ -186,7 +186,7 @@ export default { content: [ { iconPath: '/static/report.png', - text: '告警', + text: '详情', }, // { // iconPath: '/static/record.png', @@ -196,10 +196,10 @@ export default { iconPath: '/static/about.png', text: '关于', }, - { - iconPath: '/static/access.png', - text: '接入', - }, + // { + // iconPath: '/static/access.png', + // text: '接入', + // }, ], client: null, timer: null, @@ -243,7 +243,7 @@ export default { this.$util.toast('下载成功') } else if (e.text === '记录') { uni.navigateTo({ url: '/pages/device/APF/record' }) - } else if (e.text === '告警') { + } else if (e.text === '详情') { uni.navigateTo({ url: '/pages/device/APF/report?id=' + this.devId }) } else if (e.text === '关于') { uni.navigateTo({ url: '/pages/device/APF/about?id=' + this.devId }) @@ -353,7 +353,7 @@ export default { this.downloadImg() uni.setNavigationBarTitle({ title: this.deviceInfo.devName || '设备详情' }) this.topolodyData = this.topolodyData.filter((item) => { - let index = this.deviceInfo.appsLineTopologyDiagramPO.findIndex((element) => { + let index = this.deviceInfo.appsLineTopologyDiagramPO?.findIndex((element) => { element.label = element.name item.label = element.name return element.linePostion === item.linePostion @@ -577,6 +577,12 @@ export default { text: '用户', }) } + if (this.userInfo.authorities === 'operation_manager') { + this.content.push({ + iconPath: '/static/access.png', + text: '接入', + }) + } } this.$util.getDictData('Line_Position').then((res) => { this.topolodyData = res.map((item) => { diff --git a/pages/device/DVR/detail.vue b/pages/device/DVR/detail.vue index c8031a0..4296824 100644 --- a/pages/device/DVR/detail.vue +++ b/pages/device/DVR/detail.vue @@ -1,286 +1,292 @@ - - - + + + diff --git a/pages/device/realTime/index.vue b/pages/device/realTime/index.vue index 6e7cc61..dd174bc 100644 --- a/pages/device/realTime/index.vue +++ b/pages/device/realTime/index.vue @@ -69,7 +69,7 @@ @finished="initChart('echartV3', 'echartsDataV3')" > - 电压有效值 + 电压有效值(kV) - 电压有效值 + 电流有效值(A) @@ -125,6 +125,7 @@ + @@ -133,12 +134,14 @@ const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') import { MQTT_IP, MQTT_OPTIONS } from '@/common/js/mqtt.js' import mqtt from 'mqtt/dist/mqtt.js' import { getBaseRealData } from '@/common/api/harmonic.js' +import hoverMenu from '@/hover-menu/components/hover-menu/hover-menu.vue' export default { - components: {}, + components: { hoverMenu }, props: {}, data() { return { loading: true, + devId: '', // 使用上面定义的图表配置项 option: {}, echartsData0: {}, @@ -183,30 +186,72 @@ export default { equipmentName: '', runStatus: 1, connection: false, + content: [ + { + iconPath: '/static/report.png', + text: '详情', + }, + { + iconPath: '/static/about.png', + text: '关于', + }, + ], + isPrimaryUser: 0, } }, onLoad(options) { - console.log('🚀 ~ options:', options) this.lineKey = 0 + this.devId = options.id this.lineList = JSON.parse(options.lineList) this.lineId = this.lineList[0].lineId this.engineeringName = options.engineeringName this.equipmentName = options.equipmentName this.runStatus = options.runStatus + this.isPrimaryUser = options.isPrimaryUser this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo) this.echartsData0 = this.initEcharts0() this.echartsData1 = this.initEcharts1() - this.echartsDataV1 = this.initEcharts('#DAA520', 0, 'A相(kV)') - this.echartsDataV2 = this.initEcharts('#2E8B57', 0, 'B相(kV)') - this.echartsDataV3 = this.initEcharts('#A52a2a', 0, 'C相(kV)') - this.echartsDataA1 = this.initEcharts('#DAA520', 1, 'A相(A)') - this.echartsDataA2 = this.initEcharts('#2E8B57', 1, 'B相(A)') - this.echartsDataA3 = this.initEcharts('#A52a2a', 1, 'C相(A)') + this.echartsDataV1 = this.initEcharts('#DAA520', 0, 'A相') + this.echartsDataV2 = this.initEcharts('#2E8B57', 0, 'B相') + this.echartsDataV3 = this.initEcharts('#A52a2a', 0, 'C相') + this.echartsDataA1 = this.initEcharts('#DAA520', 1, 'A相') + this.echartsDataA2 = this.initEcharts('#2E8B57', 1, 'B相') + this.echartsDataA3 = this.initEcharts('#A52a2a', 1, 'C相') this.loading = false this.$nextTick(() => { this.setMqtt(0) this.initMqtt() }) + if (this.isPrimaryUser == 1) { + this.content.splice( + 0, + 0, + { + iconPath: '/static/transfer.png', + text: '移交', + }, + { + iconPath: '/static/feedback.png', + text: '编辑', + }, + { + iconPath: '/static/delate.png', + text: '删除', + }, + ) + if (this.userInfo.authorities === 'app_vip_user') { + this.content.splice(3, 0, { + iconPath: '/static/share.png', + text: '分享', + }) + } + } + if (this.userInfo.authorities !== 'tourist') { + this.content.splice(0, 0, { + iconPath: '/static/subordinate.png', + text: '用户', + }) + } }, onUnload() { const charts = [ @@ -623,7 +668,9 @@ export default { .then((res) => { if (res.code == 'A0000') { this.connection = true - this.$util.toast(e == 0 ? '连接成功!' : '刷新成功!') + setTimeout(() => { + this.$util.toast(e == 0 ? '连接成功!' : '刷新成功!') + }, 3000) if (this.timer) { clearInterval(this.timer) this.timer = null @@ -878,6 +925,46 @@ export default { await this.setMqtt(0) await this.initMqtt() }, + trigger(e) { + console.log(e) + if (e.text === '分享') { + uni.navigateTo({ url: '/pages/device/share?id=' + this.lineId }) + } else if (e.text === '删除') { + uni.showModal({ + title: '提示', + content: '确定删除该设备吗?', + success: (res) => { + if (res.confirm) { + console.log('用户点击确定') + deleteDevice(this.devId).then((res) => { + uni.showToast({ + title: '删除成功', + icon: 'none', + }) + setTimeout(() => { + uni.navigateBack() + }, 1500) + }) + } else if (res.cancel) { + console.log('用户点击取消') + } + }, + }) + } else if (e.text === '记录') { + uni.navigateTo({ url: '/pages/device/APF/record' }) + } else if (e.text === '详情') { + uni.navigateTo({ url: '/pages/device/APF/report?id=' + this.devId }) + } else if (e.text === '关于') { + uni.navigateTo({ url: '/pages/device/APF/about?id=' + this.devId }) + } else if (e.text === '移交') { + uni.navigateTo({ url: '/pages/device/transfer?id=' + this.devId }) + } else if (e.text === '反馈') { + uni.navigateTo({ url: '/pages/device/feedback' }) + } else if (e.text === '用户') { + uni.navigateTo({ url: '/pages/device/user?id=' + this.devId + '&isPrimaryUser=' + this.isPrimaryUser }) + } + // this.$refs.fab.close() + }, }, computed: {}, @@ -990,7 +1077,7 @@ export default { } .text { text-align: center; - font-size: 30rpx; + font-size: 28rpx; } .text_center { position: absolute; diff --git a/pages/engineering/setting.vue b/pages/engineering/setting.vue index 735f394..898ffcb 100644 --- a/pages/engineering/setting.vue +++ b/pages/engineering/setting.vue @@ -1,224 +1,225 @@ - - - - - + + + + + diff --git a/pages/index/comp/apply.vue b/pages/index/comp/apply.vue index 3e1e80b..18592ae 100644 --- a/pages/index/comp/apply.vue +++ b/pages/index/comp/apply.vue @@ -107,9 +107,7 @@ export default { array: ['发生时间', '暂降深度', '持续时间'], } }, - mounted() { - this.setHeight() - }, + mounted() {}, methods: { setHeight() { @@ -118,10 +116,10 @@ export default { .boundingClientRect((rect) => { // // #ifdef H5 - this.height = rect?.height + 100 || 0 + this.height = rect?.height + 170 || 0 // #endif // #ifdef APP-PLUS - this.height = rect?.height + 90 || 0 + this.height = rect?.height + 100 || 0 // #endif }) .exec() @@ -129,7 +127,9 @@ export default { async select(val) { this.selectValue = val await this.init() - this.setHeight() + setTimeout(() => { + this.setHeight() + }, 200) }, init() { this.store = this.DataSource('/cs-harmonic-boot/eventUser/queryEventpage') diff --git a/pages/index/comp/indexYouKe.vue b/pages/index/comp/indexYouKe.vue index aae76cb..9e8b8da 100644 --- a/pages/index/comp/indexYouKe.vue +++ b/pages/index/comp/indexYouKe.vue @@ -35,13 +35,12 @@ 离线设备 - + - + --> diff --git a/pages/index/comp/indexZhuYongHu.vue b/pages/index/comp/indexZhuYongHu.vue index ceceea3..6c743d4 100644 --- a/pages/index/comp/indexZhuYongHu.vue +++ b/pages/index/comp/indexZhuYongHu.vue @@ -35,11 +35,11 @@ 离线设备 - {{ devCount.eventCount || 0 }} + {{ devCount.currentEventCount || 0 }} 暂态事件数 - {{ devCount.harmonicCount || 0 }} + {{ devCount.currentHarmonicCount || 0 }} 稳态事件数 diff --git a/pages/index/comp/steadyState.vue b/pages/index/comp/steadyState.vue index ae19e43..ed757e4 100644 --- a/pages/index/comp/steadyState.vue +++ b/pages/index/comp/steadyState.vue @@ -1,5 +1,6 @@