Пример #1
0
        public void ddlNavigationType_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            var isHideAll = false;

            if (_parentId == 0 && _menuId > 0)
            {
                var childrenCount = DataProviderWx.WebMenuDao.GetCount(PublishmentSystemId, _menuId);
                if (childrenCount > 0)
                {
                    isHideAll = true;
                }
            }

            if (isHideAll)
            {
                PhNavigationType.Visible = PhUrl.Visible = PhFunction.Visible = PhSite.Visible = false;
            }
            else
            {
                var navigationType = ENavigationTypeUtils.GetEnumType(DdlNavigationType.SelectedValue);

                PhUrl.Visible = PhFunction.Visible = PhSite.Visible = false;

                if (navigationType == ENavigationType.Url)
                {
                    PhUrl.Visible = true;
                }
                else if (navigationType == ENavigationType.Function)
                {
                    PhFunction.Visible = true;
                }
                else if (navigationType == ENavigationType.Site)
                {
                    PhSite.Visible = true;
                }
            }
        }
Пример #2
0
        public void ddlNavigationType_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            var isHideAll = false;

            if (parentID == 0 && menuID > 0)
            {
                var childrenCount = DataProviderWX.WebMenuDAO.GetCount(PublishmentSystemID, menuID);
                if (childrenCount > 0)
                {
                    isHideAll = true;
                }
            }

            if (isHideAll)
            {
                phNavigationType.Visible = phUrl.Visible = phFunction.Visible = phSite.Visible = false;
            }
            else
            {
                var navigationType = ENavigationTypeUtils.GetEnumType(ddlNavigationType.SelectedValue);

                phUrl.Visible = phFunction.Visible = phSite.Visible = false;

                if (navigationType == ENavigationType.Url)
                {
                    phUrl.Visible = true;
                }
                else if (navigationType == ENavigationType.Function)
                {
                    phFunction.Visible = true;
                }
                else if (navigationType == ENavigationType.Site)
                {
                    phSite.Visible = true;
                }
            }
        }
Пример #3
0
        public static string ParseWebMenu(PublishmentSystemInfo publishmentSystemInfo)
        {
            if (publishmentSystemInfo.Additional.WxIsWebMenu && !string.IsNullOrEmpty(publishmentSystemInfo.Additional.WxWebMenuType))
            {
                var directoryUrl = SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/components/webMenu/{publishmentSystemInfo.Additional.WxWebMenuType}");
                if (PageUtils.IsProtocolUrl(publishmentSystemInfo.PublishmentSystemUrl))
                {
                    directoryUrl = PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/components/webMenu/{publishmentSystemInfo.Additional.WxWebMenuType}"));
                }

                var menuPath = SiteFilesAssets.GetPath($"weixin/components/webMenu/{publishmentSystemInfo.Additional.WxWebMenuType}/template.html");
                var menuHtml = StlCacheManager.FileContent.GetContentByFilePath(menuPath, ECharset.utf_8);

                var startIndex   = menuHtml.IndexOf("<!--menu-->");
                var endIndex     = menuHtml.IndexOf("<!--menu-->", startIndex + 1);
                var menuTemplate = menuHtml.Substring(startIndex, endIndex - startIndex);

                var startSubIndex   = menuTemplate.IndexOf("<!--submenu-->");
                var endSubIndex     = menuTemplate.IndexOf("<!--submenu-->", startSubIndex + 1);
                var subMenuTemplate = menuTemplate.Substring(startSubIndex, endSubIndex - startSubIndex);

                var menuBuilder  = new StringBuilder();
                var menuInfoList = DataProviderWX.WebMenuDAO.GetMenuInfoList(publishmentSystemInfo.PublishmentSystemId, 0);

                var index = 0;
                foreach (var menuInfo in menuInfoList)
                {
                    var subMenuBuilder  = new StringBuilder();
                    var subMenuInfoList = DataProviderWX.WebMenuDAO.GetMenuInfoList(publishmentSystemInfo.PublishmentSystemId, menuInfo.ID);

                    if (subMenuInfoList != null && subMenuInfoList.Count > 0)
                    {
                        menuInfo.NavigationType = ENavigationTypeUtils.GetValue(ENavigationType.Url);
                        menuInfo.Url            = PageUtils.UnclickedUrl;

                        foreach (var subMenuInfo in subMenuInfoList)
                        {
                            var subMenu = subMenuTemplate.Replace("{{url}}", GetNavigationUrl(publishmentSystemInfo, ENavigationTypeUtils.GetEnumType(subMenuInfo.NavigationType), EKeywordTypeUtils.GetEnumType(subMenuInfo.KeywordType), subMenuInfo.FunctionID, subMenuInfo.ChannelID, subMenuInfo.ContentID, subMenuInfo.Url));
                            subMenu = subMenu.Replace("{{menuName}}", subMenuInfo.MenuName);
                            subMenuBuilder.Append(subMenu);
                        }
                    }
                    var menu = menuTemplate.Substring(0, startSubIndex) + subMenuBuilder.ToString() + menuTemplate.Substring(endSubIndex);

                    menu = menu.Replace("{{url}}", GetNavigationUrl(publishmentSystemInfo, ENavigationTypeUtils.GetEnumType(menuInfo.NavigationType), EKeywordTypeUtils.GetEnumType(menuInfo.KeywordType), menuInfo.FunctionID, menuInfo.ChannelID, menuInfo.ContentID, menuInfo.Url));
                    menu = menu.Replace("{{index}}", index.ToString());
                    menu = menu.Replace("{{menuName}}", menuInfo.MenuName);
                    menuBuilder.Append(menu);
                    index++;
                }

                menuHtml = menuHtml.Substring(0, startIndex) + menuBuilder.ToString() + menuHtml.Substring(endIndex);

                return($@"
<link rel=""stylesheet"" type=""text/css"" href=""{directoryUrl}/style.css"" />
<script type=""text/javascript"" src=""{directoryUrl}/script.js""></script>
{menuHtml}");
            }
            return(string.Empty);
        }