添加时间

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

View File

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

View File

@@ -48,7 +48,7 @@
<!-- @click="jump('about')" --> <!-- @click="jump('about')" -->
<view class="mine-nav" style="border-bottom: none"> <view class="mine-nav" style="border-bottom: none">
<view class="mine-nav-label">版本信息</view> <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> --> <!-- <uni-icons type="forward" color="#aaa" size="20"></uni-icons> -->
</view> </view>
<view class="mine-nav" @click="jump('layout')" style="margin-top: 20rpx; border-bottom: none"> <view class="mine-nav" @click="jump('layout')" style="margin-top: 20rpx; border-bottom: none">