<template>
  <div id="myapp">

    <!-- 头部 -->
    <div id="myapp-header" class="clearfix">
      <!-- <div class="nav-left-box fl">
          <a href="#">
            <img src="@/assets/images/logobcxin.png" alt class="logo" />
          </a>
          <a href="#" @click="hiddenMenu">
            <i class="fa fa-dedent nav-menu" v-show="showMenu"></i>
            <i class="fa nav-menu fa-indent" v-show="!showMenu"></i>
          </a>
        </div> -->
      <!-- 头部左边 左上角logo与切换组织列表 -->
      <div class="domain-box fl">
        <span class="domainlogo"><img :src="logo" id="domainlogo" v-if="logo"></span>
        <el-dropdown trigger="click">
          <span class="el-dropdown-link">{{ domainName }}<i class="el-icon-caret-bottom el-icon--right"></i></span>
          <el-dropdown-menu slot="dropdown" style="max-height: 80vh; overflow: scroll">
            <el-dropdown-item v-for="item in domainlistArr" :key="item.id">
              <div @click="changeDomainDown(item)">{{ item.name }}</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>

      <!-- 头部右边 -->
      <div class="center-nav fr">
        <!-- 平台通知滚动信息与信息管理图标 自定义-->
        <span class="center-messinfo">
          <span class="platAdspan" @click="platAdPop" v-if="remindInfoArr.length">
            <el-carousel height="20px" direction="vertical">
              <el-carousel-item v-for="(item, index) in remindInfoArr" :key="index" :title="item">{{ item
              }}</el-carousel-item>
            </el-carousel>
          </span>
          <!-- <span class="messagespan" @click="messagespanClick" title="消息中心"><i class="el-icon-message-solid"/></span> -->
        </span>

        <!-- <div class="qrcode-container" v-if="domainAdmin && isOrganizationPromoter">
          <img src="@/assets/images/invite_qrcode_icon.png" @click.stop="openQrcodeDialog" @mouseover="() => showQrcodeTip = true" @mouseleave="showQrcodeTip = false" />
          <div class="qrcode-tip" v-if="showQrcodeTip">邀请企业入驻</div>
        </div> -->

        <ul class="center-navul">
          <!-- 锁屏图标 -->
          <li class="center-navli layui-nav-item lockcms" pc>
            <a href="javascript:;" title="消息中心" @click="messagespanClick" v-if="infoLevel">
              <i class="el-icon-message-solid"></i>
            </a>
          </li>
          <li class="center-navli layui-nav-item lockcms" pc>
            <a href="javascript:;" title="客服服务" @click="contactservicespanClick" v-if="infoLevel">
              <i class="el-icon-chat-dot-round"></i>
            </a>
          </li>
          <!-- <li class="center-navli layui-nav-item lockcms" pc >
              <a href="javascript:;" @click="lockScreen" title="锁屏">
                <i class="lockScreenicon" ></i>
              </a>
            </li> -->

          <!-- 用户头像与名称 下拉个人设置与退出系统 -->
          <li class="center-navli center-navli-last">
            <div class="mysetup">
              <a href="javascript:;">
                <!-- <img src="../assets/images/face.jpg" class="centericon" /> -->
                <img src="@/assets/images/avator.png" class="centericon">
                <span class="personal-name">{{ $root.user.name }}</span>
                <i class="fa fa-angle-down pull-down"></i>
              </a>
              <div class="personal-settings">
                <span class="triangle"></span>
                <ul>
                  <li @click="editpwd">
                    <a>
                      <i class="fa fa-user-o"></i>
                      <cite>修改密码</cite>
                    </a>
                  </li>

                  <li @click="signOut">
                    <a href="javascript:;">
                      <i class="fa fa-power-off"></i>
                      <cite>退出系统</cite>
                    </a>
                  </li>
                </ul>
              </div>
            </div>
          </li>
        </ul>
      </div>

      <!-- 消息中心 -->
      <!-- v-if="notice && showMessagePopup" -->
      <div class="prompt-popup" v-if="otherNotice.length > 0 && showMessagePopup">
        <div class="message">
          <div class="close-icon">
            <div class="message-popup-close" @click.stop="closeMessagePopup">
              <i class="fa fa-times"></i>
            </div>
          </div>
          <div class="tip" v-for="(item, index) in otherNotice" :key="index">
            <span class="tip-first">{{ item.value }}&nbsp;&nbsp;</span>
            <span v-if="item.type == '0'">新消息提醒&nbsp;</span>
            <span v-if="item.type == '1'">新公告提醒&nbsp;</span>
            <span v-else-if="item.type == '2'">新回复提醒&nbsp;</span>
            <span v-else-if="item.type == '3'">新事项提醒&nbsp;</span>
            <span class="tip-tree"
              @click="jumpToInfo({ id: '03', name: '消息中心', linkType: '03', remind: 'true' })">点击查看</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 中间 左边菜单与右边内容区域 -->
    <div class="myapp-content">

      <!-- 左边菜单区域 -->
      <div class="nav-bar" ref="navbar">
        <!-- 顶部菜单 -->
        <div class="nav-MenuAll">
          <div class="nav-topMenu">
            <!-- <a href="javascript:;" key="homemenu" data-url="" :class="activeTopmenuindex==0?'activeTop':''" @click="navtopmenuclick(0)">
                  <i><img src="~@/assets/images/home/home-link.png" /></i>
                  <cite id="homemenu">首页</cite>
                </a> -->


            <a href="javascript:;" key="workmenu" data-url="" :class="activeTopmenuindex == 0 ? 'activeTop' : ''"
              @click="navtopmenuclick(0)">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="workmenu">工作台</cite>
            </a>

            <a href="javascript:;" key="project" data-url="" :class="activeTopmenuindex == 1 ? 'activeTop' : ''"
              @click="navtopmenuclick(1)" v-if="homeTemplateBoradType == 'rtpayTemplate'">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="project">项目</cite>
            </a>



            <!-- <a href="javascript:;" key="waitmenu" data-url="" :class="activeTopmenuindex==2?'activeTop':''" @click="navtopmenuclick(2,'menu')">
                    <i><img src="~@/assets/images/home/wait-link.png" /></i>
                    <cite id="waitmenu">待办</cite>
                </a>           -->


            <a href="javascript:;" key="admenu" data-url="" :class="activeTopmenuindex == 5 ? 'activeTop' : ''"
              @click="navtopmenuclick(5)" v-if="adLevel">
              <i><img src="~@/assets/images/home/message-link.png" /></i>
              <cite id="admenu">公告</cite>
            </a>


            <a href="javascript:;" key="admenu-app" data-url="" v-if="!network" :class="activeTopmenuindex == 99 ? 'activeTop' : ''"
              @click="navtopmenuclick(99)">
              <i><img src="~@/assets/images/home/20240322-133848.png" /></i>
              <cite id="admenu">App</cite>
            </a>



            <a href="javascript:;" key="news" data-url="" :class="activeTopmenuindex == 6 ? 'activeTop' : ''"
              @click="navtopmenuclick(6)" v-if="homeTemplateBoradType == 'rtpayTemplate'">
              <i><img src="~@/assets/images/home/news-link.png" /></i>
              <cite id="news">新闻</cite>
            </a>

            <a href="javascript:;" key="projectCenter" data-url="" :class="activeTopmenuindex == 7 ? 'activeTop' : ''"
              @click="navtopmenuclick(7)" style="display:none">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="projectCenter">项目中心</cite>
            </a>

            <a href="javascript:;" key="projectJt" data-url="" :class="activeTopmenuindex == 8 ? 'activeTop' : ''"
              @click="navtopmenuclick(8)" style="display:none">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="projectJt">集团项目</cite>
            </a>


            <a href="javascript:;" key="portalNews" data-url="" :class="activeTopmenuindex == 9 ? 'activeTop' : ''"
              @click="navtopmenuclick(9)" v-if="portalNewsLevel">
              <i><img src="~@/assets/images/home/portalNewsIcon.png" /></i>
              <cite id="portalNews">门户</cite>
            </a>




          </div>
          <div class="nav-bottomMenu">

            <a href="javascript:;" data-url="" @click="Im()" title="聊天" v-if="IMLevel">
              <i><img src="~@/assets/images/home/IM-link.png" /></i>
              <cite id="feedmenu"></cite>
            </a>

            <!-- <a href="javascript:;" data-url="" @click="websiteClick()" :title="website.name"
              v-if="Object.keys(website).length">
              <i><img src="~@/assets/images/home/website-link.png" /></i>
              <cite id="feedmenu"></cite>
            </a> -->

            <!-- <a href="javascript:;" data-url="" @click="websiteBKTClick()" title="百课堂官网" v-if="bktLevel">
              <i><img src="~@/assets/images/home/bktSiteIcon.png" /></i>
              <cite id="bktSite"></cite>
            </a> -->

            <a href="javascript:;" key="domainmanager" data-url="" @click="domainmanager()" title="管理后台"
              v-if="domainmanagerLevel">
              <i><img src="~@/assets/images/home/domain-link.png" /></i>
              <cite id="domainmanager"></cite>
            </a>


            <a href="javascript:;" data-url="" @click="help()" title="办事指南" v-if="GuestHelpLevel">
              <i><img src="~@/assets/images/home/helpcenter-link.png" /></i>
              <cite id="feedmenu"></cite>
            </a>
          </div>
        </div>

        <!-- 待办菜单 -->
        <div class="nav-waitMenu" v-if="showWait">
          <a :class="activewaitmenuindex == 0 ? 'activeTop' : ''"
            @click="waitclick(0, { id: '105', name: '我的待办', linkType: '105' })">
            <i><img src="~@/assets/images/home/wait2.png" /></i>
            <cite class="main-menu_title">我的待办</cite>
          </a>
          <a :class="activewaitmenuindex == 1 ? 'activeTop' : ''"
            @click="waitclick(1, { id: '104', name: '发起新建', linkType: '104' })">
            <i><img src="~@/assets/images/home/wait1.png" /></i>
            <cite class="main-menu_title">发起新建</cite>
          </a>
          <!-- <a :class="activewaitmenuindex==2?'activeTop':''" @click="waitclick(2,{id:'106',name:'经办跟踪',linkType:'106'})">
                  <i><img src="~@/assets/images/home/wait3.png" /></i>
                  <cite class="main-menu_title">经办跟踪</cite>
                </a> -->
          <a :class="activewaitmenuindex == 3 ? 'activeTop' : ''"
            @click="waitclick(3, { id: '10', name: '我的待阅', linkType: '10' })">
            <i><img src="~@/assets/images/home/wait4.png" /></i>
            <cite class="main-menu_title">我的待阅</cite>
          </a>
          <a :class="activewaitmenuindex == 4 ? 'activeTop' : ''"
            @click="waitclick(4, { id: '11', name: '我的已阅', linkType: '11' })">
            <i><img src="~@/assets/images/home/wait5.png" /></i>
            <cite class="main-menu_title">我的已阅</cite>
          </a>
          <a :class="activewaitmenuindex == 5 ? 'activeTop' : ''"
            @click="waitclick(5, { id: '08', name: '仪表分析', linkType: '08' })">
            <i><img src="~@/assets/images/home/wait6.png" /></i>
            <cite class="main-menu_title">仪表分析</cite>
          </a>
        </div>

        <!-- 左边应用菜单 v-if="showApp"-->
        <div class="nav-appMenus" v-if="showApp || showAppMENUS">
          <div class="appnametitle">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">{{ applicationName }}<i
                  class="el-icon-caret-bottom el-icon--right"></i></span>
              <el-dropdown-menu class="dropdownApp" slot="dropdown">
                <el-dropdown-item v-for="item in applistArr" :key="item.id">
                  <div @click="loadAppMenu(item.appid, item.name)">{{ item.name }}</div>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!-- 左 应用菜单区域 -->
          <el-scrollbar>
            <main_navbar :appid="appid" :key="appid" :updateMenu="updateMenu" :updateMenuData="updateMenuData"
              @add-tab="addTab" ref="mainNavBar" />
          </el-scrollbar>
          <!-- 中间切换伸缩按钮 -->
          <div class="openExpand" title="开关菜单" ref="opencloseExpandRef"
            :class="opencloseExpandBtnFlag ? '' : 'closeExpand'">
            <img src="~@/assets/images/icon_arrow.png" @click="opencloseExpandBtn(1)"
              :class="opencloseExpandBtnFlag ? 'openFlag' : 'closeFlag'" />
          </div>
        </div>


      </div>

      <!-- 右边内容区域，包括选项卡 -->
      <main_content ref="mychild" :tabs="tabs" :opencloseExpandBtnFlag="opencloseExpandBtnFlag" @add-tab="addTab"
        @close-tab="closeTab" @close-all="closeAllTab" @active-tab="activeTab" @active-home="activeHome"
        @updateViewNumber="updateViewNumber" v-bind="$attrs" v-on="$listeners" />

    </div>

    <!--一键锁屏弹窗区域-->
    <div class="lockWraper" v-if="isLock == 'true'">
      <div class="lock-content">
        <div class="img">
          <img src="../assets/images/avator.png" alt="">
        </div>
        <div class="admin-header-lock-name">
          {{ $root.user.name }}
        </div>
        <div class="input_btn">
          <span class="input-box">
            <div class="error-tip" v-if="isPasswordError == 'true'">
              密码错误，请重新输入!
            </div>
            <el-input @input="changePassword($event)" @keyup.enter.native="unlockScreen" v-model="password"
              type="password" class="admin-header-lock-input layui-input" placeholder="请输入密码解锁.." name="lockPwd"
              id="lockPwd"></el-input>
          </span>
          <span class="un-lock" @click="unlockScreen">
            解锁
          </span>
        </div>
        <div class="tip">
          {{errorTip ? errorTip : '请输入登录密码，否则不会解锁成功哦！！！'}}
        </div>
      </div>
    </div>
    <!-- 超时登录界面弹窗区域 -->
    <div>
      <el-dialog title="超时登录" :visible.sync="dialogVisible" width="30%" :modal="true" :close-on-click-modal="false"
        :close-on-press-escape="false" :show-close="false">
        <el-form size="mini" label-width="80px">
          <el-form-item label="登录账户">
            <el-input v-model="$store.state.myProfile.loginNo" autocomplete="off" disabled style="width:220px"></el-input>
          </el-form-item>
          <el-form-item label="登录密码">
            <el-input v-model="pwd" autocomplete="off" show-password style="width:220px"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="hanleClickLogin" size="mini">回到登录界面</el-button>
          <el-button type="primary" @click="hanleClick" size="mini">登录</el-button>
        </div>
      </el-dialog>
    </div>

    <!-- 组织域弹窗列表区域 -->
    <div>
      <el-dialog :visible.sync="domainDialogVisible" width="50%" append-to-body>
        <main_domain :domainList="domainList"></main_domain>
      </el-dialog>
    </div>

    <!-- Im聊天弹窗区域 -->
    <IMPop :showdialog.sync="showdialog" ref="PopChildren"></IMPop>

    <!-- 右上角平台通知  弹窗区域 -->
    <platAdPop :showdialogPlatAd.sync="showdialogPlatAd" ref="PopChildrenPlatAd"></platAdPop>

    <!-- 系统通知弹窗区域 -->
    <div>
      <el-dialog :visible.sync="systemNoticeDialogVisible" width="50%" append-to-body title="系统通知">
        <section class="systemNoticeBox" v-if="placeOfRegister_bjFlag">
          <span style="color:red;font-weight:bolder">
            1、关于通过保安管理系统填报保安员每日核酸检测和周疫苗接种数据的紧急通知，请各保安服务公司和自招保安单位优先按通知要求统计保安员每日核酸检测和周疫苗接种数据，并在系统进行填写上报。
            <a href="https://bcxin-static.obs.cn-north-1.myhuaweicloud.com/v5/qianduanFile/%E5%85%B3%E4%BA%8E%E9%80%9A%E8%BF%87%E4%BF%9D%E5%AE%89%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F%E5%A1%AB%E6%8A%A5%E4%BF%9D%E5%AE%89%E5%91%98%E6%A0%B8%E9%85%B8%E6%A3%80%E6%B5%8B%E5%92%8C%E7%96%AB%E8%8B%97%E6%8E%A5%E7%A7%8D%E7%9A%84%E9%80%9A%E7%9F%A5.docx"
              style="color:blue">点击查看通知，</a>
            <a href="http://wiki.baibaodun.cn/page/display?document_id=1841" target="_blank"
              style="color:blue">点击查看操作指南。</a>
          </span>
          <br />
          <span>2、从7月1日开始，保安员考试培训报名缴费将暂时通过线下方式进行缴费核算。线上报名缴费服务重新恢复时间将另行通知。</span>
          <br />
          <span
            style="margin-bottom: 4px;font-size: 14px; font-weight: 700; color: red;display: block;">3、【关于恢复保安员证考试的通知】</span>
          <span>各保安从业单位、保安培训学校：</span>
          <br />
          <span style="display: inline-block;text-indent: 28px;">由于北京新冠疫情形势整体好转，首都防疫举措调整，经总队研究决定，<span
              style="color:red;font-weight: 700;">正式全面恢复保安员证考试工作</span>，并落实好以下要求：</span></br>
          <span><span style="vertical-align: 1px;">①</span> 参与考试的保安员及校师资人员均需持有48小时核酸阴性证明;</span>
          <br />
          <span><span style="vertical-align: 1px;">②</span> 保安培训学校做好扫码测温及环境消杀等工作;</span>
          <br />
          <span><span style="vertical-align: 1px;">③</span> 封控区保安员暂缓;</span>
          <br />
          <span><span style="vertical-align: 1px;">④</span> 考试流程严格按规范进行。</span>
          <br />
          <span style="color:red;font-weight:bolder">4、2022年8月1日起，平台客服服务时间调整为每日9:00~20:00。</span>
          <br />
          <span><span
              style="color:red;font-weight:bolder">5、投保增员减员请注意：</span>接保险公司核心系统升级通知，兹定于8月11日20:00至22:00进行系统相关部分升级，投保，增减员会受到影响，请提前做好准备，避免升级时间段操作，感谢配合，给您带来的不便敬请谅解。</span>
          <br />
        </section>
        <section class="systemNoticeBox" v-if="!placeOfRegister_bjFlag">
          <span style="color:red;font-weight:bolder">
            * 2022年8月1日起，平台客服服务时间调整为每日9:00~20:00。
          </span>
        </section>
      </el-dialog>
    </div>
    <!-- 企业完善经纬度弹窗区域 -->
    <domainLonLatPop :domainLonLatPopDialogVisible.sync="domainLonLatPopDialogVisible"
      :domainLonLatData="domainLonLatData" @domainLonLatPopOk="domainmanager" ref="PopChildrenDomainLonLat"></domainLonLatPop>

    <!-- 监管归属地弹窗区域 -->
    <supervisionPop :supervisionDialogVisible.sync="supervisionDialogVisible"
      :isSupervisedInfoCompletedData="isSupervisedInfoCompletedData" ref="PopChildrenSupervision"></supervisionPop>

    <!-- 邀请注册二维码弹窗 -->
    <qrcodeDialog :showQrcodeDialog="showQrcodeDialog" @closeQrcodeDialog="closeQrcodeDialog" />
    <!-- 
请扫描二维码下载监管APP -->

    <el-dialog title="请扫描二维码下载监管APP" center :visible.sync="dialogVisibleApp" width="30%" :modal="true" 
        >

        <div style="text-align: center;">
          <img :src="appUrl" width="200px" height="200px" alt="" srcset="">

        </div>
      </el-dialog>
      <el-dialog
        title="修改密码通知"
        :visible.sync="updatePwdDialogVisible"
        width="30%"
        center
        append-to-body
        :modal="true"
        :show-close="updatePasswordType!='1'"
        :close-on-click-modal="false"
        custom-class="custom-dialog"
        style="margin-top: 20vh;"
        >
        <span style="color: red; text-align: center; font-size: 16px">{{updatePasswordMsg}}</span>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="upadtePwdConfirm">已了解，前往修改密码</el-button>
        </span>
      </el-dialog>
      
      <!-- 修改密码弹窗 -->
      <update-password-dialog 
        :visible.sync="showPasswordDialog" 
        :can-close="updatePasswordType!='1'"
        @success="onPasswordUpdateSuccess"
        @close="showPasswordDialog = false" 
      />
  </div>
</template>


<script>
import main_appbar from "@/components/main_appbar.vue";
import main_navbar from "@/components/main_navbar.vue";
import main_content from "@/components/main_content.vue";
import main_domain from "@/components/domain.vue";
import IMPop from "./IMPop.vue"
import platAd from "@/components/platAd.vue"
import platAdPop from "@/components/platAdPop.vue"
import Constant from "@/Constant.js";
import config from "../../public/js/obpm.config.js"
import API from "@/api.js";
import { currDate } from "@/utils/global.js"
let Base64 = require('js-base64').Base64;
const statiContextPath = config.statiContextPath;
const signonContextPath = config.signonContextPath;
import { mapState } from 'vuex'
import mixin_LockScreen from './mixin_LockScreen'//引入超时锁屏功能
import supervisionPop from "@/components/supervisionPop.vue"//监管归属地弹窗--强提醒
import domainLonLatPop from "@/components/domainLonLatPop.vue"//完善组织后台经纬度弹窗--强提醒
import qrcodeDialog from '@/components/qrcodeDialog.vue'; // 二维码弹窗
import UpdatePasswordDialog from '@/components/UpdatePasswordDialog.vue'; // 修改密码弹窗
let isDev=process.env.NODE_ENV !== "production"
export default {
  name: "mainpage",
  mixins: [mixin_LockScreen],//混入超时锁屏功能
  provide() {
    return {
      addTab: this.addTab

    }
  },
  components: {
    "obpm-main-appbar": main_appbar,
    main_navbar,
    main_content,
    main_domain,
    IMPop,
    platAd,
    platAdPop,
    supervisionPop,
    domainLonLatPop,
    qrcodeDialog,
    UpdatePasswordDialog
  },
  computed: {
    ...mapState({  //这里的...不是省略号了,是对象扩展符
      // headPhoto:(state)=>state.myProfile.headPhoto,  
      showAppMENUS(state) {
        if (state.appmenusShow) {
          this.$nextTick(() => {
            this.showApp = true
            this.$refs.mychild.setMaincontent(false) // 调用子组件的方法
            this.activeHome()
            this.applist()//查询左边下拉应用列表
            console.log(this.$refs.mainNavBar.data)
            if (state.defaultFirst == 1) {
              this.$refs.mainNavBar.defaultClickFirst(this.$refs.mainNavBar.data)
            }
          })
        }
        return state.appmenusShow
      }
    }),
    applicationName() {
      if (this.$store.state.appmenusShow) {
        this.$nextTick(() => {
          this.showApp = true
          this.$refs.mychild.setMaincontent(false) // 调用子组件的方法
          this.applist()//查询左边下拉应用列表
          console.log(this.$refs.mainNavBar.data)
          if (this.$store.state.defaultFirst == 1) {
            // this.$refs.mainNavBar.defaultClickFirst(this.$refs.mainNavBar.data)
          }
        })
      }
      let currentAppName = ''
      if (this.$store.getters.currentAppName.indexOf("-") > -1) {
        let currentAppNameIndex = this.$store.getters.currentAppName.indexOf("-")
        currentAppName = this.$store.getters.currentAppName.substr(0, currentAppNameIndex)
      } else {
        currentAppName = this.$store.getters.currentAppName
      }
      console.log(currentAppName)
      return currentAppName;
    },
    showInstance() {
      return this.$store.state.isInstance;
    },
    infoLevel(){
      let organizationLevelsStr=organizationLevels.split(',')
      if(organizationLevelsStr&&organizationLevelsStr.includes('Premium')){
        let baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions ||[]
        return this.network&&baseServiceOptions.includes('__ZiDingYiCaiDanXiaoXiZhongXin')  //权限显隐
      }
      return true
    },
    adLevel(){
      let organizationLevelsStr=organizationLevels.split(',')
      if(organizationLevelsStr&&organizationLevelsStr.includes('Premium')){
        let baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions ||[]
        return this.network&&baseServiceOptions.includes('__ZiDingYiCaiDanGongGao')  //权限显隐
      }
      return true
    },
    portalNewsLevel(){
      let organizationLevelsStr=organizationLevels.split(',')
      if(organizationLevelsStr&&organizationLevelsStr.includes('Premium')){
        let baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions ||[]
        return this.network&&baseServiceOptions.includes('__ZiDingYiCaiDanMenHu')  //权限显隐
      }
      return this.network
    },
    IMLevel(){
      let organizationLevelsStr=organizationLevels.split(',')
      if(organizationLevelsStr&&organizationLevelsStr.includes('Premium')){
        let baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions ||[]
        return this.network&&baseServiceOptions.includes('__ZiDingYiCaiDanLiaoTianIM')  //权限显隐
      }
      return this.network
    },
    domainmanagerLevel() {      
      return this.domainAdmin
    },
    bktLevel(){
      let organizationLevelsStr=organizationLevels.split(',')
      if(organizationLevelsStr&&organizationLevelsStr.includes('Premium')){
        let baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions ||[]
        return this.network&&baseServiceOptions.includes('__ZiDingYiCaiDanBaiKeTangRK')  //权限显隐
      }
      return this.network
    },
    GuestHelpLevel(){
      let organizationLevelsStr=organizationLevels.split(',')
      if(organizationLevelsStr&&organizationLevelsStr.includes('Premium')){
        let baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions ||[]
        return this.network&&baseServiceOptions.includes('__ZiDingYiCaiDanKeFuYvBangZhu')  //权限显隐
      }      
      return true
    }
  },
  // created() {
  //     // let user = this.$root.user;//main.js获取user用户信息
  //     // let obj = {
  //     //   doId: user&&user.domainId||"",
  //     //   userId: user&&user.id,
  //     //   profile: user,
  //     // }    
  //     // this.$store.commit('landingUser', obj);//查询登录用户

  //     // this.Searchdomain()//查询所有组织     
  // },
  created() {
    this.checkPasswordUpdateNotice()
    this.network = __network__ //获取__network__全局变量状态，判断显示隐藏
    this.domainlistArr = JSON.parse(localStorage.getItem("domainList")) || [];
    if (this.domainlistArr.length && this.homeTemplateBoradType != 'rtpayTemplate' && this.network) {//rt环境不要提示,内网不提示
      // this.organizationsID(localStorage.getItem("domainId")) //根据组织id获取注册地--暂不用，用右上角平台通知弹窗提醒
    }
    // this.getLock()//锁屏
    if (this.institutionalCode == '0102' || this.institutionalCode == '0103' || this.institutionalCode == '0104' || this.institutionalCode == '保安服务公司' || this.institutionalCode == '保安培训单位' || this.institutionalCode == '自行招用保安员单位') {//保安服务公司0102,保安培训单位0103,自行招用保安员单位0104
      this.isSupervisedView()//判断是否填写监管归属---需要判断机构类型--强提醒
    }

    // localStorage.getItem('__network__') ? this.judgePromoter(localStorage.getItem("domainId")) : null; // 互联网端判断是否激活分销商

    window.setInterval(() => {
      setTimeout(this.getOnlineNumber, 0);//定时查询公告数量
    }, 60000)

    let radomNum = new Date().getTime();

    this.$api.getMessage(//消息
      radomNum,
      {
        onSucess: res => {
          this.notice = res.data.data.notice;
        }
      }
    )

    this.$api.getNotificationNum(//消息公告数字
      {
        onSucess: res => {
          let otherNotice = res.data.data;
          let arr = [];
          for (let key in otherNotice) {
            let obj = {};
            if (otherNotice[key] > 0 && key != "size") {
              obj.type = key.toString();
              obj.value = otherNotice[key];
              arr.push(obj);
            }
          }
          this.otherNotice = arr;
          console.log("this.otherNotice---->", this.otherNotice)
        }
      }
    )

    this.myprofile();

    this.$api.bcxplatAdlistApi({}, {//右上角平台通知提示信息    
      onSucess: res => {
        if (res.data.errcode == 0) {
          let listArr = res.data.data.data
          console.log(listArr)
          if (listArr.length) {
            listArr.forEach(item => {
              if (currDate(true) >= item.items.__G3lF6FIrSTspuF06jEr.value && currDate(true) <= item.items.__eG17lW4psp4yq1aT0Pt.value) {//在当前时间范围内提醒
                this.remindInfoArr.push(item.items.__04C3Fur4uYFpos1vlSP.value)
              }
            })
          }
          if (this.remindInfoArr.length) {//提醒时间段有弹窗提醒
            this.platAdPop()
          }
        }
      }
    }
    )

    console.log('organizationLevels',organizationLevels)//obpm.config.js定义全局变量organizationLevels
    if(organizationLevels.indexOf('Premium')>-1){
      this.baseServiceOptions=this.$root.roleLevelsPermissionData&&this.$root.roleLevelsPermissionData.baseServiceOptions
      console.log('this.baseServiceOptions',this.baseServiceOptions)
    }

  },

  data: function () {
    return {
      appid: "km1",
      tabs: [],
      password: '',
      isLock: 'false',
      notice: 0,
      otherNotice: [],
      showMessagePopup: true,
      showMenu: true,
      Constant,
      updateMenu: '',
      updateMenuData: {},
      dialogVisible: false,
      domainDialogVisible: false,
      pwd: '',
      isPasswordError: '',
      isChangeDomain: false,
      domainList: [],
      nullPrompt: '',
      activeTopmenuindex: 0,
      activewaitmenuindex: -1,//待办默认不选中
      showWait: false,
      showApp: false,
      appname: '',
      applistArr: [],
      domainlistArr: [],
      logo: '',
      showdialog: false,
      showdialogPlatAd: false,//平台通知 弹窗
      remindInfoArr: [],//提醒消息数组列表
      platinfoli: "",//右上角平台消息第一条
      platStartTime: "",//提醒开始时间
      platEndTime: "",//提醒结束时间
      remindFlag: false,//在当前时间范围内提醒,默认不提醒显示
      domainAdmin: localStorage.getItem("domainAdmin") == 'true' ? true : false,//是否是组织管理员
      website: {},//官网名称与地址对象
      network: true,//获取__network__全局变量状态，判断显示隐藏
      domainName: localStorage.getItem("domainName") || "",
      headPhoto: "",
      homeTemplateBoradType: localStorage.getItem('homeTemplateBoradType') || 'payTemplate',
      systemNoticeDialogVisible: false,//系统通知弹窗
      placeOfRegister_bjFlag: true,//外网北京注册地显示
      opencloseExpandBtnFlag: true,//开关菜单状态
      supervisionDialogVisible: false,//监管归属地弹窗默认false--强提醒
      isSupervisedInfoCompletedData: {},
      institutionalCode: localStorage.getItem('institutionalCode') || '',//判断机构类型
      domainLonLatPopDialogVisible:false,
      domainLonLatData:{},
      showQrcodeDialog: false,
      showQrcodeTip: false,
      isOrganizationPromoter: false,
      appUrl:isDev?require('../assets/images/home/dlAppDev.png'): require('../assets/images/home/dlAppPro.png'),
      dialogVisibleApp:false,
      errorTip: '',
      updatePasswordType: localStorage.getItem('updatePasswordType') || '',
      updatePasswordMsg: localStorage.getItem('updatePasswordMsg') || '',
      updatePwdDialogVisible: false,
      showPasswordDialog: false,

    };
  },

  methods: {
    upadtePwdConfirm() {
      this.updatePwdDialogVisible = false
      this.showPasswordDialog = true
    },
    // 检查并显示密码修改提示
    checkPasswordUpdateNotice() {
      console.log('this.updatePasswordType', this.updatePasswordType, this.updatePasswordMsg)
      if (this.updatePasswordType && this.updatePasswordMsg) {
        this.updatePwdDialogVisible = true
        if (this.updatePasswordType === '2') {
          localStorage.removeItem('updatePasswordType');
          localStorage.removeItem('updatePasswordMsg');
        } 
      }
    },
    
    onPasswordUpdateSuccess() {
      this.showPasswordDialog = false;
      this.$message({
        message: '密码修改成功',
        type: 'success'
      });
      
      // 如果是强制修改密码，修改成功后清除状态
      if (this.updatePasswordType === '1') {
        localStorage.removeItem('updatePasswordType');
        localStorage.removeItem('updatePasswordMsg');
      }
    },
    isSupervisedView() {
      let domainId = localStorage.getItem("domainId") || ''
      this.$api.isSupervisedApi(domainId, {
        onSucess: res => {
          console.log('res11', res)
          if (res.data.data) {
            console.log('res.data.data监管归属', res.data.data)
            this.isSupervisedInfoCompletedData = res.data.data
            console.log(this.isSupervisedInfoCompletedData)
            if (res.data.data.superviseCompleted && res.data.data.infoCompleted) {
              this.supervisionDialogVisible = false;//有填写监管归属，隐藏监管归属弹窗
            }
            else {
              this.$message({ type: 'warning', message: '尚未填报，前往填报' })
              this.supervisionDialogVisible = true;//否则显示监管归属弹窗
            }
          }
        },
        onError: erro => {
          this.supervisionDialogVisible = false;//错误，隐藏弹窗，默认让客户可以用
          console.log('erro11', erro)
        }
      })
    },
    opencloseExpandBtn(flag) {//中间切换伸缩按钮点击事件
      if (flag) {
        this.opencloseExpandBtnFlag = !this.opencloseExpandBtnFlag
      }
      if (this.opencloseExpandBtnFlag) {//中间按钮是展开状态与菜单显示
        this.$nextTick(() => {
          this.$refs.navbar.style.display = 'flex'
          this.$refs.navbar.style.width = '250px'
          this.$refs.mychild.$refs.mainHomeContent.style.left = '250px'
          this.$refs.opencloseExpandRef.style.left = '250px'
        })
      } else {
        this.$nextTick(() => {
          this.$refs.navbar.style.display = 'block'
          this.$refs.navbar.style.width = '64px'
          this.$refs.mychild.$refs.mainHomeContent.style.left = '64px'
          this.$refs.opencloseExpandRef.style.left = '64px'
        })
      }
    },
    organizationsID(id) {//北京系统提醒
      this.$api.organizationsIDApi(id,
        {
          onSucess: res => {
            console.log(res.data.data.placeOfRegister)
            if (res.data.data.placeOfRegister && res.data.data.placeOfRegister.province.name.indexOf('北京') > -1) {
              this.systemNoticeDialogVisible = true
              this.placeOfRegister_bjFlag = true
            } else {
              this.systemNoticeDialogVisible = true
              this.placeOfRegister_bjFlag = false
            }
          }
        })
    },
    myprofile() {
      sessionStorage.setItem("myProfileName", this.$root.user.name) //存储iM聊天登录用户名
      sessionStorage.setItem("loginNo", this.$root.user.telephone) //存储iM聊天登录手机号--IM废弃，改为imIdentity
      sessionStorage.setItem("imIdentity", this.$root.user.imIdentity || '') //存储iM聊天登录---存储iM标识符，根据这个标识符获取im的sig秘钥
      let headPhotoUrl = this.$root.user.headPhoto
      if (headPhotoUrl && headPhotoUrl.indexOf("http") > -1) {
        this.headPhoto = headPhotoUrl
      } else {
        this.headPhoto = window.location.origin + '/obpm' + headPhotoUrl
      }

      localStorage.setItem('headPhotoStr', this.headPhoto)//保存本地头像地址

      let data = { s_comId: localStorage.getItem("domainId") }//根据组织id获取官网
      this.$api.getWebSiteApi(data, {
        onSucess: res => {
          if (res.data.data.data) {
            let name = res.data.data.data[0].items.__d7xhxbGk9975pvHmwrv.value
            let url = res.data.data.data[0].items.__zHBRHJJEwYAZxLwUhyO.value
            this.website = { name, url }
          }
        }
      })

      this.$api.getEnterpriseUserinfo(localStorage.getItem("domainId"), {
        onSucess: res => {
          console.log('res11',res)
          if (res.data.status == 200) {
            let isValidLonlat=res.data.data.isValidLonlat;//判断企业是否完善经纬度，没有完善强提醒
            console.log('this.domainAdmin',this.domainAdmin)
            if(this.domainAdmin&&isValidLonlat&&this.network){//是组织管理员以及没有完善经纬度--强提醒
                this.domainLonLatPopDialogVisible=true
            }
            document.title = res.data.data.sysName || '' //系统名称
            //获取icon图标
            var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
            link.type = "image/x-icon";
            link.rel = "shortcut icon";
            // link.href="http://v5qy.test.baibaodun.cn/obpm/uploads/lib/icon/upload/1.jpg"
            if (res.data.data.logoPath.indexOf("http") > -1) {
              link.href = `${res.data.data.logoPath}` //浏览器图标企业logo
            } else {
              link.href = `${obpmConfig.obpmFilePath}/uploads/lib/icon${res.data.data.logoPath}` //浏览器图标企业logo
            }
            document.getElementsByTagName("head")[0].appendChild(link);
            // console.log("查询用户信息")
            // console.log(res.data.logoUrl)          
            // console.log(res.data.logoUrl)
            if (res.data.data.logoPath.indexOf("http") > -1) {
              this.logo = res.data.data.logoPath
            } else {
              if (res.data.data.logoPath) {
                this.logo = `${obpmConfig.obpmFilePath}/uploads/lib/icon${res.data.data.logoPath}`
              } else {
                this.logo = ""
              }
            }
          }
        }
      })

    },
    Im() {//点击聊天弹窗显示
      this.showdialog = true;
      this.$refs.PopChildren.getTableRow({}, 0)
    },
    platAdPop() {//平台通知消息滚动弹窗
      this.$refs.PopChildrenPlatAd.show()
    },
    messagespanClick() {//右上角消息图标点击
      this.showWait = false
      this.showApp = false
      this.$store.state.appmenusShow = false
      this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
      this.addTab({ id: '03', name: '消息中心', linkType: '03', remind: 'true' })
    },
    contactservicespanClick() {//右上角消息图标点击
      window.open("http://v5qy.te.baibaodun.com.cn/static/portal/vue/chat.html?v=1741842615461#/", "_blank")
    },
    editpwd() {//右上角下拉修改密码
      this.showWait = false
      this.showApp = false
      this.$store.state.appmenusShow = false
      this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
      this.addTab({ id: '02', name: '修改密码', linkType: '102' })
    },
    help() {//帮助
      this.showWait = false
      this.showApp = false
      this.$store.state.appmenusShow = false
      this.$refs.mychild.setMaincontent(true) // 调用子组件的方法

      var param = {
        id: "help",
        name: '办事指南',
        linkType: '07',
        actionContent: `/static/signon/help/index.html?v=${Date.now()}#/home`,
        icon: "",
        key: ""
      }
      this.addTab(param)
    },
    feedback() {//意见反馈
      let loginNo = sessionStorage.getItem("loginNo")
      let myProfileName = sessionStorage.getItem("myProfileName")
      window.open(`https://support.qq.com/product/321476?nickname=${myProfileName}&avatar=xxx&openid=${loginNo}`)
    },
    websiteClick() {//官网
      if (this.website.url) {
        window.open(this.website.url)
      }
    },
    websiteBKTClick() {//百课堂官网
      window.open('//bktang.abcxin.cn')
    },
    domainmanager() {//切换组织管理
      this.showWait = false
      this.showApp = false
      this.$store.state.appmenusShow = false
      this.$refs.mychild.setMaincontent(true) // 调用子组件的方法

      let domainId = localStorage.getItem("domainId");
      var param = {
        id: "domainmanager",
        name: '管理后台',
        linkType: '07',
        actionContent: `/static/signon/domainCompany/index.html?v=${Date.now()}#/domain?domainId=${domainId}`,
        icon: "",
        key: ""
      }
      this.addTab(param)
    },
    changeDomainDown(item) {//头部左上角切换组织--新版本直接从缓存里面获取    
      if (item.name) {
        localStorage.setItem("accessToken", item.accessToken)//切换组织，重新获取新的accessToken
        localStorage.setItem("domainName", item.name)//存储组织域名称--给员工管理-甲方
        localStorage.setItem("domainId", item.id)//域id
        localStorage.setItem("domainAdmin", item.domainAdmin)//是否是组织管理员
        localStorage.setItem("employeeId", item.employeeId)//保存当前公司的当前用户
        localStorage.setItem("institutionalCode", item.institutionalCode)//机构类型 
        localStorage.setItem("businessToken", item.businessToken||'')//自定义角色授权token
        localStorage.setItem("organizationLevels", item.organizationLevels||'')//组织级别-基础版本，高级版...
        window.location.reload()//重新刷新页面
      }

    },
    Searchdomain() {//查询所有组织---注释掉，从登录跳转页获取

    },
    navtopmenuclick(index, type) {
      this.showWait = false
      this.showApp = false
      this.activeTopmenuindex = index
      if (index === 0) {//首页--工作台     
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        this.activeHome()
        this.applist()//查询左边下拉应用列表
        return
      }
      if (index === 1) {//项目      
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        var param = {
          id: "project",
          name: '项目',
          linkType: '07',
          actionContent: `/static/signon/project/index.html?v=${Date.now()}#/Project`,
          icon: "icon-1",
          key: "project"
        }
        this.addTab(param)
        return
      }
      if (index === 2) {//待办
        this.showWait = true
        this.$store.state.appmenusShow = false
        if (type == 'menu') {
          this.waitclick(0, { id: '105', name: '我的待办', linkType: '105' }) //默认点击第一个待办菜单
        }
        this.$refs.mychild.setMaincontent(false) // 调用子组件的方法        
        return
      }
      if (index === 3) {//工作台
        this.showApp = true
        this.$refs.mychild.setMaincontent(false) // 调用子组件的方法
        var param = {
          id: "workmenu",
          name: '工作台',
          linkType: 'application',
          actionContent: "",
          icon: "-1",
          key: ""
        }
        this.addTab(param)//新组件Tab
        this.applist()//查询左边下拉应用列表
        return
      }
      if (index === 4) {//知识库
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法 
        return
      }
      if (index === 5) {//公告
        this.showWait = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        var param = {
          id: "ad",
          name: '公告',
          linkType: 'ad',
          actionContent: "",
          notice: this.notice,
          icon: "",
          key: ""
        }
        this.addTab(param)
        return
      }
      if (index === 6) {//新闻      
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        var param = {
          id: "news",
          name: '新闻',
          linkType: '07',
          actionContent: `/static/signon/news/index.html?v=${Date.now()}#/`,
          icon: "icon-1",
          key: "news"
        }
        this.addTab(param)
        return
      }
      if (index === 7) {//项目中心    
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        var param = {
          id: "projectCenter",
          name: '项目中心',
          linkType: '07',
          actionContent: `/static/signon/project/index.html?v=${Date.now()}#/projectCenter`,
          icon: "icon-1",
          key: "projectCenter"
        }
        this.addTab(param)
        return
      }
      if (index === 8) {//集团项目    
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        var param = {
          id: "projectJt",
          name: '集团项目',
          linkType: '07',
          actionContent: `/static/signon/project/index.html?v=${Date.now()}#/projectJt`,
          icon: "icon-1",
          key: "projectJt"
        }
        this.addTab(param)
        return
      }
      if (index === 9) {//门户      
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
        var param = {
          id: "portalNews",
          name: '门户',
          linkType: '07',
          actionContent: `/static/signon/portalNews/index.html?v=${Date.now()}#/`,
          icon: "icon-1",
          key: "portalNews"
        }
        this.addTab(param)
        return
      }

      if (index === 99) {//App
  this.dialogVisibleApp=true
        return
      }
      if (index === 100) {//商城应用市场-->appId=='__aNKPFCBuZfyQNzlnlZ9'      
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法

        let promise = new Promise((resolve, reject) => {
          this.$api.orgshoptoken({},//商城新的token
            {
              onSucess: res => {
                console.log('res', res)
                let shopToken = res.data && res.data.accessToken || ''
                resolve(shopToken)
              }
            }
          )
        })
        promise.then(shopToken => {
          let url = ``
          if (location.hostname.indexOf('te') > -1 || location.hostname.indexOf('de') > -1 || location.hostname.indexOf('localhost') > -1) {//测试环境
            let enterUrl = `https://shop.ws.baibaodun.com.cn/autologin`
            let redirectUrl = ``
            url = `${enterUrl}?accesstoken=${shopToken}&redirectUrl=${redirectUrl}`
          } else if (location.hostname.indexOf('pre') > -1) {//预发布环境
            let enterUrl = `https://shop.mall.pre.baibaodun.cn/autologin`
            let redirectUrl = ``
            url = `${enterUrl}?accesstoken=${shopToken}&redirectUrl=${redirectUrl}`
          } else {//生产环境
            let enterUrl = `https://shop.mall.baibaodun.cn/autologin`
            let redirectUrl = ``
            url = `${enterUrl}?accesstoken=${shopToken}&redirectUrl=${redirectUrl}`
          }
          var param = {
            id: "shop",
            name: '商城应用市场',
            linkType: '07',
            actionContent: url,
            icon: "icon-1",
            key: "shop"
          }

          this.addTab(param)
          return
        })
      }
      if (index === 101) {//企业钱包-->appId=='__ZG0ZtjrEhvNbj2rlOsF'      
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法

        let promise = new Promise((resolve, reject) => {
          this.$api.orgshoptoken({},//商城新的token
            {
              onSucess: res => {
                console.log('res', res)
                let shopToken = res.data && res.data.accessToken || ''
                resolve(shopToken)
              }
            }
          )
        })

        promise.then(shopToken => {
          let url = ``
          if (location.hostname.indexOf('te') > -1 || location.hostname.indexOf('de') > -1 || location.hostname.indexOf('localhost') > -1) {//测试环境
            let enterUrl = `https://shop.ws.baibaodun.com.cn/autologin`
            let redirectUrl = `https://pay.ws.baibaodun.com.cn`
            url = `${enterUrl}?accesstoken=${shopToken}&redirectUrl=${redirectUrl}`
          } else if (location.hostname.indexOf('pre') > -1) {//预发布环境
            let enterUrl = `https://shop.mall.pre.baibaodun.cn/autologin`
            let redirectUrl = `https://pay.mall.pre.baibaodun.cn`
            url = `${enterUrl}?accesstoken=${shopToken}&redirectUrl=${redirectUrl}`
          } else {//生产环境
            let enterUrl = `https://shop.mall.baibaodun.cn/autologin`
            let redirectUrl = `https://pay.mall.baibaodun.cn`
            url = `${enterUrl}?accesstoken=${shopToken}&redirectUrl=${redirectUrl}`
          }
          var param = {
            id: "pay",
            name: '企业钱包',
            linkType: '07',
            actionContent: url,
            icon: "icon-1",
            key: "pay"
          }

          this.addTab(param)
          return
        })


      }
    },
    waitclick(index, obj) {//待办菜单点击
      this.activewaitmenuindex = index
      this.addTab(obj)
    },
    applist() {//查询左边--下拉应用列表 

      let data = {//只查询电脑端应用
        search_clientype: "电脑端",
      }
      this.$api.getApplicationsAll(data, {
        onSucess: response => {
          if (response.data && response.data.errmsg == "ok") {
            console.log(response.data)
            if (response.data.data.data.length) {
              let arr = []
              response.data.data.data.forEach((item, index) => {
                let obj = {}
                let obj2 = {}
                obj.title = item.items['__4ReuvgLxTKieJDzGu2L'].value
                obj.cateSort = item.items['__sJO2jdvlNEznauT5KQa'].value //分类排序  

                obj.children = []
                obj2.img = item.items['__oTDoKOfuYRsmXS7DfDk'].value ? JSON.parse(item.items['__oTDoKOfuYRsmXS7DfDk'].value)[0].path : ""  //应用图标
                obj2.name = item.items['__M0NXUq24HGrzQrmjLwj'].value  //应用名称 
                obj2.appid = item.items['__ZLG2HsnA374L6Ww4X6P'].value //应用id   
                obj2.appSort = item.items['__zsh5fkZEXwof08KVNMe'].value //应用id

                obj.children.push(obj2)
                arr.push(obj)

              })
              console.log(arr)
              arr.sort((a, b) => { return Number(a.cateSort) - Number(b.cateSort) }) //分类排序cateSort 

              const titleMap = {}
              const transferObj = arr.reduce((prev, next) => {
                if (titleMap[next.title]) {
                  prev[next.title].children.push(...next.children)
                } else {
                  titleMap[next.title] = true
                  prev[next.title] = { children: next.children }
                }
                return prev
              }, {})


              let arr2 = []
              for (let i in transferObj) {
                let obj = {}
                obj.title = i
                transferObj[i].children.sort((a, b) => { return Number(a.appSort) - Number(b.appSort) }) //应用排序cateSort 
                obj.children = transferObj[i].children
                arr2.push(obj)
              }

              let arr3 = []
              arr2.forEach(item => {
                item.children.forEach(its => {
                  let obj = {}
                  obj.appid = its.appid
                  obj.name = its.name
                  arr3.push(obj)
                })
              })

              if (location.host.indexOf("v5qy.te.baibaodun.cn") > -1) {
                if (localStorage.getItem("domainId") != '__2gH5luUlviULa7KnmqW') {//临时过滤使用--后期删除--测试117环境
                  arr3 = arr3.filter(item => {
                    return item.appid != "__gZxrYDgj8OpfztxSuUg"
                  })
                }
              } else {
                if (localStorage.getItem("domainId") != '__Qqg3L4GhNXG4iRAmcTB') {//临时过滤使用--后期删除--正式环境
                  arr3 = arr3.filter(item => {
                    return item.appid != "__gZxrYDgj8OpfztxSuUg" //不在这个组织，组织权益应用隐藏
                  })
                }
              }
              console.log(arr3)
              this.applistArr = arr3

            }

          }
        }
      });
    },
    loadAppMenu(appId, name) {//点击右边application.vue应用列表 查询左边应用菜单
      if (appId != "km" && appId != "pm" && appId != "qm") {
        this.$root.appid = appId;
      }
      this.$store.dispatch("loadMenus", { appId, name });
      if (appId == '__xkeybkGaZa1SboC9GL1') {//智能人事（__xkeybkGaZa1SboC9GL1）、机构用户管理（__d1qEDy3wYq8VF5KvUoE）
        let obj = { name, appId }
        localStorage.setItem('appidSupervise', JSON.stringify(obj))
      }
    },
    updateViewNumber(menuData) {
      this.updateMenuData = menuData;
      this.updateMenu = new Date().getTime();
    },
    hiddenMenu() {
      this.showMenu = !this.showMenu;
      this.$refs.mychild.setMaincontent() // 调用子组件的方法
    },

    jumpToInfo(val) {
      this.showMessagePopup = false;
      this.addTab(val);
    },

    closeMessagePopup() {
      this.showMessagePopup = false;
    },

    signOut() {//退出系统
      this.$api.removeOnlineUser({
        onSucess: res => {
          if (res.status == 200) {
            console.log("res--->", res.status);
          }
        }
      })
      try {
        this.$api.LogOut({
          onSucess: res => {
                let statiContextPath = obpmConfig.statiContextPath;
                let signonContextPath = obpmConfig.signonContextPath
                let url = ""
                if (statiContextPath) { //5.0 trunk
                  url = window.location.origin + statiContextPath + signonContextPath + "/index.html" // http://49.4.123.194/static/signon/index.html
                }
                window.location.href = url
                let cookies = document.cookie.match(/[^=;]+(?=\=)/g);
                if (cookies) {
                  for (let i = cookies.length; i--;) {
                    document.cookie = cookies[i] + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'
                  }
                }
                localStorage.clear()
                sessionStorage.clear()
          }
        }); 
      } catch (error) {
                let statiContextPath = obpmConfig.statiContextPath;
                let signonContextPath = obpmConfig.signonContextPath
                let url = ""
                if (statiContextPath) { //5.0 trunk
                  url = window.location.origin + statiContextPath + signonContextPath + "/index.html" // http://49.4.123.194/static/signon/index.html
                }
                window.location.href = url
                let cookies = document.cookie.match(/[^=;]+(?=\=)/g);
                if (cookies) {
                  for (let i = cookies.length; i--;) {
                    document.cookie = cookies[i] + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'
                  }
                }
                localStorage.clear()
                sessionStorage.clear()
      }
         
    },

    getLock() {//一键锁屏
      let val = sessionStorage.getItem('screenLock');
      if (val) {
        this.isLock = val;
      } else {
        this.isLock = 'false';
      }
    },

    getOnlineNumber() {//定时查询公告数量
      this.$api.getNotification(
        {
          onSucess: res => {
            if (res.data.data.data && res.data.data.data.length > 0) {
              let data = res.data.data.data[0];
              this.$notify({
                title: '',
                dangerouslyUseHTMLString: true,
                message: '你有一条新消息',
                duration: 5000,
                customClass: 'fontclass'
              });
            }
          }
        }
      )
    },

    // systemManagement(){//进入组织管理后台
    //   let domainid = localStorage.getItem("domainId");
    //   let domainName;//企业域名称
    //   for(let i = 0; i < this.domainList.length; i ++) {
    //     if(domainid === this.domainList[i].id) {
    //       domainName = this.domainList[i].name
    //     }
    //   }
    //   let statiContextPath = obpmConfig.statiContextPath;
    //   let systemUrl = '';
    //   if(statiContextPath) { //5.0 trunk
    //     systemUrl = obpmConfig.statiContextPath + "/domain/index.html#/domain?domainid=" + domainid + "&from=systemManagement" + "&name=" + domainName;//&from=systemManagement让deisgner那边可以获取到标识
    //   }else { //4.4 stable
    //     systemUrl = obpmConfig.obpmFilePath + "/domain/index.html#/domain?domainid=" + domainid + "&from=systemManagement" + "&name=" + domainName;
    //   }
    //   window.open(systemUrl);//新窗口打开组织管理后台
    // },

    changeDomain() {
      this.domainDialogVisible = true;
    },

    //退出系统
    Actionquit() {
      API.LogOut({
        onSucess: response => {
          if (response.status == 200) {
            window.location = "http://localhost:8080/signon/";
          }
        },
        onError: error => {
          console.log(error);
        }
      });
    },

    hanleClickLogin() {//超时登录界面弹窗--回到登录界面
      let statiContextPath = obpmConfig.statiContextPath;
      let url = ""
      if (statiContextPath) { //5.0 trunk
        url = "http://" + window.location.host + statiContextPath + "/signon/index.html"
      } else { //4.4 stable
        url = "http://" + window.location.host + "/signon/index.html"
      }
      window.location.href = url
    },

    hanleClick() {//超时登录界面弹窗--登录
      let cookie = document.cookie.split(";");
      let language, url, path
      for (let i = 0; i < cookie.length; i++) {
        if (cookie[i].indexOf("USERLANGUAGE") >= 0) {
          language = cookie[i].split("=")[1];
        }
      }
      let str = Base64.encode(this.pwd);
      let userPwd;
      if (str.length > 2) {
        let lp = str.substr(0, 2);
        let rp = str.substr(2, str.length);
        userPwd = rp + lp;
      }
      let data = {
        username: this.$store.state.myProfile.loginNo,
        password: userPwd,
        remember: "0",
        debug: false,
        domainName: this.$store.state.myProfile.domainName,
        checkcode: "",
        language: language,
        url: url,
        path: path
      }
      this.$api.signonLogin(
        data,
        {
          onSucess: res => {
            if (res.data.resultCode != 0) {
              //更新accessToken
              document.cookie = res.data.accessToken
              localStorage.setItem("accessToken", res.data.accessToken);
              this.pwd = '';
              this.dialogVisible = false;
              this.$message({
                message: '登录成功',
                type: 'success'
              });
            } else {
              this.$message.error('登录失败，输入密码有误');
            }
          }
        }
      )
    },
    //一键锁频
    lockScreen() {
      if (this.$store.state.lastTimeFlag == false) return;//iframe嵌套第三方，如员工保险应用，企业钱包关闭锁屏
      this.password = '';
      this.isLock = 'true';
      sessionStorage.setItem('screenLock', 'true');
    },

    changeMenu: function (appid) {
      this.appid = appid;
    },

    activeHome: function () {//点击首页，去掉所有tab选项卡
      this.tabs.forEach(function (value) {
        value.active = false;
      });
      this.showWait = false
      this.showApp = false
      this.$store.state.appmenusShow = false
    },

    addTab(param) {//核心，左边菜单---应用菜单点击显示 右边iframe Tab模式
      // debugger
      param.currentAppName = this.$store.getters.currentAppName //获取vuex应用名称--核心代码
      var flag = false;
      this.tabs.forEach(function (value) {
        if (value.id && value.id == param.id) {
          value.active = true;
          if (param.linkType == '01') { //视图
            value.randomNumber = param.randomNumber;
          }
          flag = flag || true;
        } else {
          value.active = false;
        }
      });

      if (flag) return;
      this.tabs.forEach(function (value) {
        value.active = false; //所有隐藏选项卡
      });
      param.active = true; //当前显示选项卡
      this.tabs.push(param);
    },

    closeAllTab() {//关闭所有选项卡--隐藏左边菜单
      this.tabs = [];
      this.showApp = false
      this.$store.state.appmenusShow = false
      this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
      this.$store.state.searchDataStore = []
      this.$store.state.pageDataStore = []
    },

    closeTab: function (tab, tabindex) {//关闭当前选项卡，选中前一个选项卡
      console.log(tab)
      console.log(tabindex)
      if (this.$store.state.searchDataStore.length) {
        this.$store.state.searchDataStore.forEach((item, index) => {
          if (item.appId == tab.appId && item.viewId == tab.actionContent) {
            this.$store.state.searchDataStore.splice(index, 1)//关闭视图--清掉vuex单个视图的记住数据
          }
        })
      }
      if (this.$store.state.pageDataStore.length) {
        this.$store.state.pageDataStore.forEach((item, index) => {
          if (item.appId == tab.appId && item.viewId == tab.actionContent) {
            this.$store.state.pageDataStore.splice(index, 1)//关闭视图--清掉vuex单个视图的记住数据
          }
        })
      }
      console.log(this.$store.state.searchDataStore)
      let tabs = this.tabs;
      if (tabindex >= 0) { //点击X关闭
        console.log(JSON.stringify(this.tabs))
        tabs.splice(tabindex, 1);
        if (tab.active) {
          if (tabs.length > 0 && ((tabs.length - 1) >= tabindex)) {
            tabs[tabindex].active = true;
          } else if (tabs.length > 0 && ((tabs.length - 1) < tabindex)) {
            if (tabindex > 0) {
              tabs[tabindex - 1].active = true;//选中前一个选项卡
            }
          }
        }
        // if(tabs[tabs.length-1]) {
        //   tabs[tabs.length-1].active = true;
        // }
      } else { //单击返回按钮
        let i = -1;
        this.tabs.forEach(function (value, index) {
          if ((value.id && value.id == tab.id) || (value._select && value._select == tab._select)) {
            i = index;
          }
        });
        this.tabs.splice(i, 1);
        let act = this.tabs[i];
        if (act) {
          this.activeTab({ id: act._select ? act._select : act.id });
        } else if (i >= 1) {
          let act = this.tabs[i - 1];
          this.activeTab({ id: act._select ? act._select : act.id });
        } else {
          if (this.tabs.length > 0)
            this.tabs[this.tabs.length - 1].active = true;
        }
      }

      if (this.tabs.length == 0) {//关闭最后一个，所有左边菜单隐藏
        this.showWait = false
        this.showApp = false
        this.$store.state.appmenusShow = false
        this.$refs.mychild.setMaincontent(true) // 调用子组件的方法
      }
    },

    activeTab: function (tab, index) {//选中选项卡
      if (index >= 0) {
        this.tabs.forEach((value, i) => {
          if (i == index) {
            value.active = true;
          } else {
            value.active = false;
          }
        });
      } else {
        this.tabs.forEach((value) => {
          if ((value.id && value.id == tab.id) || (value._select && value._select == tab._select) || (value._select && value._select == tab.id)) {
            value.active = true;
            return;
          } else {
            value.active = false;
          }
        });
      }
    },

    openQrcodeDialog() {
      this.showQrcodeDialog = true;
    },

    closeQrcodeDialog() {
      this.showQrcodeDialog = false;
    },

    judgePromoter(id) {
      this.$api.judgePromoterApi(id,
        {
          onSucess: res => {
            this.isOrganizationPromoter = res.data.data.isOrganizationPromoter;
            console.info('promoter', this.isOrganizationPromoter);
          }
        })
    }
  },
  watch: {
    showInstance(val) {
      if (val) {
        this.dialogVisible = true;
      }
    },
  }
};
</script>

<style lang="scss" scoped>
::v-deep .custom-dialog {
  height: auto;
  .el-dialog__title{
    font-size: 24px;
    font-weight: bold;
  }
  .el-dialog__body{
    padding: 10px 25px 10px;
  }
  .el-dialog__header{
    padding: 30px 20px 10px;
  }
}

.lockWraper {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(24, 38, 46, 0.6);
  z-index: 999999!important;
  color: red;

  .lock-content {
    width: 460px;
    height: 240px;
    background: white;
    border-radius: 5px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-top: -120px;
    margin-left: -230px;

    .img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      overflow: hidden;
      position: absolute;
      left: 50%;
      top: -30px;
      margin-left: -30px;

      img {
        width: 60px;
        height: 60px;
      }
    }

    .admin-header-lock-name {
      margin-top: 43px;
      width: 100%;
      text-align: center;
      color: #333636;
      margin-bottom: 55px;
    }

    .input_btn {
      width: 100%;
      padding-left: 95px;
      padding-right: 95px;
      box-sizing: border-box;
      display: -webkit-flex;
      display: flex;
      justify-content: center;
      align-items: center;

      .input-box {
        position: relative;

        .error-tip {
          position: absolute;
          top: -35px;
          padding: 5px 5px;
          border: 1px solid red;
          border-radius: 4px;
          font-size: 12px;

          &::after {
            position: absolute;
            top: 26px;
            content: "";
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 7px solid red;
          }

          &::before {
            position: absolute;
            top: 25px;
            z-index: 10;
            content: "";
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 7px solid #fff;
          }
        }
      }

      #lockPwd {
        width: 200px;
        height: 30px;
        border-radius: 3px;
        background: #797979;
        display: inline-block;
        padding-left: 10px;
        font-size: 14px;
        color: #fff;
        border: none;
        vertical-align: middle;
        margin-right: 10px;
        outline: none;
      }

      .un-lock {
        display: inline-block;
        height: 30px;
        line-height: 30px;
        background: #0076f6;
        color: #fff;
        width: 60px;
        border-radius: 3px;
        text-align: center;
        cursor: pointer;
      }

      ::-webkit-input-placeholder {
        /* WebKit browsers */
        color: #fff;
      }

      :-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        color: #fff;
      }

      ::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        color: #fff;
      }

      :-ms-input-placeholder {
        /* Internet Explorer 10+ */
        color: #fff;
      }
    }

    .tip {
      width: 100%;
      padding: 0 15px;
      box-sizing: border-box;
      margin-top: 20px;
      text-align: center;
    }

  }
}

.fontclass {
  .el-notification__content {
    .notice_actor {
      color: #0095FF;
    }

    .notice_summary {
      color: #0095FF;
    }
  }

}

.fa-lock:before,
.lockScreenicon:before {
  display: none;
  cursor: default;
}

.nav-appMenus {
  .el-scrollbar {
    height: calc(100% - 30px) !important;
    overflow-x: scroll;

    .el-scrollbar__wrap {
      overflow: auto;

      .el-scrollbar__view {
        white-space: nowrap;
        height: calc(100%);
      }
    }
  }
}

//中间切换伸缩按钮
.openExpand {
  position: fixed;
  left: 250px;
  top: 50%;
  width: 11px;
  height: 32px;
  z-index: 1;
  cursor: pointer;
  overflow: hidden;

  img {
    position: absolute;
    top: 0;
    left: 0;

    &:hover {
      top: 0;
      left: -12px;
    }

    &.openFlag {}

    &.closeFlag {
      top: -32px;
      left: 0;

      &:hover {
        top: -32px;
        left: -12px;
      }
    }
  }

}

.openExpand.closeExpand {
  left: 64px;
}

// update
.center-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 100%;

  .qrcode-container {
    position: relative;
    cursor: pointer;

    .qrcode-tip {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100px;
      position: absolute;
      padding: 5px;
      background-color: #fff;
      border-radius: 5px;
      color: #333333;
      font-size: 12px;
      top: 35px;
      right: -40px;
      z-index: 99;
    }
  }
}
</style>
