<config>
{
    "navigationBarTitleText": "",
    "backgroundColorTop":'#f5f7fa',
    "backgroundColorBottom":'#f5f7fa',
    "navigationBarBackgroundColor": "#f5f7fa",
}
</config>
<template>
    <div class="container">
        <div class="top">
            <img class="avatar" v-if="userInfo" :src="userInfo.avatar" alt="" />
            <div class="right">
                <div>
                    <div class="txt1" v-if="userInfo">{{ userInfo.realName }}</div>
                    <div class="idNo" v-if="userInfo">
                        <img class="id-img" src="../native/icon_login_shenfenzheng@3x.png" alt="" />
                        <div class="txt2">{{ idNo }}</div>
                    </div>
                </div>
                <!-- <img class="setting" src="../native/tabbar/icon_bianji@3x.png" alt="" /> -->
            </div>
        </div>
        <div class="background">
            <img class="img" src="../native/tabbar/info_img_gerenyue@3x.png" alt="" />
            <div class="money">
                <div>
                    <div class="money1">
                        <img class="money-img" src="../native/icon_jiage@3x (2).png" alt="" />
                        <div class="money2">{{ list.money || 0 }}</div>
                    </div>
                    <div class="text1">个人账号余额</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 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:24px;height:24px;margin-top:1px" src="../native/icon_inter@3x.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@3x.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:24px;height:24px;margin-top:1px" src="../native/icon_inter@3x.png" alt="" />
                </div>
            </div>
        </div>
        <!-- v-if="roomInfo && roomInfo.checkout" -->
        <div class="content1">
            <div class="title1">我的服务</div>
            <div class="border"></div>
            <div class="box">
                <div class="div" @click="navigateTo('/pages/repairReport')">
                    <img class="tit-img" src="../native/tabbar/wode_icon_baoxiu@3x.png" alt="" />
                    <div class="text">保修申请</div>
                </div>
                <div class="div" @click="navigateTo('/pages/cleanReport')">
                    <img class="tit-img" src="../native/tabbar/wode_icon_dasao@3x.png" alt="" />
                    <div class="text">打扫申请</div>
                </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/tabbar/wode_icon_shouming@3x.png" alt="" />
                    <div class="text">帮助说明</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.$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 {
        display: flex;
        align-items: center;
        .avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            margin: 0 16px;
        }
        .right {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 66.5%;
            .txt1 {
                font-size: 21px;
                font-weight: bold;
                color: #000000;
                line-height: 29px;
            }
            .idNo {
                display: flex;
                align-items: center;
                margin-top: 6px;
                .id-img {
                    width: 24px;
                    height: 24px;
                    margin-right: 4px;
                }
                .txt2 {
                    font-size: 14px;
                    font-weight: bold;
                    color: #000000;
                    line-height: 20px;
                }
            }
            .setting {
                width: 30px;
                height: 30px;
            }
        }
    }
    .border {
        height: 1px;
        background: #f5f7fa;
        margin: 16px 0;
    }
    .background {
        position: relative;
        display: flex;
        margin: 28px 20px 20px;
        .img {
            height: 128px;
            width: 100%;
        }
        .money {
            position: absolute;
            display: flex;
            margin: 16px 0 0 16px;
            .money1 {
                .flex();
                margin-bottom: 3px;
                .money2 {
                    font-size: 26px;
                    font-family: DIN-Bold, DIN;
                    font-weight: bold;
                    color: #fff;
                    line-height: 31px;
                }
                .money-img {
                    width: 11px;
                    height: 13px;
                    margin-top: 6px;
                }
            }
            .text1 {
                font-size: 13px;
                font-weight: normal;
                color: #ffffff;
                line-height: 18px;
            }
            .btn {
                display: flex;
                align-items: center;
                .btn1 {
                    width: 72px;
                    height: 26px;
                    background: rgba(255, 255, 255, 0.33);
                    border-radius: 13px;
                    border: 1px solid #ffffff;
                    font-weight: bold;
                    line-height: 26px;
                    text-align: center;
                    color: #ffffff;
                    margin: 0 20px 0 56px;
                }
                .btn2 {
                    width: 72px;
                    height: 26px;
                    background: #ffffff;
                    font-weight: bold;
                    line-height: 26px;
                    text-align: center;
                    color: #5d7dff;
                    border-radius: 13px;
                }
            }
        }
        .deposit {
            position: absolute;
            top: 80px;
            left: 80px;
            font-size: 13px;
            .flex();
            justify-content: space-between;
            font-weight: bold;
            color: #ffffff;
            line-height: 18px;
            &.deposit1 {
                left: 0;
                width: 100%;
            }
            .deposit-money {
                .flex();
            }
            .jump {
                .flex();
                .jump-img {
                    width: 24px;
                    height: 24px;
                    margin: 2px 0 0 2px;
                }
            }
        }
        span {
            font-size: 16px;
            font-family: DIN-Bold, DIN;
            font-weight: bold;
            color: #ffffff;
            line-height: 19px;
        }
        .span {
            font-size: 14px;
        }
    }
    .content1 {
        margin: 20px;
        padding: 20px 12px;
        background: #ffffff;
        box-shadow: 0px 2px 4px 0px rgba(1, 168, 91, 0.04);
        border-radius: 12px;
        .title1 {
            font-size: 18px;
            font-weight: bold;
            color: #000000;
            line-height: 25px;
        }
        .box {
            width: 100%;
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            margin: 0 14px;
            .div {
                margin-right: 27px;
                text-align: center;
                .tit-img {
                    width: 36px;
                    height: 36px;
                    margin-bottom: 6px;
                }
                .text {
                    font-size: 14px;
                    font-weight: normal;
                    color: #000000;
                    line-height: 20px;
                    margin-bottom: 25px;
                }
            }
        }
    }
    /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;
        }
    }
}
</style>
