webpackJsonp([18],{"0/wi":function(e,i,a){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=a("SQ4B"),r=a("vGYV"),n=a("qI5z"),o={name:"BindingMail",data:function(){return{mailBindingForm:{mail:"",verifyCode:""},loading:!1,hasVerifyCode:!1,codeTime:60,user:{},rules:{verifyCode:[{required:!0,message:"请输入验证码",trigger:"blur"},{min:6,max:6,message:"验证码长度为6个字符",trigger:"blur"}],mail:[{required:!0,message:"请输入邮箱",trigger:"blur"},{validator:function(e,i,a){i?/^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/.test(i)?a():a(new Error("请输入正确的邮箱格式")):a()},trigger:"blur"}]}}},methods:{setUserInfo:function(){var e=this,i=Object(r.J)("user")&&Object(r.J)("user").userVO.id;t.a.get("/api/user/"+i).then(function(i){e.user=i.userVO})},getVerifyCode:function(){var e=this,i={id:this.user.id,email:this.mailBindingForm.mail};t.a.put("/api/verify/email",i).then(function(i){if("ERROR"==i.msg)Object(n.a)("error",i.data);else{Object(n.a)("success",i.data),e.hasVerifyCode=!0;var a=e,t=setInterval(function(){a.codeTime>0?a.codeTime--:(clearInterval(t),a.hasVerifyCode=!1,this.codeTime=10)},1e3)}}).catch(function(e){Object(n.a)("error","获取验证码失败:"+e.data)})},bindingEmail:function(){var e=this;this.$refs.mailBindingForm.validate(function(i){if(!i){e.showLoading();var a={id:e.user.id,email:e.mailBindingForm.mail,verifyCode:e.mailBindingForm.verifyCode};t.a.put("/api/user/email",a).then(function(i){e.hideLoading(),"ERROR"==i.msg?(Object(n.a)("error","绑定失败:"+i.data),e.codeTime=60,e.hasVerifyCode=!1):(Object(n.a)("success","绑定成功"),e.$router.push({path:"/personal/mailBinding"}))}).catch(function(i){e.hideLoading(),Object(n.a)("error",i.data)})}})},showLoading:function(){this.loading=!0},hideLoading:function(){this.loading=!1}},mounted:function(){this.setUserInfo()}},l={render:function(){var e=this,i=e.$createElement,a=e._self._c||i;return a("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticStyle:{"margin-top":"20px"}},[a("el-form",{staticStyle:{width:"400px"},attrs:{"label-width":"80px",rules:e.rules,model:e.mailBindingForm}},[a("el-form-item",{attrs:{label:"邮箱号",prop:"mail"}},[a("el-input",{model:{value:e.mailBindingForm.mail,callback:function(i){e.$set(e.mailBindingForm,"mail",i)},expression:"mailBindingForm.mail"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"验证码",prop:"verifyCode"}},[a("el-input",{staticClass:"input-with-select",attrs:{placeholder:"验证码内容"},model:{value:e.mailBindingForm.verifyCode,callback:function(i){e.$set(e.mailBindingForm,"verifyCode",i)},expression:"mailBindingForm.verifyCode"}},[a("el-button",{attrs:{slot:"append",disabled:e.hasVerifyCode},on:{click:e.getVerifyCode},slot:"append"},[e._v(e._s(e.hasVerifyCode?e.codeTime:"获取验证码"))])],1),e._v(" "),e.hasVerifyCode?a("span",[e._v("验证码已发送到您邮箱上")]):e._e()],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary",plain:""},on:{click:e.bindingEmail}},[e._v("完成绑定")])],1)],1)],1)},staticRenderFns:[]};var s=a("VU/8")(o,l,!1,function(e){a("lKQm")},"data-v-ca216cea",null);i.default=s.exports},lKQm:function(e,i){}});