zs 2 年 前
コミット
8e03868df8
2 ファイル変更58 行追加42 行削除
  1. 17 11
      pages/home/index.vue
  2. 41 31
      pagesHome/notice/index.vue

+ 17 - 11
pages/home/index.vue

@@ -128,13 +128,13 @@
 				limit: 10,
 				page: 0,
 				// 未读消息
-				notice_total:0,
+				notice_total: 0,
 				// 返回顶部
 				scrollTop: 0,
 				old_scrollTop: 0
 			};
 		},
-		onLoad:async function() {
+		onLoad: async function() {
 			const that = this;
 			await that.search();
 			await that.notice();
@@ -147,15 +147,18 @@
 		},
 		methods: {
 			// 消息通知
-			notice(){
+			notice() {
 				const that = this;
 				uni.getStorage({
 					key: 'token',
 					success: async (res) => {
 						let user = that.$jwt(res.data);
 						if (user && user._id) {
-							let res = await that.$api(`/notice`, 'GET',{customer: user._id,status:'0'});
-							if (res.errcode == '0') that.$set(that, `notice_total`,res.total);
+							let res = await that.$api(`/notice`, 'GET', {
+								customer: user._id,
+								status: '0'
+							});
+							if (res.errcode == '0') that.$set(that, `notice_total`, res.total);
 						}
 					}
 				})
@@ -211,7 +214,7 @@
 				}
 			},
 			// 系统消息页
-			toNotice(){
+			toNotice() {
 				uni.navigateTo({
 					url: `/pagesHome/notice/index`
 				})
@@ -337,12 +340,13 @@
 			display: flex;
 			justify-content: center;
 			align-items: center;
-			.one_1{
+
+			.one_1 {
 				width: 88vw;
 				background-color: var(--fFB1Color);
 				border-radius: 20px;
 				padding: 0 2vw;
-				
+
 				input {
 					font-size: var(--font15Size);
 					color: var(--fffColor);
@@ -350,15 +354,17 @@
 					width: 100%;
 					padding: 1.5vw 0;
 				}
-				
+
 				.placss {
 					color: var(--fffColor);
 				}
 			}
-			.one_2{
+
+			.one_2 {
 				width: 12vw;
 				text-align: center;
-				.iconfont{
+
+				.iconfont {
 					font-size: 24px;
 				}
 			}

+ 41 - 31
pagesHome/notice/index.vue

@@ -4,7 +4,8 @@
 			<view class="one">
 				<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
 					<view class="list-scroll-view">
-						<view class="one_1" @tap="toNotice()"><text class="iconfont icon-a-qingchuquanbuyidu"></text>全部已读</view>
+						<view class="one_1" @tap="toNotice()"><text
+								class="iconfont icon-a-qingchuquanbuyidu"></text>全部已读</view>
 						<view class="list" v-for="(item,index) in list" :key="index">
 							<uni-badge class="badge" :text="item.num" absolute="leftTop" size="normal">
 								<view class="list_1">
@@ -30,9 +31,9 @@
 				user: {},
 				list: [],
 				// 状态
-				statusList:[],
+				statusList: [],
 				// 来源
-				sourceList:[],
+				sourceList: [],
 				total: 0,
 				page: 0,
 				skip: 0,
@@ -71,23 +72,23 @@
 			// 查询列表
 			async search() {
 				const that = this;
-					let info = {
-						skip: that.skip,
-						limit: that.limit,
-						customer:that.user._id
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					customer: that.user._id
+				}
+				const res = await that.$api(`/notice`, `GET`, {
+					...info,
+				})
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data];
+					for (let val of list) {
+						if (val.status) val.zhStatus = that.searchStatus(val.status)
+						if (val.source) val.zhSource = that.searchSource(val.source)
+						if (val.status != '1') val.num = 1
 					}
-					const res = await that.$api(`/notice`, `GET`, {
-						...info,
-					})
-					if (res.errcode == '0') {
-						let list = [...that.list, ...res.data];
-						for (let val of list) {
-							if (val.status) val.zhStatus = that.searchStatus(val.status)
-							if (val.source) val.zhSource = that.searchSource(val.source)
-							if(val.status!='1')val.num=1
-						}
-						that.$set(that, `list`, list)
-						that.$set(that, `total`, res.total)
+					that.$set(that, `list`, list)
+					that.$set(that, `total`, res.total)
 				}
 			},
 			// 查询状态
@@ -105,12 +106,12 @@
 				else return '暂无'
 			},
 			// 全部已读
-			async toNotice(){
+			async toNotice() {
 				const that = this;
-				let list =that.list.filter((i) => i.status != '1');
+				let list = that.list.filter((i) => i.status != '1');
 				for (let val of list) {
 					const res = await that.$api(`/notice/${val._id}`, `POST`, {
-						status:'1'
+						status: '1'
 					})
 					if (res.errcode == '0') {
 						that.clearPage();
@@ -165,34 +166,43 @@
 <style lang="scss">
 	.main {
 		.one {
-			.one_1{
+			.one_1 {
 				padding: 2vw;
 				text-align: center;
-				.iconfont{
-					color:#707070;	
+
+				.iconfont {
+					color: #707070;
 				}
+
 				color:#707070;
 			}
+
 			.list {
 				display: flex;
 				justify-content: space-between;
 				margin: 2vw 2vw 0 2vw;
 				padding: 2vw;
 				border-radius: 5px;
-				border: 1px solid #f5f5f5;;
-				.badge{
+				border: 1px solid #f5f5f5;
+				;
+
+				.badge {
 					display: flex;
 					justify-content: space-between;
-					.list_1{
+
+					.list_1 {
 						padding: 2vw 0 0 0;
 						font-size: 14px;
-						text{
+
+						text {
 							color: var(--f85Color);
 						}
 					}
-					.list_2{
+
+					.list_2 {
 						font-size: 12px;
-						text{
+
+						text {
 							color: var(--f85Color);
 						}
 					}