添加时间

This commit is contained in:
guanj
2025-08-19 09:50:23 +08:00
parent 127adcd524
commit 67ea86015a
6 changed files with 818 additions and 776 deletions

View File

@@ -1,299 +1,321 @@
import request from './request'
import cache from './cacheKey.js'
import { getImageUrl } from '@/common/api/basic'
import { apiUpdatePush } from '@/common/api/user'
import { queryDictDataCache } from '../api/dictionary.js'
import cacheKey from './cacheKey.js'
import config from '@/common/js/config'
import jsrsasign from 'jsrsasign'
const toast = (title, duration = 1500, call, mask = false, icon = 'none') => {
if (Boolean(title) === false) {
return
}
uni.showToast({
title,
duration,
mask,
icon,
})
setTimeout(() => {
call && call()
}, duration)
}
/**
* @description 格式化时间
* @param time
* @param cFormat
* @returns {string|null}
*/
function parseTime(time, cFormat) {
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
time = parseInt(time)
}
if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay(),
}
return format.replace(/{([ymdhisa])+}/g, (result, key) => {
let value = formatObj[key]
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
}
/**
* @description 格式化时间
* @param time
* @param option
* @returns {string}
*/
function formatTime(time, option) {
if (('' + time).length === 10) {
time = parseInt(time) * 1000
} else {
time = +time
}
if (option) {
return parseTime(time, option)
} else {
const d = new Date(time)
const now = Date.now()
const diff = (now - d) / 1000
if (diff < 30) {
return '刚刚'
} else if (diff < 3600) {
// less 1 hour
return Math.ceil(diff / 60) + '分钟前'
} else if (diff < 3600 * 24) {
return Math.ceil(diff / 3600) + '小时前'
} else if (diff < 3600 * 24 * 2) {
return '1天前'
}
return (
d.getMonth() + 1 + '月' + d.getDate() + '日'
// +
// d.getHours() +
// '时'
// +
// d.getMinutes() +
// '分'
)
}
}
const h5Helper = {
isAndroid: function () {
return window.navigator.appVersion.toLowerCase().indexOf('android') != -1
},
isIOS: function () {
return window.navigator.appVersion.toLowerCase().indexOf('iphone') != -1
},
isWeiXinWeb: function () {
var ua = window.navigator.userAgent.toLowerCase()
return ua.match(/MicroMessenger/i) == 'micromessenger'
},
}
// 验证手机号格式
const validatePhoneNumber = (phone) => {
if (!phone) return false
var testReg = /^1[23456789]\d{9}$/
return testReg.test(phone)
}
const getUserLocation = (call) => {
uni.getLocation({
type: 'wgs84',
success: function (address) {
call(address)
},
fail: (err) => {
uni.showModal({
title: '提示',
content: '定位失败,请打开定位权限',
success: function (res) {
if (res.confirm) {
uni.openSetting({
success: (resSett) => {
if (resSett.authSetting['scope.userLocation']) {
uni.getLocation({
success: (address) => {
call && call(address)
},
})
}
},
})
}
},
})
},
})
}
// 加载用户配置
var globalConfigIsLoading = false,
global_config = null,
globalConfigCallbacks = []
/**
* 加载用户配置
* @param call 加载成功后的回调
* @param need_fresh 是否及时刷新用户配置
*/
const loadConfig = (call, need_fresh = false) => {
if (call && global_config && !need_fresh) {
call(global_config)
return
}
if (globalConfigIsLoading) {
globalConfigCallbacks.push(call)
return
}
globalConfigIsLoading = true
request({
url: '/org/userResource/userMsg',
})
.then((rs) => {
globalConfigIsLoading = false
global_config = rs.data
uni.setStorage({
key: 'userInfo',
data: global_config,
})
if (call) {
call(global_config)
}
for (var i = 0; i < globalConfigCallbacks.length; i++) {
globalConfigCallbacks[i](global_config)
}
globalConfigCallbacks = []
})
.catch((err) => {
globalConfigIsLoading = false
console.warn(err)
// uni.reLaunch({ url: '/pages/user/login' })
})
}
const prePage = () => {
let pages = getCurrentPages()
let prePage = pages[pages.length - 2]
return prePage
}
const loginSuccess = (data, jump = true) => {
return new Promise((resolve, reject) => {
console.log(data)
uni.setStorageSync('access_token', data.token_type + ' ' + data.access_token)
uni.setStorageSync('refresh_token', data.refresh_token)
let userInfo = decodeToken(data.access_token)
console.log(userInfo)
// let strings = data.access_token.split('.') //截取token获取载体
// console.log(escape, atob)
// var userInfo = JSON.parse(decodeURIComponent(escape(atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
userInfo.authorities = userInfo.authorities[0]
if (userInfo.headSculpture) {
userInfo.avatar = config.static + userInfo.headSculpture
}
console.log(userInfo)
uni.setStorageSync(cache.userInfo, userInfo)
apiUpdatePush()
resolve(userInfo)
if (jump) {
queryDictDataCache().then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
})
console.log('reLaunch')
uni.reLaunch({
url: '/pages/index/index',
fail: (err) => {
console.log(err)
},
})
}
})
}
/**
* 只针对列表页的刷新
* @param {*} number
* @param {*} time
*/
const refreshPrePage = (number = 1, time = 1500) => {
let pages = getCurrentPages()
let prePage = pages[pages.length - number - 1]
if (prePage && time) {
prePage.$vm.store?.reload()
setTimeout(() => {
uni.navigateBack({
delta: number,
})
}, time)
}
}
const decodeToken = (token) => {
let obj = null
if (token !== '') {
const payload = jsrsasign.KJUR.jws.JWS.parse(token)
if (payload.hasOwnProperty('payloadObj')) {
obj = payload.payloadObj
}
}
return obj
}
const getDictData = (key) => {
return new Promise((resolve, reject) => {
let dictData = uni.getStorageSync(cacheKey.dictData)
if (dictData) {
resolve(dictData.filter((item) => item.code === key)[0]?.children || [])
} else {
// 查询字典
queryDictDataCache().then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
resolve(res.data.filter((item) => item.code === key)[0]?.children || [])
}).catch(err=>{
reject(err)
})
}
})
}
export default {
validatePhoneNumber,
toast,
formatTime,
parseTime,
h5Helper,
getUserLocation,
loadConfig,
prePage,
loginSuccess,
refreshPrePage,
getDictData,
}
import request from './request'
import cache from './cacheKey.js'
import { getImageUrl } from '@/common/api/basic'
import { apiUpdatePush } from '@/common/api/user'
import { queryDictDataCache } from '../api/dictionary.js'
import cacheKey from './cacheKey.js'
import config from '@/common/js/config'
import jsrsasign from 'jsrsasign'
const toast = (title, duration = 1500, call, mask = false, icon = 'none') => {
if (Boolean(title) === false) {
return
}
uni.showToast({
title,
duration,
mask,
icon,
})
setTimeout(() => {
call && call()
}, duration)
}
/**
* @description 格式化时间
* @param time
* @param cFormat
* @returns {string|null}
*/
function parseTime(time, cFormat) {
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
time = parseInt(time)
}
if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay(),
}
return format.replace(/{([ymdhisa])+}/g, (result, key) => {
let value = formatObj[key]
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
}
/**
* @description 格式化时间
* @param time
* @param option
* @returns {string}
*/
function formatTime(time, option) {
if (('' + time).length === 10) {
time = parseInt(time) * 1000
} else {
time = +time
}
if (option) {
return parseTime(time, option)
} else {
const d = new Date(time)
const now = Date.now()
const diff = (now - d) / 1000
if (diff < 30) {
return '刚刚'
} else if (diff < 3600) {
// less 1 hour
return Math.ceil(diff / 60) + '分钟前'
} else if (diff < 3600 * 24) {
return Math.ceil(diff / 3600) + '小时前'
} else if (diff < 3600 * 24 * 2) {
return '1天前'
}
return (
d.getMonth() + 1 + '月' + d.getDate() + '日'
// +
// d.getHours() +
// '时'
// +
// d.getMinutes() +
// '分'
)
}
}
// 获取当天日期(年月日)
function getToday() {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始需+1
const day = String(today.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
// 获取3个月前的日期
function getThreeMonthsAgo() {
const threeMonthsAgo = new Date();
threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3); // 月份减3
const year = threeMonthsAgo.getFullYear();
const month = String(threeMonthsAgo.getMonth() + 1).padStart(2, '0');
const day = String(threeMonthsAgo.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
const h5Helper = {
isAndroid: function () {
return window.navigator.appVersion.toLowerCase().indexOf('android') != -1
},
isIOS: function () {
return window.navigator.appVersion.toLowerCase().indexOf('iphone') != -1
},
isWeiXinWeb: function () {
var ua = window.navigator.userAgent.toLowerCase()
return ua.match(/MicroMessenger/i) == 'micromessenger'
},
}
// 验证手机号格式
const validatePhoneNumber = (phone) => {
if (!phone) return false
var testReg = /^1[23456789]\d{9}$/
return testReg.test(phone)
}
const getUserLocation = (call) => {
uni.getLocation({
type: 'wgs84',
success: function (address) {
call(address)
},
fail: (err) => {
uni.showModal({
title: '提示',
content: '定位失败,请打开定位权限',
success: function (res) {
if (res.confirm) {
uni.openSetting({
success: (resSett) => {
if (resSett.authSetting['scope.userLocation']) {
uni.getLocation({
success: (address) => {
call && call(address)
},
})
}
},
})
}
},
})
},
})
}
// 加载用户配置
var globalConfigIsLoading = false,
global_config = null,
globalConfigCallbacks = []
/**
* 加载用户配置
* @param call 加载成功后的回调
* @param need_fresh 是否及时刷新用户配置
*/
const loadConfig = (call, need_fresh = false) => {
if (call && global_config && !need_fresh) {
call(global_config)
return
}
if (globalConfigIsLoading) {
globalConfigCallbacks.push(call)
return
}
globalConfigIsLoading = true
request({
url: '/org/userResource/userMsg',
})
.then((rs) => {
globalConfigIsLoading = false
global_config = rs.data
uni.setStorage({
key: 'userInfo',
data: global_config,
})
if (call) {
call(global_config)
}
for (var i = 0; i < globalConfigCallbacks.length; i++) {
globalConfigCallbacks[i](global_config)
}
globalConfigCallbacks = []
})
.catch((err) => {
globalConfigIsLoading = false
console.warn(err)
// uni.reLaunch({ url: '/pages/user/login' })
})
}
const prePage = () => {
let pages = getCurrentPages()
let prePage = pages[pages.length - 2]
return prePage
}
const loginSuccess = (data, jump = true) => {
return new Promise((resolve, reject) => {
console.log(data)
uni.setStorageSync('access_token', data.token_type + ' ' + data.access_token)
uni.setStorageSync('refresh_token', data.refresh_token)
let userInfo = decodeToken(data.access_token)
console.log(userInfo)
// let strings = data.access_token.split('.') //截取token获取载体
// console.log(escape, atob)
// var userInfo = JSON.parse(decodeURIComponent(escape(atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
userInfo.authorities = userInfo.authorities[0]
if (userInfo.headSculpture) {
userInfo.avatar = config.static + userInfo.headSculpture
}
console.log(userInfo)
uni.setStorageSync(cache.userInfo, userInfo)
apiUpdatePush()
resolve(userInfo)
if (jump) {
queryDictDataCache().then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
})
console.log('reLaunch')
uni.reLaunch({
url: '/pages/index/index',
fail: (err) => {
console.log(err)
},
})
}
})
}
/**
* 只针对列表页的刷新
* @param {*} number
* @param {*} time
*/
const refreshPrePage = (number = 1, time = 1500) => {
let pages = getCurrentPages()
let prePage = pages[pages.length - number - 1]
if (prePage && time) {
prePage.$vm.store?.reload()
setTimeout(() => {
uni.navigateBack({
delta: number,
})
}, time)
}
}
const decodeToken = (token) => {
let obj = null
if (token !== '') {
const payload = jsrsasign.KJUR.jws.JWS.parse(token)
if (payload.hasOwnProperty('payloadObj')) {
obj = payload.payloadObj
}
}
return obj
}
const getDictData = (key) => {
return new Promise((resolve, reject) => {
let dictData = uni.getStorageSync(cacheKey.dictData)
if (dictData) {
resolve(dictData.filter((item) => item.code === key)[0]?.children || [])
} else {
// 查询字典
queryDictDataCache().then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
resolve(res.data.filter((item) => item.code === key)[0]?.children || [])
}).catch(err=>{
reject(err)
})
}
})
}
export default {
validatePhoneNumber,
toast,
formatTime,
parseTime,
h5Helper,
getUserLocation,
loadConfig,
prePage,
loginSuccess,
refreshPrePage,
getDictData,
getToday,
getThreeMonthsAgo
}

View File

@@ -2,8 +2,8 @@
"name" : "灿能物联",
"appid" : "__UNI__88BC25B",
"description" : "",
"versionName" : "1.6.7",
"versionCode" : 167,
"versionName" : "1.6.8",
"versionCode" : 168,
"transformPx" : false,
"sassImplementationName" : "node-sass",
/* 5+App */
@@ -70,13 +70,7 @@
/* SDK */
"sdkConfigs" : {
"ad" : {},
"maps" : {
"amap" : {
"name" : "",
"appkey_ios" : "73262624599d79ee4ad8bba2ab4a0958",
"appkey_android" : "c93dd87e087f3686a9d4463ce5ebcbe1"
}
},
"maps" : {},
"push" : {
"unipush" : {
"version" : "2",
@@ -156,6 +150,9 @@
},
"router" : {
"base" : ""
},
"unipush" : {
"enable" : false
}
},
"mp-toutiao" : {

View File

@@ -1,230 +1,240 @@
<template>
<Cn-page :loading="loading">
<view class="content" slot="body">
<view class="content-item" v-for="(item, index) in store.data" :key="index" @click="jump(item)">
<view class="content-item-header">
<uni-badge class="uni-badge-left-margin" :is-dot="true" :text="item.status == '1' ? 0 : 1"
absolute="rightTop" size="small" style="margin-top: 30rpx;">
<view class="content-item-header-icon">
<image mode="aspectFill" :src="staticIcon" style="height: 60rpx; width: 60rpx"></image>
</view>
</uni-badge>
<view class="content-item-header-right">
<view class="content-item-header-right-title">{{ item.equipmentName }}</view>
<!-- <view class="content-item-header-right-des">{{ item.engineeringName }} {{ item.projectName }}</view> -->
<view class="content-item-header-right-des">工程名称{{ item.engineeringName }}</view>
<view class="content-item-header-right-des">项目名称{{ item.projectName }}</view>
<!-- <view class="content-item-header-right-des">监测点名称{{ item.lineName }}</view> -->
<!-- <view class="content-item-header-right-des">暂态类型{{ item.showName }}</view> -->
<!-- <view class="content-item-header-right-des">{{ item.subTitle }}</view> -->
</view>
<view class="ml10" v-if="type === '0' || item.status != '1'">🔍</view>
</view>
<view class="content-item-footer">{{ item.subTitle }}</view>
</view>
<!-- <uni-card
:title="item.equipmentName"
:extra="item.status == '1' ? '' : '未读'"
:sub-title="item.subTitle"
thumbnail="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
@click="jump(item)"
v-for="(item, index) in store.data"
:key="index"
>
<view class="term-list-bottom">
<view class="term-list-bottom-item" v-for="(item2, textIndex) in item.dataSet" :key="textIndex">
{{ item2.showName + ':' + (item2.value == 3.1415926 ? '-' : item2.value) + (item2.unit || '') }}
</view>
</view>
</uni-card> -->
<Cn-empty v-if="store.empty" style="padding-top: 400rpx"></Cn-empty>
<uni-load-more v-if="store.status == 'loading' || (store.data && store.data.length > 0)"
:status="store.status"></uni-load-more>
</view>
</Cn-page>
</template>
<script>
import list from '@/common/js/list'
import { updateStatus } from '@/common/api/message'
export default {
mixins: [list],
data() {
return {
loading: true,
type: '',
staticIcon: '',
}
},
onLoad(o) {
this.type = '3'
this.devId = o.id
switch (this.type) {
case '0':
uni.setNavigationBarTitle({ title: '暂态事件' })
this.staticIcon = '/static/zantai2.png'
break
case '1':
uni.setNavigationBarTitle({ title: '稳态事件' })
this.staticIcon = '/static/steady2.png'
break
case '2':
uni.setNavigationBarTitle({ title: '运行事件' })
this.staticIcon = '/static/run2.png'
break
case '3':
uni.setNavigationBarTitle({ title: '设备告警' })
this.staticIcon = '/static/device_bad2.png'
break
}
this.init()
},
onNavigationBarButtonTap(e) {
uni.showModal({
title: '提示',
content: '确定要全部标记为已读吗?',
success: (res) => {
if (res.confirm) {
updateStatus({
type: this.type,
eventIds: [],
}).then(() => {
this.loading = true
this.store.reload()
})
}
},
})
},
methods: {
async init() {
let dictData = await this.$util.getDictData('app_event')
console.log(dictData)
this.store = this.DataSource('/cs-harmonic-boot/eventUser/queryEventpage')
this.store.params.type = this.type
this.store.params.deviceId = this.deviceId
this.store.loadedCallback = () => {
this.store.data.forEach((item) => {
if (this.type === '3') {
item.showName = '告警,告警码:' + (item.code || '-')
}
if (this.type !== '0') {
item.subTitle = `${item.startTime}发生${item.showName}`
} else {
item.subTitle =
`发生时间:${item.startTime}` +
item.dataSet
.map((item2) => {
return (
item2.showName +
'' +
(item2.value == 3.1415926 ? '-' : item2.value) +
(item2.unit || '')
)
})
.join('')
}
})
this.loading = false
}
this.store.reload()
},
jump(item) {
if (this.type === '0') {
let str = JSON.stringify(item).replace(/%/g, '百分比')
uni.navigateTo({ url: '/pages/message/messageDetail?detail=' + encodeURIComponent(str) })
} else {
if (item.status != '1') {
item.status = '1'
updateStatus({
eventIds: [item.id],
})
}
}
},
},
}
</script>
<style lang="scss">
.content {
.content-item {
margin: 20rpx;
padding: 20rpx 20rpx;
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 6rpx 2rpx;
border-radius: 8rpx;
border: 1px solid #ebeef5;
background: #fff;
.content-item-header {
display: flex;
padding: 20rpx 0;
border-bottom: 1px solid #ebeef5;
.content-item-header-icon {
display: flex;
align-items: center;
justify-content: center;
width: 100rpx;
height: 100rpx;
border-radius: 8rpx;
background: $uni-theme-color;
}
.content-item-header-right {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
// height: 140rpx;
margin-left: 20rpx;
.content-item-header-right-title {
font-size: 28rpx;
font-weight: bold;
color: #111;
}
.content-item-header-right-des {
font-size: 24rpx;
color: #999;
}
}
}
.content-item-footer {
margin-top: 20rpx;
font-size: 24rpx;
color: #999;
}
}
// padding-top: 20rpx;
}
.term-list-bottom {
.term-list-bottom-item {
font-size: 28rpx;
margin-bottom: 10rpx;
display: flex;
justify-content: space-between;
// view:first-of-type{
// color: #111;
// }
}
.term-list-bottom-item:last-of-type {
margin-bottom: 0;
}
}
/deep/ .uni-list-item {
background-color: $uni-theme-white !important;
}
/deep/ .uni-card__header-extra-text {
color: #dd524d !important;
font-size: 20rpx;
}
</style>
<template>
<Cn-page :loading="loading">
<view class="content" slot="body">
<view class="content-item" v-for="(item, index) in store.data" :key="index" @click="jump(item)">
<view class="content-item-header">
<uni-badge
class="uni-badge-left-margin"
:is-dot="true"
:text="item.status == '1' ? 0 : 1"
absolute="rightTop"
size="small"
style="margin-top: 30rpx"
>
<view class="content-item-header-icon">
<image mode="aspectFill" :src="staticIcon" style="height: 60rpx; width: 60rpx"></image>
</view>
</uni-badge>
<view class="content-item-header-right">
<view class="content-item-header-right-title">{{ item.equipmentName }}</view>
<!-- <view class="content-item-header-right-des">{{ item.engineeringName }} {{ item.projectName }}</view> -->
<view class="content-item-header-right-des">工程名称{{ item.engineeringName }}</view>
<view class="content-item-header-right-des">项目名称{{ item.projectName }}</view>
<!-- <view class="content-item-header-right-des">监测点名称{{ item.lineName }}</view> -->
<!-- <view class="content-item-header-right-des">暂态类型{{ item.showName }}</view> -->
<!-- <view class="content-item-header-right-des">{{ item.subTitle }}</view> -->
</view>
<view class="ml10" v-if="type === '0' || item.status != '1'">🔍</view>
</view>
<view class="content-item-footer">{{ item.subTitle }}</view>
</view>
<!-- <uni-card
:title="item.equipmentName"
:extra="item.status == '1' ? '' : '未读'"
:sub-title="item.subTitle"
thumbnail="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
@click="jump(item)"
v-for="(item, index) in store.data"
:key="index"
>
<view class="term-list-bottom">
<view class="term-list-bottom-item" v-for="(item2, textIndex) in item.dataSet" :key="textIndex">
{{ item2.showName + ':' + (item2.value == 3.1415926 ? '-' : item2.value) + (item2.unit || '') }}
</view>
</view>
</uni-card> -->
<Cn-empty v-if="store.empty" style="padding-top: 400rpx"></Cn-empty>
<uni-load-more
v-if="store.status == 'loading' || (store.data && store.data.length > 0)"
:status="store.status"
></uni-load-more>
</view>
</Cn-page>
</template>
<script>
import list from '@/common/js/list'
import { updateStatus } from '@/common/api/message'
export default {
mixins: [list],
data() {
return {
loading: true,
type: '',
staticIcon: '',
}
},
onLoad(o) {
this.type = '3'
this.devId = o.id
switch (this.type) {
case '0':
uni.setNavigationBarTitle({ title: '暂态事件' })
this.staticIcon = '/static/zantai2.png'
break
case '1':
uni.setNavigationBarTitle({ title: '稳态事件' })
this.staticIcon = '/static/steady2.png'
break
case '2':
uni.setNavigationBarTitle({ title: '运行事件' })
this.staticIcon = '/static/run2.png'
break
case '3':
uni.setNavigationBarTitle({ title: '设备告警' })
this.staticIcon = '/static/device_bad2.png'
break
}
this.init()
},
onNavigationBarButtonTap(e) {
uni.showModal({
title: '提示',
content: '确定要全部标记为已读吗?',
success: (res) => {
if (res.confirm) {
updateStatus({
type: this.type,
eventIds: [],
}).then(() => {
this.loading = true
this.store.reload()
})
}
},
})
},
methods: {
async init() {
let dictData = await this.$util.getDictData('app_event')
console.log(dictData)
this.store = this.DataSource('/cs-harmonic-boot/eventUser/queryEventpage')
this.store.params.type = this.type
this.store.params.deviceId = this.deviceId
this.store.params.startTime = this.$util.getToday()
this.store.params.endTime = this.$util.getThreeMonthsAgo()
this.store.loadedCallback = () => {
this.store.data.forEach((item) => {
if (this.type === '3') {
item.showName = '告警,告警码:' + (item.code || '-')
}
if (this.type !== '0') {
item.subTitle = `${item.startTime}发生${item.showName}`
} else {
item.subTitle =
`发生时间:${item.startTime}` +
item.dataSet
.map((item2) => {
return (
item2.showName +
'' +
(item2.value == 3.1415926 ? '-' : item2.value) +
(item2.unit || '')
)
})
.join('')
}
})
this.loading = false
}
this.store.reload()
},
jump(item) {
if (this.type === '0') {
let str = JSON.stringify(item).replace(/%/g, '百分比')
uni.navigateTo({ url: '/pages/message/messageDetail?detail=' + encodeURIComponent(str) })
} else {
if (item.status != '1') {
item.status = '1'
updateStatus({
eventIds: [item.id],
})
}
}
},
},
}
</script>
<style lang="scss">
.content {
.content-item {
margin: 20rpx;
padding: 20rpx 20rpx;
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 6rpx 2rpx;
border-radius: 8rpx;
border: 1px solid #ebeef5;
background: #fff;
.content-item-header {
display: flex;
padding: 20rpx 0;
border-bottom: 1px solid #ebeef5;
.content-item-header-icon {
display: flex;
align-items: center;
justify-content: center;
width: 100rpx;
height: 100rpx;
border-radius: 8rpx;
background: $uni-theme-color;
}
.content-item-header-right {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
// height: 140rpx;
margin-left: 20rpx;
.content-item-header-right-title {
font-size: 28rpx;
font-weight: bold;
color: #111;
}
.content-item-header-right-des {
font-size: 24rpx;
color: #999;
}
}
}
.content-item-footer {
margin-top: 20rpx;
font-size: 24rpx;
color: #999;
}
}
// padding-top: 20rpx;
}
.term-list-bottom {
.term-list-bottom-item {
font-size: 28rpx;
margin-bottom: 10rpx;
display: flex;
justify-content: space-between;
// view:first-of-type{
// color: #111;
// }
}
.term-list-bottom-item:last-of-type {
margin-bottom: 0;
}
}
/deep/ .uni-list-item {
background-color: $uni-theme-white !important;
}
/deep/ .uni-card__header-extra-text {
color: #dd524d !important;
font-size: 20rpx;
}
</style>

View File

@@ -1,236 +1,249 @@
<template>
<Cn-page :loading="loading">
<view class="content" slot="body">
<view class="content-item" v-for="(item, index) in store.data" :key="index" @click="jump(item)">
<view class="content-item-header">
<uni-badge class="uni-badge-left-margin" :is-dot="true" :text="item.status == '1' ? 0 : 1"
absolute="rightTop" size="small" :style="type == '0' ? `margin-top: 30rpx;` : ''">
<view class="content-item-header-icon">
<image mode="aspectFill" :src="staticIcon" style="height: 60rpx; width: 60rpx"></image>
</view>
</uni-badge>
<view class="content-item-header-right">
<view class="content-item-header-right-title">{{ item.equipmentName }}</view>
<!-- <view class="content-item-header-right-des">{{ item.engineeringName }} {{ item.projectName }}</view> -->
<view class="content-item-header-right-des">工程名称{{ item.engineeringName }}</view>
<view class="content-item-header-right-des">项目名称{{ item.projectName }}</view>
<view class="content-item-header-right-des" v-if="type == '0' || type == '1'">监测点名称{{
item.lineName }}</view>
<view class="content-item-header-right-des" v-if="type == '0'">暂态类型{{ item.showName}}</view>
<!-- <view class="content-item-header-right-des">{{ item.subTitle }}</view> -->
</view>
<view class="ml10" v-if="type === '0' || item.status != '1'">🔍</view>
</view>
<view class="content-item-footer">{{ item.subTitle }}</view>
</view>
<!-- <uni-card
:title="item.equipmentName"
:extra="item.status == '1' ? '' : '未读'"
:sub-title="item.subTitle"
thumbnail="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
@click="jump(item)"
v-for="(item, index) in store.data"
:key="index"
>
<view class="term-list-bottom">
<view class="term-list-bottom-item" v-for="(item2, textIndex) in item.dataSet" :key="textIndex">
{{ item2.showName + ':' + (item2.value == 3.1415926 ? '-' : item2.value) + (item2.unit || '') }}
</view>
</view>
</uni-card> -->
<Cn-empty v-if="store.empty" style="padding-top: 400rpx"></Cn-empty>
<uni-load-more v-if="store.status == 'loading' || (store.data && store.data.length > 0)"
:status="store.status"></uni-load-more>
</view>
</Cn-page>
</template>
<script>
import list from '@/common/js/list'
import { updateStatus } from '@/common/api/message'
export default {
mixins: [list],
data() {
return {
loading: true,
type: '',
staticIcon: '',
}
},
onLoad(o) {
this.type = o.type
switch (o.type) {
case '0':
uni.setNavigationBarTitle({ title: '暂态事件' })
this.staticIcon = '/static/zantai2.png'
break
case '1':
uni.setNavigationBarTitle({ title: '稳态事件' })
this.staticIcon = '/static/steady2.png'
break
case '2':
uni.setNavigationBarTitle({ title: '运行事件' })
this.staticIcon = '/static/run2.png'
break
case '3':
uni.setNavigationBarTitle({ title: '设备告警' })
this.staticIcon = '/static/device_bad2.png'
break
}
this.init()
},
// onShow() { this.init()},
onNavigationBarButtonTap(e) {
uni.showModal({
title: '提示',
content: '确定要全部标记为已读吗?',
success: (res) => {
if (res.confirm) {
updateStatus({
type: this.type,
eventIds: [],
}).then(() => {
this.loading = true
this.store.reload()
})
}
},
})
},
methods: {
async init() {
let dictData = await this.$util.getDictData('app_event')
console.log(dictData)
this.store = this.DataSource('/cs-harmonic-boot/eventUser/queryEventpage')
this.store.params.type = this.type
this.store.loadedCallback = () => {
console.log(111, this.store.data)
this.store.data.forEach((item) => {
if (this.type === '3') {
item.showName = '告警,告警码:' + (item.code || '-')
}
if (this.type !== '0') {
item.subTitle = `${item.startTime}发生${item.showName}`
} else {
item.subTitle =
`发生时间:${item.startTime}` +
item.dataSet
.map((item2) => {
return (
item2.showName +
'' +
(item2.value == 3.1415926 ? '-' : item2.value) +
(item2.unit || '')
)
})
.join('')
}
})
this.loading = false
}
this.store.reload()
},
jump(item) {
if (this.type === '0') {
let str = JSON.stringify(item).replace(/%/g, '百分比')
item.status = '1'
uni.navigateTo({ url: '/pages/message/messageDetail?detail=' + encodeURIComponent(str) })
} else {
if (item.status != '1') {
item.status = '1'
updateStatus({
eventIds: [item.id],
})
}
}
},
},
}
</script>
<style lang="scss">
.content {
.content-item {
margin: 20rpx;
padding: 20rpx 20rpx;
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 6rpx 2rpx;
border-radius: 8rpx;
border: 1px solid #ebeef5;
background: #fff;
.content-item-header {
display: flex;
padding: 20rpx 0;
border-bottom: 1px solid #ebeef5;
.content-item-header-icon {
display: flex;
align-items: center;
justify-content: center;
width: 100rpx;
height: 100rpx;
border-radius: 8rpx;
background: $uni-theme-color;
}
.content-item-header-right {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
// height: 140rpx;
margin-left: 20rpx;
.content-item-header-right-title {
font-size: 28rpx;
font-weight: bold;
color: #111;
}
.content-item-header-right-des {
font-size: 24rpx;
color: #999;
}
}
}
.content-item-footer {
margin-top: 20rpx;
font-size: 24rpx;
color: #999;
}
}
// padding-top: 20rpx;
}
.term-list-bottom {
.term-list-bottom-item {
font-size: 28rpx;
margin-bottom: 10rpx;
display: flex;
justify-content: space-between;
// view:first-of-type{
// color: #111;
// }
}
.term-list-bottom-item:last-of-type {
margin-bottom: 0;
}
}
/deep/ .uni-list-item {
background-color: $uni-theme-white !important;
}
/deep/ .uni-card__header-extra-text {
color: #dd524d !important;
font-size: 20rpx;
}
</style>
<template>
<Cn-page :loading="loading">
<view class="content" slot="body">
<view class="content-item" v-for="(item, index) in store.data" :key="index" @click="jump(item)">
<view class="content-item-header">
<uni-badge
class="uni-badge-left-margin"
:is-dot="true"
:text="item.status == '1' ? 0 : 1"
absolute="rightTop"
size="small"
:style="type == '0' ? `margin-top: 30rpx;` : ''"
>
<view class="content-item-header-icon">
<image mode="aspectFill" :src="staticIcon" style="height: 60rpx; width: 60rpx"></image>
</view>
</uni-badge>
<view class="content-item-header-right">
<view class="content-item-header-right-title">{{ item.equipmentName }}</view>
<!-- <view class="content-item-header-right-des">{{ item.engineeringName }} {{ item.projectName }}</view> -->
<view class="content-item-header-right-des">工程名称{{ item.engineeringName }}</view>
<view class="content-item-header-right-des">项目名称{{ item.projectName }}</view>
<view class="content-item-header-right-des" v-if="type == '0' || type == '1'"
>监测点名称{{ item.lineName }}</view
>
<view class="content-item-header-right-des" v-if="type == '0'"
>暂态类型{{ item.showName }}</view
>
<!-- <view class="content-item-header-right-des">{{ item.subTitle }}</view> -->
</view>
<view class="ml10" v-if="type === '0' || item.status != '1'">🔍</view>
</view>
<view class="content-item-footer">{{ item.subTitle }}</view>
</view>
<!-- <uni-card
:title="item.equipmentName"
:extra="item.status == '1' ? '' : '未读'"
:sub-title="item.subTitle"
thumbnail="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
@click="jump(item)"
v-for="(item, index) in store.data"
:key="index"
>
<view class="term-list-bottom">
<view class="term-list-bottom-item" v-for="(item2, textIndex) in item.dataSet" :key="textIndex">
{{ item2.showName + ':' + (item2.value == 3.1415926 ? '-' : item2.value) + (item2.unit || '') }}
</view>
</view>
</uni-card> -->
<Cn-empty v-if="store.empty" style="padding-top: 400rpx"></Cn-empty>
<uni-load-more
v-if="store.status == 'loading' || (store.data && store.data.length > 0)"
:status="store.status"
></uni-load-more>
</view>
</Cn-page>
</template>
<script>
import list from '@/common/js/list'
import Calendar from './util.js'
import { updateStatus } from '@/common/api/message'
export default {
mixins: [list],
data() {
return {
loading: true,
type: '',
staticIcon: '',
}
},
onLoad(o) {
this.type = o.type
switch (o.type) {
case '0':
uni.setNavigationBarTitle({ title: '暂态事件' })
this.staticIcon = '/static/zantai2.png'
break
case '1':
uni.setNavigationBarTitle({ title: '稳态事件' })
this.staticIcon = '/static/steady2.png'
break
case '2':
uni.setNavigationBarTitle({ title: '运行事件' })
this.staticIcon = '/static/run2.png'
break
case '3':
uni.setNavigationBarTitle({ title: '设备告警' })
this.staticIcon = '/static/device_bad2.png'
break
}
this.init()
},
// onShow() { this.init()},
onNavigationBarButtonTap(e) {
uni.showModal({
title: '提示',
content: '确定要全部标记为已读吗?',
success: (res) => {
if (res.confirm) {
updateStatus({
type: this.type,
eventIds: [],
}).then(() => {
this.loading = true
this.store.reload()
})
}
},
})
},
methods: {
async init() {
let dictData = await this.$util.getDictData('app_event')
console.log(dictData)
this.store = this.DataSource('/cs-harmonic-boot/eventUser/queryEventpage')
this.store.params.type = this.type
this.store.params.startTime = this.$util.getToday()
this.store.params.endTime = this.$util.getThreeMonthsAgo()
this.store.loadedCallback = () => {
console.log(111, this.store.data)
this.store.data.forEach((item) => {
if (this.type === '3') {
item.showName = '告警,告警码:' + (item.code || '-')
}
if (this.type !== '0') {
item.subTitle = `${item.startTime}发生${item.showName}`
} else {
item.subTitle =
`发生时间:${item.startTime}` +
item.dataSet
.map((item2) => {
return (
item2.showName +
'' +
(item2.value == 3.1415926 ? '-' : item2.value) +
(item2.unit || '')
)
})
.join('')
}
})
this.loading = false
}
this.store.reload()
},
jump(item) {
if (this.type === '0') {
let str = JSON.stringify(item).replace(/%/g, '百分比')
item.status = '1'
uni.navigateTo({ url: '/pages/message/messageDetail?detail=' + encodeURIComponent(str) })
} else {
if (item.status != '1') {
item.status = '1'
updateStatus({
eventIds: [item.id],
})
}
}
},
},
}
</script>
<style lang="scss">
.content {
.content-item {
margin: 20rpx;
padding: 20rpx 20rpx;
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 6rpx 2rpx;
border-radius: 8rpx;
border: 1px solid #ebeef5;
background: #fff;
.content-item-header {
display: flex;
padding: 20rpx 0;
border-bottom: 1px solid #ebeef5;
.content-item-header-icon {
display: flex;
align-items: center;
justify-content: center;
width: 100rpx;
height: 100rpx;
border-radius: 8rpx;
background: $uni-theme-color;
}
.content-item-header-right {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
// height: 140rpx;
margin-left: 20rpx;
.content-item-header-right-title {
font-size: 28rpx;
font-weight: bold;
color: #111;
}
.content-item-header-right-des {
font-size: 24rpx;
color: #999;
}
}
}
.content-item-footer {
margin-top: 20rpx;
font-size: 24rpx;
color: #999;
}
}
// padding-top: 20rpx;
}
.term-list-bottom {
.term-list-bottom-item {
font-size: 28rpx;
margin-bottom: 10rpx;
display: flex;
justify-content: space-between;
// view:first-of-type{
// color: #111;
// }
}
.term-list-bottom-item:last-of-type {
margin-bottom: 0;
}
}
/deep/ .uni-list-item {
background-color: $uni-theme-white !important;
}
/deep/ .uni-card__header-extra-text {
color: #dd524d !important;
font-size: 20rpx;
}
</style>

View File

@@ -4,7 +4,7 @@
<view class="about">
<image src="/static/logo.png" class="logo"></image>
<view class="name">灿能物联</view>
<view class="version">Version 1.6.6</view>
<view class="version">Version 1.6.7</view>
</view>
</view>
</Cn-page>

View File

@@ -48,7 +48,7 @@
<!-- @click="jump('about')" -->
<view class="mine-nav" style="border-bottom: none">
<view class="mine-nav-label">版本信息</view>
<view style="color: #828282; font-size: 14rpx">当前版本V1.6.6</view>
<view style="color: #828282; font-size: 14rpx">当前版本V<1.6.7/view>
<!-- <uni-icons type="forward" color="#aaa" size="20"></uni-icons> -->
</view>
<view class="mine-nav" @click="jump('layout')" style="margin-top: 20rpx; border-bottom: none">