<template>
	<view class="refundBox">
		<view class="content">
			<view class="title">选择售后类型</view>
			<view class="row">
				<view class="item" @click="toApply(1)">
					<view class="item-left">
						<view class="icon">
							<text class="iconfont icon-tuikuan"></text>
						</view>
						<view class="item-left-text">
							<view>我要退款(无需退货）</view>
							<view class="text">没收到货，或与卖家协商同意不用退货只退款</view>
						</view>
					</view>
					<up-icon name="arrow-right" />
				</view>
				
				<view class="item box-jc" @click="toApply(2)">
					<view class="item-left">
						<view class="icon">
							<text class="iconfont icon-tuihuo"></text>
						</view>
						<view class="item-left-text">
							<view>我要退货退款</view>
							<view class="text">已收到货，需要退还已收到的货物</view>
						</view>
					</view>
					<up-icon name="arrow-right" />
				</view>
			</view>
		</view>
		
		<up-modal
			:show="showDialog"
			confirmText="确定申请"
			cancelText="暂不申请"
			title="您确认已收货，申请退货退款吗？"
			:confirmColor="Color"
			:showCancelButton="true"
			content="需要您寄回商品，请确认已收货"
			@confirm="confirmRefound()"
			@cancel="showDialog = false">
		</up-modal>
	</view>
</template>

<script>
	import { ref, reactive, toRefs } from 'vue'
	import { Style } from '@/utils/list.js'
	
	export default {
		setup() {
			const data = reactive({
				order_id: '',
				showDialog: false,
				type: 1,
				Theme: uni.getStorageSync('theme_index') * 1,
				Color: uni.getStorageSync('theme_color')
			})
			
			function confirmRefound() {
				uni.redirectTo({
					url: '/pages/mine/refund/apply/index?order_id=' + data.order_id +'&type=' + data.type
				})
			}
			
			function toApply(type) {
				data.type = type
				if(type == 2) {
					data.showDialog = true
				} else {
					uni.redirectTo({
						url: '/pages/mine/refund/apply/index?order_id=' + data.order_id +'&type=' + data.type
					})
				}
			}
			
			return {
				confirmRefound,
				toApply,
				...toRefs(data)
			}
		},
		onLoad(options) {
			this.order_id = options.order_id
		}
	}
</script>

<style lang="scss" scoped>
	.refundBox {
		padding: 24rpx 30rpx;
		.content {
			background: #fff;
			box-sizing: border-box;
			padding: 20rpx;
			border-radius: 10rpx;
			.title {
				font-size: 30rpx;
				font-weight: bold;
			}
			.row {
				margin-top: 20rpx;
				.item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 20rpx 0;
					&-left {
						display: flex;
						align-items: center;
						.icon{
							margin-right: 24rpx;
							.iconfont{
								font-size: 28px;
								color: v-bind('Color');
							}
						}
						&-text {
							font-size: 30rpx;
							font-weight: bold;
							.text {
								font-size: 24rpx;
								color: #999;
								margin-top: 15rpx;
								font-weight: normal;
							}
						}
					}
				}
			}
		}
	}
	
</style>

<style scoped>
/deep/ .u-modal__content{
	text-align: center;
}
</style>
