<template>
	<view class="pages">
		<view class="header">
			<view class="items" @tap="jumpPage">
				项目未标记{{ pageParams.statDateStart }}至{{ pageParams.statDateEnd }}
			</view>
		</view>
		<view class="wordslist">
			<!-- block -->
			<block v-for="(data) in pageData">
				<view class="item" :key="data.id" @click="jumpPage(data)">
					<view class="items blue">{{ data.houseName }}</view>
					<view class="items">{{ data.unTagCustomer || 0 }}</view>
					<view class="items">{{ data.tagCustomer || 0 }}</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: '', //结束时间
					orgCode: '', //id
					messageType: '',
				},
				showTimeCalender: '选择日期', //
				totalTimeShow: false, // 自定义时间
				inParams: '', // 入参
				pageData: [], // 页面数据
			};
		},

		onLoad(option) {
			if (option) {
				this.inParams = this.params(option)
			}
			if (option.orgCode) {
				this.pageParams.orgCode = option.orgCode
			}
			if (option.staTime && option.endtime) {
				this.pageParams.statDateStart = option.staTime
				this.pageParams.statDateEnd = option.endtime
			}
			if (option.messageType) {
				this.pageParams.messageType = option.messageType
			}
			console.log(this.inParams)
			this.findSensitiveWordsData()
		},

		methods: {
			// 对象转url参数
			params(json) {
				return Object.keys(json).map(key => key + '=' + json[key]).join('&');
			},

			// 
			jumpPage(data) {
				uni.navigateTo({
					url: `/pages/center/records/index?${this.inParams}&houseId=${data.houseId}`
				});
			},

			// findSensitiveWordsData
			findSensitiveWordsData() {
				this.$u.post('/customer/findNotMarkAdvisorCount', this.pageParams).then(res => {
					console.log(res)
					res.unshift({
						houseName: '项目名称',
						tagCustomer: '对比上一周',
						unTagCustomer: '未标记数量',
						id: new Date().getTime()
					})
					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;
				font-size: 32rpx;
				font-weight: bold;
				
				&.blue {
					color: #1890FF;
				}
			}
		}

		.wordslist {
			width: 100%;
			padding: 20rpx;

			.item {
				width: 100%;
				height: 90rpx;
				display: flex;
				align-items: center;

				.items {
					flex-grow: 1;
					width: 125rpx;
					text-align: center;
					font-size: 26rpx;
				}
			}
		}
	}
</style>
