<template>
	<view class="container cart clearfix">
		<tui-skeleton
			v-if="skeletonShow"
			backgroundColor="#fafafa"
			borderRadius="10rpx"
			:isLoading="true"
			:loadingType="5"
		></tui-skeleton>
		<view class="container-main" v-else>
			<view class="clearfix">
				<!-- 空白页 -->
				<view class="empty-container" v-if="isEmpty">
					<image class="empty-container-image" :src="StaticUrl + '/icon/icon-notice-empty@2x.png'"></image>
					<text class="error-text">暂无任何消息~</text>
				</view>
				<!-- 列表 -->
				<view class="tui-notice clearfix" v-for="(cell, index) in list" :key="index">
					<tui-swipe-action :operateWidth="80" :backgroundColor="'#F7F7F7'">
						<template v-slot:content>
							<view class="tui-notice-cell clearfix">
								<view class="tui-cell-top">
									<view class="cell-title"> {{ cell.text }} </view>
									<view class="cell-time"> {{ cell.time }} </view>
								</view>
								<view class="tui-cell-content"> 
									<text>{{ cell.content }}</text>
								</view> 
							</view>
						</template>
						<template v-slot:button>
							<view class="tui-custom-btn_box">
								<view class="tui-custom-btn" @tap="deleteBtn(cell.id)">
									<text class="iconfont icon-shanchu3"></text>
								</view>
							</view>
						</template>
					</tui-swipe-action>
				</view>
				<!--加载loadding-->
				<tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
				<tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
				<!--加载loadding-->
			</view>
		</view>
	</view>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
export default {
	data() {
		return {
			skeletonShow: true,
			StaticUrl: this.$Static,
			listQuery: {
				userId: 0,
				pageNum: 1,
				pageSize: 10
			},
			list: [
				{
					text: '注册成功通知',
					time: '2022-07-05 16:51:20',
					image: 'https://img.caimei365.com/group1/M00/00/1E/rB-lF2JgwhiAWYBKAAE3BA2cBSY917.jpg',
					orderId: 1234,
					content:'欢迎成为采美机构用户，祝您开启愉快的采购之旅。'
				},
				{
					text: '购买超级会员成功',
					time: '2022-07-05 16:51:20',
					image: 'https://img.caimei365.com/group1/M00/00/1E/rB-lF2JgwhiAWYBKAAE3BA2cBSY917.jpg',
					orderId: 1234,
					content:'您已成功购买3个月采美平台超级会员服务，在服务期内每月可领多张大额优惠券，还有更多超级会员专属权益等您体验，快去看看吧 >>'
				}
			],
			isEmpty: false,
			loadding: false,
			pullUpOn: true,
			pullFlag: true,
			hasNextPage: false,
			nomoreText: '上拉显示更多'
		}
	},
	onLoad() {
		this.initData()
	},
	computed: {
		...mapState(['hasLogin', 'userInfo'])
	},
	methods: {
		async initData() {
			const userInfo = await this.$api.getStorage()
			this.skeletonShow = false //预加载圆圈
			this.listQuery.userId = userInfo.userId ? userInfo.userId : 0
			this.initGetCartGoodsList()
		},
		
		initGetCartGoodsList() {
			console.log('获取消息通知数据')
		},
		initLogin() {
			this.$api.redirectTo('/pages/login/login')
		}
	},
	onPullDownRefresh() {
		//下拉刷新
		uni.stopPullDownRefresh()
	},
	onShow() {}
}
</script>

<style lang="scss">
page {
	background-color: #f7f7f7;
}
.container-main {
	width: 100%;
	box-sizing: border-box;
	padding: 24rpx;
	.empty-container-image {
		width: 260rpx;
		height: 260rpx;
		margin-top: -300rpx;
	}
}
.tui-swipeout-content{
	white-space:normal !important;
}
.tui-notice{
	margin-bottom: 24rpx;
}
.tui-notice-cell {
	width: 100%;
	height: auto;
	background-color: #ffffff;
	border-radius: 16rpx;
	box-sizing: border-box;
	padding:16rpx 24rpx;
	float: left;
	.tui-cell-top{
		width: 100%;
		height: 88rpx;
		line-height: 88rpx;
		float: left;
		.cell-title{
			font-size: 32rpx;
			color: #333333;
			float: left;
		}
		.cell-time{
			font-size: 24rpx;
			color: #999999;
			float: right;
		}
	}
	.tui-cell-content{
		width: 100%;
		height: auto;
		float: left;
		box-sizing: border-box;
		line-height: 44rpx;
		padding: 24rpx;
		background-color: #F7F7F7;
		font-size: 28rpx;
		color: #666666;
		text-align: justify;
	}
}
.tui-custom-btn_box {
	width: 80px;
	height: 100%;
	padding: 0 20rpx;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #f7f7f7;
}

.tui-custom-btn {
	width: 56rpx;
	height: 56rpx;
	border-radius: 50%;
	background-color: #f94b4b;
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	.icon-shanchu3 {
		font-size: 32rpx;
	}
}
</style>
