<template>
	<view class="settlement-view">
		<view class="settlement-com-view" @click="$u.throttle(showSettlement, 500)">
			<view class="left-view">
				<view class="time-view">{{timeText}}</view>
				<view class="order-view">
					<text>提现编号：</text>
					<text>{{data.payableRecordNumber}}</text>
				</view>
			</view>
			<view class="right-view">
				<view :class="['settlement-status-view', settlementTypeClass]">{{data.payableRecordStatusText}}</view>
				<view class="settlement-amount-view">￥{{ data.paidAmount || 0}}</view>
			</view>
		</view>
		<view class="line-view"></view>
	</view>
</template>

<script>
	export default {
		props: {
			data: {
				type: Object,
				default () {
					return {
						payableRecordId: '',
						paidTime: new Date().getTime(),
						payableRecordStatusText: '提现',
						payableRecordNumber: '',
						paidAmount: 0
					}
				},
			}
		},
		data() {
			return {

			}
		},
		computed: {
			items() {
				return {
					payableRecordNumber: '工单编号',
					businessType: '工单类型'
				}
			},
			settlementTypeClass() {
				switch (this.data) {
					case '提现':
						return 'settlement-type-y'
					case '其他':
						return 'settlement-type-h'
				}
			},
			timeText() {
				let now = this.moment().startOf('day').unix()
				let yesterday = this.moment(now*1000).subtract(1, 'days').unix()
				let date = this.moment(this.data.paidTime).startOf('day').unix()
				if(date == now) {
					return '今天'
				} else if(date == yesterday) {
					return '昨天'
				} else {
					return this.$u.timeFormat(this.data.paidTime, 'mm.dd')
				}
			}
		},
		methods: {
			showSettlement() {
				this.$emit('open', this.data.payableRecordId)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.settlement-view {
		height: 212rpx;

		.settlement-com-view {
			display: flex;
			justify-content: space-between;
			align-items: flex-start;
			padding: 30rpx;
			height: 210rpx;
			.left-view {
				.time-view {
					height: 40rpx;
					width: 80rpx;
					color: #333333;
					background-color: #F4F5F7;
					border-radius: 8rpx;
					font-size: 20rpx;
					margin-bottom: 40rpx;
					text-align: center;
					padding-top: 6rpx;
				}

				.order-view {
					font-size: 26rpx;
					color: #999999;
				}
			}

			.right-view {
				display: flex;
				flex-direction: column;
				align-items: flex-end;
			
				.settlement-status-view {
					border-radius: 8rpx;
					border: 2rpx solid #FF930D;
					font-size: 20rpx;
					color: #FF930D;
					min-width: 80rpx;
					height: 40rpx;
					text-align: center;
					margin-right: 10rpx;
					line-height: 40rpx;
    				padding: 0 10rpx;
			
					&.settlement-type-y {
						border: 2rpx solid #FF930D;
						color: #FF930D;
			
					}
			
					&.settlement-type-h {
						border: 2rpx solid #2272FF;
						color: #2272FF;
					}
				}
			
			
				.settlement-amount-view {
					font-size: 40rpx;
					font-weight: bold;
					color: #FA5A49;
					margin-top: 30rpx;
				}
			}
		}

		.line-view {
			background-color: #F4F5F7;
			height: 2rpx;
			margin: 0 30rpx;
		}
	}
</style>
