Ejemplo n.º 1
0
        public JsonResult GetMenu(long?menuId)
        {
            var menu = new Entities.MenuInfo();

            if (menuId.HasValue)
            {
                menu = _iWeixinMenuService.GetMenu(menuId.Value);
            }
            return(Json(new { success = true, title = menu.Title, urlType = menu.UrlType, url = menu.Url, parentId = menu.ParentId }));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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;
            }
            var curUrl = CurrentUrlHelper.CurrentUrlNoPort();

            switch (urlType)
            {
            case 0:
                url = string.Empty;
                break;

            case 1:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshopInfo.Id + "?shop=" + CurrentSellerManager.ShopId;
                break;

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

            case 3:
                url = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/cart/cart?shop=" + CurrentSellerManager.ShopId;
                break;

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

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

            if (menuId.HasValue)
            {
                menu.Id = menuId.Value;
                _iWeixinMenuService.UpdateMenu(menu);
            }
            else
            {
                _iWeixinMenuService.AddMenu(menu);
            }
            result.success = true;
            return(Json(result));
        }
Ejemplo n.º 4
0
        public JsonResult AddMenu(string title, string url, string parentId, int urlType)
        {
            short depth;

            if (parentId == "0")
            {
                depth = 1;
            }
            else
            {
                depth = 2;
            }
            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    menu   = new Entities.MenuInfo()
            {
                Title      = title,
                Url        = url,
                ParentId   = Convert.ToInt64(parentId),
                Platform   = PlatformType.WeiXin,
                Depth      = depth,
                ShopId     = CurrentManager.ShopId,
                FullIdPath = "1",
                Sequence   = 1,
                UrlType    = (Entities.MenuInfo.UrlTypes)urlType
            };

            _iWeixinMenuService.AddMenu(menu);
            result.success = true;
            return(Json(result));
        }