<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge" >
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
    <title>coderutil出品幸运抽奖系统</title>
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="bookmark" href="/favicon.ico" />


    <link rel="stylesheet" href="/css/common/common.css">
    <link href="/ref/layui-v2.6.8/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <script src="/js/ref/jquery-3.4.1.js" type="text/javascript"></script>
    <script src="/ref/layui-v2.6.8/layui/layui.js" type="text/javascript"></script>
    <script src="/js/common/common.js" type="text/javascript"></script>

    <style>
        .logo {
            position: absolute;
            left: 0px;
            top: 15px;
            height: 30px;
        }
        .wallet-balance {
            position: relative;
            float: right;
            border: none;
            padding: 5px 20px;
            margin-right: 100px;
            margin-top: 15px;
            background-color: transparent;
            border-radius: 100px;
            font-size: 13px;
            color: white;
            background-image: linear-gradient(to right, #fab160, #c58a3f);
            opacity: 0.8;
        }
    </style>

    <script>
        function login() {
            location.href = "/auth";
        }
    </script>
</head>
<body>
<center>

    <div style="height: 60px; width: 100%; background-color: white; border-bottom: 1px solid #eae9e9">
        <div class="div-1190px">
            
            <img src="/image/icon/logo_title.png" class="logo">

            <a class="header-level1-link float-right" id="login-menu" style="margin-right: 0px;">
                <button style="padding: 7px 10px; border-radius: 100px; margin-top: 13px; font-size: 12px; border: 1px solid #2b73f6; background-color: transparent; color: #2b73f6"
                onclick="login()">登录/注册</button>
            </a>
            <span class="header-level1-link float-right layui-btn-container" id="login-user" style="float: right; margin-right: 0px; display: none; height: 100%">
                <img src="" id="login-user-photo" class="common-login-user down-user-center" style="width: 30px; margin-top: 13px;">
            </span>
            <button class="wallet-balance">钱包余额：<b><i id="walletBalance">0</i></b>  ¥</button>
        </div>
    </div>

</center>

</body>
<script>
    refreshUserInfo();
    function refreshUserInfo() {
        $.ajax({
            url:"/api/user/getCurrentUserInfo",
            type:"get",
            success:function (data) {
                data = eval(data);
                if (data.success){
                    data = data.data;
                    $("#login-menu").hide();
                    $("#login-user").show();
                    $("#login-user-photo").attr("src", data.photo);
                    var roleCode = data.roleCode;
                    /***
                     * 登录用户设置
                     */
                    layui.use(['dropdown', 'util', 'layer', 'table'], function() {
                        var dropdown = layui.dropdown;
                        //用户
                        dropdown.render({
                            elem: '#login-user-photo'
                            , data: [ {
                                title: roleCode == 2 ? '后台管理' : ''
                                , id: roleCode == 2 ? 1 : -1
                            }, {
                                title: '退出登录'
                                , id: 2
                            }]
                            , click: function (obj) {
                                if (obj.id == 1) {
                                    location.href = "/admin/cms";
                                } else if (obj.id == 2) {
                                    loginOut();
                                }
                            }
                        });
                    })

                }
            },error:function () {}
        })
    }
</script>
</html>
