/// <summary> /// 上传图片 /// </summary> /// <param name="id"></param> /// <param name="pic"></param> /// <param name="url"></param> /// <returns></returns> public JsonResult AppUpdateImageAd(long id, string pic, string url) { var image = _iSlideAdsService.GetImageAd(0, id); if (!string.IsNullOrWhiteSpace(pic) && (!image.ImageUrl.Equals(pic))) { //转移图片 if (pic.Contains("/temp/")) { string source = pic.Substring(pic.LastIndexOf("/temp")); string dest = @"/Storage/Plat/ImageAd/"; pic = Path.Combine(dest, Path.GetFileName(source)); Core.HimallIO.CopyFile(source, pic, true); } else if (pic.Contains("/Storage/")) { pic = pic.Substring(pic.LastIndexOf("/Storage")); } } var imageAd = new ImageAdInfo { ShopId = 0, Url = url, ImageUrl = pic, Id = id }; _iSlideAdsService.UpdateImageAd(imageAd); return(Json(new { success = true })); }
public ActionResult UpdateImageAd(long id, string pic, string url, int?openTopImageAd) { var image = _iSlideAdsService.GetImageAd(CurrentSellerManager.ShopId, id); if (url.IndexOf("javascript:") > -1) { return(Json(new { success = false, msg = "错误的跳转地址" })); } if (!string.IsNullOrWhiteSpace(pic)) { string dest = string.Format(@"/Storage/Shop/{0}/ImageAd/", CurrentSellerManager.ShopId); if (pic.Contains("/temp/")) { var d = pic.Substring(pic.LastIndexOf("/temp/")); var destimg = Path.Combine(dest, Path.GetFileName(pic)); Core.HimallIO.CopyFile(d, destimg, true); pic = destimg; } else if (pic.Contains("/Storage/")) { pic = pic.Substring(pic.LastIndexOf("/Storage/")); } else { pic = ""; } } var imageAd = new Entities.ImageAdInfo { ShopId = CurrentSellerManager.ShopId, Url = url, ImageUrl = pic, Id = id }; _iSlideAdsService.UpdateImageAd(imageAd); pic = Himall.Core.HimallIO.GetImagePath(pic); if (openTopImageAd != null) { ShopApplication.UpdateOpenTopImageAd(CurrentSellerManager.ShopId, openTopImageAd.Value == 1); } ClearCache(); return(Json(new { success = true, imageUrl = pic })); }
public static ImageAdInfo GetImageAd(long shopId, long id) { return(_iSlideAdsService.GetImageAd(shopId, id)); }
/// <summary> /// 根据ID获取图轮播图片信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult GetImageAd(long id) { var models = _iSlideAdsService.GetImageAd(0, id); return(Json(new { success = true, imageUrl = models.ImageUrl, url = models.Url }, JsonRequestBehavior.AllowGet)); }