Exemplo 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;

            this.InitJumpUrlRoute();
            JumpUrlRoute jumpUrlRoute = null;

            url    = url.ToLower();
            lower  = lower.ToLower();
            str    = str.ToLower();
            lower1 = lower1.ToLower();
            List <JumpUrlRoute> jumpUrlRouteData = this.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);
        }
Exemplo n.º 2
0
        public void InitJumpUrlRoute()
        {
            this._JumpUrlRouteData = new List <JumpUrlRoute>();
            JumpUrlRoute jumpUrlRoute = new JumpUrlRoute()
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "UserOrder",
                PC         = "/userorder",
                WAP        = "/member/orders",
                WX         = "/member/orders"
            };

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

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

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

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

            this._JumpUrlRouteData.Add(jumpUrlRoute4);
        }
Exemplo n.º 3
0
        protected void JumpMobileUrl(RouteData route, string url = "")
        {
            string pathAndQuery = base.Request.Url.PathAndQuery;
            string wX           = pathAndQuery;

            if (route != null)
            {
                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"))
                {
                    if (str1 == "web")
                    {
                        this.IsAutoJumpMobile = true;
                    }
                    if ((!this.IsAutoJumpMobile ? false : this.IsMobileTerminal))
                    {
                        if (Regex.Match(pathAndQuery, "\\/m(\\-.*)?").Length < 1)
                        {
                            JumpUrlRoute routeUrl = this.GetRouteUrl(lower, str, str1, pathAndQuery);
                            switch (this.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 = (long)0;
                                    //long id = (long)0;
                                    //if (!long.TryParse(str2, out num))
                                    //{
                                    //    num = (long)0;
                                    //}
                                    //if (num > (long)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 (!this.IsExistPage(string.Concat(base.Request.Url.Scheme, "://", base.Request.Url.Authority, wX)))
                            {
                                wX = (this.visitorTerminalInfo.Terminal != EnumVisitorTerminal.WeiXin ? "/m-wap/" : "/m-weixin/");
                            }
                            base.Response.Redirect(wX);
                        }
                    }
                }
            }
        }