systemNotify.vue 3.84 KB
<template>
	<view class="notify-page">
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<view>
			<u--form labelPosition="left" :model="model1" :rules="rules" ref="form1">
				<u-form-item
					label="类型"
					prop="userInfo.sex"
					borderBottom
					@click="
						showType = true;
						hideKeyboard();
					"
					ref="item1"
				>
					<u--input v-model="model1.userInfo.type" placeholder="请选择类型" border="none"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
			</u--form>
			<u-action-sheet :show="showType" :actions="actions" title="请选择类型" @close="showType = false" @select="typeSelect"></u-action-sheet>
		</view>
		<view class="notify-main">
			<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
				<view class="u-flex main">
					<view @click="clickNotifyDetail(item)" class="u-flex main-item" v-for="(item, index) in list" :key="index">
						<view class="u-flex item">
							<view class="item-avatar"><u-avatar class="avatar" shape="circle" size="40" :src="item.avatar"></u-avatar></view>
							<view class="u-flex item-content">
								<text class="text-top">{{ item.title }}</text>
								<text class="text-bottom">{{ item.createTime }}</text>
							</view>
						</view>
						<view class="item-right">
							<text class="text">{{ item.type == 'OTHER' ? '其他' : item.type == 'MEETING' ? '会议' : '公告' }}</text>
						</view>
					</view>
				</view>
			</mescroll-body>
		</view>
		<f-tabbar></f-tabbar>
	</view>
</template>

<script>
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';

export default {
	mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
	components: {
		fTabbar
	},
	data() {
		return {
			model1: {
				userInfo: {
					type: ''
				}
			},
			showType: false,
			actions: [
				{
					name: '会议',
					value: 'MEETING'
				},
				{
					name: '公告',
					value: 'NOTICE'
				},
				{
					name: '其他',
					value: 'OTHER'
				}
			],
			page: {
				num: 0,
				size: 10
			},
			downOption: {
				auto: false //是否在初始化后,自动执行downCallback; 默认true
			},
			list: []
		};
	},
	onLoad(e) {
		// 隐藏原生的tabbar
		uni.hideTabBar();
	},
	methods: {
		typeSelect(e) {
			this.model1.userInfo.type = e.name;
			this.loadData(1, e.value);
			setTimeout(() => {
				uni.hideKeyboard();
			}, 10);
		},
		hideKeyboard() {
			uni.hideKeyboard();
		},
		/*下拉刷新的回调 */
		downCallback() {
			//联网加载数据
			this.list.length = 0;
			this.page.num = 1;
			this.loadData(1);
		},
		/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
		upCallback() {
			//联网加载数据
			this.page.num += 1;
			this.loadData(this.page.num);
		},

		loadData(pageNo, t) {
			let httpData = {
				page: pageNo,
				pageSize: 10,
				type: t
			};
			uni.$u.http
				.get('/yt/noticeUser/page', { params: httpData, custom: { load: false } })
				.then(res => {
					uni.stopPullDownRefresh();
					this.mescroll.endByPage(res.items.length, res.total);
					if (pageNo == 1) {
						this.list = res.items.map(m => {
							return {
								title: m?.sysNotice?.title,
								avatar: m?.sysNotice?.avatar,
								id: m?.sysNotice?.id,
								createTime: m?.createTime
							};
						});
					} else {
						this.list = this.list.concat(res.items);
					}
				})
				.catch(e => {
					uni.$u.toast(e.data.message);
					this.mescroll.endErr();
				});
		},
		clickNotifyDetail(e) {
			let obj = e;
			setTimeout(() => {
				uni.navigateTo({
					url: './notifyDetail?data=' + JSON.stringify(obj)
				});
			}, 500);
		}
	}
};
</script>

<style lang="scss" scoped>
@import './static/systemNotify.scss';
</style>