//import * as WxJsApi from '@/utils/wxJsApi.js' import * as API from '@/apis/login.js' import ResumeAuth from '@/components/job/ResumeAuth.vue' import { checkPhone } from '@/utils' export default { data() { return { test:process.env.NODE_ENV === "development", phone:"", isReady:false, vcode:"", error:"", second:"", password:"", maxlength:6, value:"", show:"", isSendMsgIng: false, sendMsgSecond: 60*2, tel:'', tab:0, message:"", backUrl:"", form:"", readme:true, isReady:false, auth:false, authData:{ } } }, components: { ResumeAuth }, onLoad(op){ this.form=op.form; if(this.form=="hr"){ this.tab=2 } if(this.form=="job"){ this.tab=1 } this.message=op.message; this.backUrl=op.back; console.log(op) }, computed: { inputStyle() { let style = {}; if(this.tel) { style.color = "#fff"; style.backgroundColor = this.$u.color['primary']; } return style; } }, methods: { finish(e){ if(!this.carhelp.getOpenId()){ uni.showToast({ title:"请使用“微信”访问本系统登录" }) return } uni.showLoading({ title:"加载中",mask:true, }) API.validateCode({ verifyCode: e, telephone:this.tel, openId:this.carhelp.getOpenId(), form:this.form }).then((response) => { this.loginOk(response); }).catch(error => { uni.showToast({ title:error, icon:"none" }) }) }, showphone(phone){ if(!phone){ return ""; } if(phone.length!=11){ return ""; } return phone.substring(0,3)+'****'+phone.substring(8); }, login2(){ if (!this.readme) { uni.showToast({ title: "请阅读并同意《用户协议》《隐私政策》", }) } var time= this.carhelp.get("getvcodetime"); if(time){ var nowtime= new Date().getTime() var differ=(nowtime-time)/1000 if(differ<2*60){ this.sendMsgSecond=2*60 - parseInt(differ) this.tab=4; this.msgTimeInterval(); } } if (!this.isSendMsgIng) { var checkPhoneResult = checkPhone(this.tel); if(checkPhoneResult!==true){ uni.showToast({ title: checkPhoneResult, }) return; }else{ uni.showLoading({ title:"加载中",mask:true, }) API.getVerifyCode(this.tel).then((response) => { this.tab=4; uni.hideLoading(); this.carhelp.set("getvcodetime",new Date().getTime()); this.tab=4; if(!""){ //response.message //倒计时 this.msgTimeInterval(); }else{ uni.showToast({ title:"您的验证码已经发送[5分钟有效],请勿重复点击" }) } }).catch(error => { uni.showToast({ title:error, icon:"none" }) }) } } }, //倒计时 msgTimeInterval() { this.isSendMsgIng = true; var time = this.sendMsgSecond; var _this = this; this.timer = setInterval(() => { if (time > 0) { _this.sendMsgSecond = time--; } else { _this.isSendMsgIng = false; _this.sendMsgSecond = 2*60; clearInterval(_this.timer) } }, 1000) }, login3(){ if(!this.carhelp.getOpenId()){ uni.showToast({ title:"请使用“微信”访问本系统登录" }) return } //var checkPhoneResult = checkPhone(this.tel); // if(checkPhoneResult!== true){ // uni.showToast({ // title: checkPhoneResult, // }) // return; // } if(!this.tel){ uni.showToast({ title: "请输入账号", }) return; } if(!this.password){ uni.showToast({ title: "请输入密码", }) return; } uni.showLoading({ title:"加载中",mask:true, }) API.passwordLogin({ phone:this.tel, password:this.password, openId:this.carhelp.getOpenId(), form:this.form }).then((response) => { this.loginOk(response) }).catch(error => { uni.showToast({ title:error, icon:"none" }) }) }, loginOk(response){ var token = response ? response.data.token : ''; this.carhelp.setToken(token); if("job"==this.form){ this.carhelp.setPersonInfo(response.data.jobUser ); if(["1","2"].indexOf(response.data.jobUser.isAuthentication)>-1){ this.loginBack(); }else{ uni.hideLoading(); this.auth=true; } } if("hr"==this.form){ this.carhelp.setPersonInfo(response.data.sysUser ); this.loginBack(); } }, loginBack(){ if(this.backUrl){ window.location.href="#"+this.backUrl.split(",").find(function(item){ return item.indexOf("pages/login/")==-1 }); }else{ this.gotoUrl("pages/"+this.form+"/index/index") } }, login(){ if(!this.carhelp.getOpenId()){ uni.showToast({ title:"请使用“微信”访问本系统登录" }) return } if(!this.readme){ uni.showToast({ title:"请阅读并同意《用户协议》《隐私政策》", icon:"none" }) }else{ uni.showLoading({ title: '加载中' }); API.wechatLogin({ openId:this.carhelp.getOpenId(), form:this.form }).then((response) => { this.loginOk(response) }).catch(error => { uni.showToast({ title:error, icon:"none" }) }) } } },onReady(){ if(this.message){ uni.showToast({ title:this.message.split(",")[0], icon:"none" }) } if(!this.carhelp.getOpenId()){ uni.showToast({ title:"请使用“微信”访问本系统登录" }) } this.isReady=true; },onShow(){ if(this.isReady){ } }, }