|
@@ -4,13 +4,12 @@ var loginPage = new Vue({
|
|
|
maxtime:60,
|
|
|
loginLoading: false,
|
|
|
qrCodeLogin: false,
|
|
|
- loginAccount: '',
|
|
|
- loginPassword: '',
|
|
|
rule:{
|
|
|
account: "(^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$)|(^\\d{6,12}$)",
|
|
|
password: "^[^\\u4e00-\\u9fa5]{6,30}$",
|
|
|
phone: '^\\d{6,12}$',
|
|
|
code: '^\\d{6}$',
|
|
|
+ mobile:'^1[1-9][0-9]{9}$'
|
|
|
},
|
|
|
userData: {
|
|
|
account: '',
|
|
@@ -31,6 +30,17 @@ var loginPage = new Vue({
|
|
|
shopId: '',
|
|
|
token:'',
|
|
|
},
|
|
|
+ accountParams: {// 账号密码登录
|
|
|
+ mobileOrEmail: '', //用户登录账号
|
|
|
+ password: '', //用户登录密码
|
|
|
+ },
|
|
|
+ codeParams:{// 验证码登录
|
|
|
+ mobile:'',
|
|
|
+ code:''
|
|
|
+ },
|
|
|
+ smsCodeParams:{// 获取手机短信验证码
|
|
|
+ mobile: '', //用户登录手机号
|
|
|
+ },
|
|
|
isWeChat: false,
|
|
|
text:'',
|
|
|
stautsfalse:false,
|
|
@@ -41,42 +51,145 @@ var loginPage = new Vue({
|
|
|
mobileCodeText:'获取验证码',
|
|
|
mobilTime:null,
|
|
|
isMobileDisabled:false,
|
|
|
- codeParams:{
|
|
|
- mobile:'',
|
|
|
- smsCode:''
|
|
|
- }
|
|
|
},
|
|
|
computed: {
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
- getMobileImage(){
|
|
|
-
|
|
|
- },
|
|
|
handleTabsClick(index){
|
|
|
this.loginTabs = index;
|
|
|
+ clearAllErrorTxt($('input'));
|
|
|
},
|
|
|
- hideBg:function(){
|
|
|
+ handleHideBg(){
|
|
|
this.stautsfalse=false;
|
|
|
},
|
|
|
- information:function(){
|
|
|
- window.location.href='/supplier/information.html';
|
|
|
- this.SetSoragesInfo( this.applyUse);
|
|
|
+ handleCodeMobileInput(e){// 监听输入手机号
|
|
|
+ this.codeParams.mobile = this.smsCodeParams.mobile = e.target.value;
|
|
|
+ },
|
|
|
+ handleSubLogin(){// 点击登录
|
|
|
+ if(this.loginTabs === 0){
|
|
|
+ this.userPasswordLogin();
|
|
|
+ }else{
|
|
|
+ this.userCodeLogin();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ userCodeLogin(){// 短信验证码登录
|
|
|
+ var _self = this;
|
|
|
+ if (this.loginLoading) { return false; }
|
|
|
+ this.$nextTick(function(){
|
|
|
+ if (!verifyForm()) { return false; }
|
|
|
+ _self.loginLoading = true;
|
|
|
+ UserApi.userCodeLogin(_self.codeParams,function(response){
|
|
|
+ _self.userUpdataeStatus(response)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ userPasswordLogin(){// 账号登录
|
|
|
+ var _self = this;
|
|
|
+ if (this.loginLoading) { return false; }
|
|
|
+ this.$nextTick(function(){
|
|
|
+ if (!verifyForm()) { return false; }
|
|
|
+ _self.loginLoading = true;
|
|
|
+ UserApi.PostLoginAccount(_self.accountParams,function(response){
|
|
|
+ _self.userUpdataeStatus(response)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ userUpdataeStatus(response){// 更新登录
|
|
|
+ var _self = this;
|
|
|
+ _self.loginLoading = false;
|
|
|
+ if(response.code === 0){
|
|
|
+ _self.userData = {
|
|
|
+ account: response.data.account,
|
|
|
+ email: response.data.email,
|
|
|
+ phone: response.data.bindMobile,
|
|
|
+ name: response.data.name,
|
|
|
+ userName: response.data.userName,
|
|
|
+ userId: response.data.userId,
|
|
|
+ spId: response.data.serviceProviderId,
|
|
|
+ clubId: response.data.clubId,
|
|
|
+ shopId: response.data.shopId,
|
|
|
+ userIdentity: response.data.userIdentity,
|
|
|
+ permission: response.data.userPermission,
|
|
|
+ token: response.data.token,
|
|
|
+ vipFlag: response.data.vipFlag,
|
|
|
+ firstClubType: response.data.firstClubType,
|
|
|
+ listingFee:response.data.listingFee
|
|
|
+ };
|
|
|
+ _self.setStorages( _self.userData);
|
|
|
+ // 登录成功页面跳转
|
|
|
+ var loginBeforePath = getBaseCookie("loginBeforePath");
|
|
|
+ if (loginBeforePath && loginBeforePath!='undefined' && loginBeforePath.indexOf('.html')>0) {
|
|
|
+ delBaseCookie("loginBeforePath");
|
|
|
+ window.location.href = loginBeforePath;
|
|
|
+ } else if (_self.userData.userIdentity*1 === 3) {
|
|
|
+ location.href = '/supplier/dashboard.html';
|
|
|
+ } else if (_self.userData.userIdentity*1 === 2 || _self.userData.userIdentity*1 === 4) {
|
|
|
+ location.href = '/user/dashboard.html';
|
|
|
+ } else {
|
|
|
+ location.href="/index.html";
|
|
|
+ }
|
|
|
+ } else if(response.code == '-3'){//审核未通过
|
|
|
+ _self.text =response.msg;
|
|
|
+ _self.stautsfalse = true;
|
|
|
+ _self.infofalse = true;
|
|
|
+ _self.applyUse = {
|
|
|
+ userId: response.data.userId,
|
|
|
+ shopId: response.data.shopId,
|
|
|
+ token: response.data.token
|
|
|
+ };
|
|
|
+ }else if(response.code == '-2'){
|
|
|
+ _self.stautsfalse = true;
|
|
|
+ _self.text =response.msg;
|
|
|
+ }else {// 登录失败
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleMobileCode(){// 点击获取短信验证码
|
|
|
+ var _self = this;
|
|
|
+ if( this.isMobileDisabled){ return }
|
|
|
+ this.$nextTick(function() {
|
|
|
+ if (!verifyCheack('.massageBtn')) { return false; }
|
|
|
+ UserApi.userOperateCode(_self.smsCodeParams,function (response) {
|
|
|
+ if(response.code == 0){
|
|
|
+ CAIMEI.dialog('获取验证码成功~',false,function () {});
|
|
|
+ var TIME_COUNT = 60;
|
|
|
+ if (!_self.mobilTime) {
|
|
|
+ _self.mobilCount = TIME_COUNT;
|
|
|
+ _self.isMobileDisabled = true;
|
|
|
+ _self.mobilTime = setInterval(function(){
|
|
|
+ if (_self.mobilCount > 1 && _self.mobilCount <= TIME_COUNT) {
|
|
|
+ _self.mobilCount--;
|
|
|
+ _self.mobileCodeText = _self.mobilCount +'s';
|
|
|
+ } else {
|
|
|
+ _self.isMobileDisabled = false;
|
|
|
+ clearInterval(_self.mobilTime);
|
|
|
+ _self.mobilTime = null;
|
|
|
+ _self.mobileCodeText = '获取验证码';
|
|
|
+ }
|
|
|
+ },1000)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ _self.isMobileDisabled = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
- toQrCodeLogin: function(){//切换微信登录二维码
|
|
|
+ toQrCodeLogin(){//切换微信登录二维码
|
|
|
var _self = this;
|
|
|
var timeClock = null;
|
|
|
this.qrCodeLogin = true;
|
|
|
UserApi.ToWechatLogin({},function(response){
|
|
|
var wxLogin = new WxLogin({
|
|
|
- self_redirect: true,
|
|
|
- id: "qrCodeWrap",
|
|
|
- appid: response.data.appId,
|
|
|
- scope: 'snsapi_login',
|
|
|
- redirect_uri: response.data.redirectUri,
|
|
|
- state: response.data.state,
|
|
|
- style: "black",
|
|
|
- href: "https://www.caimei365.com/css/base/base.pc.css"
|
|
|
+ self_redirect: true,
|
|
|
+ id: "qrCodeWrap",
|
|
|
+ appid: response.data.appId,
|
|
|
+ scope: 'snsapi_login',
|
|
|
+ redirect_uri: response.data.redirectUri,
|
|
|
+ state: response.data.state,
|
|
|
+ style: "black",
|
|
|
+ href: "https://www.caimei365.com/css/base/base.pc.css"
|
|
|
});
|
|
|
timeClock = setInterval(function(){
|
|
|
_self.maxtime--;
|
|
@@ -87,7 +200,7 @@ var loginPage = new Vue({
|
|
|
_self.getWrchatStatusData({state:response.data.state})
|
|
|
});
|
|
|
},
|
|
|
- getWrchatStatusData:function(params){//轮询查询用户是否扫描过二维码登录
|
|
|
+ getWrchatStatusData(params){//轮询查询用户是否扫描过二维码登录
|
|
|
var _self = this;
|
|
|
var timer = null;
|
|
|
UserApi.ToWechatPolling(params,function(response){
|
|
@@ -174,13 +287,13 @@ var loginPage = new Vue({
|
|
|
_self.stautsfalse = true;
|
|
|
_self.text ='您的供应商账号正在加速审核中,审核通过后即可登录';
|
|
|
}else{
|
|
|
- CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- // 微信公众号授权登录
|
|
|
- weChatLogin: function(){
|
|
|
+ handleWeChatLogin(){
|
|
|
+ // 微信公众号授权登录
|
|
|
if (this.isWeChat) {
|
|
|
// 微信浏览器自动授权登录
|
|
|
var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
|
|
@@ -192,10 +305,10 @@ var loginPage = new Vue({
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- toNormalLogin: function(){
|
|
|
+ toNormalLogin(){
|
|
|
this.qrCodeLogin = false;
|
|
|
},
|
|
|
- showPassword: function(event) {
|
|
|
+ showPassword(event) {
|
|
|
var el = event.currentTarget;
|
|
|
var pwdEle = $(el).siblings('input');
|
|
|
if(pwdEle.attr('type') === 'password') {
|
|
@@ -206,75 +319,19 @@ var loginPage = new Vue({
|
|
|
pwdEle.attr('type','password');
|
|
|
}
|
|
|
},
|
|
|
- blurHandle: function(event) { // 失去焦点校验
|
|
|
+ blurHandle(event) { // 失去焦点校验
|
|
|
var el = event.currentTarget;
|
|
|
verifyHandle(el);
|
|
|
},
|
|
|
- loginSubmit: function () { // 账号登录
|
|
|
- var _self = this;
|
|
|
- var pass = verifyForm();
|
|
|
- if (this.loginLoading) { return false; }
|
|
|
- this.$nextTick(function(){
|
|
|
- if (!pass) { return false; }
|
|
|
- _self.loginLoading = true;
|
|
|
- var params = {mobileOrEmail: _self.loginAccount,password: _self.loginPassword};
|
|
|
- UserApi.PostLoginAccount(params,function(response){
|
|
|
- _self.loginLoading = false;
|
|
|
- if(response.code === 0){
|
|
|
- console.log(response);
|
|
|
- _self.userData = {
|
|
|
- account: response.data.account,
|
|
|
- email: response.data.email,
|
|
|
- phone: response.data.bindMobile,
|
|
|
- name: response.data.name,
|
|
|
- userName: response.data.userName,
|
|
|
- userId: response.data.userId,
|
|
|
- spId: response.data.serviceProviderId,
|
|
|
- clubId: response.data.clubId,
|
|
|
- shopId: response.data.shopId,
|
|
|
- userIdentity: response.data.userIdentity,
|
|
|
- permission: response.data.userPermission,
|
|
|
- token: response.data.token,
|
|
|
- vipFlag: response.data.vipFlag,
|
|
|
- firstClubType: response.data.firstClubType,
|
|
|
- listingFee:response.data.listingFee
|
|
|
- };
|
|
|
- _self.setStorages( _self.userData);
|
|
|
- // 登录成功页面跳转
|
|
|
- var loginBeforePath = getBaseCookie("loginBeforePath");
|
|
|
- if (loginBeforePath && loginBeforePath!='undefined' && loginBeforePath.indexOf('.html')>0) {
|
|
|
- delBaseCookie("loginBeforePath");
|
|
|
- window.location.href = loginBeforePath;
|
|
|
- } else if (_self.userData.userIdentity*1 === 3) {
|
|
|
- location.href = '/supplier/dashboard.html';
|
|
|
- } else if (_self.userData.userIdentity*1 === 2 || _self.userData.userIdentity*1 === 4) {
|
|
|
- location.href = '/user/dashboard.html';
|
|
|
- } else {
|
|
|
- location.href="/index.html";
|
|
|
- }
|
|
|
- } else if(response.code == '-3'){//审核未通过
|
|
|
- _self.text =response.msg;
|
|
|
- _self.stautsfalse = true;
|
|
|
- _self.infofalse = true;
|
|
|
- _self.applyUse = {
|
|
|
- userId: response.data.userId,
|
|
|
- shopId: response.data.shopId,
|
|
|
- token: response.data.token
|
|
|
- };
|
|
|
- }else if(response.code == '-2'){
|
|
|
- _self.stautsfalse = true;
|
|
|
- _self.text =response.msg;
|
|
|
- }else {// 登录失败
|
|
|
- CAIMEI.Alert(response.msg,'确定',false);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- SetSoragesInfo:function(data){
|
|
|
+ SetSoragesInfo(data){
|
|
|
localStorage.setItem('APPLY_INFO',JSON.stringify(data));
|
|
|
},
|
|
|
- setStorages:function(data){//存储本地数据
|
|
|
+ setStorages(data){//存储本地数据
|
|
|
localStorage.setItem('userInfo',JSON.stringify(data));
|
|
|
+ },
|
|
|
+ information(){
|
|
|
+ window.location.href='/supplier/information.html';
|
|
|
+ this.SetSoragesInfo( this.applyUse);
|
|
|
}
|
|
|
},
|
|
|
created: function () {
|