浏览代码

消息通知的点击跳转

seyason 1 年之前
父节点
当前提交
df53f4dab7

+ 10 - 8
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/AuthRedirectController.java

@@ -26,6 +26,8 @@ import org.springframework.web.servlet.view.RedirectView;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
@@ -45,6 +47,8 @@ public class AuthRedirectController {
     private String pcUrl;
     @Value("${privateDeployURL.mobUrl}")
     private String mobUrl;
+    @Value("${privateDeployURL.authUrl}")
+    private String authUrl;
     @Value("${corpId}")
     private String corpId;
 
@@ -274,7 +278,7 @@ public class AuthRedirectController {
         boolean isMobile = "MOBILE".equals(deviceType);
         WxCorpInfo corpInfo = wxCorpInfoMapper.selectById(corpId);
         System.out.println("========================ACCESS_TOKEN====================="+wxCorpInfoService.getCorpAgentAccessToken(corpInfo));
-        System.out.println("========================CODE====================="+code);
+        System.out.println("========================CODE====================="+code+"state="+state);
         String url = WeiXinCorpController.GET_CORP_INSIDE_USERINFO_URL.replace("ACCESS_TOKEN", wxCorpInfoService.getCorpAgentAccessToken(corpInfo)).replace("CODE", code);
         String forObject = this.restTemplate.getForObject(url, String.class);
         JSONObject obj = JSONObject.parseObject(forObject);
@@ -318,11 +322,13 @@ public class AuthRedirectController {
         }
         reqParam.put("hasTriedAutoLogin", 1);
         if (!StringUtils.isEmpty(state) && state.length() > 1) {
+            System.out.println("Decode前state=="+state);
+            state = URLDecoder.decode(state, "UTF-8");
             reqParam.put("path", state);
+            System.out.println("Decode后state=="+state);
         }
 
-        String redirecUrl = null;
-        String router = "index";
+        String router = "login";//从登录页面进入系统
         if (companyId > 0) {
             HashMap compExpireInfo = getCompExpireInfo(companyId);
             if (compExpireInfo != null) {
@@ -332,11 +338,7 @@ public class AuthRedirectController {
                 reqParam.put("version", compExpireInfo.get("version"));
             }
         }
-        if (isMobile) {
-            redirecUrl = mobUrl +"/#/"+ router;
-        } else {
-            redirecUrl = pcUrl +"/#/"+ router;
-        }
+        String redirecUrl = (isMobile? mobUrl : pcUrl) +"/#/"+ router;
         ModelAndView modelAndView = new ModelAndView(
                 new RedirectView(redirecUrl), reqParam);
         reqParam.put("isPrivateCorpWX", 1);

+ 6 - 6
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.*;
 import java.math.BigDecimal;
 import java.net.URI;
+import java.net.URLEncoder;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
@@ -104,10 +105,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
 
     @Value(value = "${configEnv.isPrivateDeploy}")
     private boolean isPrivateDeploy;
-    @Value(value = "${privateDeployURL.pcUrl}")
-    private String pcUrl;
-    @Value(value = "${privateDeployURL.mobUrl}")
-    private String mobUrl;
+    @Value(value = "${privateDeployURL.authUrl}")
+    private String authUrl;
 
     @Autowired
     RestTemplate restTemplate;
@@ -260,11 +259,12 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
             String title = "";
             String jumpUrl ;
             if(isPrivateDeploy){
-                jumpUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+corpInfo.getCorpid()+"&redirect_uri="+pcUrl+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
+                jumpUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+corpInfo.getCorpid()+"&redirect_uri="+ authUrl +"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
             }else {
-                jumpUrl="https://open.weixin.qq.com/connect/oauth2/authorize?"+corpInfo.getCorpid()+"&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
+                jumpUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+corpInfo.getCorpid()+"&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
             }
             jumpUrl = jumpUrl.replace("STATE", pageRouter);
+            System.out.println("jumpUrl=="+jumpUrl);
             if ("plan/today".equals(pageRouter)) {
                 //出差
                 title = "收到新的今日计划";

+ 3 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/application-privatedev.yml

@@ -104,5 +104,6 @@ configEnv:
   isPrivateDeploy: true
 
 privateDeployURL:
-  pcUrl: http://devworkshop.ttkuaiban.com/api/corpInsideWXAuth
-  mobUrl: http://mobdevworkshop.ttkuaiban.com/api/corpInsideWXAuth
+  pcUrl: http://devworkshop.ttkuaiban.com
+  mobUrl: http://mobdevworkshop.ttkuaiban.com
+  authUrl: http://devworkshop.ttkuaiban.com/api/corpInsideWXAuth

+ 3 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/application.yml

@@ -159,5 +159,6 @@ configEnv:
   isPrivateDeploy: true
 
 privateDeployURL:
-  pcUrl: http://devworkshop.ttkuaiban.com/api/corpInsideWXAuth
-  mobUrl: http://mobdevworkshop.ttkuaiban.com/api/corpInsideWXAuth
+  pcUrl: http://devworkshop.ttkuaiban.com
+  mobUrl: http://mobdevworkshop.ttkuaiban.com
+  authUrl: http://devworkshop.ttkuaiban.com/api/corpInsideWXAuth

+ 4 - 59
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/index/index.vue

@@ -313,7 +313,6 @@ export default {
                         this.getMessage();
                         this.redirectIfNess();
                         this.$forceUpdate()
-                        // this.bindIfNessary();
                     }
                 }).catch(err => {
                     alert('err=' + err);
@@ -323,67 +322,13 @@ export default {
             var href = window.location.href;
             if (href.indexOf('path') > 0) {
                 var path = href.split('path=')[1].split('&')[0];
-                if (path == 'expense' || path == 'task') {
-                    this.$router.push(path);
+                if (path.indexOf('%2F') > 0) {
+                    path = path.replace('%2F','/');
                 }
+                this.$router.push(path);
             }
         },
-        bindIfNessary() {
-            let href = window.location.href;
-            var requestUrl = "";
-            if (this.isCorpWX && (this.user.corpwxUserid == null || this.user.corpwxUserid == undefined || this.user.corpwxUserid == 'undefined')) {//优先检查企业微信环境
-                requestUrl = "/wxcorp/bindCorpWeiXin";
-            } else if (this.isWX && (this.user.wxOpenid == null || this.user.wxOpenid == undefined || this.user.wxOpenid == 'undefined')) {
-                requestUrl = "/wechat/bindWeiXin";
-            }
-
-            if (requestUrl.length > 0) {
-                // localStorage.openId = 'o1L3L5lOrOl3_UEJjONaoT2Rne1I';
-                //会自动跳转到首页
-                // let href = 'http://hq.tangusoft.com/?code=011Ptjgc2rx1eI09Irgc2Rvsgc2PtjgF&state=1#/index';
-
-                if (href.includes("com/?code")) {  //url包括 com/?code 证明为从微信跳转回来的
-                    var url = href; //vue自动在末尾加了 #/ 符号,截取去掉
-                    var jingPosit = url.indexOf("com/") + 4; //获取域名结束的位置
-
-                    // var urlLeft = url.substring(0, jingPosit);//url左侧部分
-                    var urlRight = url.substring(jingPosit, url.length); //url右侧部分
-                    // console.log('urlRight=' + urlRight);
-                    // window.location = urlLeft + "#/home" + urlRight;//拼接跳转
-                    //获取code
-                    var code = urlRight.substring('?code='.length, urlRight.indexOf('#/index'));
-                    if (code.indexOf('&state=1') > 0) {
-                        code = code.substring(0, code.indexOf('&state=1'));
-                    }
-
-                    //调用后台接口,注册用户
-                    // console.log('获取到code=='+code);
-
-                    this.$axios.get(requestUrl, { params: { code: code, userId: this.user.id } })
-                        .then(res => {
-                            // console.log(res);
-                            if (res == null) {
-                                this.$toast.fail('绑定失败');
-                            } else if (res.errcode != null) {
-                                //报错了
-                                console.log(res.errmsg);
-                            } else {
-                                //获取openId
-                                if (res.data != null && ((this.isWX && res.data.wxOpenid != undefined)
-                                    || (this.isCorpWX && res.data.corpwxUserid != undefined))) {
-                                    localStorage.userInfo = JSON.stringify(res.data);
-                                    // console.log('绑定成功');
-                                    this.user = res.data;
-                                    window.location.href = '/#/my/center';
-                                }
-                            }
-                        }).catch(err => {
-                            alert('err=' + err);
-                        });
-                }
-            }
-        },
-
+        
         //获取消息
         getMessage() {
             this.$axios.post("/information/list", {

+ 13 - 2
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/login/index.vue

@@ -115,7 +115,18 @@
                                 this.user = res.data;
                                 // alert('本地存储的值' + localStorage.getItem('userInfo'))
                                 // window.location.href = '/#/index';
-                                this.$router.push("/index");
+                                var href = window.location.href;
+                                if (href.indexOf('path') > 0) {
+                                    var path = href.split('path=')[1].split('&')[0];
+                                    if (path.indexOf('%2F') > 0) {
+                                        path = path.replace('%2F','/');
+                                    }
+                                    
+                                    this.$router.push(path);
+                                } else {
+                                    this.$router.push("/index");
+                                }
+                                
                             }
                         }
                     }).catch(err=> {
@@ -217,7 +228,7 @@
                                 }else{
                                     corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
                                 }
-                                alert('钉钉登录==='+corpId);
+                                
                                 this.isDingding = true
                                 dd.ready(function() {
                                     dd.runtime.permission.requestAuthCode({

+ 3 - 0
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/Login.vue

@@ -147,6 +147,9 @@
                     var path = null;
                     if (href.indexOf('path') > 0) {
                         path = href.split('path=')[1].split('&')[0];
+                        if (path.indexOf('%2F') > 0) {
+                            path = path.replace('%2F','/');
+                        }
                     }
                     this.loginByUserId(loginUserId, path);
                 } else {