<template>
	<view class="Device">
		<!-- 门店数据 -->
		<view class="store_data" v-if="!isperiod">
			<view class="rowboxh">
				<view class="rowl" @tap="selectStore">
					<view class="rowltxt2">{{StoreInfo_['storeName']||'全部门店'}}</view>
					<image :class="showPicker?'xia':'xiaframes'" 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">{{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>
		<!-- 门店交易明细 -->
		<view class="store_data_detail" v-if="!isperiod">
			<!-- 数据列表 -->
			<view class="dataList">
				<view class="dataitem" v-for="(item,index) in deviceList_" :key="index"
					:style="((index+1)==deviceList_.length)?'border: none;':''">
					<view class="row1">
						<view class="name">
							{{item['deviceName']}}
							<text class="status" v-if="item['onlineStatus']=='online'">在线</text>
							<text class="status" v-if="item['onlineStatus']=='offline'"
								style="background-color: rgba(246, 82, 0, 0.08);color: #F65200;">离线</text>
						</view>
						<view class="amount" @tap="transactionDetails(item,index)">
							查看明细
							<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">
						SN：{{item['snCode']}}
					</view>
				</view>
				<!-- 无数据 -->
				<view class="nodata" v-if="deviceList_.length==0" style="margin-top: 0;height: 75vh;">
					<image :src="ImgUrl+'xzf/h5/nodata.png'" style="width: 399rpx;height: 211rpx;margin-top: 296rpx;"
						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>
	import dayjs from "dayjs"
	const starttime = dayjs().subtract(1, 'day').format('YYYY/MM/DD')
	const endtime = dayjs().format('YYYY/MM/DD')
	export default {
		name: "Device",
		props: {
			isperiod: {
				type: Boolean,
				default: false
			},
			StoreInfo_: {
				type: Object,
				default: Object
			},
			deviceList_: {
				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 {}
		},
		computed: {

		},
		mounted() {},
		computed: {

		},
		methods: {
			// 查看明细
			transactionDetails(item, index) {
				this.$emit("transactionDetails", item, index)
			},
			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)
			},
			formatDate(date) {
				return `${date.getMonth() + 1}/${date.getDate()}`;
			},
			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
			}

		}
	}
</script>

<style lang="scss">
	.Device {
		.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: 0 0 16rpx 16rpx;
			margin: 0 auto;
			/* margin-top: 25rpx; */
			margin-bottom: 50px;

			.dataList {
				width: 100%;
				/* background: #FFFFFF; */

				.dataitem {
					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;
					}

					.status {
						display: inline-block;
						width: 64rpx;
						height: 40rpx;
						background: rgba(1, 203, 136, 0.08);
						border-radius: 8rpx;

						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #01CB88;
						text-align: center;
						line-height: 40rpx;
						margin-left: 8rpx;
					}

					.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;
			border-radius: 16rpx 16rpx 0 0;

			.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: 1rpx;
					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>