<style scoped>
.comp-classpage input,.comp-classpage textarea,.comp-classpage select,.comp-classpage button{padding:0;}
hr {margin: 0;border: 0.17rem solid #e6e6e9;}
.comp-classpage{height:100%;height: 100vh;}
.Key_ExchangeManager{padding:5% 4%; }
.Key_ExchangeManager div {display:flex; margin-top:0;padding:0.4rem 0;border-bottom: 1px solid #DEDEDE;line-height: 3rem; height: 3rem;}
.Key_ExchangeManager div span{text-align:center;padding:0.3rem 0.5rem;}
.Key_ExchangeManager div input{text-indent:0.3rem; background-color: #fff;border:0px;flex:1;outline:none;color:#000;}
.Key_ExchangeManager img{width:0.9rem;height:1rem;}

.item-btn {display:inline-block;width:85%;height:2.5rem;padding:0;
margin:0 7%;margin-top:0px;margin-bottom:0px;font-size:1rem;
line-height:2.5rem;text-align:center;color:#fff;
background:#3A8AFB;border:none;border-radius:0.2rem;
margin-top:1.5rem;margin-bottom:1rem; font-weight: bold;}
input[type=button],button, input[type=submit], input[type=file], button {cursor:pointer;outline:0px; -webkit-appearance:none; }

</style>
<template>
<div class="container comp-classpage jfBaseSize" v-cloak v-bind:style="vh?'height:100vh':'height: 100%;'">
    <div id="Key_ExchangeManager" class="Key_ExchangeManager">
          <div>
        <span><img src="http://image.supercarrier8.com/h5_key/icon-user-gray.png" /></span>
        <input type="text"  class="inp" name="NickName" id="NickName" placeholder="请输入姓名" v-model="NickName" maxlength="10" minlength="1" autocomplete="off">
      </div>
      <div>
        <span><img src="http://image.supercarrier8.com/h5_key/icon-tel-gray.png" /></span>
        <input type="text"  class="inp" name="Mobile" id="Mobile" placeholder="请输入手机号" v-model="Mobile" maxlength="11" autocomplete="off"/>
    </div>
    </div>
<button class="item-btn"  @click="saveExchange()">确认提交</button>
 <ReturnHome ref="returnhome"></ReturnHome>
</div>
</template>
<script> 
	import $ from 'jquery'
	import channelHelper from "@/assets/js/channelHelper.js";
	import MintUI from 'mint-ui';
    import ReturnHome from "@/components/channel/temp001/ReturnHome";
	export default {
	name: 'Key_ExchangeManager',
	components: {ReturnHome},
    provide(){       
     return{           
        goPage:this.goPage       
     }   
    },
	props: ["cfg", "comp", "selectedPage"],
	data() {
      var that = this;
      var StroeID="";
      var NickName="";
      var Mobile="";
      var OldMobile="";

      return {
        StroeID:StroeID,
        NickName: NickName,
        Mobile:Mobile,
        OldMobile:OldMobile,
				vh:false,
			};
		},
		methods: {    
			goPage:function(pagetype){
				this.$parent.changeSelectedPage(pagetype);
			},
			judgeLogin:function(){
				var eno = this.sup8.context.enterpriseno;
				if (!channelHelper.CheckLogin(this.$parent,eno,this.sup8.context.entranceid)) {
					this.$parent.changeSelectedPage('Key_Login');
					return false;
				}
			},
			//提交确认
			saveExchange() {
				var location=this.$parent;
				var that = this;
				var eno=that.sup8.context.enterpriseno;
				var confirmBtn = $(".item-btn");
				var NickNameObj = $("#NickName");
				var MobileObj = $("#Mobile");
				var data = JSON.parse(sessionStorage.getItem("AgentStoreManager"));
				var tempOldMobile = data.TELEPHONE;
				var tempStroeID =  data.ID;
				var tempNickName = $.trim(NickNameObj.val());
				var tempMobile = $.trim(MobileObj.val());
				if (tempNickName == "") {
					MintUI.Toast('请输入姓名！');
					return false;
				}
				if (!/^1[3456789]\d{9}$/.test(tempMobile)) {
					MintUI.Toast("请输入正确的店长手机号!");
					return false;
				}
	
					//判断是否登录
					//if (!channelHelper.CheckLogin(this.$parent,eno)) {
						//return false;
					//}
					//console.log(that.loginUserInfo);
					//替换店长
				var url = "/channel/StoreManagerExchange";
				var dataParams = {
					UserToken:channelHelper.GetUserToken(),
					StroeID:tempStroeID,
					EnterpriseNo: eno,
					Name: tempNickName,
					Phone:tempMobile,
					Oldphone:tempOldMobile,
					LanguageType:channelHelper.GetLanguageType()
				};
				var cbBeforeSend = function () {
					confirmBtn.val("请稍等...");
				};
				var cbComplete = function () {
					confirmBtn.val("确定");
				};
				var cbSuccess = function (resultData) {
					if (resultData.flag) {
						MintUI.Toast('提交成功！');
						location.changeSelectedPage("A_StoreV");
					}
					else {
						MintUI.Toast(resultData.msg);
					}
				};
				var cbError = function (jqXHR, textStatus, errorThrown) {
					MintUI.Toast(jqXHR.responseText);
				};
				//请求后端
				channelHelper.CommonCallServiceAuto(url, dataParams, cbSuccess, cbError, cbBeforeSend, cbComplete);
			}
		},
		created() {
			var that=this;
			 var isDesign = location.pathname.indexOf('design');
			if(isDesign!=-1)
			{
				return;
			}
			var data = JSON.parse(sessionStorage.getItem("AgentStoreManager"));
			if(data)
			{
				that.NickName=data.Name;
				that.Mobile=data.Mobile;
			}
			//判断是否登录
    		that.judgeLogin();
			var isDesign = location.pathname.indexOf('design');
			if (!(isDesign>-1)) {
				that.$set(that,'vh',true);
			}else{
				that.$set(that,'vh',false);
			}
		},
		mounted: function () { 
			
		}
	}
</script>
