yuhaitao14 7 years ago
parent
commit
4d0c7d89a5

+ 2 - 2
shop/src/main/java/com/zskk/shop/controller/AbstractController.java

@@ -64,13 +64,13 @@ public class AbstractController {
 		try {
 			value = getCookieValue(USER_COOKIE_NAME);
 		} catch (Exception e) {
-			ZSKKError error = new ZSKKError(ErrorConstant.NO_LOGIN_ERROR.getCode(),
+			ZSKKError error = new ZSKKError(ErrorConstant.H5NO_LOGIN_ERROR.getCode(),
 					uccenter + "wx/enter/" + companyid + "?redirect=" + urlEncoding(redirect));
 			throw new ZSKKException(error);
 		}
 
 		if (value == null) {
-			ZSKKError error = new ZSKKError(ErrorConstant.NO_LOGIN_ERROR.getCode(),
+			ZSKKError error = new ZSKKError(ErrorConstant.H5NO_LOGIN_ERROR.getCode(),
 					uccenter + "wx/enter/" + companyid + "?redirect=" + urlEncoding(redirect));
 			throw new ZSKKException(error);
 		}

+ 5 - 0
shop/src/main/java/com/zskk/shop/controller/GlobalErrorController.java

@@ -25,6 +25,7 @@ import org.springframework.web.servlet.ModelAndView;
 import com.alibaba.fastjson.JSON;
 import com.zskk.shop.controller.bean.ControllerResult;
 import com.zskk.shop.exception.ErrorConstant;
+import com.zskk.shop.exception.ZSKKError;
 import com.zskk.shop.exception.ZSKKException;
 import com.zskk.shop.utils.LogUtil;
 
@@ -55,10 +56,14 @@ public class GlobalErrorController {
 		if (accept.contains(MediaType.TEXT_HTML_VALUE)){
 			//为登录 跳转到登录页面
 			if (e instanceof ZSKKException){
+				ZSKKError error = ((ZSKKException)e).getError();
 				if (((ZSKKException)e).getError().getCode() == ErrorConstant.NO_LOGIN_ERROR.getCode()){
 					String redirect = this.getRequestUrl();
 					return new ModelAndView("redirect:" + uccenter + "/login/authorize?redirect=" + redirect);
 				}
+				if (((ZSKKException)e).getError().getCode() == ErrorConstant.H5NO_LOGIN_ERROR.getCode()){
+					return new ModelAndView("redirect:" + error.getMsg());
+				}
 			}
 			
 			String errorPath = "/error";

+ 1 - 0
shop/src/main/java/com/zskk/shop/exception/ErrorConstant.java

@@ -5,6 +5,7 @@ public class ErrorConstant {
 	public static final ZSKKError SIGN_ERROR		= new ZSKKError(101, "签名错误");
 	public static final ZSKKError PARAM_ERROR		= new ZSKKError(102, "参数错误");
 	public static final ZSKKError NO_LOGIN_ERROR	= new ZSKKError(103, "未登录");
+	public static final ZSKKError H5NO_LOGIN_ERROR	= new ZSKKError(104, "H5未登录");
 	public static final ZSKKError NET_ERROR			= new ZSKKError(400, "网络错误");
 	public static final ZSKKError SERVER_ERROR		= new ZSKKError(500, "内部错误");
 	public static final ZSKKError OPTION_ERROR		= new ZSKKError(501, "操作失败,请重试");