var _Tok = JSON.parse(localStorage.getItem("_yz_TT")).yzTok; var nowId = null,Type=null; var timeObj = { "plat_1":null, "term_1":null }; var timeNum = { "plat_1":60, "term_1":60 }; // 请求手机号列表 function getPhone(_type,_cab){ Type = _type; $.ajax({ url: vipUrl +"/equipmentPhone/equipmentPhone/list?equipmentNum="+nowId, type: "GET", dataType: "JSON", async: false, //同步请求 data:{}, headers:{ "Authorization":"Bearer "+_Tok }, error: function(XMLHttpRequest) { console.log(11111) }, success:function (res) { if(res.code == 200&&res.rows.length){ _cab(res.rows[0]); }else{ _cab([]); } } }) } // 添加联系人 $(document).on("click",".bind .icon-jia",function(){ let _list = $("."+$(this).data("ty")+"li").children().length; let _sbl = $(this).siblings(); let _na = $(this).data("ty")+"_"+(_list+1); if(_sbl.is(":hidden")){ _sbl.css("display","inline-block") } let _strPh = `
联系人${_list+1}:
`; let _strPc = `
联系人${_list+1}:
` $("."+$(this).data("ty")+"li").append(Type == "main"?_strPc:_strPh); timeObj[_na] = null; timeNum[_na] = 60; }); // 删除联系人 $(document).on("click",".bind .icon-jian",function(){ let _list = $("."+$(this).data("ty")+"li").children().length; if(_list == 2){ $(this).css("display","none"); } let _fat = $("."+$(this).data("ty")+"li>div:last"); _fat.remove(); }); function getInpVal(_arr){ let _obj = []; $.each(_arr,function(index,e){ let _inp = $(e).find("input"); _obj.push([_inp[0].value,_inp[1].value]) }) return _obj; } // 发送验证码 $(document).on("click",".code_ button",function(){ let _id = $(this).attr("name"); if(timeObj[_id] == null){ let _pho = $("input[name='"+_id+"']").val(); if(_pho == ""){ ShowLoading("请先填写手机号!",1); return; } if(!(/^1[3456789]\d{9}$/.test(_pho))){ ShowLoading('手机号码有误,请重填',1); return; } $.ajax({ url: vipUrl +"/equipmentPhone/equipmentPhone/sendCode", type: "GET", dataType: "JSON", async: false, //同步请求 data:{ "phone":_pho }, headers:{ "Authorization":"Bearer "+_Tok }, error: function(XMLHttpRequest) { console.log(11111) }, success:function (res) { if(res.result=="ok"){ timeObj[_id] = setInterval(()=>{ if(timeNum[_id] < 0){ clearInterval(timeObj[_id]); timeObj[_id] = null; timeNum[_id] = 60; $("button[name='"+_id+"']").text("发送验证码"); }else{ $("button[name='"+_id+"']").text(timeNum[_id] + "s重发"); timeNum[_id] --; } },1000); ShowLoading("验证码发送成功!",1); }else{ ShowLoading("验证码发送失败!",1); } } }) } }) // 提交绑定手机号 $("button[name='confirm']").on("click","",function(){ setPhone("/equipmentPhone/add"); }); var _platli="",_termli=""; // 绑定手机号接口 function setPhone(_url,_Pid){ _platli="",_termli=""; let platObj = getInpVal($(".platli>div")); let termObj = getInpVal($(".termli>div")); let _last = 0,_len = platObj.length + termObj.length, _lastT = false; for(var i=0;i