Esempio n. 1
0
        // GET: Mobile/Home
        public ActionResult Index(int ispv = 0, string tn = "")
        {
            string crrentTemplateName = "t1";
            var    curr = _iTemplateSettingsService.GetCurrentTemplate(0);

            if (null != curr)
            {
                crrentTemplateName = curr.CurrentTemplateName;
            }
            if (ispv == 1)
            {
                if (!string.IsNullOrWhiteSpace(tn))
                {
                    crrentTemplateName = tn;
                }
            }
            ViewBag.Title     = SiteSettings.SiteName + "首页";
            ViewBag.FootIndex = 0;

            var services = CustomerServiceApplication.GetPlatformCustomerService(true, true);

            ViewBag.CustomerServices = services;
            VTemplateHelper.DownloadTemplate(crrentTemplateName, VTemplateClientTypes.WapIndex, 0);
            return(View(string.Format("~/Areas/Admin/Templates/vshop/{0}/Skin-HomePage.cshtml", crrentTemplateName)));
        }
        public ActionResult Hi_Ajax_GetTemplateByID(string client, int type = 1)
        {
            string templatePath = VTemplateHelper.GetTemplatePath(client, (VTemplateClientTypes)type);
            var    datapath     = templatePath + "data/default.json";
            var    fileName     = Server.MapPath(datapath);

            if (!System.IO.File.Exists(fileName))
            {
                return(Content(string.Empty));
            }
            StreamReader sr = new StreamReader(Server.MapPath(datapath),
                                               System.Text.Encoding.UTF8);

            try
            {
                string input = sr.ReadToEnd();
                sr.Close();
                input = input.Replace("\r\n", "").Replace("\n", "");
                return(Content(input));
            }
            catch
            {
                return(Content(""));
            }
        }
Esempio n. 3
0
        public ActionResult Detail(long id)
        {
            TopicInfo topic   = _iTopicService.GetTopicInfo(id);
            string    tmppath = VTemplateHelper.GetTemplatePath(id.ToString(), VTemplateClientTypes.WapSpecial);

            tmppath = "~" + tmppath;
            string viewpath = tmppath + "Skin-HomePage.cshtml";

            ViewBag.Title = "专题-" + topic.Name;
            return(View(viewpath));
        }
Esempio n. 4
0
        public ActionResult HomePageSetting()
        {
            var model = new VTemplateEditModel();

            model.ClientType = VTemplateClientTypes.WXSmallProgram;
            model.Name       = "smallprog";
            //门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            VTemplateHelper.DownloadTemplate("", model.ClientType, 0);
            return(View(model));
        }
Esempio n. 5
0
        //APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS
        public ActionResult AppHomePageSetting()
        {
            VTemplateEditModel model = new Models.VTemplateEditModel();

            model.ClientType = VTemplateClientTypes.AppIndex;
            model.Name       = "APP";
            //门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            VTemplateHelper.DownloadTemplate("", VTemplateClientTypes.AppIndex, 0);
            return(View(model));
        }
Esempio n. 6
0
        public ActionResult Detail(long id)
        {
            TopicInfo topicInfo = this._iTopicService.GetTopicInfo(id);
            string    str       = VTemplateHelper.GetTemplatePath(id.ToString(), VTemplateClientTypes.WapSpecial, 0L);
            string    viewName  = "~" + str + "Skin-HomePage.cshtml";

            if (topicInfo != null)
            {
                ((dynamic)base.ViewBag).Title = "专题-" + topicInfo.Name;
            }
            VTemplateHelper.DownloadTemplate(id.ToString(), VTemplateClientTypes.WapSpecial, 0L);
            return(base.View(viewName, topicInfo));
        }
Esempio n. 7
0
        /// <summary>
        /// 获取模板节点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetTemplateItem(string id, string tn = "")
        {
            string result = "";

            if (string.IsNullOrWhiteSpace(tn))
            {
                tn = "t1";
                var curr = _iTemplateSettingsService.GetCurrentTemplate(0);
                if (null != curr)
                {
                    tn = curr.CurrentTemplateName;
                }
            }
            result = VTemplateHelper.GetTemplateItemById(id, tn, VTemplateClientTypes.WapIndex);
            return(result);
        }
        public ActionResult Hi_Ajax_GetTemplateByID(string client, int type = 2)
        {
            string       templatePath = VTemplateHelper.GetTemplatePath(client, (VTemplateClientTypes)type, CurrentSellerManager.ShopId);
            var          datapath     = templatePath + "data/default.json";
            StreamReader sr           = new StreamReader(Server.MapPath(datapath),
                                                         System.Text.Encoding.UTF8);

            try
            {
                string input = sr.ReadToEnd();
                sr.Close();
                input = input.Replace("\r\n", "").Replace("\n", "");
                return(Content(input));
            }
            catch
            {
                return(Content(""));
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 模板编辑
        /// </summary>
        /// <param name="client"></param>
        /// <param name="tName"></param>
        /// <returns></returns>
        public ActionResult EditTemplate(int client = 1, string tName = "t1")
        {
            VTemplateEditModel model = new VTemplateEditModel();

            model.Name          = tName;
            model.ClientType    = (VTemplateClientTypes)client;
            model.IsShowPrvPage = true;
            string templateName = "EditTemplate";

            switch (model.ClientType)
            {
            case VTemplateClientTypes.WapSpecial:
            case VTemplateClientTypes.SellerWapSpecial:
                model.IsShowTitle   = true;
                model.IsShowTags    = true;
                model.IsShowPrvPage = false;
                model.IsShowIcon    = true;
                break;

            case VTemplateClientTypes.AppSpecial:
                model.IsShowTitle   = true;
                model.IsShowTags    = true;
                model.IsShowPrvPage = false;
                model.IsShowIcon    = true;
                templateName        = "EditTemplate-AppTopic";
                break;

            case VTemplateClientTypes.WXSmallProgramSpecial:
                model.IsShowTitle   = true;
                model.IsShowTags    = true;
                model.IsShowPrvPage = false;
                model.IsShowIcon    = true;
                templateName        = "EditTemplate-AppletTopic";
                break;
            }
            //门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            VTemplateHelper.DownloadTemplate(model.Name, model.ClientType);
            return(View(templateName, model));
        }
Esempio n. 10
0
        public ActionResult Detail(long id)
        {
            var    topic   = TopicApplication.GetTopic(id);
            string tmppath = VTemplateHelper.GetTemplatePath(id.ToString(), VTemplateClientTypes.WapSpecial);

            tmppath = "~" + tmppath;
            string viewpath = tmppath + "Skin-HomePage.cshtml";

            if (topic != null)
            {//判空处理
                ViewBag.Title = "专题-" + topic.Name;
            }
            else
            {
                throw new Himall404();
            }
            VTemplateHelper.DownloadTemplate(id.ToString(), VTemplateClientTypes.WapSpecial);
            ViewBag.ShopId = topic.ShopId;
            var vshop = VshopApplication.GetVShopByShopId(topic.ShopId);

            ViewBag.VshopId = vshop == null ? 0 : vshop.Id;
            return(View(viewpath, topic));
        }
        public ActionResult Hi_Ajax_SaveTemplate(int is_preview, string client, string content = "", int type = 1, long shopId = 0)
        {
            string  template           = client;
            string  str2               = content;
            JObject obj2               = (JObject)JsonConvert.DeserializeObject(str2);
            JToken  jt                 = obj2["page"];
            string  title              = this.TryGetJsonString(jt, "title");
            string  str4               = this.TryGetJsonString(jt, "describe");
            string  tags               = this.TryGetJsonString(jt, "tags");
            string  filepath           = this.TryGetJsonString(jt, "icon");
            VTemplateClientTypes types = (VTemplateClientTypes)type;
            string str7                = base.CurrentSiteSetting.SiteName + "首页";

            if (types == VTemplateClientTypes.WapSpecial)
            {
                int result = 0;
                if (!int.TryParse(client, out result))
                {
                    result = 0;
                }
                filepath = this.SaveIcon(filepath);
                if (!string.IsNullOrWhiteSpace(filepath))
                {
                    obj2["page"]["icon"] = filepath;
                    str2 = JsonConvert.SerializeObject(obj2);
                }
                client = this.AddOrUpdateTopic((long)result, title, tags, filepath, PlatformType.Mobile).ToString();
                string fromDirName = base.Server.MapPath(VTemplateHelper.GetTemplatePath("0", types, 0L));
                string path        = base.Server.MapPath(VTemplateHelper.GetTemplatePath(client, types, 0L));
                if (!Directory.Exists(path))
                {
                    HimallIO.CopyFolder(fromDirName, path, true);
                }
                str7 = "专题-" + title;
            }
            string str10    = VTemplateHelper.GetTemplatePath(client, types, 0);
            string fileName = str10 + "data/default.json";
            string str12    = str10 + "Skin-HomePage.cshtml";
            string message  = "保存成功";
            string str14    = "1";

            try
            {
                HimallIO.CreateFile(fileName, str2, FileCreateType.Create);
                StringBuilder builder = new StringBuilder();
                if (types == VTemplateClientTypes.WapSpecial)
                {
                    builder.Append("@model Himall.Model.TopicInfo \n");
                }
                builder.Append("@{\n");
                builder.Append("ViewBag.ShowAside = 2;//显示返回顶部按钮 \n");
                builder.Append("}\n");
                builder.Append("@{Layout = \"/Areas/Mobile/Templates/Default/Views/Shared/_Base.cshtml\";}\n");
                builder.Append("<div class=\"container\">\n");
                if (types != VTemplateClientTypes.WapSpecial)
                {
                    builder.Append("@{Html.RenderPartial(\"~/Areas/Mobile/Templates/Default/Views/Shared/_SearchBox.cshtml\");}\n");
                }
                builder.Append("<script src=\"//res.wx.qq.com/open/js/jweixin-1.0.0.js\"></script>\n");
                builder.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/WeiXinShare.js\"></script>\n");
                builder.Append("<link rel=\"stylesheet\" href=\"/Content/PublicMob/css/style.css\" />\n");
                builder.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/css.css\" rev=\"stylesheet\" type=\"text/css\">\n");
                builder.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/mycss.css\" rev=\"stylesheet\" type=\"text/css\">\n");
                builder.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/main.css\" rev=\"stylesheet\" type=\"text/css\">\n");
                builder.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/head.css\">\n");
                builder.Append(this.GetPModulesHtml(obj2));
                string lModulesHtml = this.GetLModulesHtml(obj2, template);
                builder.Append(lModulesHtml);
                builder.Append("@{Html.RenderPartial(\"~/Areas/Mobile/Templates/Default/Views/Shared/_4ButtonsFoot.cshtml\");}\n");
                builder.Append("</div>\n");
                builder.Append("<a class=\"WX-backtop\"></a>\n");
                builder.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/mui.min.js\"></script>\n");
                builder.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/AppAuto.js\"></script>\n");
                builder.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/home.js\"></script>\n");
                builder.Append(" <script src=\"~/Scripts/swipe-template.js\"></script>\n");
                if (types == VTemplateClientTypes.WapSpecial)
                {
                    builder.Append("@{Html.RenderPartial(\"~/Areas/Mobile/Templates/Default/Views/Topic/TopicDetailShare.cshtml\");}\n");
                }
                else
                {
                    builder.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/IndexShare.js\"></script>\n");
                }
                string str16 = builder.ToString();
                HimallIO.CreateFile(str12, str16, FileCreateType.Create);
                VTemplateHelper.ClearCache(client, VTemplateClientTypes.WapIndex, 0L);
            }
            catch (Exception exception)
            {
                Log.Error(exception.StackTrace + "    " + exception.Message);
                message = exception.Message;
                str14   = "0";
            }
            if (is_preview == 1)
            {
                return(base.Json(new { status = str14, msg = message, link = "/m-wap/?ispv=1&tn=" + template, tname = template }, JsonRequestBehavior.AllowGet));
            }
            return(base.Json(new { status = str14, msg = "", link = "/admin/VTemplate/EditTemplate?client=" + type.ToString() + "&tName=" + client, tname = client }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Hi_Ajax_SaveTemplate(int is_preview, string client, string content = "", int type = 2, long shopId = 0)
        {
            string dataName = client;
            string json     = content;
            long   shopid   = CurrentSellerManager.ShopId;
            var    tmpobj   = _iVShopService.GetVShopByShopId(shopid);

            if (tmpobj == null)
            {
                throw new Himall.Core.HimallException("未开通微店");
            }
            long    vshopid  = tmpobj.Id;
            JObject jo       = (JObject)JsonConvert.DeserializeObject(json);
            var     jpage    = jo["page"];
            string  title    = TryGetJsonString(jpage, "title");
            string  describe = TryGetJsonString(jpage, "describe");
            string  tags     = TryGetJsonString(jpage, "tags");
            string  icon     = TryGetJsonString(jpage, "icon");
            VTemplateClientTypes clientType = (VTemplateClientTypes)type;

            string pagetitle = CurrentSiteSetting.SiteName + "首页";

            if (clientType == VTemplateClientTypes.SellerWapSpecial)
            {
                int topicid = 0;
                if (!int.TryParse(client, out topicid))
                {
                    topicid = 0;
                }
                icon = SaveIcon(icon);
                if (!string.IsNullOrWhiteSpace(icon))
                {
                    //回写
                    jo["page"]["icon"] = icon;
                    json = JsonConvert.SerializeObject(jo);
                }
                client = AddOrUpdateTopic(topicid, title, tags, icon, PlatformType.Mobile).ToString();
                string basetemp = Server.MapPath(VTemplateHelper.GetTemplatePath("0", clientType, shopid));
                string _curtemp = Server.MapPath(VTemplateHelper.GetTemplatePath(client, clientType, shopid));
                if (!System.IO.Directory.Exists(_curtemp))
                {
                    VTemplateHelper.CopyFolder(basetemp, _curtemp);
                }
                pagetitle = "专题-" + title;
            }

            string templatePath   = VTemplateHelper.GetTemplatePath(client, clientType, shopid);
            string datapath       = templatePath + "data/default.json";
            string cshtmlpath     = templatePath + "Skin-HomePage.cshtml";
            string abTemplatePath = Server.MapPath(templatePath);
            string abDataPath     = Server.MapPath(datapath);
            string abCshtmlPath   = Server.MapPath(cshtmlpath);


            string msg    = "保存成功";
            string status = "1";

            try
            {
                StreamWriter sw = new StreamWriter(
                    abDataPath,
                    false,
                    Encoding.UTF8);
                foreach (var s in json)
                {
                    sw.Write(s);
                }
                sw.Close();
                StringBuilder htmlsb = new StringBuilder();
                if (clientType == VTemplateClientTypes.SellerWapSpecial)
                {
                    htmlsb.Append("@{ViewBag.Title = \"" + pagetitle + "\";}\n");
                }
                htmlsb.Append("@{Layout = \"/Areas/Mobile/Templates/Default/Views/Shared/_Base.cshtml\";}\n");
                htmlsb.Append("@{\n");
                htmlsb.Append("long curshopid=" + shopid.ToString() + ",curvshopid=" + vshopid.ToString() + ";\n");
                htmlsb.Append("}\n");
                htmlsb.Append("<div class=\"container\">\n");
                if (clientType != VTemplateClientTypes.SellerWapSpecial)
                {
                    htmlsb.Append("@(Html.Action(\"VShopHeader\", \"vshop\", new { id = curvshopid }))\n");
                }
                htmlsb.Append("<link rel=\"stylesheet\" href=\"/Content/PublicMob/css/style.css\" />\n");
                htmlsb.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/css.css\" rev=\"stylesheet\" type=\"text/css\">\n");
                htmlsb.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/mycss.css\" rev=\"stylesheet\" type=\"text/css\">\n");
                htmlsb.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/main.css\" rev=\"stylesheet\" type=\"text/css\">\n");
                htmlsb.Append("<link rel=\"stylesheet\" href=\"/Areas/Admin/templates/common/style/head.css\">\n");
                htmlsb.Append("<script type=\"text/javascript\">\n");
                htmlsb.Append("var curshopid=" + shopid.ToString() + ",curvshopid=" + vshopid.ToString() + ";\n");
                htmlsb.Append("</script>\n");

                htmlsb.Append(GetPModulesHtml(jo));
                string lModuleHtml = GetLModulesHtml(jo, dataName);
                htmlsb.Append(lModuleHtml);
                if (clientType == VTemplateClientTypes.SellerWapSpecial)
                {
                    htmlsb.Append("@{Html.RenderPartial(\"~/Areas/Mobile/Templates/Default/Views/Shared/_4ButtonsFoot.cshtml\");}\n");
                    htmlsb.Append("</div>\n");
                    htmlsb.Append("<a class=\"WX-backtop\"></a>\n");
                    htmlsb.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/mui.min.js\"></script>\n");
                    htmlsb.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/AppAuto.js\"></script>\n");
                    htmlsb.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/home.js\"></script>\n");
                }
                else
                {
                    htmlsb.Append("@{Html.RenderPartial(\"~/Areas/Mobile/Templates/Default/Views/Shared/_4ButtonsFoot_shop.cshtml\");}\n");
                    htmlsb.Append("</div>\n");
                    htmlsb.Append("<a class=\"WX-backtop\"></a>\n");
                    htmlsb.Append("<script src=\"~/Areas/Mobile/Templates/Default/Scripts/shophome.js\"></script>\n");
                }
                htmlsb.Append(" <script src=\"~/Scripts/swipe-template.js\"></script>\n");
                if (!System.IO.Directory.Exists(abTemplatePath))
                {
                    System.IO.Directory.CreateDirectory(abTemplatePath);
                }
                StreamWriter swhtml = new StreamWriter(abCshtmlPath, false, Encoding.UTF8);

                string html = htmlsb.ToString();
                foreach (var s in html)
                {
                    swhtml.Write(s);
                }
                swhtml.Close();
                VTemplateHelper.ClearCache(client, VTemplateClientTypes.SellerWapIndex, shopid);
                //生成静态Html

                /* 暂时不进行全部的静态化
                 * var vshop = VshopApplication.GetVShop(vshopid);
                 * ShopApplication.CheckInitTemplate(vshop.ShopId);
                 *
                 * this.ControllerContext.Controller.ViewBag.ShopId = vshop.ShopId;
                 * this.ControllerContext.Controller.ViewBag.Title = vshop.HomePageTitle;
                 *
                 * List<CustomerServiceInfo> customerServiceInfo = CustomerServiceApplication.GetMobileCustomerService(vshop.ShopId);
                 * this.ControllerContext.Controller.ViewBag.HasServices = customerServiceInfo != null ? (customerServiceInfo.Count > 0 ? true : false) : false;
                 * this.ControllerContext.Controller.ViewBag.CustomerServices = CustomerServiceApplication.GetMobileCustomerService(vshop.ShopId);
                 * this.ControllerContext.Controller.ViewBag.ShowAside = 1;
                 *
                 * this.ControllerContext.Controller.ViewBag.Keywords = "";
                 * this.ControllerContext.Controller.ViewBag.AreaName = "m-wap";
                 * this.ControllerContext.Controller.ViewBag.MAppType = "0";
                 * this.ControllerContext.Controller.ViewBag.FootIndex = 0;
                 * this.ControllerContext.Controller.ViewBag.VshopId = vshopid;
                 * html = this.ControllerContext.RenderViewToString(tempPath + "/Skin-HomePage.cshtml", new object() { });
                 * StreamWriter swcontent = new StreamWriter(Server.MapPath(tempPath + "/Skin-HomePage.cshtml"), false, Encoding.UTF8);
                 * foreach (var s in html)
                 * {
                 *   swcontent.Write(s);
                 * }
                 * swcontent.Flush();
                 * swcontent.Close();
                 * */
            }
            catch (Exception ex)
            {
                msg    = ex.Message;
                status = "0";
            }
            if (is_preview == 1)
            {
                var vshopId = _iVShopService.GetVShopByShopId(CurrentSellerManager.ShopId).Id;
                return(Json(new
                {
                    status = status,
                    msg = msg,
                    link = "/m-wap/vshop/detail/" + vshopId.ToString() + "?ispv=1&tn=" + dataName,
                    tname = dataName
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { status = status, msg = "", link = "/Selleradmin/VTemplate/EditTemplate?client=" + type.ToString() + "&tName=" + client, tname = client }, JsonRequestBehavior.AllowGet));
            }
        }