
<style scoped>  
.comp-reg {background: #fff;}
.input-box {background:#FFF;}
.comp-reg {padding:0;margin:0;}
.text-gray{color:#000;}
.reg-content{padding:0 6%;}
.reg-content div.reg-itemContent{margin:0;padding:0.42rem 0;height:2rem;line-height:2rem;display:flex;border-bottom: 1px solid #E9E9E9;}
.reg-content div.reg-itemContent .iconImg{display:inline-block;text-align:center;padding:0 0.4rem; padding-top:0.18rem;padding-left: 0;}
.reg-content .reg-itemContent .iconImg img{width:0.9rem ;height: 1rem;}
.reg-content div.reg-itemContent input{background-color: #fff;border:0px;flex:1;outline:none;color:#000;}
.reg-content .reg-itemContent input.selectItem{background: url(http://image.supercarrier8.com/h5_key/icon-arrow-gray.png) no-repeat right center;background-size:2%;}
.reg-content .reg-itemContent input:-webkit-input-placeholder { color:white;}
.reg-content .reg-itemContent input:-moz-placeholder {color:white;}
.reg-content .reg-itemContent input:-moz-placeholder {color:white;}
.reg-content .reg-itemContent input:-ms-input-placeholder {color:white;}
.reg-content .reg-itemContent .gainVC{float:right;color:#FECC41;border-radius: 0.65rem;border: 1px solid#FECC41;font-size: 0.8rem;text-align: center;display: block;width: 5rem;height: 0.7rem;line-height: 0.84rem;padding: 0.16rem 0;margin-top: 0.5rem;}
.reg-content div.addstore{color:rgb(98, 149, 254);font-size: 0.7rem;display: block;border-bottom: none;text-align: right;}
.item-btn {display:block;width:88%;height:2.6rem;padding:0;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin:0 6%;font-size:1rem;line-height:2.6rem;text-align:center;color:#fff;background:#3A8AFB;border:none;border-radius:0.2rem;margin-top:1.6rem;margin-bottom:0.34rem;}
.footer {color:#b3b3b3;text-align:center;text-shadow:1px 1px 0 rgba(255,255,255,1);margin-bottom: 1rem;}
.footer span{margin: 0 6%;}
.footer a {color:#b3b3b3;}
.mint-popup-bottom{width:100%;}
.usi-btn-cancel,
.usi-btn-sure {color: #FF6600}
.RegTip{margin-top: 5rem;text-align: center;}
.RegTip .TipText{font-size: 1.2rem; margin-bottom: 0.5rem;}
.RegTip .TipImg{margin-bottom: 0.5rem;}
.RegTip .TipImg img{width: 7rem;    text-align: center;}
.bannerbg{margin-bottom:2rem;background-image:url('http://image.supercarrier8.com/h5_key/topbanner.png');background-size:100% 100%;background-repeat:no-repeat;height: 6.4rem;}
.picker-toolbar-title .btnHeader{display: flex;}
.picker-toolbar-title .btnHeader .button{width: 50%;text-align: center; height: 3rem;}
.picker-toolbar-title .btnHeader button{flex: 1;}
.picker-toolbar-title .searchHearder{width: 80%;max-width:37.5rem;position: relative;margin: 0 auto;background-color:#f3f6ff;border-radius: 0.76rem;}
.picker-toolbar-title .searchHearder input {display: block;width:100%;padding: 0.3rem 1rem;padding-right:1.8rem;border-width:0;border-radius: 0.8rem;background-color:#f3f6ff;box-sizing: border-box;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;}
.picker-toolbar-title .searchHearder span{display: inline-block;width:1.6rem;height: 100%;position: absolute;top:0;right: 0;background: url(https://release-sup8-images.oss-cn-shanghai.aliyuncs.com/h5_key/icon-search.png) no-repeat center center;background-size:1.2rem 1.2rem; }
.picker-items{position: unset;}
.auditPopu{position: fixed;text-align: center;top:50%;margin-top:-10rem;min-height: 15.4rem;width: 84%;background: rgba(255, 255, 255, 1);margin-left:8%;border-radius: 0.2rem;}
.auditPopNew{position: fixed;text-align: center;top:50%;margin-top:-10rem;min-height: 6.4rem;width: 84%;background: rgba(255, 255, 255, 1);margin-left:8%;border-radius: 0.2rem;}
.auditPopu img,.auditPopNew img{display: block;margin: 0 auto;}
.auditPopu .successImg,.auditPopNew .successImg{width: 5rem;height: 5rem;margin-top: 2rem;}
.auditPopu h3,.auditPopNew .successImg{color:#3A8AFB;}
.auditPopu p,.auditPopNew .successImg{width:86%;margin: 0 auto; }
.auditPopu .closeImg,.auditPopNew .closeImg{width: 2rem;height: 2rem;position: absolute;bottom: -3.2rem;margin-left:-1rem;left: 50%;}
.mask {position: fixed;top: 0;left: 0;height: 100%;width: 100%;background: rgba(0, 0, 0, 0.5);}
</style>
<style>
.picker-toolbar{height: auto;}
.mint-toast{z-index:2021;}
</style>
<template>     
  <div class="container comp-reg jfBaseSize" v-cloak v-bind:style="isShow.vh?'height:100vh':'height: 100%;'"> 
    <div>
    <div class="bannerbg">
       <div class="UserPhoto" style="position:relative;top:65%;text-align:center;">
            <img v-bind:src="RegModel.UserPhoto" style="border-radius: 100%;height: 4rem;width: 4rem;"/>
        </div>
    </div>
    <div class="reg-content">
      <div class="reg-itemContent clearfix" @click="ShowGroupPop('1')" v-show="isShow.IsshowGrop">
        <span class="iconImg">
          <img src="http://image.supercarrier8.com/h5_key/icon-identity-gray.png" alt="">
        </span>
        <input class="selectItem" type="text" placeholder="请选择身份" readonly="readonly" id="GroupName" v-model="RegModel.GroupName"/>
      </div>
      <div class="reg-itemContent clearfix">
        <span class="iconImg">
          <img src="http://image.supercarrier8.com/h5_key/icon-user-gray.png" alt="">
        </span>
        <input type="text" placeholder="请输入姓名" class="inp text-gray" name="NickName" id="NickName" v-model="RegModel.NickName" autocomplete="off" />
      </div>
      <div class="reg-itemContent clearfix" @click="ShowGroupPop('2')" v-show="isShow.IsshowStore" style="">
        <span class="iconImg">
          <img src="http://image.supercarrier8.com/h5_key/icon-store-gray.png" alt="">
        </span>
        <input class="selectItem" type="text" placeholder="选择所属门店" readonly="readonly"  v-model="RegModel.StoreName" />
      </div>
        <div class="addstore" @click="goPage('Key_AStore')" v-show="isShow.IsshowStore">新增门店?</div>
      <div class="reg-itemContent clearfix" style="">
        <span class="iconImg">
          <img src="http://image.supercarrier8.com/h5_key/icon-tel-gray.png" alt="">
        </span>
        <input type="text" placeholder="请输入手机号码" class="inp text-gray" name="Mobile" id="Mobile"  v-model="RegModel.Mobile" autocomplete="off" />
      </div>
      <div class="reg-itemContent VCode clearfix">
        <span class="iconImg">
          <img src="http://image.supercarrier8.com/h5_key/icon-verificationCode-gray.png" alt="">
        </span>
        <input type="text" placeholder="请输入验证码"  class="inp text-gray" name="VerifyCode" id="VerifyCode" v-model="RegModel.VerifyCode" autocomplete="off" />
        <!-- <span class="iconImg"> -->
          <span class="gainVC" id="btnSendCode" @click="SendCode($event)" style="cursor:pointer">获取验证码</span>
        <!-- </span> -->
      </div>
       <div class="reg-itemContent clearfix">
        <span class="iconImg">
          <img src="http://image.supercarrier8.com/h5_key/icon-lock-gray.png" alt="">
        </span>
        <input type="password" style="position: fixed;top: -2999px"/>
        <input type="password" placeholder="请输入密码" class="inp text-gray" name="Password" id="Password"  v-model="RegModel.Password" autocomplete="off" />
      </div>
    </div>
    <button class="item-btn"  @click="Reg($event)">注册</button>
    <div class="footer">
      <span style="float:right;">
        <a href="javascript:void(0)" @click="goPage('Key_FPwd')">忘记密码</a> 
      </span>
      <span style="float:left;">
       <a href="javascript:void(0)" @click="goPage('Key_Login')">立即登录</a>
      </span>
    </div>

    <mt-popup v-model="popupVisible" popup-transition="popup-fade" v-bind:closeOnClickModal="isShow.isCloseOnClickModal" position="bottom">
            <mt-picker :slots="slots1" ref="picker1" value-key="Group_Name" :show-toolbar="true" style="width:100%;" v-show="showToolbar1">
                <div class="picker-toolbar-title">
                  <div class="btnHeader">
                    <el-button type="text" name="button" class="button"  @click="popupVisible=false">取消</el-button>
                    <el-button type="text" name="button" class="button"  @click="HandelConfirm(0)">确定</el-button>
                    <!-- <div class="">请选择身份</div> -->
                  </div>
                   <div class="searchHearder">
                      <input class="text-gray" type="text" placeholder="请输入身份搜索" v-model="SearchValue.SearchGroupName"/>
                      <span @click="onSearchGroupName"> </span>
                    </div>
                </div>
            </mt-picker>

             <mt-picker :slots="slots2" ref="picker2" value-key="ORGANIZATION_NAME"  :show-toolbar="true" position="bottom" style="width:100%;" v-show="showToolbar2">
                <div class="picker-toolbar-title">
                    <div class="btnHeader">
                      <el-button type="text" name="button" class="button"  @click="popupVisible=false">取消</el-button>
                      <el-button type="text" name="button" class="button"  @click="HandelConfirm(1)">确定</el-button>
                      <!-- <div class="">请选择所属门店</div> -->
                    </div>
                    <div class="searchHearder">
                      <input class="text-gray" type="text" placeholder="请输入门店搜索" v-model="SearchValue.SearchStoreName"/>
                      <span @click="onSearchStoreName"> </span>
                    </div>
                </div>
            </mt-picker>
    </mt-popup>
    </div>

    <div class="mask" v-show="isShow.IsshowMask"></div>
    <div class="auditPopu" v-show="isShow.IsshowAudit" @click="CloseTip()">
      <img class="successImg" src="http://image.supercarrier8.com/h5_key/icon-OK.png" alt="success">
      <h3>
        资料提交成功，审核中！
      </h3>
      <p v-if="!isShow.IsshowAuditSalesman">
        请耐心等待，审核成功，会以短信的方式通知您所填写的手机号！
      </p>
      <p v-else>
        请耐心等待，经销商负责人收到信息后,将尽快进行审核操作!
      </p>
      <img class="closeImg" src="http://image.supercarrier8.com/h5_key/icon-close-white.png" alt="close"> 
    </div>
    <div class="auditPopNew" v-show="isShow.IsshowReg">
      <h3>
        链接通道已关闭！
      </h3>
      <p v-if="!isShow.IsshowRegTime">
        链接注册通道已经关闭，请联系工作人员！
      </p>
      <p v-else>
        二维码已失效，请重新获取最新二维码！
      </p>
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import { Toast } from 'mint-ui';
import channelHelper from "@/assets/js/channelHelper.js";
import { base64 } from "@/assets/js/cryptoHelper";
import { util } from 'util';
import wx from "weixin-js-sdk";
import '@/assets/js/libs/js.cookie';
import { Indicator,Picker  } from 'mint-ui';
import BaiduMap from 'vue-baidu-map/components/map/Map.vue';
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
export default {
  name: "Key_Reg",
  props: ["comp", "cfg", "selectedPage"],
  data() {
    var wxUserInfo=this.sup8.context.wxUser;
    var UserPhoto="";
    if(wxUserInfo)
    {
      UserPhoto=wxUserInfo.headimgurl;
    }else{
      UserPhoto="http://image.supercarrier8.com/h5_key/icon_headDefault.png";
    }
    return {
      isShow:{
        vh:false,
        IsshowMask:false,
        IsshowAudit:false,
        IsshowAuditSalesman:false,
        IsshowReg:false,
        IsshowRegTime:false,
        IsshowGrop:true,
        IsshowStore:true,
        isCloseOnClickModal:false,
      },
      SendFlag:true,
      RegModel:{
        UserPhoto:UserPhoto,
        GroupId:"0",
        GroupName:"",
        NickName:"",
        AreaId:"",
        StoreID:"",
        ParentUserId:"",
        StoreName:"",
        RoleId:"",
        VerifyCode:"",
        Mobile: "",
        Password: "",
      },
      SearchValue:{
        SearchStoreName:"",
        SearchGroupName:""
      },
      showToolbar1: true,
      showToolbar2: false,
      slots1: [{
          values:[]
      }],
      slots2: [{
          values:[]
      }],
      popupVisible: false,
      RegTag:{
        RegisterType:"",
        RelationStores:"",
        ClerkAudit:""
      }
    };
  },
  methods: {
    GetLocation(){
      var that=this;
      wx.getLocation({
          success: function (res) {
              var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
              var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
              that.GetAreaIDByGps(latitude,longitude);
          },
          cancel: function (res) {
              alert('用户拒绝授权获取地理位置');
          }
      });
    },
    CloseTip(){
      this.isShow.IsshowMask=false;
      this.isShow.IsshowAudit=false;
      this.isShow.IsshowReg=false;
    },
     goPage(pagetype){
        this.$parent.changeSelectedPage(pagetype);
    },
    onSearchStoreName(){
      var that=this;
      that.GetStoreDrop();
    },
    onSearchGroupName(){
      var that=this;
      that.GetGroupAll();
    },
    HandelConfirm(type){
      var that=this;
      var currentobj={};
      
        if(type==0)
        {
          if(this.$refs.picker1.getValues()&&this.$refs.picker1.getValues().length>0&&this.$refs.picker1.getValues()[0]){
            currentobj=this.$refs.picker1.getValues()[0];
            that.RegModel.GroupName=currentobj.Group_Name;
            that.RegModel.GroupId=currentobj.ID;
            this.popupVisible =false;
          }else{
            Toast("请选择门店!");
          }
        }
        else
        { 
          if(this.$refs.picker2.getValues()&&this.$refs.picker2.getValues().length>0&&this.$refs.picker2.getValues()[0]){
            currentobj=this.$refs.picker2.getValues()[0];
            that.RegModel.StoreId=currentobj.ORGANIZATION_ID;
            that.RegModel.StoreName=currentobj.ORGANIZATION_NAME;
            this.popupVisible =false;
          }else{
            Toast("请选择门店!");
          }
        }
    },
    ShowGroupPop(type) {
        var that=this;
         that.popupVisible = true;
        if(type=="1")
        { 
           that.showToolbar1=true; that.showToolbar2=false;
        }else
        {
            if(that.sup8.context.orgid!=undefined)
            {
              that.popupVisible = false;
              return;
            }
             
            that.showToolbar1=false;
            that.showToolbar2=true;
        }
    },
    SendCode(e){
      var that=this;
      if(this.RegModel.Mobile == ""){
        Toast('请输入手机号码');
        return true;
       } 
       $(e.target).attr("disabled",true);
       if(!that.SendFlag)
       {
         return true;
       }
       that.SendFlag=false;
        var url = "/channel/KeyPersonSendVCode";
        var dataParams = {
            EntranceId:this.sup8.context.entranceid,
            EnterpriseNo:that.sup8.context.enterpriseno,
            Mobile:this.RegModel.Mobile,
            Type:1,
            LanguageType:"zh-cn"
        };
        var cbSuccess = function(res){
            if (res.flag) {
                $(e.target).html("已发送(60s)");
                $(e.target).attr("disabled",true);
                var i=60; 
                var setIntime=window.setInterval(function(){
                  $(e.target).html("已发送("+i+"s)");
                  if(i<=0)
                  {
                      window.clearInterval(setIntime); 
                      that.SendFlag=true; 
                      $(e.target).html("获取验证码");
                      $(e.target).removeAttr("disabled");
                  }
                  i--;
                },1000);
            }else
            { that.SendFlag=true;
               Toast(res.msg);
            }
        };
        var cbError = function(jqXHR, textStatus, errorThrown){
          that.SendFlag=true;
            MintUI.Toast(jqXHR.responseText);
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null)
    },
    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.RegTag=res.data;
            } 
            if (that.RegTag) {
              var parentuserid=that.sup8.context.parentuserid;
              if (parentuserid) {
                if (that.RegTag.RegisterType.indexOf("1")==-1) {
                  that.$set(that.isShow,'IsshowReg',true);
                  that.$set(that.isShow,'IsshowMask',true);
                }
              }else{
                if (that.RegTag.RegisterType.indexOf("2")==-1) {
                  that.$set(that.isShow,'IsshowReg',true);
                  that.$set(that.isShow,'IsshowMask',true);
                }
              }
            }
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    },
    GetStoreDrop(){
      var that=this;
        Indicator.open();
      var url = "/channel/GetOrganizationList";
        var dataParams = {
          EntranceId:this.sup8.context.entranceid,
          AreaId:that.RegModel.AreaId,
          OrganizationId:(that.sup8.context.orgid&&that.sup8.context.orgid.length>0?that.sup8.context.orgid:''),
          OrganizationName:that.SearchValue.SearchStoreName,
          EnterpriseNo:that.sup8.context.enterpriseno,
          LanguageType:channelHelper.GetLanguageType(),
          OrganizationType:"17",
          limit:100,
          offset:0,
          UserToken:"0"
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){  Indicator.close();
            if(res.flag)
            {
              that.slots2[0].values=res.data.Rows;
              if(that.sup8.context.orgid!=undefined)
              {
                $.each(res.data.Rows,function(m,n){
                    if(n.PARENT_ORGANIZATION==that.sup8.context.orgid||n.ORGANIZATION_ID==that.sup8.context.orgid)
                    {
                      that.RegModel.StoreId=that.sup8.context.orgid;
                      that.RegModel.StoreName=n.ORGANIZATION_NAME;
                    }
                });
              }
            } 
            Indicator.close();
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    GetGroupAll(){
      Indicator.open();
      var that=this;
      var url = "/channel/GetGroupAll";
        var dataParams = {
            Group_Name:that.SearchValue.SearchGroupName,
            EnterpriseNo:that.sup8.context.enterpriseno,
            LanguageType:channelHelper.GetLanguageType(),
            Limit:100,
            Offset:0,
            OrganizationType:"17"
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){ Indicator.close();
            if(res.flag)
            {
               that.slots1[0].values=res.data;
            } 
            Indicator.close();
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    onValuesChange1(picker, values) {
        if(values[0] > values[1]) {
            picker.setSlotValue(1, values[0]);
        }
    },
    onValuesChange2(picker, values) {
        if(values[0] > values[1]) {
            picker.setSlotValue(1, values[0]);
        }
    },
    // 输入验证
    validation(){ 
      if(this.RegModel.Mobile == ""){
        Toast('请输入手机号码');
        return true;
      }
      if(this.RegModel.Password == ""){
        Toast('请输入密码');
        return true;
      }
      if(this.RegModel.VerifyCode == ""){
        Toast('请输入验证码');
        return true;
      }
      if(this.RegModel.RoleId == ""){
        Toast('角色编号不能为空,请联系管理员配置!');
        return true;
      }
      return false;
    },
    GetAreaIDByGps(latitude,longitude){//获取areaID
      var that=this;
      // Indicator.open();
      var url = "/channel/GetAreaIDByGps";
      var dataParams = {
        latitude:latitude,
        longitude:longitude
      };
      var cbError=function(){Indicator.close();}
      var cbSuccess = function(res){
        if(res.flag&&res.data)
        {
          that.RegModel.AreaId=res.data;
        } that.GetStoreDrop(); Indicator.close();
      };
      //请求后端
      channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null)
    },
   AutoLogin(){
         var locationto=this.$parent;
        var that=this;var OpenId="";var nickname="";var headimgurl="";
        var wxUserInfo=this.sup8.context.wxUser;
        if(wxUserInfo)
        {
            nickname=wxUserInfo.nickname;
            headimgurl=wxUserInfo.headimgurl;
            OpenId=wxUserInfo.openid;
        }
        if(OpenId=="")
        {
            return;
        }
        var GPRS=sessionStorage.getItem("gps");
        var url = "/channel/KeyPersonUserLoginByOpenId";
        var dataParams = {
            EntranceId:this.sup8.context.entranceid,
            EnterpriseNo:that.sup8.context.enterpriseno,
            OpenId:OpenId,
            LanguageType:channelHelper.GetLanguageType(),
            IP:"",
            GPS:GPRS,
            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));
              // 页面跳转
              locationto.changeSelectedPage("Key_HPage");
            } Indicator.close();
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null)
      },
    // 用户登陆
	  loginAuto(LoginID,Password) {
        var that=this;
        var locationto=this.$parent;

        var nickname="";var headimgurl="";var openid="";var location="";
        var wxUserInfo=this.sup8.context.wxUser;
        if(wxUserInfo)
        {
          nickname=wxUserInfo.nickname;
          headimgurl=wxUserInfo.headimgurl;
          openid=wxUserInfo.openid;
        }
        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/KeyPersonLoginAndBindOpenId";
        var dataParams = {
            EntranceId:this.sup8.context.entranceid,
            EnterpriseNo: that.sup8.context.enterpriseno,
            MemberName:base64.en(LoginID),
            MemberPwd:base64.en(Password),
            OpenId: openid,
            LanguageType:channelHelper.GetLanguageType(),
            Location:location,
            IP:"",
            NickName:nickname,
            HeadImage:headimgurl
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
				  if (res.flag) {
					  localStorage.setItem('loginInfo', JSON.stringify(res.data));
					  // 页面跳转
					   locationto.changeSelectedPage("Key_HPage");
				  } else {
					  Toast(res.msg || "登录失败");
				  }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
	  },
    // 用户登陆
	  Reg(e) {
      var that=this;
      var locationto=this.$parent;
		  if (that.validation()) {
			  return;
      };
      Indicator.open();
      $(e.target).attr("disabled",true);
      var OpenId="";var location="";var headimgurl="";
      var wxUserInfo=this.sup8.context.wxUser;
      if(wxUserInfo)
      {
        OpenId=wxUserInfo.openid;
        headimgurl=wxUserInfo.headimgurl;
      }
       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 GPRS=sessionStorage.getItem("gps");
       if(that.sup8.context.parentuserid!=undefined)
       {
         that.RegModel.ParentUserId=that.sup8.context.parentuserid;
       }
       var url = "/channel/KeyPersonRegister";
        var dataParams = {
            RoleId:that.RegModel.RoleId,
            EntranceId:that.sup8.context.entranceid,
            EnterpriseNo: that.sup8.context.enterpriseno,
            MemberName: base64.en(that.RegModel.Mobile),
            Mobile:that.RegModel.Mobile,
            MemberPwd: base64.en(that.RegModel.Password),
            OpenId: OpenId,
            LanguageType:channelHelper.GetLanguageType(),
            Gps:location,
            IP:"",
            VerifyCode:that.RegModel.VerifyCode,
            NickName:that.RegModel.NickName,
            HeadImage:headimgurl,
            OrganizationId:that.RegModel.StoreId,
            GroupId:that.RegModel.GroupId,
            AreaId:that.RegModel.AreaId,
            ParentUserId:that.RegModel.ParentUserId,
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
          if (res.flag){
              Toast("注册成功");
              if(res.data.IsReAudit)
              {
                if(that.sup8.context.parentuserid&&that.sup8.context.entranceid==4){
                  that.$set(that.isShow,'IsshowAuditSalesman',true);
                }
                that.$set(that.isShow,'IsshowAudit',true);
                that.$set(that.isShow,'IsshowMask',true);
              }
              else{
                that.loginAuto(that.RegModel.Mobile,that.RegModel.Password);
              }
               $(e.target).attr("disabled",false);
            //locationto.changeSelectedPage("10");
          }else{
             $(e.target).attr("disabled",false);
            sessionStorage.removeItem('loginInfo');
            Toast(res.msg||"注册失败");
          }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    GetRoleID:function(TypeId){
        var that=this;
        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){
              that.RegModel.RoleId=res.data[0].DATA_VALUE;
          }
        };
        //请求后端
        channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    },
    CheckUrlTime()
    {
      return false;
      var that=this;
       /**判断时间戳是否过期 */
      var endtimestamp=Date.parse(new Date());
      var currenttimestamp=this.sup8.urlparams.timestamp;
      if(currenttimestamp==undefined)
      {
        return false;
      }
      var usedTime = endtimestamp - currenttimestamp;  //两个时间戳相差的毫秒数

      var days = Math.floor(usedTime / (24 * 3600 * 1000));
      //计算出小时数
      var leave1 = usedTime % (24 * 3600 * 1000);    //计算天数后剩余的毫秒数
      var hours = Math.floor(leave1 / (3600 * 1000));
      //计算相差分钟数
      var leave2 = leave1 % (3600 * 1000);        //计算小时数后剩余的毫秒数
      var minutes = Math.floor(leave2 / 1000); // 秒数
      if(minutes>2000)
      {
        return true;
      }
      return false;
    },
    CheckLogin () {
      var that=this;
      var loginToUrl=that.$parent;
      var enterpriseno=that.sup8.context.enterpriseno;
      var EntranceId=that.sup8.context.entranceid;
      var isLogin = false// 是否登录
    try {
      var openId = '0'
      var userToken = ''
      var enterpriseNo = ''
      var languageType = 'zh-cn'
      if (localStorage.getItem('loginInfo')) {
        var loginInfo = JSON.parse(localStorage.getItem('loginInfo'))
        var wxUserInfo = sessionStorage.getItem('wxUser')
        if (wxUserInfo) {
          wxUserInfo = JSON.parse(sessionStorage.getItem('wxUser'))
          openId = wxUserInfo.openid
        } else {
          openId = loginInfo.OpenId
        }
        userToken = loginInfo.UserToken
        enterpriseNo = loginInfo.EnterpriseNo
        // eslint-disable-next-line eqeqeq
        if (enterpriseno&&enterpriseno.length>0) {
          enterpriseNo = enterpriseno
        }
      }
      // eslint-disable-next-line eqeqeq
      if (userToken=='')
      {
        return false;
      }
    } catch (e) { alert(e) }
    var url = "/channel/GetLoginInfoByUserToken";
    var dataParams = {
      EntranceId: EntranceId,
      EnterpriseNo: enterpriseNo,
      OpenId: openId,
      UserToken: userToken,
      LanguageType: languageType
    };
    var cbError=function(){Indicator.close();}
    var cbSuccess = function(res){
      if (res.flag) {
        // 验证登录成功
        isLogin = true;
      } 
    };
    //请求后端
    channelHelper.CommonCallServiceAuto(url,dataParams,cbSuccess,cbError,null,null);
    return isLogin;
  },
    /* 背景图  */
    updateDom() {  
        var that = this;
        //alert(this.comp.props.bgImg.val);
        // 将当前设置的背景图片加到body标签下
        $(".bannerbg").css({
          "margin-bottom":"2rem",
          "height":"6.4rem",
          "background-repeat": "no-repeat",
          "background-color": "rgb(53, 145, 246)",
          "background-size": "100% 100%",
          "background-image":"url("+this.comp.props.bgImg.val+")"
        });
    }
  },
  components: {
    ElementUI
  },
  watch: {
     "comp.props.bgImg.val": function() {
      this.updateDom();
    }
  },
  created: function() {
      var that=this;
      that.AutoLogin();
      var isDesign = location.pathname.indexOf('design');
      if(isDesign!=-1)
      {
         return;
      }
      if(that.CheckUrlTime()&&isDesign==-1)
      {
        that.isShow.IsshowMask=true;
        that.isShow.IsshowReg=true;
        that.isShow.IsshowRegTime=true;
        return false;
      }else if(isDesign!=-1){
        that.isShow.IsshowMask=false;
        that.isShow.IsshowReg=false;
        return false;
      }
      Indicator.close();
      var eno = that.sup8.context.enterpriseno;
      if (localStorage.getItem('loginInfo') != null) {
        var loginInfo = JSON.parse(localStorage.getItem('loginInfo'))
        var enterpriseNo=loginInfo.EnterpriseNo;
        if (eno==enterpriseNo) {
          //判断是否登录
          if (that.CheckLogin()) {
            this.$parent.changeSelectedPage('Key_HPage');
            return false; 
          }
        }
      }
      var entranceid=this.sup8.context.entranceid;
      var GeoArea=that.sup8.context.geo;
      var latitude="31.86694226";var longitude="117.28269909";
      if(GeoArea)
      {
          latitude=GeoArea.latitude;
          longitude=GeoArea.longitude;
      }
      if(entranceid!="5")
      {
        that.H5KeySetting(entranceid);
      }
     if(entranceid=="1"||entranceid=="")//当关键人类型为店员的时候就读取店员基础设置信息
     {
        if (that.sup8.context.orgid&&that.sup8.context.orgid.length>0) {
          that.GetStoreDrop();
        }else{
          that.GetAreaIDByGps(latitude,longitude);
        }
        that.GetGroupAll();
        that.GetRoleID("3a70c33cd52e4b8f80ac792997e52f7e");//channelHelper.GetUserLoginInfo().OrganizationId
     }
     else if(entranceid=="2")
     {
        that.GetAreaIDByGps(latitude,longitude);
        that.GetRoleID("6cd0883176df4dffb777f06ad689af5a");
        that.isShow.IsshowGrop=false;
     }
     else if(entranceid=="3")
     {   
        that.isShow.IsshowStore=false;that.isShow.IsshowGrop=false;
        that.GetRoleID("6c0ebd2614e74dc1ae260d5aeabacbbb");
     } 
     else if(entranceid=="4")
     {
       that.isShow.IsshowStore=false;that.isShow.IsshowGrop=false;
        that.GetRoleID("2ecfc761e73748c4b488964a9a245147");
     } 
     else if(entranceid=="5")
     {
        that.isShow.IsshowStore=false;that.isShow.IsshowGrop=false;
        that.GetRoleID("eab4401d101b426e8ae36b77bdb3e9a4");
     } 
  },
  mounted: function() {
      var that=this;
      try{
       this.updateDom();
      }catch(e){}
      var isDesign = location.pathname.indexOf('design');
      if (!(isDesign>-1)) {
          that.$set(that.isShow,'vh',true);
      }else{
          that.$set(that.isShow,'vh',false);
      }
      setTimeout(()=>{
        let offsetHeight = document.body.offsetHeight;
        let scrollHeight = document.body.scrollHeight;
        this.height = scrollHeight>offsetHeight?scrollHeight+"px":offsetHeight+"px";
      },1000);
  }
};
</script>

