<style scoped>
.comp-HomePage {background-color:#fff;height:100%;height:100vh;position:relative;}
a{text-decoration:none;color: #b3b3b3;}
a:hover, a:visited, a:link, a:active {color: #b3b3b3;}
.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}
.clearfix{overflow:hidden;_zoom:1;}
.homeTop{position: relative;padding-bottom:2rem;width:100%;overflow: hidden;}
.homeTop .homeTopModule{width: 200%;margin-left:-50%;border-radius: 0 0 50% 50%;overflow: hidden;}
.HomeTopBg{animation: 20s infinite;background-size: cover;text-align: center;width:50%;margin:0 auto;position: relative;content: '';background:linear-gradient(#2CBAF9,#04A9F4);background-color:rgb(53, 145, 246);background-repeat: no-repeat;background-size:100% 100%;background-image: url(http://image.supercarrier8.com/h5_key/background-top.png);overflow: hidden; }
.HomeTopBg .headerInfo{display: flex;padding-top: 1rem;padding-left:6%;padding-right: 3%; }
.HomeTopBg .headerInfo .headImg{background-color: rgba(0,0,0,0.5);border-radius: 100%;width: 4rem;height: 4rem;border:none;margin-right: 0.8rem;}
.HomeTopBg .headerInfo .userInfo{flex:1;text-align: left;color:#fff;}
.HomeTopBg .headerInfo .userInfo div{margin:0.48rem 0;padding-left: 0.2rem;margin-top: 0;padding-top: 0.48rem;}
.HomeTopBg .headerInfo .userInfo .userName{font-size:1rem;display: block;float: left;max-width: 40%;/*overflow: hidden;*/text-overflow: ellipsis;-webkit-line-clamp: 1;-webkit-box-orient: vertical;display: -webkit-box;word-wrap:break-word;word-break:break-all;}
.HomeTopBg .headerInfo .userInfo .userType{display: block;float: left;max-width: 38%;height: 1rem;padding-top: 0.19rem;line-height: 1.2rem;overflow: hidden;padding-left: 1.3rem;background:url(http://image.supercarrier8.com/h5_key/icon-storeAssistant.png) no-repeat 0.3rem bottom;background-size: 0.8rem;color:#FBC74E;}
.HomeTopBg .headerInfo .userInfo .userSetting{float:right;width:1.2rem;height:1.2rem;}
.HomeTopBg .headerInfo .userInfo .messageTip{float:right;width:1.2rem;height:1.2rem;margin-right:1rem;position: relative;}
.HomeTopBg .headerInfo .userInfo .messageTip img{display: block;width:100%;height: 100%;}
.HomeTopBg .headerInfo .userInfo .messageTip i{position: absolute;top: -0.1rem;right: -0.66rem;color: #fff;font-style: normal;border-radius: 0.5rem; background-color: red;font-size: 0.6rem;line-height: 0.6rem;padding: 0.06rem 0.1rem;min-width: 1rem;text-align: center;}
.HomeTopBg .headerInfo .userInfo >span{max-width:10rem;min-width:2rem;text-align: center;overflow: hidden;background-color:#3678EA;display: inline-block;border-radius: 0.64rem;line-height: 1.2rem;height: 1.2rem;color:#fff;padding: 0.04rem 0.6rem;font-size: 0.7rem;}
.Total{background:#47A1F8;color:#fff;width: 85%;margin:0 auto;margin-top:1rem;border-radius: 0.4rem 0.4rem 0 0;}
.Total ul{ list-style-type: none;margin: 0; padding: 0;}
/* .Total li{float:left; display: block; } */
.Total .TotalTitle{line-height: 1.7rem;padding-left: 0.5rem;}
.Total .TotalTitle li{display: block;padding-top:0.3rem;margin-left:0.8rem;float:left; display: block;}
.Total .TotalTitle li:nth-of-type(1){margin-left:0.5rem;}
.Total .TotalTitle li.selected{border-bottom: 0.1rem solid#fff;}
.Total .TotalDetail{background:#5DB4FB;padding-bottom: 0.6rem;}
.Total .TotalDetail ul{margin-bottom: 1rem;display: flex;}
.Total .TotalDetail li{flex: 1;}
.Total .TotalDetail li span{font-size: 0.7rem;}
.Total .TotalDetail .count{font-size: 1.2rem;padding-top: 0.5rem;}
.scancode{text-align: center; position: absolute;bottom: 1rem;left: 35%;background:#fff;border-radius: 3rem;height:2rem;line-height: 2rem;width:30%;box-shadow: 0 0 1rem #bcbc;}
.scancode span{padding-left: 1.2rem;background: url('http://image.supercarrier8.com/h5_key/icon-scanningCode.png');background-repeat: no-repeat;background-position: 0rem 50%;background-size:0.9rem;}
.member-center{background: #fff;/*margin-top: 3.5rem;margin-top:75%;*/}
.member-center ul{ list-style-type: none; padding: 0; margin: 0;}
.member-center .title span{padding-left: 0.3rem;border-left: 0.2rem solid#3B8AFC;margin-left: 1rem;}
.member-center .menu{margin-top: 1rem;}
.member-center .menu li{width: 32.3%; display: block;float: left; text-align: center;border: 0.1rem solid #F8FAFF;height: 5rem;}
.member-center .menu li image{width: 2.2rem;height: 2.3rem;}
.member-center .menu  .menuicon{margin-top: 1.3rem;}
</style>

<template>
<div class="container comp-HomePage jfBaseSize" v-cloak v-bind:style="vh?'height:100vh':'height: 100%;'"> 
    <div class="homeTop">
      <div class="homeTopModule">
        <div class="HomeTopBg" id="HomeTopBg">
          <div class="headerInfo">
            <img class="headImg" v-bind:src="loginUserInfo.HeadImage?loginUserInfo.HeadImage:'http://image.supercarrier8.com/h5_key/icon_headDefault.png'" alt="头像" />
            <div class="userInfo">
              <div class="clearfix">
                <span class="userName" v-html="loginUserInfo.NickName"></span>
                <span class="userType" v-html="MemberTypeStr"></span>
                <img class="userSetting" @click="goPage('Key_USet')" src="http://image.supercarrier8.com/h5_key/icon-setting-white.png"/>
                <span class="messageTip " @click="goPage('K_MList')">
                  <img src="http://image.supercarrier8.com/h5_key/icon-message.png"/>
                  <i v-if="messageObj.messageCount&&messageObj.messageCount>0" v-html="messageObj.messageCount&&messageObj.messageCount>0?(messageObj.messageCount&&messageObj.messageCount>99?'99+':messageObj.messageCount):''"></i>
                </span>
              </div>
              <span v-html="loginUserInfo.OrganizationName?loginUserInfo.OrganizationName:'-'"  v-show="EntranceId==1||EntranceId==2"></span>
              <span v-show="EntranceId==3">门店数量 <font color="#FBC74E" v-html="ShowStoreCount.StoreCount"></font></span>
              <span v-show="EntranceId==4||EntranceId==5">编号：<span v-html="loginUserInfo.MemberNo"></span></span>
            </div>
          </div>
          <div class="Total">
             <div class="TotalTitle" v-show="EntranceId==1||EntranceId==2||EntranceId==3">
                    <ul class="clearfix">
                      <li class="selected" @click="TotalTab($event,0)">今日</li><li @click="TotalTab($event,1)">累计</li>
                    </ul>
              </div>
              <div class="TotalTitle" v-show="EntranceId==4||EntranceId==5">
                    <ul class="clearfix">
                      <li class="selected">每日数据</li>
                    </ul>
              </div>
              <div class="TotalDetail clearfix" v-show="EntranceId==1||EntranceId==2||EntranceId==3">
                  <ul id="TotalTab0" class="clearfix">
                    <li>
                      <div class="count">{{Today_Count.ScanCodeCount}}</div>
                      <span class="name">扫码量</span>
                    </li>
                    <li> 
                      <div class="count">{{Today_Count.RedBagAmount.toFixed(2)}}</div>
                      <span class="name">红包</span>
                    </li>
                      <li> 
                      <div class="count">{{Today_Count.JfAmount}}</div>
                      <span class="name">积分</span>
                    </li>
                      <li> 
                      <div class="count">{{Today_Count.GiftCount}}</div>
                      <span class="name">礼品</span>
                    </li>
                  </ul>
                  <!-- <div id="TotalTab0" class="clearfix">
                    
                  </div> -->
                  <ul id="TotalTab1" class="clearfix" style="display:none;">
                    <li>
                      <div class="count">{{Total_Count.ScanCodeCount}}</div>
                      <span class="name">扫码量</span>
                    </li>
                    <li> 
                      <div class="count">{{Total_Count.RedBagAmount.toFixed(2)}}</div>
                      <span class="name">红包</span>
                    </li>
                      <li> 
                      <div class="count">{{Total_Count.JfAmount}}</div>
                      <span class="name">积分</span>
                    </li>
                      <li> 
                      <div class="count">{{Total_Count.GiftCount}}</div>
                      <span class="name">礼品</span>
                    </li>
                  </ul>
                  <!-- <div id="TotalTab1" style="display:none;">
                      
                  </div> -->
              </div>

               <div class="TotalDetail clearfix" v-show="EntranceId==4||EntranceId==5">
                  <ul id="TotalTab0" class="clearfix" v-show="EntranceId==4">
                    <li>
                      <div class="count">{{ShowStoreCount.StoreCount}}</div>
                      <span class="name">门店数量</span>
                    </li>
                    <li> 
                      <div class="count">{{ShowStoreCount.AuditStoreCount}}</div>
                      <span class="name">待审核数量</span>
                    </li>
                  </ul>
                  <ul id="TotalTab0" class="clearfix" v-show="EntranceId==5">
                    <li>
                      <div class="count">{{ShowAgentCount.DealerCount}}</div>
                      <span class="name">经销商数量</span>
                    </li>
                    <li> 
                      <div class="count">{{ShowAgentCount.StoreCount}}</div>
                      <span class="name">门店数量</span>
                    </li>
                  </ul>
              </div>
          </div>
        </div>
      </div>
      <div class="scancode" @click="scan()" v-show="IsShow.IsShowFastScan"><span>快捷扫码</span></div>
    </div>
    
    <div class="member-center">
          <div class="title"><span>常用功能</span></div>
          <div class="menu">
            <ul>
              <li v-for="item in RoleList" :key="item.Id" @click="goPage(item.Url)" v-show="!item.IsMenu">
                <div class="menuicon"><img v-bind:src="'http://image.supercarrier8.com/h5_key/'+ item.Icon+'.png'" style="height:1.5rem;"/></div>
                <span>{{item.ShowName}}</span>
              </li>
            </ul>
        </div>
    </div>
</div>
</template>

<script>
import { Toast } from 'mint-ui';
import channelHelper from "@/assets/js/channelHelper.js";
import { base64 } from "@/assets/js/cryptoHelper";
import { debug } from 'util';
import wx from "weixin-js-sdk";
import '@/assets/js/libs/js.cookie';
import { Indicator } from 'mint-ui';
import App from '@/App.vue'
import ReturnHome from "@/components/channel/temp001/ReturnHome";
export default {
  name: 'Key_HomePage',
  components: {ReturnHome},
    provide(){       
     return{           
        goPage:this.goPage       
     }   
    },
  props: ["comp", "cfg", "selectedPage"],
  data() {
    return {
      Setting:{
        ShowIntegralMall:"1",
        WriteOffManage:"1",
        DealerManagement:"1",
        ScanReward:"1",
        EmployeManagement:"1",
        StoreManagement:"1",
        SweepYardsReward:"1"
      },
      MenuPower:{
          StoreManagement:0,
          DataView:0
      },
      IsShow:{
        IsShowCustomer:false,
        IsShowStudy:false,
        IsShowActivityArea:false,
        IsShowFastScan:false
      },
      EntranceId:this.sup8.context.entranceid,
      ShowStoreCount:0,
      MemberTypeStr:"",
      code: "",
      errMsg: "",
      RoleList:[],
      vh:false,
      Today_Count:{
        ScanCodeCount:0,
        GiftCount:0,
        RedBagAmount:0.00,
        JfAmount:0,
      },
      Total_Count:{
        ScanCodeCount:0,
        GiftCount:0,
        RedBagAmount:0.00,
        JfAmount:0,
      },
      ShowStoreCount:{
        StoreCount:0,
        AuditStoreCount:0
      },
      ShowAgentCount:{
        DealerCount:0,
        StoreCount:0
      },
      messageObj:{
        OperUserId:'',
        EnterpriseNo:this.sup8.context.enterpriseno,
        LanguageType:"zh-cn",
        messageCount:'',
        UserToken:""
      },
    }
  },
  computed:{
    loginUserInfo:function(){
        var loginUserInfo = {
          NickName:"",
          HeadImage:"",
          OrganizationName:"",
          MemberTypeStr:"",
          RoleId:"",
          UserId:"",
          MemberNo:""
        };
        var tempLoginInfo = localStorage.getItem("loginInfo");
        if ($.trim(tempLoginInfo) != "") {
          loginUserInfo = eval("(" + tempLoginInfo + ")");
        }
        return loginUserInfo;
    }
  },
  methods: {
    /* 核销扫码 */  
    scan() {
        let that = this;
        wx.scanQRCode({
            needResult: 0, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
            success: function(res) {
            },
            fail: function(e) {
                console.log(JSON.stringify(e));
            }
        });
    },
    getQueryVariable(variable)
    {
          var query = window.location.search.substring(1);
          var vars = query.split("&");
          for (var i=0;i<vars.length;i++) {
                  var pair = vars[i].split("=");
                  if(pair[0] == variable){return pair[1];}
          }
          return(false);
    },
    /* 核销扫码进入核销确认页面  */
    query(VerificationCode){
      var locationto=this.$parent;

      sessionStorage.setItem("VerificationCode",VerificationCode);
      locationto.changeSelectedPage("Key_WInfo");//跳转到核销详细
    },
    /* 关键人基础设置要用到的方法  根据基础设置判断菜单权限 */
    H5KeySetting(SettingType){
      var that=this;
      var url = "/channel/H5KeySetting";
        var dataParams = {
            SettingType:SettingType,
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
               that.Setting=res.data;
            } 
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 店长身份  店长称呼不一样  读取后台设置的 */
    GetStoreManagerCall(){
      var that=this;
      var url = "/channel/GetStoreManagerCall";
        var dataParams = {
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
               that.MemberTypeStr=res.data;
            } 
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 获取门店数量统计 */
    GetStoreCountForDealer(){
      var that=this;
      var url = "/channel/GetStoreCountForDealer";
        var dataParams = {
            DealerId:channelHelper.GetUserLoginInfo().OrganizationId,
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
               that.ShowStoreCount.StoreCount=res.data;
            } 
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 经销商业务员统计接口 */
    GetStoreCount(){
      var that=this;
      var url = "/channel/GetStoreCount";
        var dataParams = {
            UserId:that.loginUserInfo.UserId,
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType(),
            UserToken:channelHelper.GetUserToken(),
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
               that.GetStoreCount=res.data;
            } 
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 经销商业务员统计接口 */
    GetStoreCount(){
      var that=this;
      var url = "/channel/GetStoreCount";
        var dataParams = {
            UserId:that.loginUserInfo.UserId,
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType(),
            UserToken:channelHelper.GetUserToken(),
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
               that.ShowStoreCount=res.data;
            } 
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 企业业务员统计接口 */
    GetDealerAndStoreCount(){
      var that=this;
      var url = "/channel/GetDealerAndStoreCount";
        var dataParams = {
            UserId:that.loginUserInfo.UserId,
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType(),
            UserToken:channelHelper.GetUserToken(),
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
               that.ShowAgentCount=res.data;
            } 
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 根据身份MemberType类型获取身份名称 */
    GetMemberTypeName:function(TypeId){
        var that=this;
        if(channelHelper.GetUserLoginInfo().ClerkName&&that.sup8.context.entranceid==1)
        {
          that.MemberTypeStr=channelHelper.GetUserLoginInfo().ClerkName;
          return;
        }
     
      
        var url = "/channel/GetSysParaTypeList";
        var dataParams = {
            EnterpriseNo: that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType(),
            TypeId:TypeId
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          if (res.flag&&res.data){
              $.each(res.data,function(m,n){
                if(n.DATA_VALUE==that.loginUserInfo.MemberType)
                {
                  that.MemberTypeStr=n.DATA_NAME;
                }
              });
          }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 获取经销商员工菜单权限   经销商负责人可以员工权限进行设置 */
    GetDealerEmployeeMenu:function(TypeId){
        var that=this;
        var url = "/channel/GetDealerEmployeeMenu";
        var dataParams = {
            EnterpriseNo: that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType(),
            UserToken:channelHelper.GetUserToken(),
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          if (res.flag&&res.data){
             that.MenuPower=res.data;
          }
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 根据菜单设置跳转 */
    goPage(url){
        var that=this;
        var eno = that.sup8.context.enterpriseno;
        if(url.indexOf("/")!=-1||url.indexOf("http")!=-1)
        {
            location.href=url.replace("$enterpriesno",eno);
        }
        else if(url.indexOf("BASE64:")!=-1)
        {
          url=url.replace("BASE64:","").replace("$enterpriesno",eno);
           url=decodeURIComponent(decodeURI(base64.de(url))).replace("$enterpriesno",eno);
          location.href=url;
        }
        else
        {
          this.$parent.changeSelectedPage(url);
        }
    },
    /* 背景图  */
    updateDom() {  
        var that = this;
        //alert(this.comp.props.bgImg.val);
        // 将当前设置的背景图片加到body标签下
        $("#HomeTopBg").css({
          "background-repeat": "no-repeat",
          "background-color": "rgb(53, 145, 246)",
          "background-size": "100% 100%",
          "background-image":"url("+this.comp.props.bgImg.val+")"
        });
    },
    /* 今日和累计的切换 */
    TotalTab(e,type){
        $(".TotalTitle li").removeClass("selected");
        $(e.target).addClass("selected");
        $("#TotalTab"+type).show().siblings().hide();
    },
    /* 绑定数据统计 */
    BindDataCount(){
        var that=this;
        var eno=that.sup8.context.enterpriseno;
        var url = "/channel/GetTodayData";
        var dataParams = {
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo: eno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
            if (res.flag&&res.data){
               that.Today_Count=res.data;
            }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);

        var url = "/channel/GetTotalData";
        var dataParams = {
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo: eno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
            if (res.flag&&res.data){
                that.Total_Count=res.data;
            }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 绑定菜单 */
    BindMenu(){
        var that=this;
        var eno=that.sup8.context.enterpriseno;
         var url = "/channel/GetPlatFormMenus";
         var dataParams = {
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo: eno,
            LANGUAGE_TYPE:channelHelper.GetLanguageType(),
            RoleId:that.loginUserInfo.RoleId,
            PlatformId:"5",
            ModuleName:""
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            Indicator.close();
            if(that.sup8.context.entranceid=="5")
            {
              that.IsShow.IsShowFastScan=false;
            }
            if (res.flag){
                that.RoleList=res.data;
                /* 如果地址栏上带这两个参数则是演示版本 */
                if(that.getQueryVariable("demoshow")=="true")
                {
                  /* 品牌专区 */
                   that.RoleList.push({
                        "Location": "1",
                        "IsMenu": false,
                        "ChildMenus": null,
                        "Url": "http://image.supercarrier8.com/h5_key/品牌专区.png",
                        "PlatForm": null,
                        "ParentId": "172aa706c90f4c04a29b03f9357d1c58",
                        "Id": "272aa706c90f4c04a29b03f9357d1c58",
                        "ProductId": null,
                        "ModuleId": "a135d81def354e91b60279f46c7e9ab6",
                        "MenuId": "4cfed8fb40954d7bb55141a8789223f8",
                        "ShowName": "品牌专区",
                        "Icon": "icon-brandarea",
                        "Sort": 12
                   });
                   /* 巡店打卡 */
                   that.RoleList.push({
                        "Location": "1",
                        "IsMenu": false,
                        "ChildMenus": null,
                        "Url": "K_CheckS",
                        "PlatForm": null,
                        "ParentId": "372aa706c90f4c04a29b03f9357d1c58",
                        "Id": "472aa706c90f4c04a29b03f9357d1c58",
                        "ProductId": null,
                        "ModuleId": "a135d81def354e91b60279f46c7e9ab6",
                        "MenuId": "554740fcb06d4a2db361ae70978ba76e",
                        "ShowName": "巡店打卡",
                        "Icon": "icon-checkstore",
                        "Sort": 13
                   });
                }
                /* 根据后台基础设置判断菜单是否显示出来 */
                $.each(res.data,function(m,n){
                   /* 控制积分商城入口是否开放 */
                   if(that.Setting!=null&&that.Setting.ShowIntegralMall=="0"&&n.MenuId=="ba1f1be72e9d48d6ad8e751721fb3765")
                   {
                       res.data[m].IsMenu=true;
                   }
                   /* 控制核销是否显示 */
                   if(that.Setting!=null&&that.Setting.WriteOffManage=="0"&&n.MenuId=="043f4106c38c40f5be5bfba720f99140")
                   {
                       res.data[m].IsMenu=true;
                   }
                   /* 控制企业业务员经销商菜单是否显示 */
                  if(that.Setting!=null&&that.Setting.DealerManagement=="0"&&n.MenuId=="c1f455ee216811eaa4bc000c290950c7")
                   {
                       res.data[m].IsMenu=true;
                   }

                  /* 控制扫码记录菜单是否显示 */
                  if(that.Setting!=null&&that.Setting.SweepYardsReward=="0"&&n.MenuId=="f8e30a7e2056495ca9ad26e09ca6c0e7")
                   {
                      res.data[m].IsMenu=true;
                   }
                    /* 控制我的奖励菜单是否显示 */
                   if(that.Setting!=null&&that.Setting.SweepYardsReward=="0"&&n.MenuId=="030d4c412b844e51975f23b68375b309")
                   {
                       res.data[m].IsMenu=true;
                   }
                     /* 控制扫码记录菜单是否显示 */
                  if(that.Setting!=null&&that.Setting.ScanReward=="0"&&n.MenuId=="f8e30a7e2056495ca9ad26e09ca6c0e7")
                   {
                       res.data[m].IsMenu=true;
                   }
                    /* 控制我的奖励菜单是否显示 */
                   if(that.Setting!=null&&that.Setting.ScanReward=="0"&&n.MenuId=="030d4c412b844e51975f23b68375b309")
                   {
                       res.data[m].IsMenu=true;
                   }
                   /* 控制员工管理菜单是否显示 */
                  if(that.Setting!=null&&that.Setting.EmployeManagement=="0"&&n.MenuId=="b3cda307216811eaa4bc000c290950c7")
                   {
                       res.data[m].IsMenu=true;
                   }
                   /* 控制门店管理菜单是否显示 */
                  if(that.Setting!=null&&(that.Setting.StoreManagement=="0"&&n.MenuId=="11985c67216911eaa4bc000c290950c7")||(that.MenuPower.StoreManagement==0&&that.sup8.context.entranceid==4&&n.MenuId=="11985c67216911eaa4bc000c290950c7"))
                   {
                       res.data[m].IsMenu=true;
                   }
                   /* 控制数据分析查看 */
                    if(that.MenuPower!=null&&that.MenuPower.DataView==0&&that.sup8.context.entranceid==4&&n.MenuId=="b6650f0e216711eaa4bc000c290950c7")
                   {
                      res.data[m].IsMenu=true;
                   }
                  //控制店员管理菜单是否显示
                  if(that.Setting!=null&&that.Setting.ClerkManagement=="0"&&n.MenuId=="af4c880c216711eaa4bc000c290950c6")
                  {
                    res.data[m].IsMenu=true;
                  }
                  //控制客户管理菜单是否显示
                  if(!that.IsShow.IsShowCustomer&&n.MenuId=="x6650f0e216711eaa4bc000c290950cx")
                  {
                    res.data[m].IsMenu=true;
                  }
                   //控制活动专区菜单是否显示
                  if(!that.IsShow.IsShowActivityArea&&n.MenuId=="c6650f0e216711eaa4bc000c290950vz")
                  {
                    res.data[m].IsMenu=true;
                  }
                   //控制学习中心菜单是否显示
                  if(!that.IsShow.IsShowStudy&&n.MenuId=="p6650f0e216711eaa4bc000c290950nk")
                  {
                    res.data[m].IsMenu=true;
                  }
                  if(n.MenuId=="a7d453985937419d849d52d0f2200cf5")
                  {
                     res.data[m].IsMenu=true;that.IsShow.IsShowFastScan=true;
                  }
               });
            }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    /* 判断是否可以自动登录 */
    AutoLogin(){
        var that=this;var OpenId="";var location="";var nickname="";var headimgurl="";
        var wxUserInfo=this.sup8.context.wxUser;
        if(wxUserInfo)
        {
            nickname=wxUserInfo.nickname;
            if (wxUserInfo.headimgurl) {
              headimgurl=wxUserInfo.headimgurl;
            }else{
              headimgurl="http://image.supercarrier8.com/h5_key/icon_headDefault.png";
            }
            OpenId=wxUserInfo.openid;
        }
        if(OpenId=="")
        {
            return false;
        }
        var GeoArea=that.sup8.context.geo;
       if(GeoArea)
       {
          GeoArea=GeoArea.addressComponent;
          location=GeoArea.country+GeoArea.province+GeoArea.city+GeoArea.district+GeoArea.street+GeoArea.street_number;
       }
        var url = "/channel/KeyPersonUserLoginByOpenId";
        var dataParams = {
            EntranceId:this.sup8.context.entranceid,
            EnterpriseNo:that.sup8.context.enterpriseno,
            OpenId:OpenId,
            LanguageType:channelHelper.GetLanguageType(),
            IP:"",
            GPS:location,
            NickName:nickname,
            HeadImage:headimgurl
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
            if(res.flag)
            {
                localStorage.setItem("loginauto","1");
                localStorage.setItem('loginInfo', JSON.stringify(res.data));	
            } Indicator.close();
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null)
      },
      GetCustomerMenuCheck(){
        var that=this;
        var url = "/channel/GetCustomerSetting";
        var dataParams ={
          UserToken:channelHelper.GetUserToken(),
          EnterpriseNo: that.sup8.context.enterpriseno,
          LanguageType:channelHelper.GetLanguageType()
        };
        Indicator.open();
        var cbSuccess = function(res){
          if (res.flag) {
            var data=res.data;
            if(data.OpenObject)
            {
                if(data.OpenObject.indexOf(that.sup8.context.entranceid)!=-1)
                {
                  that.IsShow.IsShowCustomer=true;
                }
            }
          }
          Indicator.close();
        };
        var cbError = function(jqXHR, textStatus, errorThrown){
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    },
    GetActivityAreaCheck(){
      var that=this;
      var url = "/activity/GetH5AreaInfo";
      var dataParams = {
          UserToken:channelHelper.GetUserToken(),
          enterpriseno: that.sup8.context.enterpriseno,
          LanguageType:channelHelper.GetLanguageType()
      };
      Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          if(data.OpenObject)
          {
              if(data.OpenObject.indexOf(that.sup8.context.entranceid)!=-1)
              {
                 that.IsShow.IsShowActivityArea=true;
              }
          }
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        Indicator.close();
      };
      //请求后端
      channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,null,null,null);
    },
    GetStudyCenterCheck(){
      var that=this;
      var url = "/channel/GetStudySettingH5";
      var dataParams = {
          UserToken:channelHelper.GetUserToken(),
          enterpriseno: that.sup8.context.enterpriseno,
          LanguageType:channelHelper.GetLanguageType()
      };
      //Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          if(data.OpenObject)
          {
              if(data.OpenObject.indexOf(that.sup8.context.entranceid)!=-1)
              {
                 that.IsShow.IsShowStudy=true;
              }
          }
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        Indicator.close();
      };
      //请求后端
      channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,null,null,null);
    },
    //消息配置获取
    GetSup8UserID(){
      var that=this;
      var url = "/channel/GetSup8UserID";
      that.messageObj.UserToken=channelHelper.GetUserToken();
      var dataParams = that.messageObj;
      Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          that.$set(that.messageObj,'OperUserId',data);
          that.GetUnreadMessageCount();
        }
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        //Toast(jqXHR.responseText);
      };
      //请求后端
      channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    //未读消息个数获取
    GetUnreadMessageCount(){
      var that=this;
      var url = "/channel/GetUnreadMessageCount";
      var dataParams = that.messageObj;
      Indicator.open();
      var cbSuccess = function(res){
        var data=res.data;
        if(data){
            data=parseInt(res.data);
            that.$set(that.messageObj,'messageCount',data);
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        //Toast(jqXHR.responseText);
      };
      //请求后端
      channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
  },
  watch: {
    "comp.props.bgImg.val": function() {
      this.updateDom();
    }
  },
  created(){
      localStorage.setItem("ShowFlow",0);
      try{
      var that = this;
      var isDesign = location.pathname.indexOf('design');
      if(isDesign!=-1)
      {
         return;
      }
      var eno = that.sup8.context.enterpriseno;
      var entranceid=that.sup8.context.entranceid;
      if(localStorage.getItem("loginauto")==null)
      {
        that.AutoLogin(); 
      }
      //判断是否登录
      var isDesign = location.pathname.indexOf('/design');
      if (!channelHelper.CheckLogin(this.$parent,eno,that.sup8.context.entranceid)&&isDesign==-1) {
        this.$parent.changeSelectedPage('Key_Login')
        return false;
      }else if(isDesign!=-1){
        return false;
      }
      if (entranceid=="1"||entranceid=="2") {
        that.GetCustomerMenuCheck();
      }
      that.GetSup8UserID();
      that.GetActivityAreaCheck(); 
      that.GetStudyCenterCheck();
      that.mergeCompProps(that.comp);
      var entranceid=that.sup8.context.entranceid;
      /* 通用接口方法  */
      that.H5KeySetting(entranceid);
      if(entranceid!=2)
      {
        that.GetMemberTypeName("0086aafd572247c3a1889f6bb238bd14");
      }
      if(entranceid==1||entranceid==2||entranceid==3)
      {
        that.BindDataCount();
      }
      //找到角色id   2代表店长名称
      if(entranceid==2)
      {
        /**店长名称设置 */
        that.GetStoreManagerCall();
      }
      else if(entranceid==3)
      {
        that.GetStoreCountForDealer();
      }
      else if(entranceid==4)
      {
        that.GetDealerEmployeeMenu();
        that.GetStoreCount();
      }
      else if(entranceid==5)
      {
        that.GetDealerAndStoreCount();
      }
      that.BindMenu();
      }catch(e){
        console.log(e);
      }
  },
  mounted: function () {
    try{
      this.updateDom();
      /* 将消费者主页设置的按钮图标和按钮开关缓存起来 */
      localStorage.setItem("backbtnisshow",this.comp.props.IsShow.val);
      localStorage.setItem("backbtnicon",this.comp.props.iconimg.val);
    }catch(e){}
    /**样式兼容设计器 **/
    if(location.pathname.indexOf("/design")!=-1)
    {
        $(".footercom").css({"position":"absolute","height":"100%","width":"100%","bottom":"0"});
        $(".f-box").css({"position":"absolute","width":"100%"});
    }
   
      var that=this;
      var isDesign = location.pathname.indexOf('/design');
      if (!(isDesign>-1)) {
          that.$set(that,'vh',true);
      }else{
          that.$set(that,'vh',false);
      }
      setTimeout(()=>{
        let offsetHeight = document.body.offsetHeight;
        let scrollHeight = document.body.scrollHeight;
        this.height = scrollHeight>offsetHeight?scrollHeight+"px":offsetHeight+"px";
      },1000);
  }
}
</script>
