<template>
	<view class="app">
		<view class="content">退款金额
			<span>￥{{nurseItemPrice}}</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/pagesB/cancelorder/cancelorder.js'
	export default {
		data() {
			return {
				nurseItemPrice: null,
				appointmentOrderId: null,
				cancelAppointmentReason: '',
				timer: null,
			}
		},
		onLoad(options) {
			this.appointmentOrderId = options.appointmentOrderId
			this.nurseItemPrice = options.nurseItemPrice
		},
		methods: {
			gocancel() {
				cancellationOrder(this.appointmentOrderId, this.cancelAppointmentReason).then(res => {
					if (res.code == 500) {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error',
						})
					} else if (res.code == 200) {
						uni.setStorageSync("Refresh", 'Refresh')
						this.$refs.uToast.show({
							title: '取消成功',
							type: 'success'
						})
						if (this.timer) {
							clearTimeout(this.timer)
						}
						this.timer = setTimeout(e => {
							uni.navigateBack({
								delta: 2
							})
						}, 1500)
					}
				})
			}
		},
	}
</script>

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

		.ConfirmCancel {
			width: 217rpx;
			height: 68rpx;
			background: #26A888;
			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>