<config>
{
    "navigationBarTitleText": "",
    "backgroundColorTop":'#ffffff',
    "backgroundColorBottom":'#ffffff',
    "navigationBarBackgroundColor": "#ffffff",
}
</config>
<template>
    <div class="container">
        <div class="top-content" v-if="userInfo">
            <img class="top-bg" src="../native/bg-3.png" alt="" />

            <div class="top">
                <img class="avatar" :src="userInfo.avatar" alt="" />
                <div class="right">
                    <div>
                        <div class="txt1">{{ userInfo.realName || '未登录' }}</div>
                        <div class="idNo">
                            <img class="id-img" src="../native/no.png" alt="" />
                            <div class="txt2">{{ idNo || '********' }}</div>
                        </div>
                    </div>
                    <!-- <img class="setting" src="../native/tabbar/icon_bianji@3x.png" alt="" /> -->
                </div>
            </div>
        </div>
        <div class="content">
            <div class="background">
                <div class="money">
                    <div class="money-top">
                        <div class="text1">
                            <img src="../native/my1.png" alt="" />
                            <span>个人账号余额</span>
                        </div>
                        <div class="money1">
                            <div class="money-icon">¥</div>
                            <div class="money2">{{ list.money || 0 }}</div>
                        </div>
                    </div>
                    <div class="btn">
                        <div class="btn1" @click="navigateTo('/pages/walletdetails?type=PERSON')">提现</div>
                        <div class="btn2" @click="navigateTo('/pages/recharge?type=PERSON')">{{ btnText }}</div>
                    </div>
                </div>
            </div>
            <div v-if="list.depositStatus === 'UNPAID'" class="deposit" @click="navigateTo('/pages/deposit')">
                房租押金&nbsp;<span><span class="span">¥</span>{{ list.depositAmount || 0 }}</span
                >&nbsp;去缴费
                <img style="width:7px;height:12px;margin-top:1px" src="../native/icon_inter.png" alt="" />
            </div>
            <div class="deposit deposit1" v-if="list.depositStatus === 'PAID' || list.depositStatus === 'REFUNDING'">
                <div class="deposit-money">
                    房租押金&nbsp;<span><span class="span">¥</span>{{ list.depositAmount || 0 }}</span
                    >&nbsp;已交
                </div>
                <div class="jump" @click="show = true">
                    <div>申请退回</div>
                    <img class="jump-img" src="../native/icon_inter.png" alt="" />
                </div>
            </div>
            <div v-if="list.depositStatus === 'REFUNDED'" class="deposit" @click="navigateTo('/pages/deposit')">
                房租押金&nbsp;<span><span class="span">¥</span>{{ list.depositAmount || 0 }}</span
                >&nbsp;已退回
                <img style="width:7px;height:12px;margin-top:1px" src="../native/icon_inter.png" alt="" />
            </div>
            <!-- v-if="roomInfo && roomInfo.checkout" -->
            <div class="content1">
                <div class="title1">
                    <img src="../native/fuwu.png" alt="" />
                    <span>我的服务</span>
                </div>
                <div class="box">
                    <div class="div" @click="navigateTo('/pages/repairReport')">
                        <img class="tit-img" src="../native/my0.png" alt="" />
                        <div class="text">保修申请</div>
                        <img style="width:7px;height:12px" src="../native/icon_inter.png" alt="" />
                    </div>
                    <div class="border"></div>
                    <div class="div" @click="navigateTo('/pages/cleanReport')">
                        <img class="tit-img" src="../native/my2.png" alt="" />
                        <div class="text">打扫申请</div>
                        <img style="width:7px;height:12px" src="../native/icon_inter.png" alt="" />
                    </div>
                    <div class="border"></div>
                    <!-- <div class="div" @click="navigateTo('/pages/complaint')">
                    <img class="tit-img" src="../native/tabbar/wode_icon_tousu@3x.png" alt="" />
                    <div class="text">投诉/建议</div>
                </div> -->
                    <div class="div" @click="navigateTo('/pages/help')">
                        <img class="tit-img" src="../native/my3.png" alt="" />
                        <div class="text">帮助说明</div>
                        <img style="width:7px;height:12px" src="../native/icon_inter.png" alt="" />
                    </div>
                </div>
            </div>
        </div>

        <van-dialog
            use-slot
            :show="show"
            show-cancel-button
            cancel-button-color="#00BA64"
            confirm-button-color="#666666"
            confirmButtonText="确认退押金"
            confirm-button-open-type="getUserInfo"
            @close="show = false"
            @getuserinfo="confirm"
        >
            <img class="van-img" src="../native/popup_icon_warn_colour@3x.png" alt="" />
            <div class="van-title">退押金后将不能再享受住房服务，请再次确认是否申请退押金</div>
        </van-dialog>
    </div>
</template>
<script>
import { mapState } from 'vuex';
import Constants from '../constants';
export default {
    computed: {
        ...mapState(['userInfo', 'roomInfo']),
        idNo() {
            if (this.userInfo.idNo) {
                return this.userInfo.idNo.substr(0, 6) + '********' + this.userInfo.idNo.substr(14);
            }
            return '';
        },
        // depositStatus() {
        //     switch (this.list.depositStatus) {
        //         case Constants.DepositStatus.UNPAID:
        //             return '房间押金未交';
        //         case Constants.DepositStatus.REFUNDED:
        //             return '房间押金已退';
        //         default:
        //             return '';
        //     }
        // },
        btnText() {
            if (this.list && (this.list.money || 0) < 0) {
                return '缴费';
            }
            return '充值';
        }
    },
    data() {
        return {
            list: {},
            show: false,
            reason: ''
        };
    },
    mounted() {
        // console.log(this.roomInfo);
    },
    onShow() {
        this.$store.dispatch('updateUserInfo');
        this.$http.get('/api/mp/getRoomInfo').then(res => {
            this.list = res;
            // console.log(this.list);
            this.$store.dispatch('updateRoomInfo');
        });
    },
    methods: {
        confirm() {
            wx.showLoading({
                title: '加载中'
            });
            this.$http
                .get('/depositRefundApply/apply', {
                    checkinInfoId: this.roomInfo.checkinInfoId,
                    reason: this.reason
                })
                .then(res => {
                    wx.hideLoading();
                    wx.showToast({
                        title: '提交成功'
                        // icon: 'none'
                    });
                    this.$store.dispatch('updateRoomInfo');
                    setTimeout(() => {
                        this.navigateTo('pages/successful');
                    }, 1000);
                })
                .catch(e => {
                    wx.hideLoading();
                    wx.showToast({
                        title: e.error,
                        icon: 'none'
                    });
                });
        }
    }
};
</script>
<style lang="less" scoped>
.container {
    background: #f5f7fa;
    height: 100vh;
    .top-content {
        .top-bg {
            width: 100%;
            height: 158px;
            display: block;
        }
    }
    .top {
        display: flex;
        align-items: center;
        position: absolute;
        height: 120px;
        left: 0;
        right: 0;
        top: 0;
        padding: 0 30px;
        .avatar {
            width: 60px;
            height: 60px;
            border-radius: 10px;
        }
        .right {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-left: 20px;
            .txt1 {
                font-size: 21px;
                font-weight: bold;
                color: #ffffff;
                line-height: 29px;
            }
            .idNo {
                display: flex;
                align-items: center;
                margin-top: 12px;
                .id-img {
                    width: 18px;
                    height: 15px;
                    margin-right: 4px;
                }
                .txt2 {
                    font-size: 16px;
                    font-weight: bold;
                    color: #ffffff;
                    line-height: 22px;
                    margin-left: 10px;
                }
            }
            .setting {
                width: 30px;
                height: 30px;
            }
        }
    }
    .border {
        height: 1px;
        background: #f5f7fa;
    }
    .background {
        position: relative;
        margin: 0 20px 20px;
        padding: 20px;
        background: linear-gradient(98deg, #fdf0d5 0%, #fae9cd 100%);
        border-radius: 20px;
        .money-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .money {
            display: flex;
            flex-direction: column;
            .money1 {
                .flex();
                margin-bottom: 3px;
                .money2 {
                    font-size: 26px;
                    font-family: DIN-Bold, DIN;
                    font-weight: bold;
                    color: #000000;
                    line-height: 31px;
                }
                .money-icon {
                    font-size: 13px;
                    margin-top: 6px;
                    margin-right: 4px;
                }
                .money-img {
                    width: 11px;
                    height: 13px;
                    margin-top: 6px;
                }
            }
            .text1 {
                display: flex;
                align-items: center;
                img {
                    width: 23px;
                    height: 23px;
                }
                span {
                    font-size: 13px;
                    font-weight: bold;
                    color: rgba(0, 0, 0, 0.5);
                    line-height: 18px;
                    margin-left: 2px;
                }
            }
            .btn {
                display: flex;
                align-items: center;
                justify-content: center;
                margin-top: 14px;
                .btn1 {
                    width: 110px;
                    height: 35px;
                    background: rgba(255, 255, 255, 0.33);
                    border-radius: 18px;
                    border: 1px solid #f4871f;
                    line-height: 35px;
                    text-align: center;
                    color: #f4871f;
                    font-size: 14px;
                }
                .btn2 {
                    width: 110px;
                    height: 35px;
                    background: #f4871f;
                    line-height: 35px;
                    text-align: center;
                    color: #ffffff;
                    border-radius: 18px;
                    margin-left: 30px;
                    font-size: 14px;
                }
            }
        }
        span {
            font-size: 16px;
            font-family: DIN-Bold, DIN;
            font-weight: bold;
            color: #ffffff;
            line-height: 19px;
        }
        .span {
            font-size: 14px;
        }
    }
    .content1 {
        padding: 30px 20px 20px;
        background: #ffffff;
        box-shadow: 0px 2px 4px 0px rgba(1, 168, 91, 0.04);
        border-radius: 30px 30px 0px 0px;
        .title1 {
            font-size: 18px;
            font-weight: bold;
            color: #000000;
            line-height: 25px;
            display: flex;
            align-items: center;
            img {
                width: 13px;
                height: 16px;
                margin-right: 13px;
            }
        }
        .box {
            margin: 0 14px 0 27px;
            .div {
                display: flex;
                align-items: center;
                padding: 15px 0;
                .tit-img {
                    width: 36px;
                    height: 36px;
                }
                .text {
                    font-size: 14px;
                    font-weight: normal;
                    color: #666666;
                    line-height: 20px;
                    margin-left: 15px;
                    flex-grow: 1;
                }
            }
        }
    }
    /deep/._van-dialog {
        width: 260px;
        height: 193px;
        border-radius: 10px;
        text-align: center;
        // z-index: 9999;
        .van-title {
            font-size: 13px;
            font-weight: normal;
            color: #000000;
            line-height: 20px;
            padding: 15px 35px;
        }
        .van-img {
            width: 60px;
            height: 60px;
            margin-top: 35px;
        }
    }
}

.deposit {
    font-size: 13px;
    .flex();
    justify-content: space-between;
    font-weight: bold;
    color: #333333;
    line-height: 18px;
    height: 49px;
    background: #f5f5f5;
    border-radius: 12px;
    margin: 0 30px 20px;
    padding: 0 20px;
    &.deposit1 {
        left: 0;
        width: 100%;
    }
    .deposit-money {
        .flex();
    }
    .jump {
        .flex();
        .jump-img {
            width: 24px;
            height: 24px;
            margin: 2px 0 0 2px;
        }
    }
}

.content {
    background: #fbfbfb;
    border-radius: 30px 30px 0px 0px;
    transform: translateY(-30px);
    padding-top: 30px;
}
</style>
