var $url="/profile",$urlUpload="/profile/actions/upload",$urlSendSms="/profile/actions/sendSms",$urlVerifyMobile="/profile/actions/verifyMobile",data=utils.init({uploadUrl:null,uploadFileList:[],isSmsEnabled:!1,isUserVerifyMobile:!1,user:null,form:null,styles:null,mobileValidateRules:null,countdown:0}),methods={apiGet:function(){var i=this;$api.get($url).then(function(e){var t=e.data;i.isSmsEnabled=t.isSmsEnabled,i.isUserVerifyMobile=t.isUserVerifyMobile,i.user=t.user,i.form=_.assign({},t.user,{code:""}),i.styles=t.styles,i.isUserVerifyMobile?i.mobileValidateRules=[{required:!0,message:"请输入手机号码"},{validator:utils.validateMobile,message:"请输入有效的手机号码"}]:i.mobileValidateRules=[{validator:utils.validateMobile,message:"请输入有效的手机号码"}],i.form.avatarUrl&&i.uploadFileList.push({name:"avatar",url:i.form.avatarUrl})}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},apiSendSms:function(){var i=this;utils.loading(this,!0),$api.post($urlSendSms,{mobile:this.form.mobile}).then(function(e){e.data;utils.notifySuccess("验证码发送成功，10分钟内有效"),i.countdown=60;var t=setInterval(function(){i.countdown-=1,i.countdown<=0&&clearInterval(t)},1e3)}).catch(function(i){utils.notifyError(i)}).then(function(){utils.loading(i,!1)})},apiVerifyMobile:function(){var i=this;utils.loading(this,!0),$api.post($urlVerifyMobile,{mobile:this.form.mobile,code:this.form.code}).then(function(e){i.form.mobileVerified=!0,i.apiSubmit()}).catch(function(e){utils.loading(i,!1),utils.notifyError(e)})},apiSubmit:function(){var i=this;delete _.assign({},this.form).code,utils.loading(this,!0),$api.post($url,this.form).then(function(i){utils.success("资料修改成功！")}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},isMobile:function(i){return/^1[3|4|5|7|8][0-9]\d{8}$/.test(i)},btnSendSmsClick:function(){this.countdown>0||(this.form.mobile?this.isMobile(this.form.mobile)?this.apiSendSms():utils.notifyError("请输入有效的手机号码"):utils.notifyError("手机号码不能为空"))},btnSubmitClick:function(){var i=this;this.$refs.form.validate(function(e){e&&(i.isMobileCode?i.apiVerifyMobile():i.apiSubmit())})},uploadBefore:i=>/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.webp)$/i.exec(i.name)?!!(i.size/1024/1024<10)||(utils.error("头像图片大小不能超过 10MB!"),!1):(utils.error("头像只能是图片格式，请选择有效的文件上传!"),!1),uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(i,e,t){this.form.avatarUrl=i.value,utils.loading(this,!1),t.length>1&&t.splice(0,1)},uploadError:function(i){utils.loading(this,!1);var e=JSON.parse(i.message);utils.error(e.message)},uploadRemove(i){this.form.avatarUrl=null}},$vue=new Vue({el:"#main",data:data,methods:methods,computed:{isMobileCode:function(){return this.isUserVerifyMobile?!this.user.mobileVerified||this.user.mobile!==this.form.mobile:!!this.isSmsEnabled&&this.user.mobile!==this.form.mobile}},created:function(){this.uploadUrl=$apiUrl+$urlUpload,this.apiGet()}});