(function(){var n="https://int.xxpie.com",t="/api/photographer/mine/sendSMSVerificationCode",e="/api/photographer/mine/signInV4",o="/api/ps/mine/getPSPluginVersion";var i=require("jsonwebtoken");var r=window.localStorage.getItem("token");var a=new CSInterface;var s=new Vue({el:"#root",data:{photo:"",timeout:"获取验证码",phone:window.localStorage.getItem("username"),vcode:"",currentVersionCode:14,is_used:true,versionInfo:{},signIn:"登录/注册",errMsg:""},methods:{getVCode:function(){if(s.is_used){if(this.timeout==="获取验证码"){var e=60;s.timeout=e+"s";var o=setInterval(function(){e--;s.timeout=e+"s";if(e===0){clearInterval(o);s.timeout="获取验证码"}},1e3);axios.post(n+t,{mobile:s.phone,type:"PHOTOGRAPHER_SIGN_IN"}).then(function(e){console.log("验证码已发送");if(e.data.is_exist_user==0){s.signIn="注册"}else if(e.data.is_exist_user==1){s.signIn="登录"}}).catch(function(e){clearInterval(o);s.errMsg="获取验证码失败";s.timeout="获取验证码";s.showError();alert(e)})}}},login:function(){if(s.is_used){if(s.vcode.length===4){axios.post(n+e,{username:s.phone,verificationCode:s.vcode,platform:"PSPLUGIN"}).then(function(e){window.localStorage.setItem("token",e.data.token);window.localStorage.setItem("username",s.phone);window.location.replace("./main.html")}).catch(function(e){console.log(e);s.errMsg=e.response.data.errMsg;s.showError()})}else{alert(s.vcode.length)}}},checkUpdate:function(){axios.get(n+o).then(function(e){if(e.status==200){s.versionInfo=e.data;console.info(s.versionInfo);if(s.versionInfo.version_code>s.currentVersionCode&&s.versionInfo.is_forced_update==1){s.is_used=false}else{i.verify(r,"yijiarenonline",function(e,o){if(e){window.localStorage.removeItem("token");window.localStorage.removeItem("username")}else{window.location.replace("./main.html")}})}}}).catch(function(e){if(e.statusCode===403){window.localStorage.removeItem("token");window.localStorage.removeItem("username");window.location.replace("./index.html")}})},updateNow:function(){a.openURLInDefaultBrowser(s.versionInfo.version_url)},showError:function(){var e=document.getElementById("signInFail");e.style.opacity=1;var o=0;var n=setInterval(function(){if(o===100){clearInterval(n)}o++;e.style.opacity=1-1/100*o},30)}}})})();