Browse Source

Merge branch 'gyq_test' of http://git.bms16.com/liuwei/zx_flk_app into gyq_test

郭宇琦 3 days ago
parent
commit
72546f9554
1 changed files with 15 additions and 2 deletions
  1. 15 2
      pages/message/index.vue

+ 15 - 2
pages/message/index.vue

@@ -41,7 +41,7 @@
 					</view>
 					</view>
 					<view v-if="item.type === 1" class="btn">绑定设备</view>
 					<view v-if="item.type === 1" class="btn">绑定设备</view>
 				</view>
 				</view>
-				<view class="time">{{ item.ctime }}</view>
+				<view class="time">{{ formatTimestamp(item.ctime)}}</view>
 				<view class="dtl">{{ item.overview }}</view>
 				<view class="dtl">{{ item.overview }}</view>
 			</view>
 			</view>
 		</view>
 		</view>
@@ -71,12 +71,25 @@
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
 			this.isSys = options.isSys
 			this.isSys = options.isSys
+			
 		},
 		},
-		created() {
+		onShow(){
 			this.querySysMsgList()
 			this.querySysMsgList()
 			this.queryDeviceMsg()
 			this.queryDeviceMsg()
 		},
 		},
 		methods: {
 		methods: {
+			formatTimestamp(timestamp, isUTC = false) {
+			  const isSeconds = timestamp.toString().length === 10;
+			  const date = isSeconds ? new Date(timestamp * 1000) : new Date(timestamp);
+			
+			  const pad = (num) => num.toString().padStart(2, '0');
+			
+			  if (isUTC) {
+			    return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())} ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}`;
+			  } else {
+			    return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
+			  }
+			},
 			async readMessage() {
 			async readMessage() {
 				await request.postApi(config.API_MESSAGE_READ_MESSAGE, {
 				await request.postApi(config.API_MESSAGE_READ_MESSAGE, {
 					msg_type: 2,
 					msg_type: 2,