<template>
	<view>
		<view class="payList">
			<uni-table border stripe emptyText="暂无更多数据" >
				<uni-tr>
					<uni-th align="center" width="80">维修项目/配件</uni-th>
					<uni-th align="center" width="30">数量</uni-th>
					<uni-th align="center" width="30">单价</uni-th>
					<uni-th align="center" width="30">工时费</uni-th>
					<uni-th align="center" width="30">总计</uni-th>
					<uni-th align="center" width="30">实收</uni-th>
				</uni-tr>
				<uni-tr v-for="(item,index) in tableList" :key="index">
					<uni-td align="center">{{item.goodsName}}</uni-td>
					<uni-td align="center">{{item.num}}</uni-td>
					<uni-td align="center">{{item.unitPrice}}</uni-td>
					<uni-td align="center">{{item.hourPrice}}</uni-td>
					<uni-td align="center">{{item.sumPrice}}</uni-td>
					<uni-td align="center">{{item.payPrice}}</uni-td>
				</uni-tr>
			</uni-table>
			<view class="dataBlock">
				<view class="payInfo">
					<view class="payTitle">合计费用</view>
					<view class="payPrice">￥{{payList.payNum || 0}}</view>
				</view>
				<view class="payInfo">
					<view class="payTitle">优惠费用</view>
					<view class="payPrice">-￥{{payList.discountPrice || 0}}</view>
				</view>
				<view class="payInfo">
					<view class="payTitle">实际支付</view>
					<view class="paySure">￥{{payList.payPrice}}</view>
				</view>
				<view class="payInfo">
					<view class="payTitle">支付状态</view>
					<view class="paySure">{{payList.payStatus==1?'已支付':payList.payStatus==2?'未支付':'已挂账'}}</view>
				</view>
			</view>
		</view>
		
		<view class="payBtn" @click="toPay()" v-if="payStatus === 4">立即支付</view>
	</view>
</template>

<script>
	import {
		orderDetail,
		payOrder
	} from '../../../api/maintain.js'
	export default {
		data() {
			return {
				orderId:'',
				type:1,
				provider:'',
				payList:{},
				tableList:[],
				payStatus : ''
			};
		},
		onLoad(options){
			this.orderId = options.id
			this.getOrderDetail()
		},
		methods:{
			getOrderDetail(){
				let data = {
					id : this.orderId
				}
				orderDetail(data).then(res=>{
					this.payList = res.data
					this.payStatus = res.data.status
					this.tableList = res.data.repairOrderServicesVO
					console.log(this.payStatus);
				})
			},
			toPay(){
				let data = {
					id:this.orderId,
					payType:this.type,
					payMoney:this.payList.payPrice
				}
				uni.navigateTo({
					url:'/pages/shop/cashierDesk/cashierDesk?page=maintenance&params='+JSON.stringify(data)
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F5F5F5;
	}
.payList{
	width: 630rpx;
	padding: 40rpx 30rpx;
	position: relative;
	left: calc(50% - 345rpx);
	background: #FFFFFF;
	border-radius: 10rpx;
	margin-top: 30rpx;
}
.dataBlock{
	width: 100%;
	margin-top: 30rpx;
	display: flex;
	flex-direction: column;
	.payInfo{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 30rpx;
		.payTitle{
			font-size: 26rpx;
			font-weight: 500;
			color: #666666;
		}
		.payPrice{
			font-size: 26rpx;
			font-weight: 500;
			color: #333333;
		}
		.paySure{
			font-size: 26rpx;
			font-weight: 500;
			color: #FE5C4A;
		}
	}
}
.payBtn{
	width: 690rpx;
	height: 90rpx;
	background: linear-gradient(0deg, #0036FF 0%, #008EFF 100%);
	border-radius: 45rpx;
	position: relative;
	left: calc(50% - 345rpx);
	font-size: 32rpx;
	font-weight: 500;
	color: #FFFFFF;
	line-height: 90rpx;
	text-align: center;
	margin-top: 180rpx;
}
</style>
