chao преди 4 години
родител
ревизия
1ec5e32d9c
променени са 3 файла, в които са добавени 30 реда и са изтрити 7 реда
  1. 1 1
      src/main/resources/static/js/account/login.js
  2. 2 4
      src/main/resources/static/js/base.js
  3. 27 2
      src/main/resources/templates/we_chat/redirect_uri.html

+ 1 - 1
src/main/resources/static/js/account/login.js

@@ -158,7 +158,7 @@ var loginPage = new Vue({
                         // 登录成功页面跳转
                         var forwardUrl = document.referrer;
                         var getHrefUrl = $("#spiServer").val();
-                        if(forwardUrl=="" || forwardUrl==undefined || forwardUrl==null || forwardUrl == getHrefUrl){
+                        if(forwardUrl || forwardUrl == getHrefUrl){
                             if(_userIdentity == 4 || _userIdentity ==2){
                                 location.href = '/user/dashboard.html';
                             }else if(_userIdentity == 3){

+ 2 - 4
src/main/resources/static/js/base.js

@@ -1,14 +1,12 @@
 var spiServer = $("#spiServer").val();
 var isPC = ($(window).width()>768);
 var userAgent = navigator.userAgent.toLowerCase();
-var isWeChatBrowser = (userAgent.match(/MicroMessenger/i) === 'micromessenger');
-if (isWeChatBrowser) {
+if (userAgent.match(/MicroMessenger/i)) {
     // 微信浏览器自动授权登录
-    var urlForCurrent = window.location.href;
     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){
-            sessionStorage.setItem("urlForCurrent", urlForCurrent);
+            localStorage.setItem("loginBeforePath", window.location.href);
             window.location.href = r.data;
         }
     });

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

@@ -13,9 +13,34 @@
     var wx_state = getUrlParam('state');
     $.get(spiServer+'/user/authorizationLogin?code='+wx_code+'&state='+wx_state, function(r){
         if(r.code===0){
-            window.location.href = sessionStorage.getItem("urlForCurrent");
+            console.log(r.data);
+            var userData = {
+                account: r.data.account,
+                email: r.data.email,
+                phone: r.data.bindMobile,
+                name: r.data.name,
+                userName: r.data.userName,
+                userId: r.data.userID,
+                spId: r.data.serviceProviderID,
+                clubId: r.data.clubID,
+                shopId: r.data.shopID,
+                userIdentity: r.data.userIdentity,
+                permission: r.data.userPermission,
+                token: r.data.token
+            };
+            localStorage.setItem('userInfo',JSON.stringify(userData));
+            var loginBeforePath = sessionStorage.getItem("loginBeforePath");
+            if (loginBeforePath) {
+                window.location.href = loginBeforePath;
+            } else if (userData.userIdentity*1 === 3) {
+                location.href = '/supplier/dashboard.html';
+            } else if (userData.userIdentity*1 === 2 || userData.userIdentity*1 === 4) {
+                location.href = '/user/dashboard.html';
+            } else {
+                location.href="/index.html";
+            }
         }else{
-            alert(r.msg);
+            CAIMEI.Alert(r.msg,'确定',false);
         }
     });
 </script>