예제 #1
0
        /// <summary>
        /// 初始移动页面跳转路由列表
        /// </summary>
        //TODO:DZY[150730] 路由初始

        /*
         * _JumpUrlRouteData , 是否需要确认带下划线的成员变量规范
         */
        public void InitJumpUrlRoute()
        {
            _JumpUrlRouteData = new System.Collections.Generic.List <JumpUrlRoute>();
            JumpUrlRoute _tmp = new JumpUrlRoute()
            {
                Action = "Index", Area = "Web", Controller = "UserOrder", PC = @"/userorder", WAP = @"/member/orders", WX = @"/member/orders"
            };

            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Index", Area = "Web", Controller = "UserCenter", PC = @"/usercenter", WAP = @"/member/center", WX = @"/member/center"
            };
            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Index", Area = "Web", Controller = "Login", PC = @"/login", WAP = @"/login/entrance", WX = @"/login/entrance"
            };
            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Home", Area = "Web", Controller = "Shop", PC = @"/shop", WAP = @"/vshop/detail", WX = @"/vshop/detail", IsSpecial = true
            };
            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Submit", Area = "Web", Controller = "Order", PC = @"/order/submit", WAP = @"/order/SubmiteByCart", WX = @"/order/SubmiteByCart", IsSpecial = true
            };
            _JumpUrlRouteData.Add(_tmp);
        }
예제 #2
0
        /// <summary>
        /// 返回URL对应路由信息
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        //TODO:DZY[150730] 路由信息获取

        /*
         * TODO可移除
         */
        public JumpUrlRoute GetRouteUrl(string controller, string action, string area, string url)
        {
            InitJumpUrlRoute();
            JumpUrlRoute result = null;

            url        = url.ToLower();
            controller = controller.ToLower();
            action     = action.ToLower();
            area       = area.ToLower();
            List <JumpUrlRoute> sql = JumpUrlRouteData;

            if (!string.IsNullOrWhiteSpace(area))
            {
                sql = sql.FindAll(d => d.Area.ToLower() == area);
            }
            if (!string.IsNullOrWhiteSpace(controller))
            {
                sql = sql.FindAll(d => d.Controller.ToLower() == controller);
            }
            if (!string.IsNullOrWhiteSpace(action))
            {
                sql = sql.FindAll(d => d.Action.ToLower() == action);
            }
            result = sql.Count > 0 ? sql[0] : null;

            if (result == null)
            {
                result = new JumpUrlRoute()
                {
                    PC = url, WAP = url, WX = url
                };
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// 跳转到手机URL
        /// </summary>
        /// <param name="JumpUrl">为空表示自动处理</param>
        //TODO:DZY[150730] 统一跳转

        /* zjt
         * Url请改为小写 【参数命名规范】
         */
        protected void JumpMobileUrl(ActionExecutingContext filterContext, string url = "")
        {
            string curUrl  = Request.Path.ToString() + Request.QueryString.ToString();
            string jumpUrl = curUrl;
            var    route   = filterContext.RouteData;

            //无路由信息不跳转
            if (route == null)
            {
                return;
            }

            //路由处理
            string controller = route.Values["controller"].ToString().ToLower();
            string action     = route.Values["action"].ToString().ToLower();
            //string area = (route.DataTokens["area"] == null ? "" : route.DataTokens["area"].ToString().ToLower());


            object areaObj = null;
            string area    = "";

            if (filterContext.RouteData.Values.TryGetValue("area", out areaObj))
            {
                area = areaObj.ToString().ToLower();
            }



            if (area == "mobile" || area == "admin")
            {
                return;  //在移动端跳出
            }
            //Web区域跳转移动端
            if (area == "web")
            {
                IsAutoJumpMobile = true;
            }

            if (this.IsAutoJumpMobile && IsMobileTerminal)
            {
                if (Regex.Match(curUrl, @"\/m(\-.*)?").Length < 1)
                {
                    JumpUrlRoute jurdata = GetRouteUrl(controller, action, area, curUrl);
                    //非手机端跳转
                    switch (visitorTerminalInfo.Terminal)
                    {
                    case EnumVisitorTerminal.WeiXin:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WX;
                        }
                        jumpUrl = @"/m-WeiXin" + jumpUrl;
                        break;

                    case EnumVisitorTerminal.IOS:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WAP;
                        }
                        jumpUrl = @"/m-ios" + jumpUrl;
                        break;

                    default:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WAP;
                        }
                        jumpUrl = @"/m-wap" + jumpUrl;
                        break;
                    }

                    #region 参数特殊处理
                    if (jurdata.IsSpecial)
                    {
                        #region 店铺参数转换
                        if (jurdata.PC.ToLower() == @"/shop")
                        {
                            //商家首页参数处理
                            string strid   = route.Values["id"].ToString();
                            long   shopId  = 0;
                            long   vshopId = 0;
                            if (!long.TryParse(strid, out shopId))
                            {
                                shopId = 0;
                            }
                            if (shopId > 0)
                            {
                                var vshop = VshopApplication.GetVShopByShopId(shopId);
                                if (vshop != null)
                                {
                                    vshopId = vshop.Id;
                                }
                            }
                            jumpUrl = jumpUrl + "/" + vshopId.ToString();
                        }
                        #endregion

                        //TODO:LRL 订单页面参数转换

                        /* zjt
                         * TODO可移除,保留注释即可
                         */
                        #region  单页面参数转换
                        if (jurdata.PC.ToLower() == @"/order/submit")
                        {
                            //商家首页参数处理
                            var strcartid = string.Empty;
                            var arg       = route.Values["cartitemids"];
                            if (arg == null)
                            {
                                strcartid = Request.Query["cartitemids"].ToString();
                            }
                            else
                            {
                                strcartid = arg.ToString();
                            }
                            jumpUrl = jumpUrl + "/?cartItemIds=" + strcartid;
                        }
                        #endregion
                    }
                    #endregion

                    if (!string.IsNullOrWhiteSpace(url))
                    {
                        jumpUrl = url;
                    }
                    //string testurl = jumpUrl;
                    //testurl = Request.Url.Scheme + "://" + Request.Url.Authority + testurl;
                    ////页面不存在
                    //if (!IsExistPage(testurl))
                    //{
                    //    if (visitorTerminalInfo.Terminal == EnumVisitorTerminal.WeiXin)
                    //    {
                    //        jumpUrl = @"/m-WeiXin/";
                    //    }
                    //    else
                    //    {
                    //        jumpUrl = @"/m-wap/";
                    //    }

                    //}

                    filterContext.Result = Redirect(jumpUrl);
                }
            }
        }