<template>
	<view class="pages">
		<view class="header">
			<view class="items" @tap="totalTimeShow = true">
				{{ showTimeCalender }}
				<u-icon name="arrow-down" size="24" style="padding-left: 12rpx;"></u-icon>
			</view>
			<view class="items" @tap="jumpPage">
				明细
			</view>
		</view>
		<view class="wordslist">
			<!-- block -->
			<block v-for="(data) in pageData">
				<view class="item" :key="data.id" @click="jumpPage(data)">
					<view class="lside">{{ data.words }}</view>
					<view class="rside">{{ data.sumNum }}</view>
				</view>
			</block>
			
		</view>
		
		<u-calendar v-model="totalTimeShow" mode="range" @change="totalTimeChange"></u-calendar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageParams: {
					statDateStart: '',//开始时间
					statDateEnd: '',//结束时间
					projectId: uni.getStorageSync("buildingID").id,//项目id
				},
				showTimeCalender: '选择日期',//
				totalTimeShow: false, // 自定义时间
				
				pageData: [], // 页面数据
			};
		},
		
		onLoad() {
			this.findSensitiveWordsData()
		},
		
		methods: {
			// 
			jumpPage(data) {
				uni.navigateTo({
					url: `/pages/center/prohibited/index?refresh=refresh&staTime=${this.pageParams.statDateStart}&endtime=${this.pageParams.statDateEnd}&words=${data.words}`
				});
			},

			// findSensitiveWordsData
			findSensitiveWordsData() {
				this.$u.post('/customer/findSensitiveWordsData', this.pageParams).then(res => {
					console.log(res)
					res.unshift({
						words: '违禁词',
						id: new Date().getTime(),
						sumNum: '违禁次数'
					})
					this.pageData = res
					console.log(this.pageData, '123321s')
				})
			},
			
			// 自定义时间
			totalTimeChange(e) {
				console.log(e)
				this.pageParams.statDateStart = startDate
				this.pageParams.statDateEnd = endDate
				this.findSensitiveWordsData()
			},
		}
	}
</script>

<style lang="scss">
	.pages {
		width: 100vw;
		min-height: 100vh;
		display: flex;
		flex-direction: column;
		
		.header {
			width: 100%;
			height: 90rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			
			.items {
				height: 100%;
				flex-grow: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #666666;
				font-size: 28rpx;
			}
		}
		
		.wordslist {
			width: 100%;
			padding: 20rpx;
			
			.item {
				width: 100%;
				height: 90rpx;
				font-size: 32rpx;
				display: flex;
				align-items: center;
				
				.lside {
					flex-grow: 1;
				}
				
				.rside {
					flex-shrink: 0;
					width: 125rpx;
					text-align: center;
				}
			}
		}
	}
</style>
