소스 검색

提交代码

xiongyi 4 일 전
부모
커밋
f4352e4a83
2개의 변경된 파일100개의 추가작업 그리고 72개의 파일을 삭제
  1. 1 1
      pages/message/detail.vue
  2. 99 71
      pages/message/index.vue

+ 1 - 1
pages/message/detail.vue

@@ -3,7 +3,7 @@
 		<navBar name="信息详情"></navBar>
 		<view class="title">{{info.title}}</view>
 		<view >{{info.overview}}</view>
-		<image v-if="info.cover" :src="info.cover" class="img" mode="scaleToFill" />
+		<image v-if="info.cover" :src="info.cover" class="img" mode="aspectFill" />
 		
 		
 		

+ 99 - 71
pages/message/index.vue

@@ -24,84 +24,112 @@
 			style="display: flex;align-items: center;justify-content: center;height: 80vh;">
 			您还没有设备消息
 		</view>
-        
-        <view v-if="isSys==='1' && sysMsgList.length > 0 " style="margin-top: 20rpx;" class="sys-msg-wrap base-wrap" >
-            <view class="title">{{ $t('系统消息') }}</view>
-			
-            <view class="msg-item" v-for="(item, index) in sysMsgList" :key="index" @tap="toSystemMsgPage(item)">
-                <view class="msg">
-                    {{ item.title }}
-                    <view v-if="item.type === 1" class="btn">绑定设备</view>
-                </view>
-                <view class="time">{{ item.ctime }}</view>
-                <view class="dtl">{{ item.overview }}</view>
-            </view>
-        </view>
-		
-		<view v-if="isSys==='1' && sysMsgList.length === 0 " style="display: flex;align-items: center;justify-content: center;height: 80vh;">
+
+		<view v-if="isSys==='1' && sysMsgList.length > 0 " style="margin-top: 20rpx;" class="sys-msg-wrap base-wrap">
+
+			<view class="row">
+				<view class="title" style="display: flex;">
+					<view>{{ $t('系统消息') }}</view>
+					<view v-if="unreadCount > 0" class="bage">{{ unreadCount }}</view>
+				</view>
+			</view>
+			<view @click="gotoDetail(item)" class="msg-item" v-for="(item, index) in sysMsgList" :key="index">
+				<view class="msg">
+					<view class="flex">
+						<view v-if="item.read === '0'" class="dot"></view>
+						{{ item.title }}
+					</view>
+					<view v-if="item.type === 1" class="btn">绑定设备</view>
+				</view>
+				<view class="time">{{ item.ctime }}</view>
+				<view class="dtl">{{ item.overview }}</view>
+			</view>
+		</view>
+
+		<view v-if="isSys==='1' && sysMsgList.length === 0 "
+			style="display: flex;align-items: center;justify-content: center;height: 80vh;">
 			您还没有系统消息
 		</view>
 	</view>
 </template>
 
 <script>
-const config = require('@/common/config.js');
-const http = require('@/common/http.js');
-const request = require('@/common/request.js');
-const common = require('@/common/common.js');
-export default {
-    data() {
-        return {
-            value: 10,
-            sysMsgList: [],
-            deviceList: [],
-            deviceInfo: {},
-			isSys:'1'
-        }
-    },
-	onLoad(options){
-		this.isSys = options.isSys || '0'
-	},
-    created() {
-        this.querySysMsgList()
-        this.queryDeviceMsg()
-		this.readMessage()
-    },
-    methods: {
-		async readMessage(){
-			await request.postApi(config.API_MESSAGE_READ_MESSAGE,{msg_type:2,car_id:0})
+	const config = require('@/common/config.js');
+	const http = require('@/common/http.js');
+	const request = require('@/common/request.js');
+	const common = require('@/common/common.js');
+	export default {
+		data() {
+			return {
+				value: 10,
+				sysMsgList: [],
+				deviceList: [],
+				deviceInfo: {},
+				isSys: '1',
+				unreadCount: 0
+			}
+		},
+		onLoad(options) {
+			this.isSys = options.isSys
+		},
+		created() {
+			this.querySysMsgList()
+			this.queryDeviceMsg()
+			// this.readMessage()
 		},
-        toDeviceMsgPage(itemData) {
-            const { id } = itemData
-            uni.navigateTo({ url: `/pages/message/deviceInfo?car_id=${car_id}` })
-        }, 
-		toSystemMsgPage(itemData) {
-            const { id } = itemData
-            uni.navigateTo({ url: `/pages/message/systemInfo?id=${id}` })
-        },
-        queryDeviceMsg() {
-            http.postApi(config.API_DEVICE_MSG, {}, res => {
-                if (res.succeed) {
-                    this.deviceList = res.body.data
-                    this.deviceList.map(item => {
-                        item.message_date = common.formatTime(item.message_date)
-						item.image = item.image.split(',')[0]
-                    })
-                }
-            })
-        },
-        querySysMsgList() {
-            http.postApi(config.API_MESSAGE_LIST, { msg_type: 'PLAT' }, res => {
-                if (res.succeed) {
-                    this.sysMsgList= res.body.data.list
-                    this.sysMsgList.map(item => {
-                        item.ctime = common.formatTime(item.ctime)
-                    })
-                }
-            })
-        }
-    }
-}
+		methods: {
+			async readMessage() {
+				await request.postApi(config.API_MESSAGE_READ_MESSAGE, {
+					msg_type: 2,
+					car_id: 0
+				})
+			},
+			gotoDetail(item) {
+				request.postApi(config.API_MESSAGE_READ_MESSAGE, {
+					msg_type: 2,
+					msg_id: item.plat_msg_id,
+					car_id: ''
+				})
+
+				uni.navigateTo({
+					url: `/pages/message/detail?id=${item.plat_msg_id}`
+				})
+			},
+			toDeviceMsgPage(item) {
+				equest.postApi(config.API_MESSAGE_READ_MESSAGE, {
+					msg_type: 1,
+					car_id: item.car_id
+				})
+
+				uni.navigateTo({
+					url: `/pages/message/detail?id=${item.car_id}`
+				})
+			},
+			queryDeviceMsg() {
+				http.postApi(config.API_DEVICE_MSG, {}, res => {
+					if (res.succeed) {
+						this.deviceList = res.body.data
+						this.deviceList.map(item => {
+							item.message_date = common.formatTime(item.message_date)
+						})
+					}
+				})
+			},
+			querySysMsgList() {
+				http.postApi(config.API_MESSAGE_LIST, {
+					msg_type: 'PLAT'
+				}, res => {
+					if (res.succeed) {
+						this.sysMsgList = res.body.data.list
+						this.sysMsgList.map(item => {
+							item.ctime = common.formatTime(item.ctime)
+						})
+						this.unreadCount = this.sysMsgList.filter(item => item.read === "0").length;
+					}
+				})
+			}
+		}
+	}
 </script>
 
 <style lang="scss" scoped>