infoDialog.html 2.49 KB
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>提示信息</title>
    <link rel="stylesheet" href="css/iframe/common.css">
    <style>
        .info-footer {
            display: none;
        }
    </style>
</head>

<body>
    <div class="info-wrap">
        <div class="info-dialog info-dialog--tiny">
            <div class="info-head">
                <span class="info-title">提示</span>
                <button class="info-headerbtn" aria-label="Close">
                    <i class="info-close"></i>
                </button>
            </div>
            <div class="info-body">
                <span></span>
            </div>
            <div class="info-footer">
                <button class="info-button info-close-button">
                    <span>关 闭</span>
                </button>
            </div>
        </div>
    </div>

    <div class="info-mask"></div>

    <script>
        // window.onload = function() {

        var globalVm = ''; // 父级组件实例

        function changeText(data) {
            var str = "";
            str = typeof data === "string" ? data : JSON.stringify(data);
            document.getElementsByClassName('info-body')[0].childNodes[1].innerText = str;
            document.getElementsByClassName('info-footer')[0].style.display = "block";
            // console.log('parent window:', parent);
        }

        document.getElementsByClassName('info-headerbtn')[0].addEventListener('click', function(e) {
            var e = e || window.event;
            e.stopPropagation();
            e.preventDefault();
            try {
                globalVm.hide();
            } catch (err) {
                console.log('弹窗组件关闭的异常:', err.message)
                console.dir('父级 global:', parent)
                globalVm = parent.infoDialogVm;
                globalVm.hide();
            }
            // globalVm.showInfo('关闭弹窗', false);
        });

        document.getElementsByClassName('info-close-button')[0].addEventListener('click', function(e) {
            var e = e || window.event;
            e.stopPropagation();
            e.preventDefault();
            try {
                globalVm.hide();
            } catch (err) {
                console.log('弹窗组件关闭的异常:', err.message)
                console.dir('父级 global:', parent)
                globalVm = parent.infoDialogVm;
                globalVm.hide();
            }
        });
        // }
    </script>
</body>

</html>