view.html 3.76 KB
<html>

<head>
    <script>
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return unescape(r[2])
            return null;
        }

        function getResourceUrl(resourcetype, isPc) {
            switch (resourcetype) {
                case 0:
                case 152:
                    if (isPc) {
                        return "/workflow/request/ViewRequestForwardSPA.jsp?requestid=";
                    } else {
                        return "/spa/workflow/static4mobileform/index.html?_random=" + new Date().getTime() + "#/req?openWay=messageCenter&requestid=";
                    }
                case 1:
                case 37:
                    if (isPc) {
                        return "/spa/document/index.jsp?id=";
                    } else {
                        return "/spa/document/static4mobile/index.html#/doc/";//E9移动端文档详情页
                    }
                case 7:
                case 18:
                    if (isPc) {
                        return "/spa/crm/static/index.html#/main/crm/customerView?customerId=";
                    } else {
                        return "/mobile/plugin/crm_new/index.jsp#&/mobile/plugin/crm_new/customer.jsp?id=";
                    }
                case 2:
                    if (isPc) {
                        return "/spa/workplan/static/index.html#/main/wp/workPlanCreateSingle?workPlanId=";
                    } else {
                        return "/spa/workplan/static4mobile/index.html#/detail?workplanId=";
                    }
                case 28:
                    if (isPc) {
                        return "/spa/meeting/static/index.html#/main/meeting/dialogsingle?meetingid=";
                    } else {
                        return "/spa/meeting/static4mobile/index.html#/calendar/detail?meetingid=";
                    }
                default:
                    return "";
            }
        }

        var params = window.location.search;
        var resourcetype = getUrlParam('resourcetype');
        var resourceid = getUrlParam('resourceid');
        if (resourcetype == null) resourcetype = 0;
        var clientType = getUrlParam('em_client_type');
        var isPc = clientType == null || clientType == 'pc';
        var url = getResourceUrl(parseInt(resourcetype), isPc);
        if ((resourcetype == 1 || resourcetype == 37) && !isPc) {
            url += resourceid;
            url += params;
        } else {
            url += resourceid;
            url += params.replace('?', '&');
        }
        if ((resourcetype == 0 || resourcetype == 152) && !isPc) {
            var em_url = window.localStorage.getItem("wf_em_url");
            var em_url_open = window.localStorage.getItem("wf_em_url");
            if (window.performance.navigation.type && (em_url_open || em_url)) {
                var src = em_url_open ? em_url_open + "/open/js/jem.js" : em_url + "/open/js/jem.js"
                var head = document.getElementsByTagName("head")[0];
                var script = document.createElement('script');
                script.type = 'text/javascript';
                script.src = src;
                script.onload = function () {
                    em.ready(function () {
                        em.closeWindow();
                    })
                }
                head.appendChild(script);
                window.localStorage.removeItem("wf_em_url");
                window.localStorage.removeItem("wf_em_url_open");
            } else {
                window.location.href = url;
            }
        } else {
            window.location.href = url;
        }
    </script>
</head>

<body>
</body>

</html>