/// <summary> /// 修改主题设置 /// </summary> /// <param name="templateId">当前启用的模板ID</param> /// <param name="id">主键ID</param> /// <param name="typeId">0、默认;1、自定义主题</param> /// <param name="MainColor">主色</param> /// <param name="SecondaryColor">商城辅色</param> /// <param name="WritingColor">字体颜色</param> /// <param name="FrameColor">边框颜色</param> /// <param name="ClassifiedsColor">边框栏颜色</param> /// <returns></returns> public JsonResult updateTheme(int templateId, long id, int typeId, string MainColor = "", string SecondaryColor = "", string WritingColor = "", string FrameColor = "", string ClassifiedsColor = "") { Theme mVTheme = new Theme() { ThemeId = id, TypeId = (Himall.CommonModel.ThemeType)typeId, MainColor = MainColor, SecondaryColor = SecondaryColor, WritingColor = WritingColor, FrameColor = FrameColor, ClassifiedsColor = ClassifiedsColor }; ThemeApplication.SetTheme(mVTheme); #region 保存当前主题配色设置[前端页面使用]且保存到主题配色的Json文件 ThemeSetting theme = new ThemeSetting() { classifiedsColor = mVTheme.ClassifiedsColor, frameColor = mVTheme.FrameColor, mainColor = mVTheme.MainColor, secondaryColor = mVTheme.SecondaryColor, themeId = mVTheme.ThemeId, typeId = mVTheme.TypeId, writingColor = mVTheme.WritingColor, templateId = templateId }; List <ThemeSetting> curThemeObjs = new List <ThemeSetting>(); string path = this.Server.MapPath(_themesettings); if (System.IO.File.Exists(path)) { string currentTheme = System.IO.File.ReadAllText(path);//读取当前模板应用的主题配色 curThemeObjs = ParseFormJson <List <ThemeSetting> >(currentTheme); if (curThemeObjs != null && curThemeObjs.Count > 0) { var info = curThemeObjs.FirstOrDefault(a => a.templateId == templateId); if (info != null) { curThemeObjs.Remove(info); } } } curThemeObjs.Add(theme); string fullName = this.Server.MapPath(_themesettings); string themeJson = ObjectToJson <List <ThemeSetting> >(curThemeObjs, Encoding.UTF8); using (var fs = new FileStream(fullName, FileMode.Create, FileAccess.Write)) { var buffer = System.Text.Encoding.UTF8.GetBytes(themeJson); fs.Write(buffer, 0, buffer.Length); } #endregion return(Json(new { status = 1 })); }
/// <summary> /// 主题设置 /// </summary> private void setTheme() { Himall.DTO.Theme vmTheme = ThemeApplication.getTheme(); ViewBag.TypeId = vmTheme.TypeId; ViewBag.WritingColor = vmTheme.WritingColor; ViewBag.SecondaryColor = vmTheme.SecondaryColor; ViewBag.MainColor = vmTheme.MainColor; ViewBag.FrameColor = vmTheme.FrameColor; ViewBag.ClassifiedsColor = vmTheme.ClassifiedsColor; }
/// <summary> /// 修改主题设置 /// </summary> /// <param name="id">主键ID</param> /// <param name="typeId">0、默认;1、自定义主题</param> /// <param name="MainColor">主色</param> /// <param name="SecondaryColor">商城辅色</param> /// <param name="WritingColor">字体颜色</param> /// <param name="FrameColor">边框颜色</param> /// <param name="ClassifiedsColor">边框栏颜色</param> /// <returns></returns> public JsonResult updateTheme(long id, int typeId, string MainColor = "", string SecondaryColor = "", string WritingColor = "", string FrameColor = "", string ClassifiedsColor = "") { Theme mVTheme = new Theme() { ThemeId = id, TypeId = (Himall.CommonModel.ThemeType)typeId, MainColor = MainColor, SecondaryColor = SecondaryColor, WritingColor = WritingColor, FrameColor = FrameColor, ClassifiedsColor = ClassifiedsColor }; ThemeApplication.SetTheme(mVTheme); return(Json(new { status = 1 })); }
public ActionResult UserCenterCss() { Himall.DTO.Theme vmTheme = ThemeApplication.getTheme(); return(PartialView("_UserCenterCss", vmTheme)); }
public ActionResult OrderTopBarCss() { Himall.DTO.Theme vmTheme = ThemeApplication.getTheme(); return(PartialView("_OrderTopBarCss", vmTheme)); }
public ActionResult SetTheme() { return(View(ThemeApplication.getTheme())); }