Ejemplo n.º 1
0
        public JumpUrlRoute GetRouteUrl(string controller, string action, string area, string url)
        {
            JumpUrlRoute item;
            string       lower  = controller;
            string       str    = action;
            string       lower1 = area;

            InitJumpUrlRoute();
            JumpUrlRoute jumpUrlRoute = null;

            url    = url.ToLower();
            lower  = lower.ToLower();
            str    = str.ToLower();
            lower1 = lower1.ToLower();
            List <JumpUrlRoute> jumpUrlRouteData = JumpUrlRouteData;

            if (!string.IsNullOrWhiteSpace(lower1))
            {
                jumpUrlRouteData = jumpUrlRouteData.FindAll((JumpUrlRoute d) => d.Area.ToLower() == lower1);
            }
            if (!string.IsNullOrWhiteSpace(lower))
            {
                jumpUrlRouteData = jumpUrlRouteData.FindAll((JumpUrlRoute d) => d.Controller.ToLower() == lower);
            }
            if (!string.IsNullOrWhiteSpace(str))
            {
                jumpUrlRouteData = jumpUrlRouteData.FindAll((JumpUrlRoute d) => d.Action.ToLower() == str);
            }
            if (jumpUrlRouteData.Count > 0)
            {
                item = jumpUrlRouteData[0];
            }
            else
            {
                item = null;
            }
            jumpUrlRoute = item;
            if (jumpUrlRoute == null)
            {
                JumpUrlRoute jumpUrlRoute1 = new JumpUrlRoute()
                {
                    PC  = url,
                    WAP = url,
                    WX  = url
                };
                jumpUrlRoute = jumpUrlRoute1;
            }
            return(jumpUrlRoute);
        }
Ejemplo n.º 2
0
        protected void JumpMobileUrl(System.Web.Routing.RouteData route, string url = "")
        {
            string pathAndQuery = base.Request.Url.PathAndQuery;
            string wX           = pathAndQuery;

            if (route == null)
            {
                return;
            }
            string lower = route.Values["controller"].ToString().ToLower();
            string str   = route.Values["action"].ToString().ToLower();
            string str1  = (route.DataTokens["area"] == null ? "" : route.DataTokens["area"].ToString().ToLower());

            if (str1 == "mobile")
            {
                return;
            }
            if (str1 == "web")
            {
                IsAutoJumpMobile = true;
            }
            if (IsAutoJumpMobile && IsMobileTerminal && Regex.Match(pathAndQuery, "\\/m(\\-.*)?").Length < 1)
            {
                JumpUrlRoute routeUrl = GetRouteUrl(lower, str, str1, pathAndQuery);
                switch (visitorTerminalInfo.Terminal)
                {
                case EnumVisitorTerminal.WeiXin:
                    {
                        if (routeUrl != null)
                        {
                            wX = routeUrl.WX;
                        }
                        wX = string.Concat("/m-weixin", wX);
                        break;
                    }

                case EnumVisitorTerminal.IOS:
                {
                    if (routeUrl != null)
                    {
                        wX = routeUrl.WAP;
                    }
                    wX = string.Concat("/m-ios", wX);
                    break;
                }

                default:
                {
                    if (routeUrl != null)
                    {
                        wX = routeUrl.WAP;
                    }
                    wX = string.Concat("/m-wap", wX);
                    break;
                }
                }
                if (routeUrl.IsSpecial)
                {
                    if (routeUrl.PC.ToLower() == "/shop")
                    {
                        string str2 = route.Values["id"].ToString();
                        long   num  = 0;
                        long   id   = 0;
                        if (!long.TryParse(str2, out num))
                        {
                            num = 0;
                        }
                        if (num > 0)
                        {
                            VShopInfo vShopByShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(num);
                            if (vShopByShopId != null)
                            {
                                id = vShopByShopId.Id;
                            }
                        }
                        wX = string.Concat(wX, "/", id.ToString());
                    }
                    if (routeUrl.PC.ToLower() == "/order/submit")
                    {
                        string empty = string.Empty;
                        object item  = route.Values["cartitemids"];
                        empty = (item != null ? item.ToString() : base.Request.QueryString["cartitemids"]);
                        wX    = string.Concat(wX, "/?cartItemIds=", empty);
                    }
                }
                if (!string.IsNullOrWhiteSpace(url))
                {
                    wX = url;
                }
                if (!IsExistPage(string.Concat(base.Request.Url.Scheme, "://", base.Request.Url.Authority, wX)))
                {
                    wX = (visitorTerminalInfo.Terminal != EnumVisitorTerminal.WeiXin ? "/m-wap/" : "/m-weixin/");
                }
                base.Response.Redirect(wX);
            }
        }
Ejemplo n.º 3
0
        public void InitJumpUrlRoute()
        {
            _JumpUrlRouteData = new List <JumpUrlRoute>();
            JumpUrlRoute jumpUrlRoute = new JumpUrlRoute()
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "UserOrder",
                PC         = "/userorder",
                WAP        = "/member/orders",
                WX         = "/member/orders"
            };

            _JumpUrlRouteData.Add(jumpUrlRoute);
            JumpUrlRoute jumpUrlRoute1 = new JumpUrlRoute()
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "UserCenter",
                PC         = "/usercenter",
                WAP        = "/member/center",
                WX         = "/member/center"
            };

            _JumpUrlRouteData.Add(jumpUrlRoute1);
            JumpUrlRoute jumpUrlRoute2 = new JumpUrlRoute()
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "Login",
                PC         = "/login",
                WAP        = "/login/entrance",
                WX         = "/login/entrance"
            };

            _JumpUrlRouteData.Add(jumpUrlRoute2);
            JumpUrlRoute jumpUrlRoute3 = new JumpUrlRoute()
            {
                Action     = "Home",
                Area       = "Web",
                Controller = "Shop",
                PC         = "/shop",
                WAP        = "/vshop/detail",
                WX         = "/vshop/detail",
                IsSpecial  = true
            };

            _JumpUrlRouteData.Add(jumpUrlRoute3);
            JumpUrlRoute jumpUrlRoute4 = new JumpUrlRoute()
            {
                Action     = "Submit",
                Area       = "Web",
                Controller = "Order",
                PC         = "/order/submit",
                WAP        = "/order/SubmiteByCart",
                WX         = "/order/SubmiteByCart",
                IsSpecial  = true
            };

            _JumpUrlRouteData.Add(jumpUrlRoute4);
        }