12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using CZFW.Framework.Interface;
- using CZFW.Framework.Model;
- using CZFW.Framework.Model.Entity;
- using CZFW.Framework.Model.ViewModel;
- using CZKJ.GBRS2.WebMVC.Models;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace CZKJ.GBRS2.WebMVC.ViewComponents
- {
- public class HeaderViewComponent : ViewComponent
- {
- public IViewComponentResult Invoke()
- {
- var items = GetItems();
- return View(items);
- }
- private HeaderModel GetItems()
- {
- INavigation context = CZHttpContext.ServiceProvider.GetService(typeof(INavigation)) as INavigation;
- ISysConfig sys = CZHttpContext.ServiceProvider.GetService(typeof(ISysConfig)) as ISysConfig;
- var model = new HeaderModel();
- model.NavigationModel = context.GetNavigationTreeByMark("0$15231983314041342$");
- var result = sys.GetSysConfig("CLogo", "Llogo");
- model.BigLogo = result.FirstOrDefault(x => x.Key == "CLogo").Value;
- model.SmallLogo = result.FirstOrDefault(x => x.Key == "Llogo").Value;
- var session = HttpContext.Session.GetString("GBRS2018");
- if (!string.IsNullOrWhiteSpace(session))
- {
- var user= JsonConvert.DeserializeObject<CZKJ.GBRS2.Model.UserInfoModel>(session);
- model.Name = user.Customer_info.Name;
- model.NickName = user.Nickname;
- model.IsLogin = true;
- model.Head_Url = user.Head_url;
- }
- model.BeforeUrl = $"{Request.Scheme}{Request.PathBase}{Request.Path}{Request.QueryString}";
- return model;
- }
- }
- }
|