<template>
	<view class="app">
		<view class="content">退款金额
			<span>￥{{totalPrice}}</span>
		</view>
		<view class="reason">
			<view class="ability">退款原因</view>
			<u-input v-model="cancelAppointmentReason" type="textarea" placeholder="请输入退款原因" />
		</view>
		<view class="ConfirmCancel" @tap="gocancel()">确认取消
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import baseurl from '@/api/baseurl.js'
	import {
		cancellationOrder
	} from '@/api/cancelorder/cancelorder.js'
	export default {
		data() {
			return {
				timer:null,
				totalPrice: null,
				orderId: null,
				cancelAppointmentReason: '',
			}
		},
		onLoad(options) {
			this.orderId = options.orderId
			this.totalPrice = options.totalPrice
		},
		methods: {
			gocancel() {
				cancellationOrder(this.orderId, this.cancelAppointmentReason).then(res => {
					if (res.code == 500) {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error',
						})
					} else if (res.code == 200) {
						this.$refs.uToast.show({
							title: '取消成功',
							type: 'success'
						})
						if (this.timer) {
							clearTimeout(this.timer)
						}
						this.timer = setTimeout(e => {
							uni.navigateBack({
								delta: 1
							})
						}, 1500)
					}
				})
			}
		},
	}
</script>

<style lang="scss">
	.app {
		background-color: #F4F5F7;
		width: 100%;
		color: #000000;

		.ConfirmCancel {
			width: 217rpx;
			height: 68rpx;
			background: #4C7BC9;
			border-radius: 26rpx;
			color: #FFFFFF;
			line-height: 68rpx;
			text-align: center;
			margin: 20vh 20rpx 0 0;
			float: right;
		}

		.reason {
			width: 95%;
			height: 342rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
			border-radius: 20rpx;
			margin: 10px auto;
			padding: 2%;
			font-size: 30rpx;

			input {
				padding-top: 10rpx;
			}

			.ability {
				width: 100%;
				height: 60rpx;
				border-bottom: 1rpx solid #D8D4D4;
			}
		}

		.content {
			width: 95%;
			background: #FFFFFF;
			box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
			border-radius: 20rpx;
			margin: 0 auto;
			line-height: 70rpx;
			padding: 2%;
			font-size: 30rpx;

			span {
				float: right;
				font-size: 38rpx;
				color: red;
			}
		}

	}
</style>
