<template>
	<view class="Store">
		<!-- 选择时间 -->
		<view class="select_time" @tap="selectTime" v-if="!isperiod">
			<image class="time" :src="ImgUrl+'xzf/h5/time.png'" mode="aspectFit"></image>
			<view class="content">{{starttime}}~{{endtime}}</view>
			<image :class="calendar?'xiaframes':'xia'" :src="ImgUrl+'xzf/h5/xia.png'" mode="aspectFit"></image>
		</view>
		<!-- 门店数据 -->
		<view class="store_data" v-if="!isperiod">
			<view class="rowboxh">
				<view class="rowl" @tap="selectStore">
					<view class="rowltxt2">{{StoreInfo_['storeName']||'全部门店'}}</view>
					<image :class="showPicker?'xiaframes':'xia'" style="margin-left: 16rpx;"
						:src="ImgUrl+'xzf/h5/xia.png'" mode="aspectFit"></image>
				</view>
				<view class="rowr">
					当前设备 <text class="text">{{storeInfo['onlineDeviceCnt']||0}}</text> 台，离线<text class="text"
						style="color: #F65200 !important">{{storeInfo['offlineDeviceCnt']||0}}</text>台
				</view>
			</view>
			<view class="warning" v-if="storeInfo['offlineDeviceCnt']>0">
				<image class="warnpng" style="width: 25rpx;height: 25rpx;margin-left:  25rpx;"
					:src="ImgUrl+'xzf/h5/warnpng.png'">
				</image>
				<text
					style="display: inline-block;margin-left: 8rpx;">有{{storeInfo['offlineDeviceCnt']||0}}台设备离线，无法统计准确数据，请尽快处理</text>
			</view>
			<view class="rowbox">
				<view class="rowl">
					<view class="rowltxt">交易笔数(笔)</view>
					<view class="rowltxt2">{{storeInfo['totalCnt']||0}}</view>
				</view>
				<view class="rowr">
					<view class="rowltxt">营业额(元)</view>
					<view class="rowltxt2">{{storeInfo['totalAmount']||0}}</view>
				</view>
			</view>
			<!-- 数据列表 -->
			<view class="dataList" v-if="!isperiod">
				<view class="dataitem" v-for="(item,index) in storeInfo['cateringData']" :key="index">
					<image class="weuiicon" :src="ImgUrl+item['mealTypePng']||'xzf/h5/zao.png'" mode="aspectFit">
					</image>
					<view class="ritbox">
						<view class="" style="display: flex;align-items: center;position: relative;">
							<view class="catering">{{item['mealType']}}</view>
							<view class="count">{{item['dealCnt']}}笔</view>
							<view class="amount">{{item['dealAmount']}}元</view>
						</view>
						<van-progress style="margin-top: 10rpx;height: 8rpx;" pivot-text="" pivot-color="#E9E7E7;"
							color="#01CB88" :percentage="item['perc']" />
						<view class="line" v-if="!((index+1)==storeInfo['cateringData'].length)"></view>
					</view>
				</view>
			</view>
		</view>
		<view class="tisp" v-if="!isperiod">
			<text>因校园设备网络波动，数据可能延迟更新</text>
		</view>
		<!-- 门店交易明细 -->
		<view class="store_data_detail" v-if="!isperiod">
			<view class="jiaoyi">
				交易明细
			</view>
			<!-- 数据列表 -->
			<view class="dataList">
				<view class="dataitem" v-for="(item,index) in flowsList" :key="index"
					:style="((index+1)==flowsList.length)?'border: none;':''" @tap="transactionDetails(item,index)">
					<view class="row1">
						<view class="name">
							{{item.deviceName||''}}
						</view>
						<view class="amount">
							{{item.amount||''}}元
							<image class="rigth" style="width: 15rpx;height: 25rpx;margin-left: 16rpx;"
								:src="ImgUrl+'xzf/h5/rigth.png'" mode="aspectFit"></image>
						</view>
					</view>
					<view class="row2 time">
						{{item.dealTime||''}}
					</view>
				</view>
				<div class="van-list__finished-text" v-if="totalCnt>0&&(totalCnt==flowsList.length)">没有更多了</div>
				<div class="van-list__error-text" v-if="totalCnt!=flowsList.length" @tap="Loadmore">点击加载更多...</div>
				<!-- 无数据 -->
				<view class="nodata" v-if="flowsList.length==0" style="margin-top: 0;">
					<image :src="ImgUrl+'xzf/h5/nodata.png'" style="width: 399rpx;height: 211rpx;" mode="aspectFit">
					</image>
					<view class="text1">暂无数据</view>
				</view>
			</view>
		</view>
		<!-- 高峰期文案 无数据 -->
		<view class="default">
			<!-- 高峰期 -->
			<view class="gaofengqi" v-if="isperiod">
				<image :src="ImgUrl+'xzf/h5/gaofengqi.png'" mode="aspectFit"></image>
				<view class="text1">当前为使用高峰期</view>
				<view class="text2">（建议避开就餐时段查询）</view>
			</view>
			<!-- 无数据 -->
			<!-- <view class="nodata" v-if="typecheck==2">
				<image :src="ImgUrl+'xzf/h5/nodata.png'" mode="aspectFit"></image>
				<view class="text1">暂无数据</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		name: "Store",
		props: {
			totalCnt: {
				type: Number,
				default: 0
			},
			isperiod: {
				type: Boolean,
				default: false
			},
			StoreInfo_: {
				type: Object,
				default: Object
			},
			flowsList: {
				type: Array,
				default: Array
			},
			storeInfo: {
				type: Object,
				default: Object
			},
			showPicker: {
				type: Boolean,
				default: false
			},
			calendar: {
				type: Boolean,
				default: false
			},
			starttime: {
				type: String,
				default: ""
			},
			endtime: {
				type: String,
				default: ""
			},
			ImgUrl: {
				type: String,
				default: ""
			},
			ImgUrl2: {
				type: String,
				default: ""
			},
		},
		data() {
			return {
				typecheck: 2,
			}
		},
		computed: {

		},
		mounted() {},
		computed: {

		},
		methods: {
			// 查看明细
			transactionDetails(item, index) {
				console.log(11111111);
				this.$emit("transactionDetails", item, index)
			},
			Loadmore() {
				this.$emit("Loadmore", true)
			},
			onConfirmStore(value, index) {
				console.warn(`当前值：${value}, 当前索引：${index}`);
				this.selectStore()
			},
			onChangeStore(picker, value, index) {
				console.warn(`当前值：${value}, 当前索引：${index}`);
			},
			onCancelStore() {
				this.selectStore()
			},
			// 选择门店
			selectStore() {
				this.$emit("selectStore", true)
			},
			onConfirm(date) {
				const [start, end] = date;
				// this.calendar = false;
				this.starttime = dayjs(start).format('YYYY/MM/DD')
				this.endtime = dayjs(end).format('YYYY/MM/DD')
			},
			selectTime() {
				// this.calendar = true
				this.$emit("selectTime", true)
			}
		}
	}
</script>

<style lang="scss">
	.Store {
		.xiaframes {
			display: block;
			width: 17rpx;
			height: 15rpx;
			position: relative;
			transform: rotate(-90deg);
		}

		.warning {
			display: flex;
			align-items: center;
			width: 100%;
			height: 44rpx;
			background: rgba(246, 82, 0, 0.09);

			font-size: 22rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #F65200;
		}

		.store_data_detail {
			width: 686rpx;
			min-height: 400rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin: 0 auto;
			margin-top: 25rpx;
			margin-bottom: 50px;

			.dataList {
				width: 100%;
				/* background: #FFFFFF; */
				.dataitem:nth-child(1){
					border-top: 1rpx solid #E2E2E2;
				}

				.dataitem {
					margin-left: 32rpx;
					height: 154rpx;
					display: flex;
					align-items: center;
					border-bottom: 1rpx solid #E2E2E2;
					flex-direction: column;
					justify-content: center;


					.name {
						height: 40rpx;
						font-size: 30rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: rgba(0, 0, 0, 0.85);
						line-height: 40rpx;
					}

					.amount {
						display: flex;
						align-items: center;
						height: 44rpx;
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: rgba(0, 0, 0, 0.85);
						line-height: 44rpx;

						position: absolute;
						right: 52rpx;
					}

					.row1 {
						display: flex;
						align-items: center;
						width: 100%;
						// margin-left: 32rpx;
						position: relative;
					}

					.row2 {
						width: 100%;

						height: 44rpx;
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: rgba(0, 0, 0, 0.35);
						line-height: 44rpx;
						// padding-left: 32rpx;
					}
				}
			}

			.jiaoyi {
				display: flex;
				align-items: center;

				height: 100rpx;
				/* background: #FFFFFF; */
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #333333;
				padding-left: 24rpx;
			}
		}

		.select_time {
			width: 686rpx;
			height: 72rpx;
			background: #FFFFFF;
			border-radius: 36rpx;
			margin: 0 auto;
			margin-top: 24rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.xia {
				width: 17rpx;
				height: 15rpx;
				position: relative;
			}

			.time {
				width: 32rpx;
				height: 32rpx;
				position: relative;
			}

			.content {
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.85);
				line-height: 40rpx;
				padding: 0 16rpx;
			}
		}

		.tisp {
			height: 33rpx;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #868686;
			line-height: 33rpx;
			margin-left: 48rpx;
			margin-top: 12rpx;
		}

		.store_data {
			width: 686rpx;
			min-height: 890rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin: 0 auto;
			margin-top: 25rpx;

			.rowboxh {
				width: 638rpx;
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 0 auto;

				.rowl {
					display: flex;
					align-items: center;
				}

				.rowr {
					height: 33rpx;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: rgba(0, 0, 0, 0.5);
					line-height: 33rpx;

					.text {
						color: rgba(0, 0, 0, 0.85) !important;
					}
				}

				.xia {
					width: 17rpx;
					height: 15rpx;
					position: relative;
				}
			}

			.dataList {
				width: 638rpx;
				/* height: 72rpx; */
				margin: 0 auto;

				.catering {
					font-size: 30rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: rgba(0, 0, 0, 0.85);
					line-height: 42rpx;
				}

				.count {
					font-size: 24rpx;
					font-family: DINAlternate-Bold, DINAlternate;
					font-weight: bold;
					color: rgba(0, 0, 0, 0.35);
					line-height: 28rpx;
					margin-left: 22rpx;
				}

				.amount {
					font-size: 28rpx;
					font-family: DINAlternate-Bold, DINAlternate;
					font-weight: bold;
					color: rgba(0, 0, 0, 0.85);
					line-height: 32rpx;
					position: absolute;
					right: 0;
				}

				.dataitem {
					height: 120rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				.line {
					width: 542rpx;
					height: 0.5rpx;
					background-color: #E2E2E2;
					position: absolute;
					bottom: -30rpx;
				}

				.ritbox {
					position: relative;
					width: 542rpx;
				}

				.weuiicon {
					width: 72rpx;
					height: 72rpx;
					position: relative;
				}
			}

			.rowbox {
				height: 168rpx;
				display: flex;
				align-items: center;
				padding-left: 18rpx;
				padding-right: 25rpx;
				justify-content: space-between;

				.rowltxt {
					height: 28rpx;
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					line-height: 28rpx;
				}

				.rowltxt2 {
					height: 54rpx;
					font-size: 60rpx;
					font-family: AlibabaSans102Ver2-Medium, AlibabaSans102Ver2;
					font-weight: 500;
					color: #333333;
					line-height: 54rpx;
					margin-top: 18rpx;
				}

				.rowl {
					text-align: left;
					height: 100rpx;
					margin-top: 18rpx;
				}

				.rowr {
					text-align: right;
					height: 100rpx;
				}
			}

		}

		.default {}

		.gaofengqi,
		.nodata {
			text-align: center;
			margin-top: 341rpx;
		}

		.gaofengqi {
			image {
				width: 500rpx;
				height: 254rpx;
				position: relative;
			}
		}

		.text1 {
			height: 40rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.45);
			line-height: 40rpx;
		}

		.text2 {
			height: 40rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.25);
			line-height: 40rpx;
		}

		.nodata {
			image {
				width: 499rpx;
				height: 311rpx;
				position: relative;
			}
		}
	}
</style>