<template>
	<view class="app">
		<view class="content">
			<view class="name">
				退款商品
			</view>
			<view class="details">
				<view class="detailslist">
					<image :src="baseurl+order.attributePitureUrl" mode=""></image>
					<view class="model">
						<view class="top">
							<span v-if="order.orderType =='HEALTH_CONSULTATION'">健康咨询</span>
							<span v-else>{{order.goodsName}}</span>
							<span v-if="order.orderType=='DIRECT_BUY'">￥{{order.goodsPrice}}</span>
						</view>
						<view class="bottom" v-if="order.orderType !='HEALTH_CONSULTATION'">
							<span>型号：{{order.goodsAttributeName}}</span>
							<span>X{{order.goodsCount}}</span>
						</view>
					</view>
					<view class="payinfo">
						<text class="pay">实付款</text>
						<text class="price"
							v-if="order.orderType=='DIRECT_BUY'||order.orderType =='HEALTH_CONSULTATION'">￥{{order.totalPrice}}</text>
						<text class="price"
							v-if="order.orderType=='INTEGRAL_EXCHANGE'">{{order.integralExchangeSill}}健康豆</text>
					</view>
				</view>
			</view>
		</view>
		<view class="refundinfo" v-if="order.orderType !='HEALTH_CONSULTATION'">
			<view class="refund">
				选择退款类型
			</view>
			<view class="myrefund" @tap='goApplforrefund(1)'>
				<image class="images" src="@/static/pagesB/myrefund.png" mode=""></image>
				<view class="refundfo">
					<view>我要退款(无需退货)</view>
					<view class="text">没收到货</view>
				</view>
				<image class="picture pictures" src="../../static/huijiantou.png" mode=""></image>

			</view>
			<view class="myrefund" @tap='goApplforrefund(2)'>
				<image class="images" src="@/static/pagesB/refundgoods.png" mode=""></image>
				<view class="refundfo">
					<view>我要退货退款</view>
					<view class="text">已收到货，需要退还收到的货物</view>
				</view>
				<image class="picture" src="../../static/huijiantou.png" mode=""></image>
			</view>
		</view>
		<view class="" v-else>
			<view class="discribe">
				<view class="voucher">退款原因</view>
				<view class="supplement">
					<u-input v-model="order.refundReasonRemark" type="textarea" height="100" :auto-height="true"
						placeholder="请输入退款原因" />
				</view>
			</view>
			<view class="Submit" @tap='refundinfo'>提交</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		refund
	} from '@/api/pagesB/Applforrefund/index.js'
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				baseurl: '', //url
				order: {
					refundReasonRemark: '',
				},
			}
		},
		methods: {
			//退款
			refundinfo() {
				this.order.updateTime = null
				refund(this.order).then(
					res => {
						if (res.code == 500) {
							this.$refs.uToast.show({
								title: res.msg,
								type: 'error'
							})
						} else {
							uni.setStorageSync("Refresh", 'Refresh')
							this.$refs.uToast.show({
								title: '退款申请提交成功',
								type: 'success',
								duration: '1500'
							})
							if (this.timer) {
								clearTimeout(this.timer)
							}
							this.timer = setTimeout(e => {
								uni.navigateBack({
									delta: 2
								})
							}, 1500)
						}
					})
			},
			//退款页面
			goApplforrefund(e) {
				if (e == 1) {
					uni.navigateTo({
						url: `/pagesB/Applforrefund/Applforrefund?typename=${'我要退款(无需退货)'}&order=${JSON.stringify(this.order)}`
					})
				} else {
					uni.navigateTo({
						url: `/pagesB/Applforrefund/Applforrefund?typename=${'已收到货，需要退还收到的货物'}&order=${JSON.stringify(this.order)}`
					})
				}
			},
		},
		onLoad(options) {
			if (options.order) {
				this.order = JSON.parse(options.order)
				this.order.id = this.order.goodsOrderId
			} else if (options.list) {

				this.order = JSON.parse(options.list)
				this.order.attributePitureUrl = this.order.personPictureUrl

				// console.log(this.order,'78787')

				this.order.id = this.order.goodsOrderId

			}
			// console.log(this.order,'777')
			this.baseurl = baseurl
		}
	}
</script>

<style lang="scss">
	@import './refundType.scss';
</style>