修改 app问题

This commit is contained in:
GGJ
2024-09-23 08:50:16 +08:00
parent 1dbecd890f
commit 56a2db2b48
9 changed files with 635 additions and 542 deletions

View File

@@ -1,4 +1,4 @@
// export const MQTT_IP = '192.168.1.18:8083/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
// export const MQTT_IP = '192.168.1.24:10215/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
export const MQTT_IP = 'pqmcn.com:8085/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
const MQTT_USERNAME = 't_user'//mqtt用户名

View File

@@ -2,8 +2,8 @@
"name" : "灿能物联",
"appid" : "__UNI__88BC25B",
"description" : "",
"versionName" : "1.6.0",
"versionCode" : 160,
"versionName" : "1.6.1",
"versionCode" : 161,
"transformPx" : false,
/* 5+App */
"app-plus" : {

View File

@@ -88,7 +88,7 @@ export default {
onNavigationBarButtonTap(e) {
uni.showModal({
title: '提示',
content: '确定要全部标记为已读吗1',
content: '确定要全部标记为已读吗?',
success: (res) => {
if (res.confirm) {
updateStatus({

View File

@@ -175,7 +175,7 @@ export default {
if (messagePage) {
uni.setTabBarBadge({
index: 1,
text: messagePage ? messagePage + '' : '',
text:messagePage ? (messagePage > 99 ? '99+' : messagePage + '') : '',
})
} else {
uni.removeTabBarBadge({

View File

@@ -30,6 +30,7 @@
</template>
<script>
import { getDevCount } from '../../common/api/device.js'
export default {
data() {
return {
@@ -37,8 +38,10 @@ export default {
userInfo: {},
messageCount: {},
timer: null,
devCount: {},
}
},
methods: {
init() {
this.userInfo = uni.getStorageSync('userInfo')
@@ -76,10 +79,58 @@ export default {
break
}
},
getDevCount() {
if (uni.getStorageSync('projectList')[1] != undefined) {
getDevCount(uni.getStorageSync('projectList')[1].engineeringId).then((res) => {
this.devCount = res.data
this.devCount.currentOffLineDevs.forEach((item) => {
item.runStatus = 1
})
this.devCount.offLineDevs.forEach((item) => {
item.runStatus = 1
})
uni.setStorage({
key: this.$cacheKey.messageCount,
data: this.devCount,
})
let messagePage =
this.devCount.runCount +
this.devCount.eventCount +
this.devCount.alarmCount +
this.devCount.harmonicCount
let minePage = this.devCount.feedBackCount
if (messagePage) {
uni.setTabBarBadge({
index: 1,
text:messagePage ? (messagePage > 99 ? '99+' : messagePage + '') : '',
})
} else {
uni.removeTabBarBadge({
index: 1,
})
}
if (minePage) {
uni.setTabBarBadge({
index: 2,
text: minePage + '',
})
} else {
uni.removeTabBarBadge({
index: 2,
})
}
// #ifdef APP-PLUS
plus.runtime.setBadgeNumber(messagePage + minePage)
// #endif
})
}
},
},
onLoad(options) {},
onShow() {
this.init()
this.getDevCount()
this.messageCount = uni.getStorageSync(this.$cacheKey.messageCount) || {}
this.timer = setInterval(() => {
this.messageCount = uni.getStorageSync(this.$cacheKey.messageCount) || {}

View File

@@ -84,11 +84,11 @@ export default {
}
this.init()
},
onShow() {},
// onShow() { this.init()},
onNavigationBarButtonTap(e) {
uni.showModal({
title: '提示',
content: '确定要全部标记为已读吗2',
content: '确定要全部标记为已读吗?',
success: (res) => {
if (res.confirm) {
updateStatus({
@@ -136,8 +136,13 @@ export default {
this.store.reload()
},
jump(item) {
console.log(`123`,item);
console.log(`123`,this.type);
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') {

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.0</view>
<view class="version">Version 1.6.1</view>
</view>
</view>
</Cn-page>

View File

@@ -2,38 +2,72 @@
<!-- #ifdef APP-NVUE -->
<cell>
<!-- #endif -->
<view :hover-class="!clickable && !link ? '' : 'uni-list-chat--hover'" class="uni-list-chat" @click.stop="onClick">
<view
:hover-class="!clickable && !link ? '' : 'uni-list-chat--hover'"
class="uni-list-chat"
@click.stop="onClick"
>
<view :class="{ 'uni-list--border': border, 'uni-list-chat--first': isFirstChild }"></view>
<view class="uni-list-chat__container">
<view class="uni-list-chat__header-warp">
<view v-if="avatarCircle || avatarList.length === 0" class="uni-list-chat__header" :class="{ 'header--circle': avatarCircle }">
<image class="uni-list-chat__header-image" :class="{ 'header--circle': avatarCircle }" :src="avatarUrl" mode="aspectFill"></image>
<view
v-if="avatarCircle || avatarList.length === 0"
class="uni-list-chat__header"
:class="{ 'header--circle': avatarCircle }"
>
<image
class="uni-list-chat__header-image"
:class="{ 'header--circle': avatarCircle }"
:src="avatarUrl"
mode="aspectFill"
></image>
</view>
<!-- 头像组 -->
<view v-else class="uni-list-chat__header">
<view v-for="(item, index) in avatarList" :key="index" class="uni-list-chat__header-box" :class="computedAvatar"
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }">
<image class="uni-list-chat__header-image" :style="{ width: imageWidth + 'px', height: imageWidth + 'px' }" :src="item.url"
mode="aspectFill"></image>
<view
v-for="(item, index) in avatarList"
:key="index"
class="uni-list-chat__header-box"
:class="computedAvatar"
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"
>
<image
class="uni-list-chat__header-image"
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"
:src="item.url"
mode="aspectFill"
></image>
</view>
</view>
</view>
<view v-if="badgeText && badgePositon === 'left'" class="uni-list-chat__badge uni-list-chat__badge-pos" :class="[isSingle]">
<view
v-if="badgeText && badgePositon === 'left'"
class="uni-list-chat__badge uni-list-chat__badge-pos"
:class="[isSingle]"
>
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
</view>
<view class="uni-list-chat__content">
<view class="uni-list-chat__content-main">
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
<view style="flex-direction: row;">
<view style="flex-direction: row">
<text class="draft" v-if="isDraft">[草稿]</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{isDraft?note.slice(14,-1):note}}</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{
isDraft ? note.slice(14, -1) : note
}}</text>
</view>
</view>
<view class="uni-list-chat__content-extra">
<slot>
<text class="uni-list-chat__content-extra-text">{{ time }}</text>
<view v-if="badgeText && badgePositon === 'right'" class="uni-list-chat__badge" :class="[isSingle, badgePositon === 'right' ? 'uni-list-chat--right' : '']">
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
<view
v-if="badgeText && badgePositon === 'right'"
class="uni-list-chat__badge"
:class="[isSingle, badgePositon === 'right' ? 'uni-list-chat--right' : '']"
>
<text class="uni-list-chat__badge-text">{{
badgeText === 'dot' ? '' : badgeText
}}</text>
</view>
</slot>
</view>
@@ -47,7 +81,7 @@
<script>
// 头像大小
const avatarWidth = 45;
const avatarWidth = 45
/**
* ListChat 聊天列表
@@ -77,50 +111,50 @@
props: {
title: {
type: String,
default: ''
default: '',
},
note: {
type: String,
default: ''
default: '',
},
clickable: {
type: Boolean,
default: false
default: false,
},
link: {
type: [Boolean, String],
default: false
default: false,
},
to: {
type: String,
default: ''
default: '',
},
badgeText: {
type: [String, Number],
default: ''
default: '',
},
badgePositon: {
type: String,
default: 'right'
default: 'right',
},
time: {
type: String,
default: ''
default: '',
},
avatarCircle: {
type: Boolean,
default: false
default: false,
},
avatar: {
type: String,
default: ''
default: '',
},
avatarList: {
type: Array,
default() {
return [];
}
}
return []
},
},
},
// inject: ['list'],
computed: {
@@ -129,36 +163,38 @@
},
isSingle() {
if (this.badgeText === 'dot') {
return 'uni-badge--dot';
return 'uni-badge--dot'
} else {
const badgeText = this.badgeText.toString();
const badgeText = this.badgeText.toString()
if (badgeText.length > 1) {
return 'uni-badge--complex';
return 'uni-badge--complex'
} else {
return 'uni-badge--single';
return 'uni-badge--single'
}
}
},
computedAvatar() {
if (this.avatarList.length > 4) {
this.imageWidth = avatarWidth * 0.31;
return 'avatarItem--3';
this.imageWidth = avatarWidth * 0.31
return 'avatarItem--3'
} else if (this.avatarList.length > 1) {
this.imageWidth = avatarWidth * 0.47;
return 'avatarItem--2';
this.imageWidth = avatarWidth * 0.47
return 'avatarItem--2'
} else {
this.imageWidth = avatarWidth;
return 'avatarItem--1';
}
this.imageWidth = avatarWidth
return 'avatarItem--1'
}
},
},
watch: {
avatar: {
handler(avatar) {
if (avatar.includes('://')) {
uniCloud.getTempFileURL({
fileList: [avatar]
}).then(res=>{
uniCloud
.getTempFileURL({
fileList: [avatar],
})
.then((res) => {
// console.log(res);
// 兼容uniCloud私有化部署
let fileList = res.fileList || res.result.fileList
@@ -168,8 +204,8 @@
this.avatarUrl = avatar
}
},
immediate: true
}
immediate: true,
},
},
data() {
return {
@@ -177,17 +213,17 @@
border: true,
// avatarList: 3,
imageWidth: 50,
avatarUrl:''
};
avatarUrl: '',
}
},
mounted() {
this.list = this.getForm()
if (this.list) {
if (!this.list.firstChildAppend) {
this.list.firstChildAppend = true;
this.isFirstChild = true;
this.list.firstChildAppend = true
this.isFirstChild = true
}
this.border = this.list.border;
this.border = this.list.border
}
},
methods: {
@@ -195,52 +231,52 @@
* 获取父元素实例
*/
getForm(name = 'uniList') {
let parent = this.$parent;
let parentName = parent.$options.name;
let parent = this.$parent
let parentName = parent.$options.name
while (parentName !== name) {
parent = parent.$parent;
parent = parent.$parent
if (!parent) return false
parentName = parent.$options.name;
parentName = parent.$options.name
}
return parent;
return parent
},
onClick() {
if (this.to !== '') {
this.openPage();
return;
this.openPage()
return
}
if (this.clickable || this.link) {
this.$emit('click', {
data: {}
});
data: {},
})
}
},
openPage() {
if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) {
this.pageApi(this.link);
this.pageApi(this.link)
} else {
this.pageApi('navigateTo');
this.pageApi('navigateTo')
}
},
pageApi(api) {
uni[api]({
url: this.to,
success: res => {
success: (res) => {
this.$emit('click', {
data: res
});
data: res,
})
},
fail: err => {
fail: (err) => {
this.$emit('click', {
data: err
});
console.error(err.errMsg);
data: err,
})
console.error(err.errMsg)
},
})
},
},
}
});
}
}
};
</script>
<style lang="scss">
@@ -471,7 +507,8 @@
overflow: hidden;
}
.draft ,.uni-list-chat__content-note {
.draft,
.uni-list-chat__content-note {
margin-top: 3px;
color: $note-color;
font-size: $note-size;