<template>
    <fixed-bar v-if="isShow">
        <view class="order-refund-fixed">
            <or-button @click="$emit('click:button')"></or-button>
        </view>
    </fixed-bar>
</template>

<script>
import fixedBar from "../fixed_bar/fixed_bar.vue";
import orButton from "./button.vue";
import { mapState } from 'vuex';
/**
 * 全部订单都能退两次, 所有订单最多只能退2次款
 * 只要订单金额是未全退的，都能退
 * 0元订单不能退
 * 
*/
export default {
    components: {
        fixedBar,
        orButton
    },
    props: [ 'pay_amount', 'refund_amount', 'refund_times' ],
    computed: {
        ...mapState([ 'brandInfo' ]),
        payAmount(){
            let { pay_amount } = this;
            return +pay_amount || 0
        },
        refundAmount(){
            let { refund_amount } = this;
            return +refund_amount || 0
        },
        isShow(){
            console.log('brandInfo', this.brandInfo)
            let { payAmount, refundAmount, refund_times, brandInfo } = this;
            if(
                payAmount - refundAmount > 0
                &&[0, 1].includes(refund_times)
                &&brandInfo?.permission?.['1018'] // 退款权限
            ){
                return true
            }
            return false
        }
    },
}
</script>

<style lang="scss">
    .order-refund-fixed{
        padding: 10upx 24upx;
        background: #F2F2F7;
        @include ctf(flex-end);
    }
</style>