123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- var loginPage = new Vue({
- el: "#loginPage",
- data: {
- 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}$"
- },
- userData: {
- account: '',
- email: '',
- phone: '',
- name: '',
- userName: '',
- userId: '',
- spId: '',
- clubId: '',
- shopId: '',
- identity: '',
- permission: '',
- token: ''
- },
- applyUse:{
- clubId: '',
- shopId: '',
- token:'',
- },
- isWeChat: false,
- text:'',
- stautsfalse:false,
- infofalse:false,
- isSlideFinishState:true
- },
- computed: {
- },
- methods: {
- hideBg:function(){
- this.stautsfalse=false;
- },
- information:function(){
- window.location.href='/supplier/information.html';
- this.SetSoragesInfo( this.applyUse);
- },
- toQrCodeLogin: function(){//切换微信登录二维码
- 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"
- });
- timeClock = setInterval(function(){
- _self.maxtime--;
- if (_self.maxtime == 0) {
- clearInterval(timeClock);
- };
- },1000);
- _self.getWrchatStatusData({state:response.data.state})
- });
- },
- getWrchatStatusData:function(params){//轮询查询用户是否扫描过二维码登录
- var _self = this;
- var timer = null;
- UserApi.ToWechatPolling(params,function(response){
- if(response.code == -90){
- if(_self.maxtime == 0){
- clearInterval(timer);
- _self.maxtime = 60;
- $('#qrCodeWrap').append('<div class="model"><div class="refresh-div"><img class="refresh" src="/img/base/shua.png" alt=""><p>二维码已失效,点击刷新</p></div></div>');
- $('#qrCodeWrap .model').click(function () {
- $(this).remove();
- _self.toQrCodeLogin();
- })
- }else{
- timer = setTimeout(function(){
- _self.getWrchatStatusData(params);
- },3000)
- }
- }else {
- clearTimeout(timer); //清理定时任务
- 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,
- unionId:response.data.unionId,
- firstClubType:response.data.firstClubType,
- vipFlag: response.data.vipFlag,
- 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 == -4){
- _self.userData = {
- account: response.data.account,
- email: response.data.email,
- phone: response.data.bindMobile,
- name: response.data.name ? response.data.name : response.data.userName,
- 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,
- unionId:response.data.unionId,
- listingFee:response.data.listingFee
- };
- _self.setStorages( _self.userData);
- setTimeout(function(){
- window.location.href = '/bind.html';
- },1000);
- }else if(response.code == '-3'){//审核未通过
- _self.text ='您的供应商账号审核未通过,原因:图片模糊,营业执照错误,审核人员在后台填写的内容';
- _self.stautsfalse = true;
- _self.infofalse = true;
- _self.applyUse = {
- userId: response.data.userId,
- shopId: response.data.shopId,
- token: response.data.token
- };
- console.log(_self.applyUse);
- }else if(response.code == '-2'){
- _self.stautsfalse = true;
- _self.text ='您的供应商账号正在加速审核中,审核通过后即可登录';
- }else{
- CAIMEI.Alert(response.msg,'确定',false);
- }
- }
- });
- },
- // 微信公众号授权登录
- weChatLogin: function(){
- if (this.isWeChat) {
- // 微信浏览器自动授权登录
- var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
- $.get(coreServer+'/user/login/auth/link?mode=2&redirectUri='+urlForWeChat, function(r){
- if(r.code===0 && r.data){
- setBaseCookie("weChatAutoLogin", 2);
- window.location.href = r.data;
- }
- });
- }
- },
- toNormalLogin: function(){
- this.qrCodeLogin = false;
- },
- showPassword: function(event) {
- var el = event.currentTarget;
- var pwdEle = $(el).siblings('input');
- if(pwdEle.attr('type') === 'password') {
- $(el).addClass('on');
- pwdEle.attr('type','text');
- } else {
- $(el).removeClass('on');
- pwdEle.attr('type','password');
- }
- },
- blurHandle: function(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){
- localStorage.setItem('APPLY_INFO',JSON.stringify(data));
- },
- setStorages:function(data){//存储本地数据
- localStorage.setItem('userInfo',JSON.stringify(data));
- }
- },
- created: function () {
- var userAgent = navigator.userAgent.toLowerCase();
- this.isWeChat = userAgent.match(/MicroMessenger/i);
- // this.weChatAutoLogin();
- },
- mounted: function () {
- var _self = this;
- var SlideVerifyPlug = window.slideVerifyPlug;
- var slideVerify = new SlideVerifyPlug('#verify-wrap',{
- wrapWidth:'350',//设置 容器的宽度 ,不设置的话,会设置成100%,需要自己在外层包层div,设置宽度,这是为了适应方便点;
- initText:'请向右滑动滑块', //设置 初始的 显示文字
- sucessText:'验证通过',//设置 验证通过 显示的文字
- getSuccessState:function(res){
- //当验证完成的时候 会 返回 res 值 true,只留了这个应该够用了
- console.log(res);
- if(slideVerify.slideFinishState){
- $('.value').html(slideVerify.slideFinishState)
- $('#resetBtn').removeClass('prohibit')
- _self.isSlideFinishState = false;
- }
- }
- });
- $('body').on("focus",'[needverify]:visible',function(){
- $(this).siblings('.errTips').removeClass("show").siblings('.checked').removeClass("show");
- });
- //enter键登录
- if(!_self.isSlideFinishState){
- $(document).keyup(function (e) {
- var e = e || event;
- e.stopPropagation();
- if (e.keyCode === 13) {
- _self.loginSubmit();
- }
- });
- }
- }
- });
|