index.html 7.04 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta charset='UTF-8'/>
    <title>Yoho!UFO运营平台</title>
    <script type="text/javascript" src="/ufoPlatform/js/vue.min.js"></script>
    <script type="text/javascript" src="/ufoPlatform/js/iview.min.js"></script>
    <script type="text/javascript" src="/ufoPlatform/js/axios.min.js"></script>
    <link rel="stylesheet" href="/ufoPlatform/css/iview.css">
    <style type="text/css">
        html,body {
            width: 100%;
            height: 100%;
        }
        .wrapper {
            position: absolute;
            width: 100%;
            height: 100%;
            background-color: #fff;
        }
        a {
            display: block;
            text-decoration: none;
            color: #fff;
        }

        .main {
            width: 100%;
            height: 100%;
            display: flex;
            display: -webkit-flex;
            flex-direction: row;
            -webkit-flex-direction: row;
            align-items: flex-start;
            -webkit-align-items: flex-start;
            justify-content: flex-start;
            -webkit-justify-content: flex-start;
        }
        
        .ivu-menu-item {
            text-align: left;
        }

        .menu-container {
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            -webkit-flex-direction: column;
            flex-grow: 0;
            -webkit-flex-grow: 0;
            flex-shrink: 0;
            -webkit-flex-shrink: 0;
            width: 200px;
            height: 100%;
            background-color: #515a6e;
        }

        .main-title {
            height: 80px;
            color: #fff;
            font-size: 26px;
            line-height: 80px;
            text-align: center;
            flex-shrink: 0;
            -webkit-flex-shrink: 0;
        }

        .menu {
            flex-grow: 1;
            -webkit-flex-grow: 1;
            flex-shrink: 1;
            -webkit-flex-shrink: 1;
            overflow-y: scroll;
            overflow-x: hidden;
        }
        
        .menu::-webkit-scrollbar {
            display: none;
        }

        .user-info {
            display: flex;
            display: -webkit-flex;
            flex-direction: row;
            -webkit-flex-direction: row;
            justify-content: center;
            align-items: center;
            flex-shrink: 0;
            -webkit-flex-shrink: 0;
            flex-grow: 0;
            -webkit-flex-grow: 0;
            height: 60px;
            color: rgba(255,255,255,0.7);
            font-size: 14px;
        }
        .user-info p {
            display: block;
            text-align: right;
            max-width: 60%;
            white-space: nowrap;
            padding-right: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .user-info a {
            display: block;
            text-align: center;
            color: rgba(255,255,255,0.7);
        }

        .content {
            width: 80%;
            height: 100%;
            flex-grow: 1;
            -webkit-flex-grow: 1;
            flex-shrink: 1;
            -webkit-flex-shrink: 1;
        }


    </style>
</head>
<body>
<div class="wrapper">
    <div class="main" id="main">
        <div class="menu-container">
            <div class="main-title">
                <p>UFO运营平台</p>
            </div>
            <div class="menu">
                <i-menu :theme="theme" accordion width="200">
                    <submenu key="item.title" v-for="(item, index) in menuList" :name="index">
                        <template slot="title">
                            {{item.title}}
                        </template>
                        <menu-item key="subItem.id" v-for="(subItem, subIndex) in item.list"
                                   :name="`${index}-${subIndex}`">
                            <a :data-id="subItem.id" :data-url="`${subItem.menu_url}`" @click="gotoPage"
                               href="javascript:void(0)">{{subItem.menu_name}}</a>
                        </menu-item>
                    </submenu>
                </i-menu>
            </div>
            <div class="user-info">
                    <p>您好: {{trueName}},</p>
                    <a href="javascript:void(0)" @click="logout">注销</a>
            </div>
        </div>
        <div class="content">
            <iframe id="content_iframe" :src="pageurl" frameborder="0" width="100%" height="100%"></iframe>
        </div>
    </div>
</div>
    <script type="text/javascript">
      const domain = document.location.href.indexOf('test3') > 0 ? 'http://java-ufo-platform.test3.ingress.dev.yohocorp.com' : '';
      const contextPath = '/ufoPlatform';

      let app = new Vue({
        el: '#main',
        data: {
          theme: 'dark',
          trueName: '',
          menuList: [],
          pageurl: domain + contextPath + '/html/index/homePage.html'
        },
        mounted: function () {
          this.getUserInfo();
          this.getMenuList();
        },
        methods: {
          getUserInfo: function () {
            let self = this;
            axios.defaults.withCredentials = true;
            axios.post(domain + contextPath + '/loginController/getLoginUserInfo.do').then(ret => {
               console.log('userInfo:', ret);
              let result = ret.data.data || {};
              if (result.truename) {
                self.trueName = result.truename;
              }
              window.rollId = result.role_id;
            }).catch(e => {
              document.location.href = contextPath + '/html/login.html'
            });
          },
          getMenuList: function() {
            let self = this;
            axios.defaults.withCredentials = true;
            axios.post(domain + contextPath + '/loginController/getLoginUserMenu.do').then(ret => {
              console.log(ret);
              let data = ret.data.data || [];
              let result = [];
              for(let i in ret.data.data) {
                let obj = {title: i, list: ret.data.data[i]};
                result.push(obj);
              }
              self.menuList = result;

            })
          },
          gotoPage: function(e) {
            if (e.currentTarget.dataset.url) {
                if (e.currentTarget.dataset.url.indexOf("?") > 0) {
                    this.pageurl = contextPath + e.currentTarget.dataset.url + '&time_version=' + new Date().getTime();
                } else {
                    this.pageurl = contextPath + e.currentTarget.dataset.url + '?time_version=' + new Date().getTime();
                }

            }
          },
          logout: function() {
            axios.defaults.withCredentials = true;
            axios.post(domain + contextPath + '/loginController/logout.do').then(ret => {
              document.location.href = document.location.protocol + '//' + document.location.hostname + '/ufoPlatform/html/login.html';
            })
          }
        }
      });
    </script>
</body>
</html>