コード例 #1
0
        public JsonResult UpdateMenu(string menuId, string menuName, int urlType, string url, string parentId)
        {
            var curUrl = CurrentUrlHelper.CurrentUrlNoPort();

            switch (urlType)
            {
            case 1:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/";
                break;

            case 2:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/vshop";
                break;

            case 3:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/category/Index";
                break;

            case 4:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/member/center";
                break;

            case 5:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/cart/cart";
                break;

            default:
                break;
            }
            if ((!string.IsNullOrEmpty(url)) && (!(url.ToLower().Contains("http://") || url.ToLower().Contains("https://"))))
            {
                throw new Himall.Core.HimallException("链接必须以http://开头");
            }

            Result result   = new Result();
            var    menuInfo = new Entities.MenuInfo();

            menuInfo.Id       = Convert.ToInt64(menuId);
            menuInfo.Title    = menuName;
            menuInfo.UrlType  = (Entities.MenuInfo.UrlTypes)urlType;
            menuInfo.Url      = url;
            menuInfo.ParentId = Convert.ToInt64(parentId);
            _iWeixinMenuService.UpdateMenu(menuInfo);
            result.success = true;
            return(Json(result));
        }
コード例 #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));
        }