Преглед на файлове

异常上报id换deviceId

gcz преди 3 години
родител
ревизия
e740cbf1e3

+ 14 - 0
pages.json

@@ -116,6 +116,20 @@
 				"navigationStyle":"custom",// 隐藏系统导航栏
 				"navigationBarTitleText": "设备详情"
 			}
+		},
+		{
+			"path": "pages/center/message/message",
+			"style": {
+				"navigationStyle":"custom",// 隐藏系统导航栏
+				"navigationBarTitleText": "消息通知"
+			}
+		},
+		{
+			"path": "pages/center/message/messageInfo",
+			"style": {
+				"navigationStyle":"custom",// 隐藏系统导航栏
+				"navigationBarTitleText": "消息详情"
+			}
 		}
 		
     ],

+ 65 - 0
pages/center/message/message.scss

@@ -0,0 +1,65 @@
+.swiper-wrap{
+	display: flex;
+	flex-direction: column;
+	height: calc(100vh - var(--window-top));
+	width: 100%;
+	.swiper-box {
+		flex: 1;
+	}
+}
+.page-box{
+	margin: 25rpx 40rpx;
+	.message{
+		overflow: hidden;
+		margin-bottom: 20rpx;
+		background-color: #fff;
+		border-radius: 15rpx;
+		.message-top{
+			margin-bottom: 20rpx;
+			padding: 25rpx 40rpx;
+			.car{
+				font-size: 32rpx;
+				font-weight: 600;
+				color: #3A3A3A;
+				line-height: 45rpx;
+				letter-spacing: 1px
+			}
+			.addr{
+				color: #858585;
+				font-size: 26rpx;
+				line-height: 37rpx;
+			}
+			.message-top-right{
+				padding: 0 15rpx;
+				height: 50rpx;
+				line-height: 48rpx;
+				border-radius: 5rpx;
+				position: relative;
+			}
+		}
+		.message-center{
+			padding: 0 40rpx 25rpx;
+			border-bottom: 1px solid #DFDFDF;
+			.message-center-item{
+				margin-bottom: 9rpx;
+				font-size: 26rpx;
+				font-weight: 400;
+				color: #595959;
+				line-height: 37rpx;
+				letter-spacing: 1px;
+				overflow : hidden;
+				text-overflow: ellipsis;
+				display: -webkit-box;
+				-webkit-line-clamp: 2;
+				-webkit-box-orient: vertical;
+			}
+		}
+		.u-cell_title{
+			color: "#008CFF" ;
+		}
+	}
+}
+.time{
+	margin-left: 115px;
+	margin-top: 10px;
+}

+ 149 - 0
pages/center/message/message.vue

@@ -0,0 +1,149 @@
+<template>
+	<view>
+		<u-navbar 
+		title-color="#fff" 
+		:custom-back="customBack" 
+		:border-bottom="false" 
+		back-icon-color="#CCE8FF"
+			:background="{background: 'linear-gradient(99deg, #7A4398 0%, #5A5DB9 100%)' }" title="消息中心" />
+		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
+			<scroll-view scroll-y style="height: 100%; width: 100%;" v-for="(messageItem, index) in  messageList"
+				:key="messageItem.id">
+				<view class="time">{{messageItem.createTime}}</view>
+				<view class="page-box">
+					<view class="message" @click="goDetails(messageItem)">
+						<view class="message-top u-flex">
+							<view class="message-top-left u-flex-1">
+								<view class="car">{{messageItem.title}}</view>
+							</view>
+							<view class="message-top-right u-flex-2">
+								<u-badge :is-dot="true" type="error" v-if="messageItem.readFlag=='0'"></u-badge>
+							</view>
+						</view>
+						<view class="message-center">
+							<view class="message-center-item">{{messageItem.content}}</view>
+						</view>
+						<view class="message-bottom">
+							<u-cell-item title="查看详情" style="color: #008CFF;"></u-cell-item>
+						</view>
+					</view>
+				</view>
+			</scroll-view>
+		</mescroll-body>
+		<u-toast ref="uToast" />
+	</view>
+</template>
+
+<script>
+	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
+	export default {
+		mixins: [MescrollMixin], // 使用mixin
+		data() {
+			return {
+				messageList: []
+			};
+		},
+		methods: {
+			// 返回上一页
+			customBack() {
+				uni.getStorage({
+					key: 'messageBack',
+					success: (res) => {
+						this.$u.route({
+							type: 'switchTab',
+							url: res.data
+						})
+					},
+					fail: (err) => {
+						uni.switchTab({
+							url: '/pages/index/index'
+						})
+					}
+				})
+			},
+			/*下拉刷新的回调*/
+			downCallback() {
+				// 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
+				this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
+			},
+			/*上拉加载的回调*/
+			upCallback(page) {
+				let pageNum = page.num; // 页码, 默认从1开始
+				let pageSize = page.size; // 页长, 默认每页10条
+				this.$u.api.getMessageList({
+						pageSize: pageSize,
+						pageNum: pageNum
+					})
+					.then(res => {
+						if (res.code == 200) {
+							// 接口返回的当前页数据列表 (数组)
+							let curPageData = res.data?.rows ?? [];
+							// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
+							let curPageLen = curPageData.length;
+							// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
+							let totalPage = res.data.pages;
+							// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
+							let totalSize = res.data.total;
+							// 接口返回的是否有下一页 (true/false)
+							let hasNext = res.data.page < res.data.pages;
+
+							//设置列表数据
+							if (page.num == 1) this.messageList = []; // 如果是第一页需手动置空列表
+							this.messageList = this.messageList.concat(curPageData); // 追加新数据
+							// 后台接口有返回列表的总页数 totalPage
+							this.mescroll.endByPage(curPageLen, totalPage);
+							setTimeout(() => {
+								this.mescroll.endSuccess(curPageLen)
+							}, 20)
+						} else {
+							this.mescroll.endErr()
+						}
+					})
+			},
+			// 跳转消息详情
+			goDetails(item) {
+				if (Number(item.readFlag) === 0) {
+					this.$u.api.messageRead({
+							newId: item.id
+						})
+						.then(res => {
+							if (res.code == 200) {
+								this.$u.route({
+									url: 'pages/center/message/messageInfo',
+									params: {
+										details: JSON.stringify(item)
+									}
+								});
+							} else {
+								this.$refs.uToast.show({
+									title: res.msg,
+									type: 'error'
+								})
+							}
+						})
+				} else {
+					this.$u.route({
+						url: 'pages/message/messageInfo',
+						params: {
+							details: JSON.stringify(item)
+						}
+					});
+				}
+			}
+		},
+	};
+</script>
+
+<style>
+	/* #ifndef H5 */
+	page {
+		height: 100%;
+		background-color: #F6F6FF;
+	}
+
+	/* #endif */
+</style>
+
+<style lang="scss" scoped>
+	@import "./message.scss";
+</style>

+ 75 - 0
pages/center/message/messageInfo.vue

@@ -0,0 +1,75 @@
+<template>
+	<view class="info">
+		<u-navbar
+			title-color="#fff"
+			:custom-back="customBack"
+			:border-bottom="false"
+			back-icon-color="#CCE8FF"
+			:background="{background: 'linear-gradient(99deg, #7A4398 0%, #5A5DB9 100%)' }"
+			title="消息详情"></u-navbar>
+		<view class="time">{{details.createTime}}</view>
+		<view class="box">
+			<view class="title">{{details.title}}</view>
+			<view class="content">{{details.content}}</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				details: {}
+			};
+		},
+		onLoad(page) {
+			const details = JSON.parse(page.details)
+			if (details) {
+				this.details = details
+			}
+		},
+		methods: {
+			customBack() {
+				this.$u.route({
+					url: 'pages/message/message'
+				});
+			}
+		}
+
+	}
+</script>
+
+<style>
+	/* #ifndef H5 */
+	page {
+		height: 100%;
+		background-color: #F6F6FF;
+	}
+
+	/* #endif */
+</style>
+
+<style lang="scss" scoped>
+	.info {
+		padding: 40rpx 40rpx;
+
+	}
+
+	.box {
+		margin-top: 20rpx;
+		background-color: white;
+		border-radius: 15rpx;
+
+		.title {
+			padding-top: 20rpx;
+			text-align: center;
+			font-size: 40rpx;
+		}
+	}
+
+	.content {
+		text-indent: 2em;
+		padding: 20rpx 40rpx;
+		line-height: 44rpx;
+	}
+</style>

+ 3 - 3
pages/deviceList/deviceListType1/deviceInfo.vue

@@ -79,7 +79,7 @@
 				deviceType:'',
 				title:'设备详情',
 				pageData:[],
-				deviceID:'',
+				id:'',
 				downOption:{
 					auto:false // 不自动加载 (mixin已处理第一个tab触发downCallback)
 				},
@@ -127,7 +127,6 @@
 		},
 		onLoad(page){
 			this.deviceID = page.id;
-			this.form.deviceId = page.id;
 			if(page.roadName){
 				this.roadName = page.roadName;
 				this.title = page.roadName;
@@ -180,9 +179,10 @@
 				})
 			},
 			findRoadSpaceVoById(){
-				this.$u.api.findRoadSpaceVoById({id:this.deviceID}).then(res=>{
+				this.$u.api.findRoadSpaceVoById({id:this.id}).then(res=>{
 					if(res.code==200){
 						this.pageData = res.data;
+						this.form.deviceId = res.data.deviceId;
 						// console.log('findRoadSpaceVoById',res);
 					}else{
 						uni.showToast({

+ 4 - 4
pages/deviceList/deviceListType2/deviceInfo.vue

@@ -79,7 +79,7 @@
 				deviceType:'',
 				title:'设备详情',
 				pageData:[],
-				deviceID:'',
+				id:'',
 				downOption:{
 					auto:false // 不自动加载 (mixin已处理第一个tab触发downCallback)
 				},
@@ -126,8 +126,7 @@
 			}
 		},
 		onLoad(page){
-			this.deviceID = page.id;
-			this.form.deviceId = page.id;
+			this.id = page.id;
 			if(page.roadName){
 				this.roadName = page.roadName;
 				this.title = page.roadName;
@@ -180,9 +179,10 @@
 				})
 			},
 			findRoadSpaceVoById(){
-				this.$u.api.findRoadSpaceVoById({id:this.deviceID}).then(res=>{
+				this.$u.api.findRoadSpaceVoById({id:this.id}).then(res=>{
 					if(res.code==200){
 						this.pageData = res.data;
+						this.form.deviceId = res.data.deviceId;
 						// console.log('findRoadSpaceVoById',res);
 					}else{
 						uni.showToast({

+ 4 - 4
pages/deviceList/deviceListType3/deviceInfo.vue

@@ -51,7 +51,7 @@
 				deviceType:'',
 				title:'设备详情',
 				pageData:[],
-				deviceID:'',
+				id:'',
 				popupShow:false,
 				labelWidth:190,
 				action:this.config.upFileUrl,
@@ -84,8 +84,7 @@
 			}
 		},
 		onLoad(page){
-			this.deviceID = page.id;
-			this.form.deviceId = page.id;
+			this.id = page.id;
 			if(page.roadName){
 				this.roadName = page.roadName;
 				this.title = page.roadName;
@@ -136,9 +135,10 @@
 				})
 			},
 			findParkDeviceById(){
-				this.$u.api.findParkDeviceById({id:this.deviceID}).then(res=>{
+				this.$u.api.findParkDeviceById({id:this.id}).then(res=>{
 					if(res.code==200){
 						this.pageData = res.data;
+						this.form.deviceId = res.data.deviceId;
 						// console.log('findParkDeviceById',res);
 					}else{
 						uni.showToast({

+ 1 - 1
pages/index/index.vue

@@ -4,7 +4,7 @@
 			<view class="header f-padding">
 				<view class="header-item header-title">
 					欢迎登录 
-					<view class="message" @click="openPage('pages/center/news/news')">
+					<view class="message" @click="openPage('pages/center/message/message')">
 						<u-icon name="bell"></u-icon>
 						<u-badge type="error" class="badge" :count="newsTotal" :offset='[-10,-10]'></u-badge>
 					</view>