<template>
	<view class="page">
		<u-navbar title="改价记录" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='36' id="navbar">
		</u-navbar>
		<scroll-view class="qixinglist" scroll-y refresher-enabled  @refresherrefresh="onRefresh" :refresher-triggered="isRefreshing" refresher-default-style="black">
			<view class="qixinglist_item" v-for="(item,index) in qixinglist" :key="index">
				<view class="top">
					操作人：{{item.userName == null ? '--' : item.userName}}
				</view>
				<view class="bot">
					<view class="lt">
						<view class="">
							<text>骑行费原价：</text> {{item.beforeFee.ridingFee == null ? '--' : item.beforeFee.ridingFee}}元 <text style="margin-left:20rpx">改价后：</text> {{item.afterFee.ridingFee == null ? '--' : item.afterFee.ridingFee}}元
						</view>
						<view class="">
							<text>调度费原价：</text> {{item.beforeFee.dispatchFee == null ? '--' : item.beforeFee.dispatchFee}}元 <text style="margin-left:20rpx">改价后：</text> {{item.afterFee.dispatchFee == null ? '--' : item.afterFee.dispatchFee}}元
						</view>
						<view class="">
							<text>管理费原价：</text> {{item.beforeFee.manageFee == null ? '--' : item.beforeFee.manageFee}}元 <text style="margin-left:20rpx">改价后：</text> {{item.afterFee.manageFee == null ? '--' : item.afterFee.manageFee}}元
						</view>
					</view>
					<view class="rt">
						
					</view>
				</view>
			</view>
			<view class="dibutishi">
				当前没有更多改价记录咯...
			</view>
		</scroll-view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				iconobj:this.$store.state.iconobj,
                bgc: {
                	backgroundColor: "#F7F7F7",
                },
				activeindex:1,
				current: 0,
				currents: 0,
				pageNum:1,
				qixinglist:[],
				total:'',
				status:'',
				isRefreshing: false,
				id:''
			}
		},
		onLoad(option) {
			this.id = option.id
            this.getlist()
		},
		onShow() {
			
		},
		methods: {
			// 下拉刷新
			onRefresh() {
				this.isRefreshing = true
				this.pageNum = 1
				this.getlist()
				setTimeout(() => {
					this.isRefreshing = false
				}, 1000)
			},
			// 计算实付金额
			formatPayedAmount(payedAmount, payRefunded, payRefunding) {
				if (!payedAmount) return '0.00';
				const amount = parseFloat(payedAmount) || 0;
				const refunded = parseFloat(payRefunded) || 0;
				const refunding = parseFloat(payRefunding) || 0;
				const actualAmount = amount - (refunded + refunding);
				return `${actualAmount.toFixed(2)}`;
			},
			// 跳转到骑行订单详情
			btnxqqx(id){
				uni.navigateTo({
					url:'/page_user/yongche/orderxq?id=' + id
				})
			},
			computedList(seconds, showSeconds = true) {
			  if (isNaN(seconds)) return "--"
			    const h = Math.floor(seconds / 3600)
			    const m = Math.floor((seconds % 3600) / 60)
			    const s = seconds % 60
			    const parts = []
			    if (h > 0) parts.push(`${h}时`)
			    if (m > 0 || h > 0) parts.push(`${m}分`) // 如果有小时则始终显示分钟
			    if (showSeconds) parts.push(`${s}秒`)
			    return parts.join("") || "0钟"
			},
			// 计算开始时间到现在的时间差
			computeTimeDiff(startTime) {
				if (!startTime) return '--';
				const start = new Date(startTime);
				const now = new Date();
				const diff = Math.floor((now - start) / 1000); // 转换为秒
				
				const hours = Math.floor(diff / 3600);
				const minutes = Math.floor((diff % 3600) / 60);
				
				let result = '';
				if (hours > 0) result += `${hours}时`;
				if (minutes > 0 || hours > 0) result += `${minutes}分`;
				
				return result || '0分';
			},
			// 请求订单列表
			getlist(){
				this.$u.get(`/bst/feeLog/listAll?orderId=${this.id}`).then((res) => {
					if (res.code == 200) {
						this.qixinglist = res.data
					}
				})
			},
			
			// 点击进入订单详情
			btnxq(){
				uni.navigateTo({
					url:'/page_fenbao/orderxq'
				})
			},
			
			// 滚动骑行订单到底部分页请求
			handqixing() {
				if(this.total > this.qixinglist.length){
					this.getlist()
				}
			},
			// 滚动租车订单到底部分页请求
			handleScrollToLower() {
			   console.log(11)
			},
			// 点击骑行订单tabs筛选
			changes(index) {
				this.currents = index
				if(index == 0){
					this.status = ''
				}else if(index == 1){
					this.status = 'WAIT_PAY'
				}else if(index == 2){
					this.status = 'FINISHED'
				}
				this.pageNum = 1
				this.getlist()
			},
			// 点击租车tabs筛选
			change(index) {
				this.current = index
			},
			// 点击切换tab选项
			btnac(num){
				if(num == 1){
					this.activeindex = 1
				}else{
					this.activeindex = 2
				}
				this.pageNum = 1
				this.getlist()
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F7F7F7;
	}
	.qixinglist{
		height: 76vh;
		overflow: scroll;
		padding-bottom: 20rpx;
		box-sizing: border-box;
		.dibutishi{
			width: 100%;
			text-align: center;
			margin-top: 18rpx;
			color: #ccc;
		}
		.qixinglist_item{
			margin-top: 18rpx;
			width: 714rpx;
			max-height: 452rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin: auto;
			margin-top: 20rpx;
			padding: 24rpx 28rpx;
			box-sizing: border-box;
			.bot{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.lt{
					font-size: 28rpx;
					color:#3D3D3D;
					view{
						margin-top: 8rpx;
					}
					text{
						color: #808080;
					}
				}
				.rt{
					font-size: 32rpx;
					color: #3D3D3D;
				}
			}
			.top{
				display: flex;
				justify-content: space-between;
				.rt{
					font-size: 26rpx;
					color: #808080;
				}
				.lt{
					display: flex;
					align-items: center;
					font-weight: 600;
					font-size: 32rpx;
					color: #3D3D3D;
					image{
						width: 42rpx;
						height: 42rpx;
						margin-right: 18rpx;
					}
				}
			}
		}
	}
	.zuchelist{
		height: 76vh;
		overflow: scroll;
		padding-bottom: 20rpx;
		box-sizing: border-box;
		.dibutishi{
			width: 100%;
			text-align: center;
			margin-top: 18rpx;
			color: #ccc;
		}
		.zuchelist_item{
			width: 714rpx;
			max-height: 700rpx;
			padding-bottom: 28rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin: auto;
			margin-top: 20rpx;
			overflow: hidden;
		}
		.bot{
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 693rpx;
			margin: auto;
			padding: 0 14rpx;
			box-sizing: border-box;
			margin-top: 40rpx;
			.rt{
				display: flex;
				justify-content: space-between;
				.huan{
					width: 106rpx;
					height: 52rpx;
					background: #4297F3;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 2rpx solid #4297F3;
					text-align: center;
					line-height: 52rpx;
					font-size: 26rpx;
					color: #FFFFFF;
					margin-left: 10rpx;
				}
				.xuzu{
					width: 106rpx;
					height: 52rpx;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 2rpx solid #4297F3;
					font-size: 26rpx;
					color: #4297F3;
					text-align: center;
					line-height: 52rpx;
				}
			}
			.lt{
				view{
					font-size: 26rpx;
					color: #3D3D3D;
					margin-top: 18rpx;
				}
			}
		}
		.quche{
			padding: 0 24rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			margin-top: 18rpx;
			.price{
				font-weight: 600;
				font-size: 32rpx;
				color: #3D3D3D;
			}
			text{
				font-size: 26rpx;
				color: #3D3D3D;
			}
		}
		.top{
			width: 714rpx;
			height: 84rpx;
			background: linear-gradient( 270deg, rgba(220,237,255,0) 0%, #DCEDFF 80%);
			line-height: 84rpx;
			font-size: 24rpx;
			color: #3D3D3D;
			padding:0 24rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
		}
	}
	@keyframes fadeIn {
	  from {
	    opacity: 0;
	  }
	  to {
	    opacity: 1;
	  }
	}
	@keyframes fadeIns {
	  from {
		transform: translateX(-500%);
	  }
	  to {
		transform: translateX(0%);
	  }
	}
	@keyframes fadeInss {
	  from {
		transform: translateX(500%);
	  }
	  to {
		transform: translateX(0%);
	  }
	}
	.navtab{
		display: flex;
		width: 100%;
		height: 114rpx;
		position: relative;
		background-color: #C4E1FF;
		z-index: 1;
		.qxtabs{
			width: 50%;
			text-align: center;
			padding-top: 40rpx;
			box-sizing: border-box;
			font-weight: 600;
			font-size: 36rpx;
			color: #3D3D3D;
			animation: fadeIn 0.3s ease-in-out forwards;
			text{
				width: 54rpx;
				height: 6rpx;
				background: #4297F3;
				border-radius: 4rpx 4rpx 4rpx 4rpx;
				display: block;
				margin: auto;
				margin-top: 8rpx;
				animation: fadeIns 0.5s ease-in-out forwards;
			}
			image{
				width: 439rpx;
				height: 114rpx;
				position: absolute;
				bottom:0;
				right: 0;
				z-index: -1;
			}
		}
		.zctabs{
			width: 50%;
			font-size: 32rpx;
			font-weight: 600;
			color: #3D3D3D;
			text-align: center;
			padding-top: 46rpx;
			box-sizing: border-box;
			image{
				width: 400rpx;
				height: 94rpx;
				position: absolute;
				bottom: 0;
				left:0;
				z-index: -2;
			}
		}
		.qxtab{
			width: 50%;
			text-align: center;
			padding-top: 46rpx;
			box-sizing: border-box;
			font-weight: 600;
			font-size: 32rpx;
			color: #3D3D3D;
			image{
				width: 439rpx;
				height: 94rpx;
				position: absolute;
				bottom:0;
				right: 0;
				z-index: -2;
			}
		}
		.zctab{
			width: 50%;
			font-weight: 600;
			font-size: 36rpx;
			color: #3D3D3D;
			text-align: center;
			padding-top: 40rpx;
			box-sizing: border-box;
			animation: fadeIn 0.3s ease-in-out forwards;
			text{
				animation: fadeInss 0.5s ease-in-out forwards;
				width: 54rpx;
				height: 6rpx;
				background: #4297F3;
				border-radius: 4rpx 4rpx 4rpx 4rpx;
				display: block;
				margin: auto;
				margin-top: 8rpx;
			}
			image{
				width: 400rpx;
				height: 114rpx;
				position: absolute;
				top: 0;
				left:0;
				z-index: -1;
			}
		}
	}
    .topbj{
		width: 100%;
		height: 22rpx;
		background-color: #C4E1FF;
	}
</style>