public JsonResult AddMenu(string title, string url, string parentId, int urlType)
        {
            short depth;

            if (parentId == "0")
            {
                depth = 1;
            }
            else
            {
                depth = 2;
            }

            switch (urlType)
            {
            case 1:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/";
                break;

            case 2:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop";
                break;

            case 3:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/category/Index";
                break;

            case 4:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/member/center";
                break;

            case 5:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/cart/cart";
                break;

            default:
                break;
            }
            if ((!string.IsNullOrEmpty(url)) && (!url.Contains("http://")))
            {
                throw new Himall.Core.HimallException("链接必须以http://开头");
            }
            Result   result = new Result();
            MenuInfo menu   = new MenuInfo()
            {
                Title      = title,
                Url        = url,
                ParentId   = Convert.ToInt64(parentId),
                Platform   = PlatformType.WeiXin,
                Depth      = depth,
                ShopId     = CurrentManager.ShopId,
                FullIdPath = "1",
                Sequence   = 1,
                UrlType    = (MenuInfo.UrlTypes)urlType
            };

            _iWeixinMenuService.AddMenu(menu);
            result.success = true;
            return(Json(result));
        }
Exemple #2
0
        public JsonResult AddMenu(string title, string url, string parentId, int urlType, long?menuId)
        {
            var   vshopInfo = _iVShopService.GetVShopByShopId(CurrentSellerManager.ShopId);
            short depth;

            if (parentId == "0")
            {
                depth = 1;
            }
            else
            {
                depth = 2;
            }

            switch (urlType)
            {
            case 1:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshopInfo.Id + "?shop=" + CurrentSellerManager.ShopId;
                break;

            case 2:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/category?vshopid=" + vshopInfo.Id + "&shop=" + CurrentSellerManager.ShopId;
                break;

            case 3:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/cart/cart?shop=" + CurrentSellerManager.ShopId;
                break;

            case 4:
                url = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/member/center?shop=" + CurrentSellerManager.ShopId;
                break;

            default:
                break;
            }
            if ((!string.IsNullOrEmpty(url)) && (!url.Contains("http://")))
            {
                throw new Himall.Core.HimallException("链接必须以http://开头");
            }
            Result   result = new Result();
            MenuInfo menu   = new MenuInfo()
            {
                Title      = title,
                Url        = url,
                ParentId   = Convert.ToInt64(parentId),
                Platform   = PlatformType.WeiXin,
                Depth      = depth,
                ShopId     = CurrentSellerManager.ShopId,
                FullIdPath = "1",
                Sequence   = 1,
                UrlType    = (MenuInfo.UrlTypes)urlType
            };

            if (menuId.HasValue)
            {
                menu.Id = menuId.Value;
                _iWeixinMenuService.UpdateMenu(menu);
            }
            else
            {
                _iWeixinMenuService.AddMenu(menu);
            }
            result.success = true;
            return(Json(result));
        }