<template>
	<view class="pages">
		<u-navbar title="订单详情" :border-bottom="false" :background="bgc" back-icon-color="#3D3D3D" title-color='#3D3D3D'
			title-size='36' height='44'></u-navbar>
        
		<view class="box">
			<view class="top">
				订单详情
			</view>
			<view class="xiao">
				 <view>订单编号</view>
				 <view>{{obj.billNo == undefined ? '--' : obj.billNo}}</view>
			</view>
			<view class="xiao">
				 <view>租赁用户</view>
				 <view>{{obj.userName == undefined ? '--' : obj.userName}}</view>
			</view>
			<view class="xiao">
				 <view>设备编号</view>
				 <view style="color: #8883F0;">{{obj.deviceNo == undefined ? '--' : obj.deviceNo}}</view>
			</view>
			<view class="xiao">
				 <view>经营场所</view>
				 <view style="color: #8883F0;">{{obj.storeName == undefined ? '--' : obj.storeName}}</view>
			</view>
			<view class="xiao">
				 <view>经营地址</view>
				 <view>{{obj.storeAddress == undefined ? '--' : obj.storeAddress}}</view>
			</view>
			<view class="xiao">
				 <view>房间号</view>
				 <view>{{obj.room == undefined ? '--' : obj.storeAddress}}号</view>
			</view>
			<view class="xiao">
				 <view>支付时间</view>
				 <view>{{obj.payTime == undefined ? '--' : obj.payTime}}</view>
			</view>
			<view class="xiao">
				 <view>购买套餐</view>
				 <view>{{obj.suitName == undefined ? '--' : obj.suitName}}</view>
			</view>
			<view class="xiao">
				 <view>套餐时长</view>
				 <view>{{obj.suitTime == undefined ? '--' : obj.suitTime}}小时</view>
			</view>
			<view class="xiao">
				 <view>支付类型</view>
				 <view>{{obj.channelName == undefined ? '--' : obj.channelName}}</view>
			</view>
			<view class="xiao">
				 <view>套餐金额</view>
				 <view>￥{{obj.money == undefined ? '--' : obj.money}}</view>
			</view>
			<view class="xiao">
				 <view>结束时间</view>
				 <view>{{obj.suitEndTime == undefined ? '--' : obj.suitEndTime}}</view>
			</view>
			<view class="xiao">
				 <view>订单状态</view>
				 <view>使用中</view>
			</view>
			<view class="xiao">
				 <view>直属合作伙伴</view>
				 <view>{{obj.agentName == undefined ? '--' : obj.agentName}}（{{obj.agentMobile == undefined ? '--' : obj.agentMobile}}）</view>
			</view>
			<view class="xiao">
				 <view>直属渠道商</view>
				 <view>{{obj.bizName == undefined ? '--' : obj.bizName}}（{{obj.bizMobile == undefined ? '--' : obj.bizMobile}}）</view>
			</view>
			<view class="xiao">
				 <view>创业者</view>
				 <view>{{obj.investorName == undefined ? '--' : obj.investorName}}（{{obj.investorMobile == undefined ? '--' : obj.investorMobile}}）</view>
			</view>
			<view class="symx">
				收益明细
			</view>
			<view class="xiao" v-for="(item,index) in obj.bonusList" :key="index">
				<view class="one">{{item.arrivalName == undefined ? '--' : item.arrivalName}}（<text v-if="item.arrivalType == 1">平台</text><text v-if="item.arrivalType == 2">公司</text><text v-if="item.arrivalType == 3">合作伙伴商</text><text v-if="item.arrivalType == 4">渠道商</text><text v-if="item.arrivalType == 5">创业者</text><text v-if="item.arrivalType == 6">经营场所</text>）{{item.point}}%</view>
				<view class="two">￥{{item.amount == undefined ? '--' : item.amount}}</view>
			</view>
		</view>
		<view class="sb" v-if="userflag" @click="btntz" style="width:680rpx;height: 100rpx;display: flex;justify-content: space-between;background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin: auto;
			padding: 32rpx 24rpx;
			box-sizing: border-box;	font-size: 28rpx;
					color: #3D3D3D;
			margin-top: 30rpx;align-items: center;">
			<text class="shen">￥{{obj.money == undefined ? '--' : obj.money}}</text> <text>退款</text>
		</view>
		<!-- 退款弹窗 -->
		<view class="tanc" v-if="maskflag">
			<view class="top">
				请输入退款金额
			</view>
			<view class="shuzhi">
				 <input type="text" v-model="inptext" placeholder="请输入退款金额"/>
			</view>
			<view class="anniu">
				<view class="qux" @click="btnqx">
					取消
				</view>
				<view class="qd" @click="btnqd">
					确定
				</view>
			</view>
		</view>
		<view class="mask" v-if="maskflag"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					// backgroundColor: "#8883f0",
				}, 
				billId:'',
				obj:{},
				userflag:false,
				maskflag:false,
				inptext:'',
				userid:''
			}
		},
		onLoad(option) {
			this.userid = uni.getStorageSync('userType').userId
            this.billId = option.billId
			this.getxq()
		},
		// 分享到好友（会话）
		onShareAppMessage: function() {
			return {
				title: '创亿康',
				path: '/pages/index/index'
			}
		},

		// 分享到朋友圈  
		onShareTimeline: function() {
			return {
				title: '创亿康',
				query: '',
				path: '/pages/index/index'
			}
		},
		methods: {
            getxq(){
				this.$u.get(`/app/bill/arrival/${this.billId}`).then(res => {
					if(res.code == 200){
						this.obj = res.data
						if(this.userid == res.data.agentId && res.data.status == 2){
							this.userflag = true
						}else{
							this.userflag = false
						}
					}
				})
			}, 
			// 取消退款
			btnqx(){
				this.maskflag = false
				this.inptext = ''
			},
			// 退款
			btntz(){
				this.maskflag = true
			},
			btnqd(){
				if(this.inptext > this.obj.money){
					uni.showToast({
						title: '退款金额不能大于订单金额',
						icon: 'none',
						duration: 3000
					})
				}else{
					this.maskflag = false
					let data = {
						billId:this.billId,
						refundAmount:this.inptext
					}
					this.$u.put(`/app/bill/refund`,data).then((res) => {
						if (res.code == 200) {
							uni.showToast({
								title: '操作成功',
								icon: 'success',
								duration: 3000
							})
							setInterval(()=>{
								uni.navigateBack()
							},1000)
						}else{
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 3000
							})
						}
					})
				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-title {
		padding-bottom: 15rpx;
	}

	/deep/ .u-icon__icon {
		padding-bottom: 15rpx;
	}
    .mask{
    	width: 100%;
    	height: 100vh;
    	position: fixed;
    	top: 0;
    	left: 50%;
    	transform: translateX(-50%);
    	background-color: #000;
    	opacity: .6;
    } 
	.tanc {
		width: 594rpx;
		height: 420rpx;
		background: #FFFFFF;
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		position: fixed;
		left: 50%;
		transform: translateX(-50%);
		top: 506rpx;
		z-index: 98;
	
		.anniu {
			display: flex;
			justify-content: space-between;
			padding: 0 44rpx;
			box-sizing: border-box;
			margin-top: 64rpx;
			width: 100%;
	
			.qux {
				width: 234rpx;
				height: 80rpx;
				border-radius: 40rpx 40rpx 40rpx 40rpx;
				border: 2rpx solid #8883F0;
				font-size: 36rpx;
				color: #8883F0;
				text-align: center;
				line-height: 80rpx;
			}
	
			.qd {
				width: 234rpx;
				height: 80rpx;
				background: #8883F0;
				border-radius: 40rpx 40rpx 40rpx 40rpx;
				font-size: 36rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 80rpx;
			}
		}
	
		.shuzhi {
			display: flex;
			align-items: center;
			// justify-content: space-between;
			justify-content: center;
			// padding:  0 60rpx;
			margin-top: 50rpx;
			box-sizing: border-box;
	
			input {
				width: 500rpx;
				height: 76rpx;
				border-radius: 10rpx 10rpx 10rpx 10rpx;
				border: 2rpx solid #808080;
				padding-left: 10rpx;
				box-sizing: border-box;
				margin: 0 10rpx;
				z-index: 99 !important;
			}
		}
	
		.top {
			font-weight: 600;
			font-size: 36rpx;
			color: #3D3D3D;
			width: 100%;
			text-align: center;
			padding-top: 40rpx;
			box-sizing: border-box;
		}
	
		image {
			width: 198rpx;
			height: 172rpx;
			position: absolute;
			top: 12rpx;
			right: 20rpx;
			opacity: .5;
		}
	}
	.pages {
		background-color: #F7FAFE !important;
		height: 100vh;
		width: 100%;
		padding: 28rpx;
		box-sizing: border-box;
		.box{
			width: 100%;
			max-height: 100%;
			background-color: #fff;
			border-radius: 20rpx;
			padding: 24rpx 28rpx;
			box-sizing: border-box;
			.top{
				font-size: 28rpx;
				color: #3D3D3D;
				font-weight: 600;
				border-bottom: 1px solid #D8D8D8;
				padding-bottom: 20rpx;
				box-sizing: border-box;
			}
			.xiao{
				display: flex;
				justify-content: space-between;
				font-size: 24rpx;
				color: #3D3D3D;
				margin-top: 20rpx;
			}
			.symx{
				font-size: 28rpx;
				color: #3D3D3D;
				font-weight: 600;
				border-top: 1px solid #D8D8D8;
				padding-top: 20rpx;
				box-sizing: border-box;
				margin-top: 20rpx;
			}
		}
	}

</style>