webpackJsonp([21],{"4z3q":function(e,i,n){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var o=n("SQ4B"),t=n("vGYV"),r=n("qI5z"),a={name:"ReBindingMobile",data:function(){return{loading:!1,active:0,user:{},phoneBindingForm:{phone:"",verifyCode:"",newPhone:""},hasVerifyCode:!1,codeTime:60,rules:{verifyCode:[{required:!0,message:"请输入验证码",trigger:"blur"},{min:6,max:6,message:"验证码长度为6个字符",trigger:"blur"}],phone:[{required:!0,message:"请输入手机号",trigger:"blur"}],newPhone:[{required:!0,message:"请输入手机号",trigger:"blur"},{min:11,max:11,message:"手机号不合法",trigger:"blur"}]}}},methods:{setUserInfo:function(){var e=this,i=Object(t.J)("user")&&Object(t.J)("user").userVO.id;o.a.get("/api/user/"+i).then(function(i){e.user=i.userVO,e.phoneBindingForm.phone=e.user.mobile})},reBindingMobile:function(){var e=this;if(this.showLoading(),0===this.active){var i={id:this.user.id,mobile:this.user.mobile,verifyCode:this.phoneBindingForm.verifyCode};o.a.put("/api/verify/old/mobile",i).then(function(i){e.hideLoading(),2e4===i.code?(Object(r.a)("success","验证成功"),e.active=1,e.phoneBindingForm.phone="",e.phoneBindingForm.verifyCode="",e.hasVerifyCode=!1,e.codeTime=60,e.setUserInfo()):(Object(r.a)("error","验证原手机失败:"+i.data),e.codeTime=60,e.hasVerifyCode=!1)}).catch(function(i){e.phoneBindingForm.phone="",e.phoneBindingForm.verifyCode="",e.codeTime=60,e.hasVerifyCode=!1,e.hideLoading(),Object(r.a)("error","验证原手机失败:"+i.data)})}else{var n={id:this.user.id,mobile:this.phoneBindingForm.newPhone,verifyCode:this.phoneBindingForm.verifyCode};o.a.put("/api/user/mobile",n).then(function(i){e.hideLoading(),"ERROR"==i.msg?Object(r.a)("error","绑定失败:"+i.data):(Object(r.a)("success","绑定成功"),e.$router.push({path:"/personal/phoneBinding"}))}).catch(function(i){e.hideLoading(),Object(r.a)("error","绑定失败:"+i.data)})}},getVerifyCode:function(){var e=this;if(0===this.active){var i={id:this.user.id,mobile:this.phoneBindingForm.phone};o.a.put("/api/verify/mobile",i).then(function(i){var n=e;if("ERROR"==i.msg)Object(r.a)("error","验证码获取失败:"+i.data);else{e.hasVerifyCode=!0,Object(r.a)("success",i.data);var o=setInterval(function(){n.codeTime>0?n.codeTime--:(clearInterval(o),n.hasVerifyCode=!1,this.codeTime=10)},1e3)}}).catch(function(e){Object(r.a)("error","获取验证码失败:"+e.data)})}else{var n={id:this.user.id,mobile:this.phoneBindingForm.newPhone};o.a.put("/api/verify/mobile",n).then(function(i){var n=e;if("ERROR"==i.msg)Object(r.a)("error","验证码获取失败:"+i.data);else{e.hasVerifyCode=!0,Object(r.a)("success",i.data);var o=setInterval(function(){n.codeTime>0?n.codeTime--:(clearInterval(o),n.hasVerifyCode=!1,this.codeTime=10)},1e3)}}).catch(function(e){Object(r.a)("error","获取验证码失败:"+e.data)})}},showLoading:function(){this.loading=!0},hideLoading:function(){this.loading=!1}},mounted:function(){this.setUserInfo()}},s={render:function(){var e=this,i=e.$createElement,n=e._self._c||i;return n("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}]},[n("el-steps",{staticStyle:{margin:"20px"},attrs:{active:e.active,"process-status":"finish"}},[n("el-step",{attrs:{title:"验证原手机"}}),e._v(" "),n("el-step",{attrs:{title:"绑定新手机"}})],1),e._v(" "),n("el-form",{ref:e.phoneBindingForm,staticStyle:{width:"400px"},attrs:{"label-width":"80px",rules:e.rules,model:e.phoneBindingForm}},[0===e.active?n("el-form-item",{attrs:{label:"原手机号",prop:"phone"}},[n("span",{model:{value:e.phoneBindingForm.phone,callback:function(i){e.$set(e.phoneBindingForm,"phone",i)},expression:"phoneBindingForm.phone"}},[e._v(e._s(this.user.mobile))])]):e._e(),e._v(" "),1===e.active?n("el-form-item",{attrs:{label:"新手机号",prop:"newPhone"}},[n("el-input",{model:{value:e.phoneBindingForm.newPhone,callback:function(i){e.$set(e.phoneBindingForm,"newPhone",i)},expression:"phoneBindingForm.newPhone"}})],1):e._e(),e._v(" "),n("el-form-item",{attrs:{label:"验证码",prop:"verifyCode"}},[n("el-input",{staticClass:"input-with-select",attrs:{placeholder:"验证码内容"},model:{value:e.phoneBindingForm.verifyCode,callback:function(i){e.$set(e.phoneBindingForm,"verifyCode",i)},expression:"phoneBindingForm.verifyCode"}},[n("el-button",{attrs:{slot:"append",disabled:e.hasVerifyCode},on:{click:e.getVerifyCode},slot:"append"},[e._v(e._s(e.hasVerifyCode?e.codeTime:"获取验证码")+"\n ")])],1),e._v(" "),e.hasVerifyCode?n("span",[e._v("验证码已发送到您手机上")]):e._e()],1),e._v(" "),n("el-form-item",[n("el-button",{attrs:{type:"primary",plain:""},on:{click:e.reBindingMobile}},[e._v(e._s(0===this.active?"下一步":"完成绑定")+"\n ")])],1)],1)],1)},staticRenderFns:[]};var d=n("VU/8")(a,s,!1,function(e){n("sv6S")},"data-v-9682d8a6",null);i.default=d.exports},sv6S:function(e,i){}});