Bladeren bron

登录优化

chao 4 jaren geleden
bovenliggende
commit
4a2578e5d3

+ 7 - 19
src/main/resources/static/css/account/login.css

@@ -30,25 +30,13 @@ footer .footTop{display:none;}
 .loginForm .showPwd{position:absolute;right:22px;top:16px;width:22px;height:16px;cursor:pointer}
 .loginForm .showPwd:before{width:22px;height:20px;background-position:-240px -299px}
 .loginForm .showPwd.on:before{width:22px;height:20px;background-position:-205px -299px}
-#qrCodeWrap .model{
-        position: absolute;
-        width: 200px;
-        height: 200px;
-        top: 15px;
-        left: 98px;
-        display: flex;
-        justify-content: center;
-        align-items: center;
-        background: rgba(255,255,255,1);
-        color: #999;
-        z-index: 99999;
-        cursor: pointer;
-        border: 1px solid #EBEBEB;
-}
-#qrCodeWrap .model .refresh{width: 21px;height: 21px;display: block;margin: 0 auto;margin-bottom: 3px;}
-#qrCodeWrap .model  .refresh-div{width: 100px;height: 64px;display: block;}
-#qrCodeWrap .model  .refresh-div p{text-align: center;font-size: 14px;line-height: 20px;}
-.baseHeadCenter.account .accountLogin{display: none;}
+#qrCodeWrap{position:relative}
+#qrCodeWrap .model{position:absolute;width:200px;height:200px;top:15px;left:98px;display:flex;justify-content:center;align-items:center;background:rgba(255,255,255,.9);color:#000;z-index:99999;cursor:pointer;border:1px solid #EBEBEB}
+#qrCodeWrap .model .refresh{width:21px;height:21px;display:block;margin:0 auto 3px}
+#qrCodeWrap .model .refresh-div{width:100px;height:64px;display:block}
+#qrCodeWrap .model .refresh-div p{text-align:center;font-size:14px;line-height:20px}
+.baseHeadCenter.account .accountLogin{display:none}
+
 
 }
 

+ 5 - 3
src/main/resources/static/js/account/login.js

@@ -61,7 +61,7 @@ var loginPage = new Vue({
                     if(_self.maxtime == 0){
                         clearInterval(timer);
                         _self.maxtime = 60;
-                        $('#qrCodeWrap').append('<div class="model"><div class="refresh-div"><img class="refresh" src="/web/login/img/shua.png" alt=""><p>二维码已失效,点击刷新</p></div></div>');
+                        $('#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();
@@ -90,8 +90,9 @@ var loginPage = new Vue({
                         };
                         _self.setStorages( _self.userData);
                         // 登录成功页面跳转
-                        var loginBeforePath = getCookie("loginBeforePath");
+                        var loginBeforePath = getBaseCookie("loginBeforePath");
                         if (loginBeforePath && loginBeforePath!=='undefined') {
+                            delBaseCookie("loginBeforePath");
                             window.location.href = loginBeforePath;
                         } else if (_self.userData.userIdentity*1 === 3) {
                             location.href = '/supplier/dashboard.html';
@@ -151,8 +152,9 @@ var loginPage = new Vue({
                         };
                         _self.setStorages( _self.userData);
                         // 登录成功页面跳转
-                        var loginBeforePath = getCookie("loginBeforePath");
+                        var loginBeforePath = getBaseCookie("loginBeforePath");
                         if (loginBeforePath && loginBeforePath!=='undefined') {
+                            delBaseCookie("loginBeforePath");
                             window.location.href = loginBeforePath;
                         } else if (_self.userData.userIdentity*1 === 3) {
                             location.href = '/supplier/dashboard.html';

+ 22 - 9
src/main/resources/static/js/base.js

@@ -12,15 +12,15 @@ if(localStorage.getItem('userInfo')){
     GLOBAL_USER_IDENTITY = globalUserData.userIdentity;
     GLOBAL_SHOP_ID = globalUserData.shopId;
 } else {
-    if(!getCookie("weChatAutoLogin")){
+    if(!getBaseCookie("weChatAutoLogin")){
         var userAgent = navigator.userAgent.toLowerCase();
         if (userAgent.match(/MicroMessenger/i)) {
             // 微信浏览器自动授权登录
             var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
             $.get(spiServer+'/user/authorizationLink?redirectUri='+urlForWeChat, function(r){
                 if(r.code===0 && r.data){
-                    setCookie("loginBeforePath", window.location.href);
-                    setCookie("weChatAutoLogin", 1);
+                    setBaseCookie("loginBeforePath", window.location.href);
+                    setBaseCookie("weChatAutoLogin", 1);
                     window.location.href = r.data;
                 }
             });
@@ -116,6 +116,7 @@ var globalHead = new Vue({
         // 退出登录
         userLogOut: function(){
             localStorage.removeItem('userInfo');
+            delBaseCookie("loginBeforePath");
             this.loginStatus = false;
             window.location.href = "/index.html";
         },
@@ -196,7 +197,7 @@ $(function(){
                     text: btnTxt,
                     btnClass: 'btn-confirm-login',
                     action: function(){
-                        setCookie("loginBeforePath", window.location.href);
+                        setBaseCookie("loginBeforePath", window.location.href);
                         window.location.href = '/login.html';
                     }
                 },
@@ -210,12 +211,13 @@ $(function(){
     // 去登录弹窗
     $('body').on("click", '.toLogin',function () {
         //loginAert('<span>你还未登录</span><span>请登录后再进行购买</span>', '去登录');
-        setCookie("loginBeforePath", window.location.href);
+        setBaseCookie("loginBeforePath", window.location.href);
         window.location.href = '/login.html';
     });
     // 退出登录
     $('body').on("click", '.toLogOut',function () {
         localStorage.removeItem('userInfo');
+        delBaseCookie("loginBeforePath");
         globalHead.loginStatus = false;
         window.location.href = "/index.html";
     });
@@ -324,7 +326,7 @@ $(function(){
 
 });
 // 公共方法
-function setCookie(cname,cvalue,exdays){
+function setBaseCookie(cname,cvalue,exdays){
     if (exdays) {
         var d = new Date();
         d.setTime(d.getTime()+(exdays*24*60*60*1000));
@@ -334,7 +336,7 @@ function setCookie(cname,cvalue,exdays){
         document.cookie = cname+"="+cvalue+"; path=/";
     }
 }
-function getCookie(cname){
+function getBaseCookie(cname){
     if (document.cookie) {
         var name = cname + "=";
         var ca = document.cookie.split(';');
@@ -347,6 +349,14 @@ function getCookie(cname){
     }
     return "";
 }
+function delBaseCookie(cname){
+    var exp = new Date();
+    exp.setTime(exp.getTime() - 1);
+    var cval=getBaseCookie(cname);
+    if(cval!=null) {
+        document.cookie= cname + "="+cval+";expires="+exp.toGMTString();
+    }
+}
 function getDateStr(dd, addCount) {
     dd.setDate(dd.getDate() + addCount);//获取addCount天后的日期
     var y = dd.getFullYear();
@@ -494,6 +504,7 @@ function tokenAjax(type, url, params, callback, errorBack){
         success : function (res) {
             if(res.code === -99){
                 localStorage.removeItem('userInfo');
+                delBaseCookie("loginBeforePath");
                 window.location.href ='/login.html';
             }else{
                 callback(res);
@@ -561,14 +572,15 @@ function setProductPrice(productList, productIds, userId, callback){
 }
 // 登录后返回登录前页面
 function toBeforePath(){
-    var loginBeforePath = getCookie("loginBeforePath");
+    var loginBeforePath = getBaseCookie("loginBeforePath");
     if (loginBeforePath && loginBeforePath!=='undefined') {
+        delBaseCookie("loginBeforePath");
         window.location.href = loginBeforePath;
     }
     window.location.href = '/index.html';
 }
 function toLogin() {//去登录
-    setCookie("loginBeforePath", window.location.href);
+    setBaseCookie("loginBeforePath", window.location.href);
     window.location.href = '/login.html';
 }
 function  upgrade () { //升级会员
@@ -576,6 +588,7 @@ function  upgrade () { //升级会员
 }
 function toLogOut() {//登出
     localStorage.removeItem('userInfo');
+    delBaseCookie("loginBeforePath");
     this.loginStatus = false;
     window.location.href = "/index.html";
 }

+ 1 - 1
src/main/resources/static/js/product/detail.js

@@ -152,7 +152,7 @@ var productDetail = new Vue({
             }
         },
         toLogin: function() {
-            setCookie("loginBeforePath", window.location.href);
+            setBaseCookie("loginBeforePath", window.location.href);
             window.location.href = '/login.html';
         },
 		addShopCart: function(){ //加入购物车

+ 2 - 1
src/main/resources/templates/we_chat/redirect_uri.html

@@ -29,8 +29,9 @@
                 token: r.data.token
             };
             localStorage.setItem('userInfo',JSON.stringify(userData));
-            var loginBeforePath = getCookie("loginBeforePath");
+            var loginBeforePath = getBaseCookie("loginBeforePath");
             if (loginBeforePath && loginBeforePath!=='undefined') {
+                delBaseCookie("loginBeforePath");
                 window.location.href = loginBeforePath;
             } else if (userData.userIdentity*1 === 3) {
                 location.href = '/supplier/dashboard.html';