<template>
	<view class="msg">
		<statusBar :item="navBarData"></statusBar>
		<view class="top">
			<view class="left" @click="puMsg" :class="current == 0 ? info1 : info2">
				<text class="">消息通知</text>
				<view v-if="current == 0" class="yun">
					<image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
						mode="aspectFill"></image>
				</view>
			</view>
			<view class="right" @click="sysMsg" :class="current == 1 ? info1 : info2">
				<text class="">系统通知</text>
				<view v-if="current == 1" class="yun">
					<image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
						mode="aspectFill"></image>
				</view>
			</view>
		</view>
		
		<swiper class="scroll-view-height" @change="swipeIndex" :current="current" :duration="300">
			<swiper-item>
				<scroll-view scroll-y="true" style="height: 100%;">
					<view class="">
						<view class="" v-for="(item,index) in Msglist" :key="index">
							<view class="msgBlock" v-if="item.type==0">
								<view class="tit">
									<view>活动报名成功</view>
									<view class="msgtime">
										{{item.create_at}}
									</view>
								</view>
								<view class="contxt">恭喜！您已成功完成<text style="color: rgba(0, 86, 168, 1);">“{{item.acName}}”</text>活动报名。您的参与信息已经成功提交，您现在是我们活动的一部分，我们非常期待与您共度美好时光。</view>
								<view class="contxt">
									 以下是一些额外信息，以确保您充分了解您的参与：
								</view>
								<view class="contxt1" style="display: flex;">
									<view class="" style="width: 2em;text-align: center;">•</view>
									<view class=""> 活动名称: [{{item.acName}}]</view>
								</view>
								<view class="contxt1" style="display: flex;">
									<view class="" style="width: 2em;text-align: center;">•</view>
									<view class=""> 日期: [×××]</view>
								</view>
								<view class="contxt1" style="display: flex;">
									<view class="" style="width: 2em;text-align: center;">•</view>
									<!-- <view class=""> 时间: [{{item.begin_at}}]</view> -->
									<view class=""> 时间: [×××]</view>
								</view>
								<view class="contxt1" style="display: flex;">
									<view class="" style="width: 2em;text-align: center;">•</view>
									<view class=""> 地点: [{{item.address}}]</view>
								</view>
							</view>
							
							<view class="msgBlock" v-if="item.type==1">
								<view class="tit">
									<view>活动开始提醒</view>
									<text class="msgtime">{{item.create_at}}</text>
								</view>
								<view class="contxt">
									<text style="color: rgba(0, 86, 168, 1);">“丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期”</text>活动现在已经在我们的平台上正式上线，欢迎您点击浏览和积极参加。不要错过这个令人兴奋的机会，我们期待着与您一同度过难忘的时光。点击活动名称进入活动详情哦！
								</view>
							</view>
						</view>
					</view>
					<!-- <view class="loading">
						<view v-if="clLoading==1">数据加载中...</view>
						<view v-if="clLoading==2">没有更多了~~</view>
					</view> -->
					
				</scroll-view>
			</swiper-item>
		
			<swiper-item>
				<scroll-view scroll-y="true" style="height: 100%;">
					<view class="">
						<view class="" v-for="(item,index) in Msglist" :key="index">
							<view class="msgBlock"  v-if="item.type==2">
								<view class="tit">
									<view>恭喜您，成功加入会员</view>
									<text class="msgtime">{{item.create_at}}</text>
								</view>
								<view class="contxt1">
									尊敬的<text style="color: rgba(0, 86, 168, 1);">{{item.username}}</text>, 
								</view>
								<view class="contxt">
										我们很高兴通知您，您已成功加入<text style="color: rgba(0, 86, 168, 1);">[XXX小程序会员]</text>！欢迎加入我们的团队，我们期待与您一同合作并参与。
								</view>
							</view>
						</view>
					</view>
					<!-- <view class="loading">
						<view v-if="sysLoading==1">数据加载中...</view>
						<view v-if="sysLoading==2">没有更多了~~</view>
					</view> -->
					
				</scroll-view>
			</swiper-item>
		</swiper>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navBarData: {
					title: '活动消息',
					btn: 1
				},
				Msglist:[],
				currentPage:1,
				current: 0, //登录方式切换
				info1: "info1", //类名
				info2: "info2",
			};
		},
		methods:{
			// 获取数据
			getdata() {
				let data = {
					oid: this.$store.state.user.openid, //用户id
					page: this.currentPage,
					lim: 30
				}
				this.$request('/selectMessage', "POST", data).then(res => {
					console.log('获取', res);
					// this.list = [this.list,...res[0]]
					this.Msglist = res[0]
					// console.log('获取',this.list);
				})
			},
			// 更新已读
			updateisread() {
				let data = {
					oid: this.$store.state.user.openid, //用户id
					// type: 2,
				}
				this.$request('/updateIsRead', "POST", data).then(res => {
					// console.log('获取', res);
				})
			},
			puMsg(){
				this.current =0;
			},
			sysMsg(){
				this.current = 1;
			},
			swipeIndex(index) {
				this.current = index.detail.current;
			},
		},
		onShow() {
			this.getdata()
			this.updateisread()
		}
	}
</script>

<style lang="scss">
	.msg {
		display: flex;
		flex-direction: column;
		flex: 1;
		justify-content: space-between;
		width: 750rpx;
		height: 100vh;
		.loading {
			height: 30rpx;
			text-align: center;
			padding-top: 20rpx;
			padding-bottom: 100rpx;
			font-size: 26rpx;
			color: #888;
			line-height: 2em;
		}
		
		.top {
			display: flex;
			justify-content: space-between;
			margin: auto;
			width: 100%;
			background-color: #ffffff;
			padding: 10px 20%;
		
			.info1 {
				font-weight: bold !important;
				position: relative;
				color: rgba(0, 0, 0, 0.8);
				font-size: 34rpx;
				line-height: 48rpx;
				width: 136rpx;
				height: 48rpx;
				text-align: center;
				.yun {
					width: 134rpx;
					height: 32rpx;
					position: absolute;
					left: 0;
					bottom: -10rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		
			.info2 {
				color: rgba(0, 0, 0, 0.6);
				font-size: 34rpx;
				font-weight: 400;
				line-height: 48rpx;
				width: 136rpx;
				height: 48rpx;
				text-align: center;
				font-family: 微软雅黑;
			}
		}
		.scroll-view-height {
			padding: 20rpx 0;
			flex: 1;
			.msgBlock{
				width: 720rpx;
				margin: auto;
				background-color: #ffffff;
				border-radius: 12px;
				padding: 28rpx 24rpx 32rpx 24rpx;
				margin-bottom: 20rpx;
				.tit{
					font-size: 34rpx;
					font-weight: 400;
					height: 48rpx;
					line-height: 48rpx;
					margin-bottom: 20rpx;
					color: rgba(0, 0, 0, 0.8);
					display: flex;
					justify-content: space-between;
					.msgtime{
						line-height: 58rpx;
							font-size: 28rpx;
							color: rgba(0, 0, 0, 0.4);
					}
				}
				.contxt{
					text-indent: 2em;
					color: rgba(0, 0, 0, 0.6);
					font-size: 28rpx;
					line-height: 40rpx;
				}
				.contxt1{
					color: rgba(0, 0, 0, 0.6);
					font-size: 28rpx;
					line-height: 40rpx;
				}
			}
			
			
		}
	}
</style>