<template>
    <view class="RefundHistory">
        <view class="goods-item">
            <image :src="goodsInfo.cover" mode="aspectFill" class="good-img" />
            <view class="item--content">
                <view class="title">{{goodsInfo.goods_name}}</view>
                <view class="sub_title" v-if="goodsInfo.shop">{{goodsInfo.shop.name}}</view>
                <view class=" number">
                    共 {{goodsInfo.qty}} 件
                </view>
            </view>
        </view>
        
        <view class="total">
            <view class="total-item grey">
                申请金额<text>{{refund_total || '0.00'}} DT</text>
            </view>
            <view class="total-item">
                合计退款<text>{{refund_total|| '0.00'}} DT</text>
            </view>
        </view>
        
        <view class="logistics--logs">
            <block v-for="(log, logIndex) in logs" :key="logIndex">
                <view class="item">
                    <view class="">{{log.state_text}}</view>
                    <view class="">{{log.created_at}}</view>
                    <view class="">{{log.remark}}</view>
                </view>
            </block>
        </view>
    </view>
</template>
<script>
    import {
        refundsLogs
    } from '@/apis/interfaces/order.js'
    export default {
        data() {
            return {
                logs: [],
                goodsInfo: {},
                refund_total:''
            }
        },
        onLoad() {
            refundsLogs(this.$Route.query.id).then(res => {
                console.log(res)
                this.logs = res.logs
                this.goodsInfo = res.refund.items[0]
                this.refund_total = res.refund.refund_total
            }).catch(err => {
                uni.showToast({
                    title: err.message,
                    icon: 'none',
                    mask: true,
                })
            })
        },
        methods: {
            copyNo() {
                uni.setClipboardData({
                    data: this.info.no,
                    success: res => {
                        uni.showToast({
                            title: "单号已复制",
                            icon: "none"
                        })
                    }
                })
            }
        }
    }
</script>
<style lang="scss" scoped>
    $margin: 30rpx;
    $radius: 10rpx;

    .RefundHistory {
        padding: $padding;
        min-height: 100vh;
        background-color: #f9f9f9;
    }

    .logistics--header {
        position: relative;
        background: linear-gradient(to right, #34ce98, #22aa98);
        color: white;
        padding: $margin $margin $margin*2;
        min-height: 88rpx;

        .logo {
            width: 88rpx;
            height: 88rpx;
            background: white;
            vertical-align: top;
        }

        .info {
            position: absolute;
            left: $margin * 2 + 88rpx;
            top: $margin;
            font-size: 28rpx;

            &--no {
                line-height: 44rpx;
                font-weight: normal;

                text {
                    margin-left: $margin/2;
                }
            }

            &--company {
                height: 44rpx;
                line-height: 40rpx;
                font-weight: normal;
            }
        }
    }

    .logistics--logs {
        position: relative;
        background: white;
        border-radius: $radius $radius 0 0;
        z-index: 9;
        padding: $margin;
        overflow: hidden;
        margin-top: 30rpx;
        min-height: 50vh;

        .item {
            position: relative;
            margin-top: $margin;
            padding-left: 50rpx;
            font-size: 28rpx;
            color: #444;

            &::after,
            &::before {
                position: absolute;
                content: " ";
            }

            &::before {
                top: 10rpx;
                left: 10rpx;
                background-color: #ddd;
                height: 200%;
                width: 2rpx;
            }

            &::after {
                width: 22rpx;
                height: 22rpx;
                background-color: #ddd;
                left: 0;
                top: 10rpx;
                border-radius: 50%;
            }

            &:first-child {
                margin-top: 0;

                &::after {
                    background-color: #34CE98;
                }
            }
        }
    }

    .goods-item {
        background-color: #Fff;
        width: 100%;
        display: inline-block;
        // border-bottom: solid 1rpx #eee;

        // padding: $padding;
        padding-left: $padding;
        padding-top: $padding;
        padding-bottom: $padding - 15;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        box-sizing: border-box;

        .good-img {
            width: 160rpx;
            height: 160rpx;
            border-radius: 10rpx;
        }

        .item--content {
            flex: 1;
            padding: $padding - 10;

            .number {
                font-size: 28rpx;
                color: #666;
                padding-top: 20rpx;
            }

            &>.title {
                font-size: 30rpx;
                color: #333;
                font-weight: bold;
                // @extend .ellipsis-1;
            }

            &>.sub_title {
                color: #a05f0c;
                font-size: 26rpx;
                padding-top: 6rpx;
                // @extend .ellipsis-1;
            }

            &>.price {
                padding-top: 10rpx;
                display: flex;
                flex-direction: row;
                align-items: flex-end;
                justify-content: flex-end;
                box-sizing: border-box;
                font-weight: bold;
                font-size: 36rpx;
                color: $text-price;

                // @extend .ellipsis-1;
                .price-type {
                    display: flex;
                    flex-direction: row;
                    align-items: center;
                    justify-content: space-between;
                    box-sizing: border-box;
                    flex: 1;

                    text {
                        margin-right: $margin/2;
                        padding-left: 10rpx;
                        font-size: 60%;
                        padding-bottom: 4rpx;
                    }

                    .kucun {
                        color: $text-gray;
                        font-weight: normal;
                    }
                }

            }
        }

    }
    
    .total {
        background-color: #fff;
        padding: 0 $padding $padding $padding;
        border-top: solid 2rpx #f9f9f9;
        font-size: 28rpx;
        color: #333;
    
        .total-item {
            flex: 1;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            box-sizing: border-box;
            padding-top: $padding;
    
            text {
                font-size: 32rpx;
            }
        }
    
        .grey {
            color: #666;
        }
    }
</style>
