浏览代码

消息应用

xiaohaizhao 2 年之前
父节点
当前提交
a836e23dfc

+ 3 - 1
pages/index/home/index.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "MsgList": "/pages/index/message/modules/list/index"
+  }
 }

+ 5 - 3
pages/index/home/index.wxml

@@ -1,4 +1,5 @@
-<scroll-view scroll-y class="scrollPage">
+<view class="head" />
+<Yl_ListBox id='ListBox' pullDown='{{false}}'>
 	<swiper class="screen-swiper square-dot" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500">
 		<swiper-item wx:for="{{bannerList}}" wx:key>
 			<image src="{{item.attinfos[0].url}}" mode="aspectFill" />
@@ -19,5 +20,6 @@
 			</view>
 		</block>
 	</view>
-	<view style="height: 160rpx;" />
-</scroll-view>
+	<MsgList list="{{msgList}}" />
+	<view style="height: 200rpx;" />
+</Yl_ListBox>

+ 2 - 1
pages/index/message/detail.js

@@ -17,7 +17,8 @@ Page({
       })
       this.setData({
         detailsData: res.data
-      })
+      });
+      getApp().globalData.socketCallback()
     })
   },
 })

+ 2 - 1
pages/index/message/detail.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+  }
 }

+ 11 - 7
pages/index/message/index.js

@@ -18,9 +18,13 @@ Component({
       where: {}
     },
     total: 0,
+    tabshow: false
   },
   methods: {
     init() {
+      this.setData({
+        tabshow: true
+      })
       this.getlist(true)
     },
     getlist(init = false) {
@@ -48,14 +52,14 @@ Component({
         })
       })
     },
-    toDetails(e) {
-      const {
-        item
-      } = e.currentTarget.dataset;
-      wx.navigateTo({
-        url: '/pages/index/message/detail?id=' + item.messageid,
+    //切换tab选项
+    tabChange({
+      detail
+    }) {
+      this.setData({
+        "content.type": detail.name
       })
+      this.getlist(true);
     },
-
   }
 })

+ 3 - 1
pages/index/message/index.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "list": "./modules/list/index"
+  }
 }

+ 0 - 49
pages/index/message/index.scss

@@ -22,52 +22,3 @@ page {
 	font-weight: bold !important;
 }
 
-/* 消息列表 */
-.list {
-	position: relative;
-	height: 194rpx;
-	width: 690rpx;
-	box-sizing: border-box;
-	border-radius: 16rpx;
-	overflow: hidden;
-	background: #ffffff;
-	margin: 20rpx auto 0;
-	padding: 30rpx;
-
-	.title {
-			height: 40rpx;
-			font-size: 28rpx;
-			font-family: PingFang SC-Medium, PingFang SC;
-			font-weight: 500;
-			color: #333333;
-	}
-
-	.content {
-			width: 620rpx;
-			font-size: 24rpx;
-			font-family: PingFang SC-Regular, PingFang SC;
-			color: #666666;
-			margin-top: 16rpx;
-	}
-
-	.time {
-			font-size: 20rpx;
-			font-family: PingFang SC-Regular, PingFang SC;
-			color: #999999;
-			margin-top: 16rpx;
-
-			.tag {
-					margin-right: 10rpx;
-			}
-	}
-
-	.unread-item {
-			position: absolute;
-			width: 16rpx;
-			height: 16rpx;
-			background: var(--error);
-			border-radius: 50%;
-			top: 6rpx;
-			right: 6rpx;
-	}
-}

+ 2 - 9
pages/index/message/index.wxml

@@ -1,17 +1,10 @@
-<van-tabs id='tabs' active="{{ content.type }}" color='var(--assist)' tab-active-class='tab-active-class' bind:change="tabChange">
+<van-tabs id='tabs' wx:if="{{tabshow}}" active="{{ content.type }}" color='var(--assist)' tab-active-class='tab-active-class' bind:change="tabChange">
     <van-tab title="应用消息" name='应用' />
     <van-tab title="系统消息" name='系统' />
 </van-tabs>
 <Yl_ListBox id="ListBox" height="{{height}}" bind:getlist='getlist'>
     <view class="unread">总共{{total}}条</view>
-    <navigator url="#" class='list' wx:for="{{list}}" data-item="{{item}}" bindtap="toDetails">
-        <view class="title line-1">{{item.title}}</view>
-        <view class="content line-1">{{item.message}}</view>
-        <view class="time">
-            <van-tag class="tag" wx:if="{{item.objectname}}" plain type="primary">{{type.query(item.objectname)}}</van-tag>{{item.createdate}}
-        </view>
-        <view wx:if="{{item.isread=='0'}}" class="unread-item" />
-    </navigator>
+    <list list="{{list}}" />
     <Yl_Empty wx:if="{{!list.length}}" />
     <view style="height: 180rpx;" />
 </Yl_ListBox>

+ 5 - 0
pages/index/message/modules/list/index.js

@@ -0,0 +1,5 @@
+Component({
+  properties: {
+    list: Array
+  }
+})

+ 4 - 0
pages/index/message/modules/list/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 48 - 0
pages/index/message/modules/list/index.scss

@@ -0,0 +1,48 @@
+/* 消息列表 */
+.list {
+	position: relative;
+	height: 194rpx;
+	width: 690rpx;
+	box-sizing: border-box;
+	border-radius: 16rpx;
+	overflow: hidden;
+	background: #ffffff;
+	margin: 20rpx auto 0;
+	padding: 20rpx 30rpx;
+
+	.title {
+			font-size: 28rpx;
+			font-family: PingFang SC-Medium, PingFang SC;
+			font-weight: 500;
+			color: #333333;
+	}
+
+	.content {
+			width: 620rpx;
+			font-size: 24rpx;
+			font-family: PingFang SC-Regular, PingFang SC;
+			color: #666666;
+			margin-top: 12rpx;
+	}
+
+	.time {
+			font-size: 20rpx;
+			font-family: PingFang SC-Regular, PingFang SC;
+			color: #999999;
+			margin-top: 16rpx;
+
+			.tag {
+					margin-right: 10rpx;
+			}
+	}
+
+	.unread-item {
+			position: absolute;
+			width: 16rpx;
+			height: 16rpx;
+			background: var(--error);
+			border-radius: 50%;
+			top: 6rpx;
+			right: 6rpx;
+	}
+}

+ 8 - 0
pages/index/message/modules/list/index.wxml

@@ -0,0 +1,8 @@
+<navigator url="/pages/index/message/detail?id={{item.messageid}}" class='list' wx:for="{{list}}" wx:key="messageid">
+	<view class="title line-1">{{item.title}}</view>
+	<view class="content line-1">{{item.message}}</view>
+	<view class="time">
+		<van-tag class="tag" wx:if="{{item.objectname}}" plain type="primary">{{type.query(item.objectname)}}</van-tag>{{item.createdate}}
+	</view>
+	<view wx:if="{{item.isread=='0'}}" class="unread-item" />
+</navigator>

+ 1 - 0
pages/login/modules/login.js

@@ -74,6 +74,7 @@ function toHome() {
     wx.reLaunch({
         url: '/pages/index/index'
     })
+    if (!getApp().globalData.socketEstablish) getApp().initSocket();
 }
 /* 站点数据查询 */
 module.exports = {