优化强制更新功能

This commit is contained in:
guanj
2026-06-18 16:34:25 +08:00
parent edc5dc55aa
commit f008bcb4b8
22 changed files with 1774 additions and 1650 deletions

View File

@@ -1,11 +1,11 @@
<script>
import { queryDictDataCache } from './common/api/dictionary.js'
import { getImageUrl } from '@/common/api/basic'
import { checkAppUpdate } from './common/js/update.js'
export default {
onLaunch: function () {
checkAppUpdate()
// uni.onPushMessage((res) => {
// console.log("收到推送消息:",res) //监听推送消息
// })

View File

@@ -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 = {

View File

@@ -1,52 +1,102 @@
import { getLastData } from '../api/user.js'
/** 规范化版本号,如 v1.6.83 → [1, 6, 83] */
const normalizeVersion = (version) => {
if (!version) return []
return String(version)
.replace(/^v/i, '')
.split('.')
.map((part) => parseInt(part, 10) || 0)
}
/**
* 比较版本号
* @returns 1 远端较新需更新 | 0 相同 | -1 本地较新
*/
const compareVersion = (remote, local) => {
const remoteParts = normalizeVersion(remote)
const localParts = normalizeVersion(local)
const len = Math.max(remoteParts.length, localParts.length)
for (let i = 0; i < len; i++) {
const rv = remoteParts[i] || 0
const lv = localParts[i] || 0
if (rv > lv) return 1
if (rv < lv) return -1
}
return 0
}
/** 自定义调试基座 / HBuilder 标准基座,不走线上更新 */
const isCustomDebugBase = (appName = '') => {
return /自定义基座|custom debug|HBuilder|DCloud/i.test(appName)
}
export const checkAppUpdate = () => {
// #ifndef APP-PLUS
return
// #endif
// 开发环境跳过检查
const isDev = process.env.NODE_ENV === 'development'
// if (isDev) {
if (isDev) {
console.log('开发环境,不执行更新检查')
return
// }
}
// 自定义基座调试,跳过更新检查
// try {
// const { appName } = uni.getSystemInfoSync()
// if (isCustomDebugBase(appName)) {
// console.log('自定义基座调试中,不执行更新检查')
// return
// }
// } catch (e) {}
// 获取当前应用信息
plus.runtime.getProperty(plus.runtime.appid, (info) => {
// if (isCustomDebugBase(info?.name)) {
// console.log('自定义基座调试中,不执行更新检查')
// return
// }
const currentVersion = info.version
getLastData()
.then((res) => {
.then((res) => {
// let res = {
// data: {
// versionName: 'v1.6.83',
// forceUpdate: '1',
// androidPath: 'https://app.liuyingyong.cn/build/download/3c26e400-3a33-11f1-8997-a16e76fa35b3',
// // androidPath: 'http://112.4.144.18:8040/shiningCloud/file/canneng_wulian.apk',
// iosPath: 'xxxx',
// },
// }
if (!res?.data) {
console.log('未获取到版本信息')
return
}
// let res = {
// data: {
// versionName: 'v1.6.83',
// forceUpdate: '1',
// androidPath: 'https://app.liuyingyong.cn/build/download/3c26e400-3a33-11f1-8997-a16e76fa35b3',
// // androidPath: 'http://112.4.144.18:8040/shiningCloud/file/canneng_wulian.apk',
// iosPath: 'xxxx',
// },
// }
if (!res?.data) {
console.log('未获取到版本信息')
return
}
// 适配新的接口返回格式,默认强制更新
const { versionName, androidPath, iosPath, forceUpdate = '1' } = res.data
console.log('🚀 ~ checkAppUpdate ~ versionName, currentVersion:', versionName, currentVersion)
// 适配新的接口返回格式
const { versionName, androidPath, iosPath, forceUpdate = '1' } = res.data
// 版本相同或本地较新则不需要更新
if (compareVersion(versionName, currentVersion) <= 0) {
console.log('已是最新版本')
return
}
// 版本相同则不需要更新
if (versionName.includes(currentVersion)) {
console.log('已是最新版本')
return
}
const isForce = forceUpdate !== '0' // 默认强制更新,'0' 为可选更新
const isForce = forceUpdate === '1' // 字符串 '1' 表示强制更新
const iosUrl = iosPath
const iosUrl = iosPath
handleUpdate({ version: versionName, androidPath, iosUrl, isForce })
})
.catch((err) => {
console.error('获取版本接口失败', err)
})
handleUpdate({ version: versionName, androidPath, iosUrl, isForce })
})
.catch((err) => {
console.error('获取版本接口失败', err)
})
})
}
@@ -58,9 +108,9 @@ const handleUpdate = ({ version, androidPath, iosUrl, isForce }) => {
const isIOS = plus.os.name === 'iOS'
if (isAndroid) {
handleAndroidUpdate({ androidPath, isForce })
handleAndroidUpdate({ version, androidPath, isForce })
} else if (isIOS) {
handleIOSUpdate({ iosUrl, isForce })
handleIOSUpdate({ version, iosUrl, isForce })
} else {
console.warn('未知操作系统')
}
@@ -69,7 +119,7 @@ const handleUpdate = ({ version, androidPath, iosUrl, isForce }) => {
/**
* 处理安卓更新
*/
const handleAndroidUpdate = ({ androidPath, isForce }) => {
const handleAndroidUpdate = ({ version, androidPath, isForce }) => {
if (!androidPath?.length) {
console.error('未找到安卓安装包')
uni.showToast({
@@ -80,18 +130,18 @@ const handleAndroidUpdate = ({ androidPath, isForce }) => {
}
const downloadUrl = androidPath
const content = isForce ? `发现新版本 ${version},请立即更新后继续使用` : `发现新版本 ${version},是否立即更新?`
uni.showModal({
title: '更新提示',
content: '发现新版本,是否立即更新?',
showCancel: !isForce, // 强制更新隐藏取消按钮
content,
showCancel: false,
confirmText: '去更新',
cancelText: '暂不更新',
success: (modalRes) => {
if (modalRes.confirm) {
downloadAndInstallApk(downloadUrl)
} else if (isForce) {
// 强制更新用户取消,退出应用
// 强制更新用户按返回键关闭弹窗时退出
plus.runtime.quit()
}
},
@@ -101,7 +151,7 @@ const handleAndroidUpdate = ({ androidPath, isForce }) => {
/**
* 处理iOS更新
*/
const handleIOSUpdate = ({ iosUrl, isForce }) => {
const handleIOSUpdate = ({ version, iosUrl, isForce }) => {
if (!iosUrl) {
console.error('未找到iOS下载链接')
uni.showToast({
@@ -111,22 +161,23 @@ const handleIOSUpdate = ({ iosUrl, isForce }) => {
return
}
const content = isForce
? `发现新版本 ${version},请前往 App Store 更新后继续使用`
: `发现新版本 ${version},请前往 App Store 更新`
uni.showModal({
title: '更新提示',
content: '发现新版本,请前往 App Store 更新',
showCancel: !isForce,
content,
showCancel: false,
confirmText: '去更新',
cancelText: '暂不更新',
success: (modalRes) => {
if (modalRes.confirm) {
plus.runtime.openURL(iosUrl)
}
// 强制更新时,无论确认还是取消都退出应用
if (isForce) {
setTimeout(() => {
plus.runtime.quit()
}, 300) // 给跳转留一点时间
}, 300)
} else if (isForce) {
// 强制更新且用户取消,退出应用
}
},
})
@@ -143,14 +194,22 @@ const downloadAndInstallApk = (url) => {
close: false, // 不允许用户关闭
padlock: true, // 锁定屏幕
})
let progressClosed = false
const closeProgress = () => {
if (progressClosed) return
progressClosed = true
progressWaiting.close()
}
const options = {
filename: '_doc/update/canneng_wulian.apk',
timeout: 120,
timeout: 300,
}
console.log('🚀 ~ downloadAndInstallApk ~ url:', url)
const downloadTask = plus.downloader.createDownload(url, options, (downloadedFile, status) => {
progressWaiting.close()
closeProgress()
if (status === 200) {
installApk(downloadedFile.filename, url)
@@ -161,9 +220,10 @@ const downloadAndInstallApk = (url) => {
// // 更新进度
downloadTask.addEventListener('statechanged', (task) => {
if (progressClosed) return
if (task.state === 3 && task.totalSize > 0) {
const percent = ((task.downloadedSize / task.totalSize) * 100).toFixed(0)
console.log("🚀 ~ downloadAndInstallApk ~ percent:", percent)
console.log('🚀 ~ downloadAndInstallApk ~ percent:', percent)
// 直接更新 waiting 的标题,不会闪烁
progressWaiting.setTitle(`正在下载更新 ${percent}%`)
}
@@ -197,11 +257,13 @@ const installApk = (filePath, downloadUrl) => {
uni.showModal({
title: '安装失败',
content: `安装失败:${error.message}\n请检查是否已开启安装权限`,
showCancel: false,
confirmText: '重试',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
downloadAndInstallApk(downloadUrl)
} else {
plus.runtime.quit()
}
},
})
@@ -216,11 +278,13 @@ const handleDownloadError = (downloadUrl) => {
uni.showModal({
title: '下载失败',
content: '网络异常或下载链接失效,是否重试?',
showCancel: false,
confirmText: '重试',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
downloadAndInstallApk(downloadUrl)
} else {
plus.runtime.quit()
}
},
})

View File

@@ -16,15 +16,15 @@ export default {
},
computed: {
svgHtml() {
if (this.name == '电压暂降') {
if (this.name == '暂降') {
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<path d="M8,50 L15,50 L18,38 L21,28 L24,38 L27,50 L30,62 L33,72 L36,62 L39,50 L42,38 L45,28 L48,38 L51,50 L54,56 L56,54 L58,55 L60,54 L63,56 L66,60 L68,62 L70,60 L72,56 L75,54 L77,52 L79,54 L81,56 L84,50 L87,38 L90,28 L93,38 L96,50" fill="none" stroke="#2563eb" stroke-width="4"/>
</svg>`
} else if (this.name == '电压暂升') {
} else if (this.name == '暂升') {
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<path d="M8,50 L15,50 L18,38 L21,28 L24,38 L27,50 L30,62 L33,72 L36,62 L39,50 L42,38 L45,28 L48,38 L51,50 L54,43 L56,34 L58,26 L60,34 L63,43 L66,54 L68,60 L70,54 L72,43 L75,34 L77,26 L79,34 L81,43 L84,50 L87,38 L90,28 L93,38 L96,50" fill="none" stroke="#e6a23c" stroke-width="4"/>
</svg>`
} else if (this.name == '电压中断') {
} else if (this.name == '中断') {
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<path d="M8,50 L15,50 L18,38 L21,28 L24,38 L27,50 L30,62 L33,72 L36,62 L39,50 L42,38 L45,28 L48,38 L51,50 L54,50 L57,50 L60,50 L63,50 L66,50 L69,50 L72,50 L75,50 L78,50 L81,50 L84,50 L87,38 L90,28 L93,38 L96,50" fill="none" stroke="#6b7280" stroke-width="4"/>
</svg>`

View File

@@ -46,6 +46,7 @@
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
"<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
@@ -124,7 +125,10 @@
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
"usingComponents" : true,
"unipush" : {
"enable" : false
}
},
"mp-alipay" : {
"usingComponents" : true
@@ -139,7 +143,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" : ""
@@ -152,7 +156,7 @@
"base" : ""
},
"unipush" : {
"enable" : false
"enable" : true
},
"sdkConfigs" : {
"maps" : {}

View File

@@ -118,7 +118,7 @@
{
"path": "pages/mine/setupMessage",
"style": {
"navigationBarTitleText": "个性化推荐"
"navigationBarTitleText": "推送通知配置"
}
},

View File

@@ -5,14 +5,8 @@
<view class="transfer">
<!-- <div class="transfer-img" ref="qrCodeUrl" /> -->
<!-- <uqrcode ref="uqrcode" canvas-id="qrcode" :value="content" :options="{ margin: 10 }"></uqrcode> -->
<uqrcode
ref="uqrcode"
canvas-id="qrcode"
:value="content"
size="200"
@complete="complete"
:loading="false"
></uqrcode>
<uqrcode ref="uqrcode" canvas-id="qrcode" :value="content" size="200" @complete="complete"
:loading="false"></uqrcode>
<view style="height: 200rpx"></view>
<view class="transfer-text">请让接收人员扫码接收</view>
<view class="transfer-btn">
@@ -24,24 +18,16 @@
</view>
</view>
</Cn-page>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog
style="width: 90%; margin: 5%"
type="info"
cancelText="禁止"
confirmText="允许"
title="权限说明"
content='是否允许"灿能物联"使用相机?'
@confirm="handleScon('camera')"
@close="dialogClose"
></uni-popup-dialog>
</uni-popup>
<uni-popup ref="message" type="message">
<uni-popup-message type="info" :duration="0" style="width: 90%; margin: 5%">
<view style="color: #909399; font-style: 16px">相机权限使用说明:</view>
<view style="color: #6c6c6c; margin-top: 3rpx; "> 用于相机扫描二维码!</view>
</uni-popup-message>
</uni-popup>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog style="width: 90%; margin: 5%" type="info" cancelText="禁止" confirmText="允许" title="权限说明"
content='是否允许"灿能物联"使用相机?' @confirm="handleScon('camera')" @close="dialogClose"></uni-popup-dialog>
</uni-popup>
<uni-popup ref="message" type="message">
<uni-popup-message type="info" :duration="0" style="width: 90%; margin: 5%">
<view style="color: #909399; font-style: 16px">相机权限使用说明:</view>
<view style="color: #6c6c6c; margin-top: 3rpx; "> 用于相机扫描二维码!</view>
</uni-popup-message>
</uni-popup>
</view>
</template>
<script>
@@ -82,17 +68,17 @@ export default {
plus.os.name == 'Android' &&
plus.navigator.checkPermission('android.permission.CAMERA') === 'undetermined'
) {
//未授权
this.$refs.message.open()
this.$refs.alertDialog.open('bottom')
//未授权
this.$refs.message.open()
this.$refs.alertDialog.open('bottom')
} else {
this.handleScon()
}
},
handleScon() {
this.$refs.message.close()
this.$refs.message.close()
uni.scanCode({
onlyFromCamera:true,
// onlyFromCamera:false,
success: (res) => {
console.log(res)
let data = JSON.parse(res.result)
@@ -107,7 +93,7 @@ export default {
},
})
},
dialogClose() {this.$refs.message.close()},
dialogClose() { this.$refs.message.close() },
},
onLoad(options) {
this.options = options
@@ -125,8 +111,7 @@ export default {
flex-direction: column;
align-items: center;
.transfer-img {
}
.transfer-img {}
.transfer-text {
font-size: 28rpx;

View File

@@ -222,21 +222,21 @@ export default {
},
judgment(val, key) {
switch (val) {
case '电压暂降':
case '暂降':
return {
type: 'sag',
icon: 'icon-a-svg4',
color: '#2563eb',
size: '25',
}
case '电压暂升':
case '暂升':
return {
type: 'swell',
icon: 'icon-a-svg5',
color: '#e6a23c',
size: '25',
}
case '电压中断':
case '中断':
return {
type: 'interrupt',
icon: 'icon-zhongduan2',

View File

@@ -1,7 +1,7 @@
<template>
<view class="index-zhuyonghu">
<template v-if="devCount.engineeringListLength > 0">
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-gongcheng" size="18" color="#376cf3" />
<text>所有工程设备统计</text>
</view>
@@ -33,7 +33,7 @@
</view>
<!-- <view class="mt20"></view> -->
</template>
<!-- <view class="canneng-index-title mb20">当前工程设备统计</view>
<!-- <view class="canneng-index-title mb20 ml20">当前工程设备统计</view>
<view class="header">
<view class="header-item" @click="jump('nowEngineering')">
<view class="header-item-value"
@@ -50,7 +50,7 @@
<view class="header-item-label">离线设备</view>
</view>
</view> -->
<view class="canneng-index-title mt20 canneng-index-title-with-icon">
<view class="canneng-index-title mt20 ml20 canneng-index-title-with-icon">
<uni-icons type="settings" size="18" color="#376cf3" />
<text>常用功能</text>
</view>

View File

@@ -1,7 +1,7 @@
<template>
<view class="index-zhuyonghu">
<template v-if="devCount.engineeringListLength > 1">
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-gongcheng" size="18" color="#376cf3" />
<text>所有工程设备统计</text>
</view>
@@ -21,7 +21,7 @@
</view>
<view class="mt20"></view>
</template>
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-zaixianjianceshebei" size="18" color="#376cf3" />
<text>当前工程设备统计</text>
</view>

View File

@@ -1,7 +1,7 @@
<template>
<view class="index-zhuanzhi">
<template v-if="devCount.engineeringListLength > 1">
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-gongcheng" size="18" color="#376cf3" />
<text>所有工程设备统计</text>
</view>
@@ -35,7 +35,7 @@
</view>
<view class="mt20"></view>
</template>
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-zaixianjianceshebei" size="18" color="#376cf3" />
<text>当前工程设备统计</text>
</view>

View File

@@ -1,7 +1,7 @@
<template>
<view class="index-zhuyonghu">
<template v-if="devCount.engineeringListLength > 1">
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-gongcheng" size="18" color="#376cf3" />
<text>所有工程设备统计</text>
</view>
@@ -21,7 +21,7 @@
</view>
<view class="mt20"></view>
</template>
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-zaixianjianceshebei" size="18" color="#376cf3" />
<text>当前工程设备统计</text>
</view>
@@ -49,7 +49,7 @@
<view class="header-item-label">稳态事件数</view>
</view>
</view>
<view class="canneng-index-title mt20 canneng-index-title-with-icon">
<view class="canneng-index-title mt20 ml20 canneng-index-title-with-icon">
<uni-icons type="settings" size="18" color="#376cf3" />
<text>常用功能</text>
</view>

View File

@@ -1,7 +1,7 @@
<template>
<view class="index-zhuanzhi">
<template v-if="devCount.engineeringListLength > 1">
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-gongcheng" size="18" color="#376cf3" />
<text>所有工程设备统计</text>
</view>
@@ -33,7 +33,7 @@
</view>
<view class="mt20"></view>
</template>
<view class="canneng-index-title mb20 canneng-index-title-with-icon">
<view class="canneng-index-title mb20 ml20 canneng-index-title-with-icon">
<uni-icons custom-prefix="iconfont" type="icon-zaixianjianceshebei" size="18" color="#376cf3" />
<text>当前工程设备统计</text>
</view>

View File

@@ -1,4 +1,5 @@
<template>
<page-meta :page-style="'overflow:' + (indicatorPopupShow ? 'hidden' : 'visible')"></page-meta>
<view class="itic2-page">
<view class="itic2-content">
<view class="project-header card">
@@ -60,7 +61,10 @@
<Cn-icon-transient name="监测点" />
</view>
<view class="card-header-info">
<text class="point-name ellipsis">{{ point.pointName }}</text>
<view class="point-name-row">
<text class="point-name ellipsis">{{ point.pointName }}</text>
</view>
<view class="meta-row">
<text class="meta-item ellipsis">项目{{ point.projectName }}</text>
<text class="meta-item ellipsis">设备{{ point.deviceName }}</text>
@@ -100,7 +104,7 @@
</view>
</view>
<view class="more-btn" @click="onMoreIndicators(point)">
<view class="more-btn" v-if="shouldShowMoreBtn(point)" @click="onMoreIndicators(point)">
<uni-icons type="list" size="16" color="#376cf3" />
<text>更多指标</text>
</view>
@@ -116,13 +120,13 @@
<uni-icons type="arrow-up" size="22" color="#fff"></uni-icons>
</view>
<uni-popup ref="indicatorPopup" type="bottom">
<uni-popup ref="indicatorPopup" type="bottom" :safe-area="false" @change="onIndicatorPopupChange">
<view class="indicator-popup">
<view class="indicator-popup-header">
<view class="indicator-popup-header" @touchmove.stop.prevent>
<text class="indicator-popup-cancel" @click="closeIndicatorPopup">取消</text>
<text class="indicator-popup-confirm" @click="confirmIndicatorPopup">确定</text>
</view>
<view class="indicator-popup-list" scroll-y>
<scroll-view class="indicator-popup-list" scroll-y :show-scrollbar="false" @touchmove.stop>
<view v-if="targetLists.length === 0" class="indicator-popup-empty">
<text>暂无指标数据</text>
</view>
@@ -133,7 +137,7 @@
<uni-icons v-if="popupSelectedIndicators.includes(item.name)" type="checkmarkempty" size="18"
color="#376cf3" />
</view>
</view>
</scroll-view>
</view>
</uni-popup>
</view>
@@ -144,8 +148,17 @@ import { queryByCode, queryCsDictTree } from '@/common/api/dictionary'
import { getLineDataByEngineer } from '@/common/api/harmonic'
import { getDevCount } from '@/common/api/device.js'
/** 无本地缓存时的默认展示指标:电压、电流 */
const DEFAULT_INDICATOR_CODES = ['Key_Power_Quality_V', 'Key_Power_Quality_I']
/** 治理测点(lineType=0)卡片默认展示的指标 */
const GOVERNANCE_DEFAULT_INDICATORS = [
'电网电流',
'电网电压',
'负载电流',
'总输出电流',
]
export default {
data() {
return {
@@ -168,6 +181,7 @@ export default {
listStatus: 'noMore',
lineDataRequestId: 0,
showBackTop: false,
indicatorPopupShow: false,
}
},
onPageScroll(e) {
@@ -248,6 +262,7 @@ export default {
deviceName: point.deviceName || '',
pointName: point.pointName || '',
dataTime: point.dataTime || '',
lineType: point.lineType,
children: this.groupChildren(point.children || []),
}))
},
@@ -278,7 +293,9 @@ export default {
},
formatPhaseValue(value) {
if (value === null || value === undefined || value === '') return '-'
return String(value)
const num = Number(value)
if (Number.isNaN(num)) return String(value)
return num.toFixed(2)
},
hasTPhaseData(child) {
return child.T !== undefined && child.T !== null && child.T !== '-'
@@ -358,6 +375,9 @@ export default {
this.$refs.indicatorPopup.close()
this.popupSelectedIndicators = []
},
onIndicatorPopupChange(e) {
this.indicatorPopupShow = !!e.show
},
// 切换弹窗内指标勾选状态
togglePopupIndicator(name) {
const idx = this.popupSelectedIndicators.indexOf(name)
@@ -377,23 +397,43 @@ export default {
this.saveSelectedIndicators()
this.closeIndicatorPopup()
},
// 查看更多指标
// 跳转指标详情页;治理测点展示全部指标,普通测点展示未选中的指标
onMoreIndicators(point) {
uni.setStorageSync('monitorPointDetail', {
...point,
engineeringName: this.engineeringName,
selectedIndicators: [...this.selectedIndicators],
selectedIndicators:
point.lineType === 0
? [...GOVERNANCE_DEFAULT_INDICATORS]
: [...this.selectedIndicators],
showAllIndicators: point.lineType === 0,
})
uni.navigateTo({
url: '/pages/index/comp/targetInfo',
})
},
// 获取监测点当前展示的指标数据
// 治理测点默认 4 项;普通测点按顶部已选指标过滤
getDisplayChildren(point) {
return (point.children || []).filter((child) =>
const children = point.children || []
if (point.lineType === 0) {
return GOVERNANCE_DEFAULT_INDICATORS.map((name) =>
children.find((child) => this.matchIndicator(child.name, name)),
).filter(Boolean)
}
return children.filter((child) =>
this.selectedIndicators.some((name) => this.matchIndicator(child.name, name)),
)
},
// 治理测点存在默认四项以外的指标时显示「更多指标」
shouldShowMoreBtn(point) {
if (point.lineType !== 0) return true
const children = point.children || []
return children.some(
(child) =>
!GOVERNANCE_DEFAULT_INDICATORS.some((name) => this.matchIndicator(child.name, name)),
)
},
// 将指标列表按每行两个分组
chunkedChildren(children) {
const result = []
@@ -421,7 +461,7 @@ export default {
}
.itic2-content {
padding: 20rpx 0 40rpx;
padding: 20rpx 0 0rpx;
box-sizing: border-box;
}
@@ -642,12 +682,30 @@ export default {
min-width: 0;
}
.point-name-row {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 8rpx;
min-width: 0;
}
.point-name {
display: block;
flex: 1;
min-width: 0;
font-size: 30rpx;
font-weight: 700;
color: #333333;
margin-bottom: 8rpx;
}
.point-type-tag {
flex-shrink: 0;
padding: 4rpx 12rpx;
font-size: 22rpx;
color: #2ba471;
background: #2ba47115;
border-radius: 8rpx;
line-height: 1.2;
}
.meta-row {
@@ -784,7 +842,7 @@ export default {
}
.indicator-popup-list {
max-height: 60vh;
height: 60vh;
padding: 16rpx 0;
box-sizing: border-box;
}

View File

@@ -27,12 +27,9 @@
</view>
<view v-if="moreChildren.length" class="params-section">
<view
v-for="(rowItems, rowIdx) in chunkedChildren(moreChildren)"
:key="rowIdx"
class="double-row"
>
<view v-for="(child, childIdx) in rowItems" :key="child.targetId || childIdx" class="param-group">
<view v-for="(rowItems, rowIdx) in chunkedChildren(moreChildren)" :key="rowIdx" class="double-row">
<view v-for="(child, childIdx) in rowItems" :key="child.targetId || childIdx"
class="param-group">
<view class="param-title">
<text>{{ child.name }}{{ child.unit ? ` (${child.unit})` : '' }}</text>
</view>
@@ -41,15 +38,18 @@
</view>
<view v-else class="phase-vertical">
<view class="phase-item-vertical">
<text class="phase-value-vertical" :style="{ color: phaseColors[0].color }">{{ child.A }}</text>
<text class="phase-value-vertical" :style="{ color: phaseColors[0].color }">{{
child.A }}</text>
</view>
<view class="phase-divider" />
<view class="phase-item-vertical">
<text class="phase-value-vertical" :style="{ color: phaseColors[1].color }">{{ child.B }}</text>
<text class="phase-value-vertical" :style="{ color: phaseColors[1].color }">{{
child.B }}</text>
</view>
<view class="phase-divider" />
<view class="phase-item-vertical">
<text class="phase-value-vertical" :style="{ color: phaseColors[2].color }">{{ child.C }}</text>
<text class="phase-value-vertical" :style="{ color: phaseColors[2].color }">{{
child.C }}</text>
</view>
</view>
</view>
@@ -78,6 +78,10 @@ export default {
computed: {
moreChildren() {
const children = this.pointInfo.children || []
// 治理测点「更多指标」页展示全部
if (this.pointInfo.lineType === 0 && this.pointInfo.showAllIndicators) {
return children
}
const selected = this.getSelectedIndicators()
return children.filter(
(child) => !selected.some((name) => this.matchIndicator(child.name, name)),
@@ -210,6 +214,7 @@ export default {
display: flex;
gap: 20rpx;
align-items: center;
justify-content: end;
padding: 16rpx 20rpx;
}

View File

@@ -72,6 +72,7 @@ import Engineering from './comp/engineering.vue'
import list from '../../common/js/list'
import { getDevCount } from '../../common/api/device.js'
import { queryEngineering } from '@/common/api/engineering.js'
import { checkAppUpdate } from '@/common/js/update.js'
export default {
mixins: [list],
@@ -252,6 +253,11 @@ export default {
this.showBackTop = e.scrollTop > 200
},
onLoad() {
// #ifdef APP-PLUS
checkAppUpdate()
// #endif
// 页面加载时,动态配置导航栏按钮
if (!uni.getStorageSync(this.$cacheKey.access_token)) {
uni.reLaunch({
@@ -289,6 +295,8 @@ export default {
// #endif
},
onShow() {
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
let access_token = uni.getStorageSync(this.$cacheKey.access_token)
@@ -319,7 +327,7 @@ export default {
},
}
</script>
<style lang="scss">
<style lang="scss" scoped>
.popup-content {
background: #fff;
}

View File

@@ -101,7 +101,7 @@ export default {
this.getDevCount()
this.$nextTick(() => {
if (params.type !== '') {
this.current = params.type - 0
this.current = (params.type - 0)||0
}
if (params.engineeringName != '') {
this.$refs.cnFilterCriteria && this.$refs.cnFilterCriteria.external(params)

View File

@@ -259,7 +259,7 @@ export default {
handleScon() {
this.$refs.message.close()
uni.scanCode({
onlyFromCamera: true,
// onlyFromCamera: false,
success: (res) => {
console.log('条码类型:' + res.scanType)
console.log('条码内容:' + res.result)

View File

@@ -76,11 +76,11 @@
border-radius: 20rpx;
}
/* 电压暂降 - 蓝色系 */
/* 暂降 - 蓝色系 */
.sag .event-icon {
background-color: #2563eb20;
}
/* 电压暂升 - 橙色系 */
/* 暂升 - 橙色系 */
.swell .event-icon {
background-color: #e6a23c20;
}

View File

@@ -115,9 +115,9 @@ export default {
filterValue: 0,
dataList: [
{ value: 0, label: '暂态数量', key: '' },
{ value: 0, label: '暂降', key: '电压暂降' },
{ value: 0, label: '中断', key: '电压中断' },
{ value: 0, label: '暂升', key: '电压暂升' },
{ value: 0, label: '暂降', key: '暂降' },
{ value: 0, label: '中断', key: '中断' },
{ value: 0, label: '暂升', key: '暂升' },
],
status: 'noMore', //more加载前 loading加载中 noMore加载后
sort: 0,
@@ -177,21 +177,21 @@ export default {
},
judgment(val, key) {
switch (val) {
case '电压暂降':
case '暂降':
return {
type: 'sag',
icon: 'icon-a-svg4',
color: '#2563eb',
size: '25',
}
case '电压暂升':
case '暂升':
return {
type: 'swell',
icon: 'icon-a-svg5',
color: '#e6a23c',
size: '25',
}
case '电压中断':
case '中断':
return {
type: 'interrupt',
icon: 'icon-zhongduan2',