<template>
	<view class="content">
		<view class="container">
			<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
			<view class="lan-box">
				<view class="">收银员:{{ handoverList && handoverList.baseInfo ? handoverList.baseInfo.realName : '未知姓名' }}
				</view>
				<view class="b-ss">
					<view class="">今日累计:¥{{indexData.totalPayMoney}}</view>
					<view class="d-s" @click="jump()">
						<view class="">交班记录</view>
						<u-icon name="arrow-right" color="#fff" size="18"></u-icon>
					</view>
				</view>
			</view>


			<view class="box_">
				<view class="top-box">
					员工交接单
				</view>
				<view class="h-box">门店:{{handoverList && handoverList.baseInfo ? handoverList.baseInfo.storeName : '-'}}
				</view>
				<view class="h-box">
					上班时间:{{ handoverList && handoverList.baseInfo ? handoverList.baseInfo.startTime : '-' }}</view>
				<view class="h-box">
					下班时间:{{ handoverList && handoverList.baseInfo ? handoverList.baseInfo.endTime : '-' }}</view>

				<view class="h-box">
					订单金额:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilOrder : 0+ handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardOrder : 0 }}
				</view>
				<view class="h-box">
					优惠金额:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilDiacount : 0 }}
				</view>
				<view class="h-box">
					会员充值:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardPaid : 0 }}
				</view>
				<view class="h-box">
					退款金额:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilRefund : 0 + handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardRefund : 0 }}
				</view>
				<view class="h-box">
					实收金额:{{ (Number)(handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilPaid : 0) + (Number)(handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardPaid : 0) }}
				</view>
			</view>
			<view style="width: 100%; height: 78px; "></view>
			<view class="bottom-d" @click="shift">
				<view class="anniu">
					交班
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import request from "../../utils/request";

	import headers from '../../components/header/headers.vue'

	export default {
		data() {
			return {
				titles: "交接班",
				handoverList: "",
				indexData: {
					totalPayMoney: '0',
					totalCount: '0',
					totalRefund: '0',
				},
				form: {}
			}
		},
		onShow() {
			// this.actList = ["1", "1", "1", "1", "1", ]
			// this.status = "nomore" 底部刷新结束
			this.handoverByPos()
		},
		onPullDownRefresh() {
			console.log("刷新");
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			// this.show = true
			setTimeout(() => {
				console.log("加载执行");
			}, 2000)
		},
		components: {
			headers
		},
		methods: {
			goback() {
				uni.navigateBack()
			},
			//交班信息
			handoverByPos() {
				request({
					url: 'business/handoverRecord/handoverByPos',
					method: 'get',
					params: this.form
				}).then((res) => {
					if (res.code == 200) {
						this.handoverList = res.data;
					} else {
						uni.showToast({
							title: res.data,
							icon: "none"
						})
					}
				})
			},
			jump() {
				uni.navigateTo({
					url: '/pagesHome/changeShifts/list'
				})
			},
			// 获取销售数据
			getIndexData() {
				request({
					url: 'business/allOrderInfo/getIndexData4Pos',
					method: 'get',
					params: this.form
				}).then((res) => {
					if (res.code == 200) {
						this.indexData = res.data
					} else {
						uni.showToast({
							title: res.data,
							icon: "none"
						})
					}
				})
			},
			// 获取销售数据
			shift() {
				let recordData = this.handoverList

				let handoverRecord = {
					startTime: this.handoverList.baseInfo.startTime,
					recordData: JSON.stringify(recordData),
					type: 0,
					status: this.handoverList.baseInfo.handoverType,
					staffId: this.staff.staffId
				}
				request({
					url: 'business/handoverRecord/addByPos',
					method: 'post',
					data: handoverRecord
				}).then((res) => {
					if (res.code == 200) {
						this.indexData = res.data
					} else {
						uni.showToast({
							title: res.data,
							icon: "none"
						})
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #fff;
		// background: linear-gradient(180deg, #B2D2FC 0%, #B2D2FC 14%, rgba(255, 255, 255, 0.84) 24%, rgba(255, 255, 255, 0.84) 100%);
		height: 100vh;
	}

	.container {
		width: 100%;
		background: #fff;
		box-sizing: border-box;
		padding-top: 88px;
	}

	.img-box {
		image {
			width: 100%;
			height: 100%;
		}
	}

	.lan-box {
		width: 100%;
		height: 100px;
		background: #0864e9;
		box-sizing: border-box;
		padding: 15px;
		color: #fff;
		font-weight: bold;
	}

	.b-ss {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 15px auto;
	}

	.d-s {
		display: flex;
		align-items: center;

	}

	.box_ {
		width: 95%;
		border-radius: 8px;
		box-sizing: border-box;
		padding: 15px;
		border: 1px solid #0864e9;
		margin: 15px auto;
	}

	.top-box {
		width: 100%;
		border-bottom: 1px solid #F0F0F0;
		box-sizing: border-box;
		padding-bottom: 15px;
		font-weight: bold;
		font-size: 16px;
		color: #0864E9;
	}

	.h-box {
		font-weight: 500;
		font-size: 14px;
		color: #333333;
		margin: 15px auto;
	}

	.bottom-d {
		width: 100%;
		position: fixed;
		bottom: 0px;
		left: 0px;
		height: 98px;
		background: #FFFFFF;
		box-shadow: 0px -1px 4px 0px rgba(67, 104, 212, 0.1);
	}

	.anniu {
		width: 265px;
		height: 48px;
		background: #0864E9;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		border-radius: 50px;
		margin: 10px auto;
	}
</style>