<template>
	<view class="content">
		<view class="headr">
			<view class="money-box">
				<view class="body-title">
					<view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
					<view class="header">曝光量</view>
				</view>
			</view>
			<!-- <view class="uni-input choose-time" @click="show = true">{{ now_date }}</view> -->
			<view class="month">
				<image src="../../static/icon/sdata.png" mode=""></image>
				<view class="store-data">
					<view class="data">{{ num }}</view>
					<view class="tit">总曝光量</view>
				</view>
			</view>
		</view>
		<view class="list-wrapper">
			<scroll-view scroll-y="true" :style="{ height: height }" class="swiper-box" @scrolltolower="loadData">
				<!-- 空白页 -->
				<view v-for="(item, index) in 10" class="item flex">
					<view class="item-left">
						<view class="item-avator"><image src="../../static/error/missing-face.png" mode=""></image></view>
						<view class="item-info">
							<view class="item-name">成攻闪拓(黄岩店）</view>
							<view class="address">浙江台州市椒江区市府大道124号</view>
						</view>
					</view>
					<view class="item-right">
						曝光量:
						<text>200</text>
					</view>
				</view>
				<uni-load-more :status="loadingType"></uni-load-more>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import empty from '@/components/empty';
// import { merchantList } from '@/api/merchant.js';
export default {
	data() {
		return {
			show: false, //日历
			is_show: false, //搜索是否显示
			keyword: '', //搜索关键字
			height: '', //滚动区域高度
			dataList: [], //月订单
			num: 0, //订单总数
			loadingType: 'more',
			page: 1,
			limit: 10,
			real_name: ''
		};
	},
	components: {
		empty,
		uniLoadMore
	},
	onReady(res) {
		var _this = this;
		uni.getSystemInfo({
			success: resu => {
				const query = uni.createSelectorQuery();
				query.select('.list-wrapper').boundingClientRect();
				query.exec(function(res) {
					console.log(res, 'ddddddddddddd');
					_this.height = resu.windowHeight - res[0].top + 'px';
					console.log('打印页面的剩余高度', _this.height);
				});
			},
			fail: res => {}
		});
	},
	onLoad() {
		// this.loadData();
	},
	methods: {
		bindDateChange(e) {
			console.log(e);
			this.now_date = e.detail.value;
			this.loadingType = 'more';
			this.page = 1;
			this.dataList = [];
			this.loadData();
		},
		showInput() {
			this.is_show = true;
		},
		search() {
			console.log('search');
			this.real_name = this.keyword;
			this.dataList = [];
			this.page = 1;
			this.loadingType = 'more';
			this.loadData();
		},
		loadData() {
			let obj = this;
			console.log('加载数据');
			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
				return;
			}
			obj.loadingType = 'loading';
			console.log(obj.now_date);
			merchantList({ page: obj.page, limit: obj.limit, data: obj.now_date, real_name: obj.real_name }).then(({ data }) => {
				console.log(data);
				obj.num = data.count;
				obj.dataList = obj.dataList.concat(data.data);
				obj.page++;
				if (data.data.length == obj.limit) {
					obj.loadingType = 'more';
				} else {
					obj.loadingType = 'noMore';
				}
			});
		},
		toBack() {
			uni.navigateBack({});
		},
		bindDateChange(e) {
			console.log(e.detail, 'dddddddddddd');
			this.now_date = e.detail.value;
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background-color: #f5f5f5;
}

.headr {
	height: 468rpx;
	background: linear-gradient(180deg, #ff4c4c 0%, #ff7474 100%);
	position: relative;
	.money-box {
		padding-top: var(--status-bar-height);
		color: #ffffff;
		text-align: center;
		justify-content: center;
		position: relative;
		.body-title {
			height: 80rpx;
			text-align: center;
			font-size: 35rpx;
			position: relative;
			.header {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #fffeff;
				height: 80rpx;
				font-size: 32rpx;
				font-weight: 700;
				z-index: 9;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.goback-box {
				position: absolute;
				z-index: 10;
				left: 24rpx;
				top: 0;
				height: 80rpx;
				display: flex;
				align-items: center;
			}
			.goback {
				width: 30rpx;
				height: 36rpx;
			}
		}
	}
	.time {
		width: 100%;
		color: #ffffff;
		padding-left: 30rpx;
		font-size: 28rpx;
	}
	.month {
		position: absolute;
		top: 40rpx;
		bottom: 0;
		left: 0;
		right: 0;
		margin: auto;
		height: 275rpx;
		width: 275rpx;

		image {
			width: 100%;
			height: 100%;
		}

		.store-data {
			position: absolute;
			height: 275rpx;
			width: 275rpx;
			text-align: center;
			color: #fff;
			top: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			.data {
				font-size: 50rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #ffffff;
				padding-bottom: 20rpx;
			}

			.tit {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #ffffff;
			}
		}
	}
}
.list-wrapper {
	margin-top: 24rpx;
}
.item {
	width: 710rpx;
	background: #ffffff;
	box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
	border-radius: 10rpx;
	margin: 0 auto 20rpx;
	padding: 26rpx 30rpx 26rpx 20rpx;
	.item-left {
		display: flex;
		justify-content: start;
		align-items: center;
		.item-avator {
			width: 120rpx;
			height: 120rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.item-info {
			margin-left: 10rpx;
			line-height: 1;
			.item-name {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}
			.address {
				font-size: 21rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				margin-top: 20rpx;
			}
		}
	}
	.item-right {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
		text {
			color: #ff4c4c;
		}
	}
}
</style>
