/// <summary>
        /// 微商城模板管理
        /// </summary>
        /// <returns></returns>
        public ActionResult VHomepage()
        {
            string crrentTemplateName = "t1";
            var    curr = _iTemplateSettingsService.GetCurrentTemplate(0);

            if (null != curr)
            {
                crrentTemplateName = curr.CurrentTemplateName;
            }

            var helper         = new GalleryHelper();
            var themes         = helper.LoadThemes();
            var CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals(crrentTemplateName.ToLower()));

            if (CurTemplateObj == null)
            {
                CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals("t1"));
            }
            if (CurTemplateObj == null)
            {
                throw new HimallException("错误的模板:" + crrentTemplateName);
            }
            ViewBag.CurrentTemplate = CurTemplateObj;
            ViewBag.CurUrl          = Request.Url.Scheme + "://" + Request.Url.Authority;
            return(View(themes.Where(t => t.ThemeName != crrentTemplateName.ToLower()).ToList()));
        }
        /// <summary>
        /// 微商城首页模板
        /// </summary>
        /// <returns></returns>
        public ActionResult VHomepage()
        {
            //Models.VshopHomeSiteViewModel model = new Models.VshopHomeSiteViewModel();
            //未开通微店就进不去首页设置
            //VShopInfo vshop =
            //model.VShop = vshop;
            //model.ShopId = CurrentSellerManager.ShopId;
            //model.SlideImage = _iSlideAdsService.GetSlidAds(CurrentSellerManager.ShopId, SlideAdInfo.SlideAdType.VShopHome).ToList();
            //model.Banner = _iNavigationService.GetSellerNavigations(CurrentSellerManager.ShopId, PlatformType.WeiXin).ToList();
            var vshop = _iVShopService.GetVShopByShopId(CurrentSellerManager.ShopId);

            if (vshop == null)
            {
                //throw new Himall.Core.HimallException("未开通微店");
            }
            ViewBag.IsOpenVShop = vshop != null;
            ViewBag.VShopId     = vshop == null ? 0 : vshop.Id;
            ViewBag.ShopId      = CurrentSellerManager.ShopId;
            string crrentTemplateName = "t1";
            var    curr = _iTemplateSettingsService.GetCurrentTemplate(CurrentSellerManager.ShopId);

            if (null != curr)
            {
                crrentTemplateName = curr.CurrentTemplateName;
            }

            var helper         = new GalleryHelper();
            var themes         = helper.LoadThemes(CurrentSellerManager.ShopId);
            var CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals(crrentTemplateName.ToLower()));

            if (CurTemplateObj == null)
            {
                CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals("t1"));
            }
            if (CurTemplateObj == null)
            {
                throw new HimallException("错误的模板:" + crrentTemplateName);
            }
            ViewBag.CurrentTemplate = CurTemplateObj;
            ViewBag.CurUrl          = Request.Url.Scheme + "://" + Request.Url.Authority;
            return(View(themes.Where(t => t.ThemeName != crrentTemplateName.ToLower()).ToList()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 微商城模板管理
        /// </summary>
        /// <returns></returns>
        public ActionResult VHomepage()
        {
            string crrentTemplateName = "t1";
            var    curr = _iTemplateSettingsService.GetCurrentTemplate(0);

            if (null != curr)
            {
                crrentTemplateName = curr.CurrentTemplateName;
            }

            var helper         = new GalleryHelper();
            var themes         = helper.LoadThemes();
            var CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals(crrentTemplateName.ToLower()));

            if (CurTemplateObj == null)
            {
                CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals("t1"));
            }
            if (CurTemplateObj == null)
            {
                throw new MallException("错误的模板:" + crrentTemplateName);
            }
            ViewBag.CurrentTemplate = CurTemplateObj;

            #region 二维码图片
            string qrCodeImagePath = string.Empty;
            string url             = CurrentUrlHelper.CurrentUrl();
            Bitmap map;
            map = Core.Helper.QRCodeHelper.Create(url + "/m-wap");
            MemoryStream ms = new MemoryStream();
            map.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            qrCodeImagePath = "data:image/gif;base64," + Convert.ToBase64String(ms.ToArray()); // 将图片内存流转成base64,图片以DataURI形式显示
            ms.Dispose();

            ViewBag.CurUrl          = url;
            ViewBag.QrCodeImagePath = qrCodeImagePath;
            #endregion
            return(View(themes.Where(t => t.ThemeName != crrentTemplateName.ToLower()).ToList()));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 小程序微店首页模板
        /// </summary>
        /// <returns></returns>
        public ActionResult SmallProgVHomepage()
        {
            //Models.VshopHomeSiteViewModel model = new Models.VshopHomeSiteViewModel();
            //未开通微店就进不去首页设置
            //VShopInfo vshop =
            //model.VShop = vshop;
            //model.ShopId = CurrentSellerManager.ShopId;
            //model.SlideImage = _iSlideAdsService.GetSlidAds(CurrentSellerManager.ShopId, SlideAdInfo.SlideAdType.VShopHome).ToList();
            //model.Banner = _iNavigationService.GetSellerNavigations(CurrentSellerManager.ShopId, PlatformType.WeiXin).ToList();
            var vshop = _iVShopService.GetVShopByShopId(CurrentSellerManager.ShopId);

            if (vshop == null)
            {
                //throw new Mall.Core.MallException("未开通微店");
            }
            ViewBag.IsOpenVShop = vshop != null;
            ViewBag.VShopId     = vshop == null ? 0 : vshop.Id;
            ViewBag.ShopId      = CurrentSellerManager.ShopId;
            string crrentTemplateName = "t1";
            //var curr = _iTemplateSettingsService.GetCurrentTemplate(CurrentSellerManager.ShopId);
            //if (null != curr)
            //{
            //    crrentTemplateName = curr.CurrentTemplateName;
            //}

            var helper         = new GalleryHelper();
            var themes         = helper.LoadThemes(CurrentSellerManager.ShopId);
            var CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals(crrentTemplateName.ToLower()));

            if (CurTemplateObj == null)
            {
                CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals("t1"));
            }
            if (CurTemplateObj == null)
            {
                throw new MallException("错误的模板:" + crrentTemplateName);
            }
            ViewBag.CurrentTemplate = CurTemplateObj;
            ViewBag.CurUrl          = Request.Scheme + "://" + Request.Host.ToString();
            var siteSetting = SiteSettingApplication.SiteSettings;

            if (!string.IsNullOrWhiteSpace(siteSetting.WeixinAppletId) && !string.IsNullOrWhiteSpace(siteSetting.WeixinAppletSecret))
            {
                ViewBag.IsHaveApplet = true;
            }

            //获取指定页面小程序码
            try
            {
                var            wxhelper    = new WXHelper();
                var            accessToken = wxhelper.GetAccessToken(SiteSettings.WeixinAppletId, SiteSettings.WeixinAppletSecret);
                var            data        = "{\"path\":\"pages/vShopHome/vShopHome?id=" + vshop.Id + "\",\"width\":600}";
                HttpWebRequest request     = (HttpWebRequest)WebRequest.Create("https://api.weixin.qq.com/wxa/getwxacode?access_token=" + accessToken); //创建url
                request.Method      = "POST";
                request.ContentType = "application/json;charset=UTF-8";
                byte[] load = Encoding.UTF8.GetBytes(data);
                request.ContentLength = load.Length;
                Stream writer = request.GetRequestStream();
                writer.Write(load, 0, load.Length);
                HttpWebResponse response        = (HttpWebResponse)request.GetResponse();
                Stream          s               = response.GetResponseStream();
                byte[]          mg              = StreamToBytes(s);
                MemoryStream    ms              = new MemoryStream(mg);
                string          qrCodeImagePath = string.Empty;
                qrCodeImagePath = "data:image/gif;base64," + Convert.ToBase64String(ms.ToArray());
                ms.Dispose();
                ViewBag.QrCodeImagePath = qrCodeImagePath;
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }

            return(View(themes.Where(t => t.ThemeName != crrentTemplateName.ToLower()).ToList()));
        }