<template><page-meta :root-font-size="fontSize+'px'"></page-meta>
    <seller-base :show="false">
    <view class="div seller-refund-form">
      <view class="div common-header-wrap">
        <view :style="'height:'+navHeight+'px'"></view>
        <view class="common-header-holder"></view>
        <view class="common-header-fixed">
        <title-header />
        <uni-nav-bar :title="'处理'+title" class="common-header" left-icon="back" @clickLeft="goBack()">
        </uni-nav-bar>
      </view>
      </view>

      <view class="div form">
          <flex-line :show-border="true">
          <text class="span">{{'同意'+title}}</text>
          <view class="div" slot="right">
			  <radio-group @change="radioChange(1,$event)">
			    <label v-for="(item, index) in seller_state_options" :key="index">
			  	<radio :value="item.value" :checked="seller_state==item.value" />
			  	<text>{{item.label}}</text>
			    </label>
			  </radio-group>
          </view>
          </flex-line>
          <flex-line v-if="refund_type==2" :show-border="true">
          <text class="span">弃货</text>
          <view class="div" slot="right">
			  <radio-group @change="radioChange(2,$event)">
			    <label v-for="(item, index) in return_type_options" :key="index">
			  	<radio :value="item.value" :checked="return_type==item.value" />
			  	<text>{{item.label}}</text>
			    </label>
			  </radio-group>
          </view>
          </flex-line>
          <flex-line class="field-line menu-item" :show-border="true"><text class="span field-name">备注信息</text><view class="div field-line-right" slot="right"><input class="field-input" type="textarea" v-model="seller_message" /></view></flex-line>

        <view class="div pt-10 pb-10"><view class="div common-btn ds-button-large" @click="submitInformation">保存</view></view>
      </view>
    </view>
</seller-base>
</template>

<script>
import {getFontSize} from '@/util/common'

import TitleHeader from '../../TitleHeader'

import SellerBase from '../SellerBase'



import { editRefund } from '../../../api/sellerRefund'
import flexLine from '../../flexLine'
export default {
  components:{

  TitleHeader,

  SellerBase,

  flexLine,

  },
  name: 'SellerRefundForm',
  data(){
    return {
      navHeight: 0,
      refund_id: 0,
      seller_message: '',
      seller_state: '2',
      refund_type: '',
      title: '',
      return_type: '2',
      return_type_options: [
        {
          label: '是',
          value: '1'
        },
        {
          label: '否',
          value: '2'
        }
      ],
      seller_state_options: [
        {
          label: '是',
          value: '2'
        },
        {
          label: '否',
          value: '3'
        }
      ]
    }
  },
  mounted(){

  // #ifdef  MP-WEIXIN

  this.navHeight = uni.getMenuButtonBoundingClientRect().height

  // #endif

  },
  computed:{

  fontSize(){

    return getFontSize()

  },

  },
  onLoad: function (option) {
	this.refund_id = option.refund_id
	this.refund_type = option.refund_type
	this.title = option.refund_type == 2 ? '退货' : '退款'
  },

  methods:{
	radioChange(i,e){
	  switch(i){
		case 1:
		this.seller_state=e.detail.value
		break
		case 2:
		this.return_type=e.detail.value
		break
	  }
	},
	
    goBack(){uni.navigateBack({delta:1})},

    submitInformation () {
      editRefund(this.refund_id, this.return_type, this.seller_message, this.seller_state).then(res => {
        uni.showToast({icon:'none',title: res.message})
        uni.navigateBack({delta:1})
      }).catch(function (error) {
        uni.showToast({icon:'none',title: error.message})
      })
    }

  }
}
</script>
<style lang="scss">
    .seller-refund-form{
        .mint-radiolist {
            display: flex;
            .mint-cell {
                flex: 1;
                .mint-radio-input:checked + .mint-radio-core {
                    background-color: $primaryColor !important;
                    border-color: $primaryColor !important;
                }
                &:after{display: none}
            }
        }
    }
</style>
<style  lang="scss" scoped>
.form{background: #fff;padding:0 $pageSpace}
  .seller-refund-form {
    background: #fff;

    .menu-item {
    }
  }


</style>
