锘縞onst app = Vue.createApp({ data() { return { code: "", device: 1, smsCount: 0, mobile: "", oneCode: "", password: "", isShow: true, isAgree: true, codeTip: "", mobileTip: "", passwordTip: "", codeText: "鑾峰彇楠岃瘉鐮?, twoWeekAutoLogin: false } }, created() { this.device = this.getDevice(); }, methods: { wxScanLogin(domId, appid, redirect_uri) { let code = new WxLogin({ self_redirect: true, id: domId, appid: appid, scope: "snsapi_login", redirect_uri: redirect_uri, state: 1, style: "block", href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O21hcmdpbi10b3A6MHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLnN0YXR1c19pY29uIHtkaXNwbGF5OiBub25lfQouaW1wb3dlckJveCAuc3RhdHVzIHt0ZXh0LWFsaWduOiBjZW50ZXI7fQouaW1wb3dlckJveCAuaW5mbyB7ZGlzcGxheTogbm9uZTt9" }); }, inputPws(event) { if(event.keyCode == 13) { this.login(); return; } }, login(isAgentLogin, agentDomain) { const that = this; if (!that.mobile) { that.mobileTip = "璇疯緭鍏ユ墜鏈哄彿鐮?; return; } if (!/^1[\d]{10}$/.test(that.mobile)) { that.mobileTip = "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜"; return; } if (!that.password) { that.passwordTip = "璇疯緭鍏ュ瘑鐮?; return; } var param = { pws: that.password, mobile: that.mobile, isAgentLogin: isAgentLogin?true:false, keepTwoWeek: that.twoWeekAutoLogin, agentInviteCode: util.queryString("inviteCode"), } util.post("/UserApi/Login", param, (data) => { if (data.result != 1) { util.showMsg(data.data); return; } if (isAgentLogin) { //鏈嶅姟鍟嗙櫥褰曪紝绱檸瀹樼綉鍙兘鐧诲綍鏈嶅姟鍟嗕腑鍙 util.syncLogin(agentDomain, data.data.loginToken, () => { document.location.href = agentDomain; },null,"isTwoWeek=" + that.twoWeekAutoLogin); return; } var d = new Date(); if (this.twoWeekAutoLogin) { d.setDate(d.getDate() + data.data.validTime/60/24); d.setMinutes(d.getMinutes() - 1); localStorage.setItem("_login", JSON.stringify({ "token": data.data.loginToken, "name": data.data.name, "image": data.data.image, "expireTime": d })); } else { d.setMinutes(d.getMinutes() + 290); localStorage.setItem("_login", JSON.stringify({ "token": data.data.loginToken, "name": data.data.name, "image": data.data.image, "expireTime": d })); } if (!util.isNullOrEmpty(util.queryString("inviteCode"))) { location.href = "/inviteSuccess.html"; return; } var url = util.queryString("return"); if (util.isNullOrEmpty(url)) { location.href = "/"; return; } else { location.href = url; return; } }); }, wxLogin(appid, host, isAgentLogin) { var redirect_uri = "https://" + host + "/Callback/WeiXinLoginCallback"; var param = ""; if (isAgentLogin) { if (util.isNullOrEmpty(param)) { redirect_uri += "?isAgentLogin=true"; } else { redirect_uri += "&isAgentLogin=true"; } } var agentInviteCode = util.queryString("inviteCode"); if (!util.isNullOrEmpty(agentInviteCode)) { if (util.isNullOrEmpty(param)) { redirect_uri += "?agentInviteCode=" + agentInviteCode; } else { redirect_uri += "&agentInviteCode=" + agentInviteCode; } } var returnUrl = util.queryString("return"); if (!util.isNullOrEmpty(returnUrl)) { if (util.isNullOrEmpty(param)) { redirect_uri += "?returnUrl=" + returnUrl; } else { redirect_uri += "&returnUrl=" + returnUrl; } } redirect_uri = encodeURIComponent(redirect_uri); if (this.device == 3) { var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&connect_redirect=1&state=2#wechat_redirect"; location.href = url; } else if (this.device == 1) { this.wxScanLogin("wx_login_container", appid, redirect_uri); document.getElementsByClassName("weixin-tc")[0].style.display = "block"; } }, getDevice() { var device = 1; if (document.documentElement.clientWidth <= 768) { device = 2; } if (device == 2 && /MicroMessenger/i.test(window.navigator.userAgent)) { device = 3; } return device; }, // ***** 娉ㄥ唽浼佷笟浼氬憳 ***** getSmsCode() { const that = this; //鍒ゆ柇鎵嬫満鍙 if (!/^1[\d]{10}$/.test(that.mobile)) { that.mobileTip = "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜"; return; } var tipCode = document.getElementsByClassName("forget-one-tip-code")[0]; //楠岃瘉鐮佹牎楠 if (that.oneCode.length != 4) { tipCode.style.display = "block" return; } else { tipCode.style.display = "none" } util.post("/User/CheckSessionCode", { 'mobile': that.mobile, 'code': that.oneCode }, function (data) { if (data.result != 1) { util.showMsg(data.data); changeCode(); return; } var leftTime = 60; var timer = setInterval(function () { leftTime--; that.codeText = '閲嶆柊鍙戦€?' + leftTime + ')绉?; if (leftTime == 0) { that.smsCount = 0; clearInterval(timer); that.codeText = '閲嶆柊鍙戦€?; } }, 1000); that.smsCount += 1; util.post("/UserApi/RegitSendMobileCode", { 'mobile': that.mobile, 'thirdPlatformType': 0 }, //鍙戣捣璇锋眰 function (data) { if (data.result != 1) { that.smsCount = 0; leftTime = 60; clearInterval(timer); that.codeText = '閲嶆柊鍙戦€?; util.showMsg(data.data); return; } } ); }); }, registerClick() { const that = this; if (!that.isAgree) { util.showMsg("璇峰厛闃呰骞跺悓鎰忕传铏庢敞鍐屾湇鍔″崗璁強闅愮绛栫暐"); return; } //鍒ゆ柇鎵嬫満鍙 if (!/^1[\d]{10}$/.test(that.mobile)) { that.mobileTip = "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜"; return; } //楠岃瘉鐮佹牎楠 if (!that.code) { that.codeTip = "璇疯緭鍏ョ煭淇¢獙璇佺爜"; return; } if (!that.password) { that.passwordTip = "璇疯緭鍏ュ瘑鐮?; return; } if (!util.checkPassWord(that.password)) { that.passwordTip = "瀵嗙爜鐢?-16浣嶅瓧姣?鏁板瓧缁勬垚锛屽尯鍒嗗ぇ灏忓啓"; return; } var param = { mobile: that.mobile, inputCode: that.code, password: that.password, isAgentLogin: false, inviteCode: util.queryString("inviteCode"), } util.post("/UserApi/CommitRegiste", param, function (data) { if (data.result != 1) { util.showMsg(data.data); return; } var d = new Date(); d.setMinutes(d.getMinutes() + 290); localStorage.setItem("_login", JSON.stringify({ "token": data.data.loginToken, "name": data.data.name, "image": data.data.image, "expireTime": d })); location.href = '/register/success.html'; }); }, //鐢宠鏈嶅姟鍟 serviceRegisterClick() { const that = this; if (!that.isAgree) { util.showMsg("璇峰厛闃呰骞跺悓鎰忕传铏庢敞鍐屾湇鍔″崗璁強闅愮绛栫暐"); return; } if (!/^1[\d]{10}$/.test(that.mobile)) { that.mobileTip = "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜"; return; } //楠岃瘉鐮佹牎楠 if (!that.code) { that.codeTip = "璇疯緭鍏ョ煭淇¢獙璇佺爜"; return; } if (!that.password) { that.passwordTip = "璇疯緭鍏ュ瘑鐮?; return; } if (!util.checkPassWord(that.password)) { that.passwordTip = "瀵嗙爜鐢?-16浣嶅瓧姣?鏁板瓧缁勬垚锛屽尯鍒嗗ぇ灏忓啓"; return; } var param = { mobile: that.mobile, inputCode: that.code, password: that.password, isAgentLogin: false, inviteCode: util.queryString("inviteCode"), } util.post("/UserApi/CommitRegiste", param, function (data) { if (data.result != 1) { util.showMsg(data.data); return; } var d = new Date(); d.setMinutes(d.getMinutes() + 290); localStorage.setItem("_login", JSON.stringify({ "token": data.data.loginToken, "name": data.data.name, "image": data.data.image, "expireTime": d })); location.href = "/applyservice/information.html"; }); } } }).mount("#app");