微信商品图片无法显示/上传问题优化(30%)
This commit is contained in:
1 parent
b7241236ca
commit
1aa0954e43
7 files changed
+175
-34
No files matched your search
@@ -128,6 +128,7 @@
|
|||||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
|
<Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
|
||||||
@@ -142,6 +143,7 @@
|
|||||||
<Reference Include="System.Web.Services" />
|
<Reference Include="System.Web.Services" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
<Reference Include="zxing, Version=0.12.0.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
|
<Reference Include="zxing, Version=0.12.0.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\DllReference\zxing.dll</HintPath>
|
<HintPath>..\DllReference\zxing.dll</HintPath>
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ namespace AllBase
|
|||||||
{
|
{
|
||||||
rst = "";
|
rst = "";
|
||||||
//return LoadImage(imgUrl);
|
//return LoadImage(imgUrl);
|
||||||
|
|
||||||
|
if (imgUrl.Contains("wxapp"))
|
||||||
|
{
|
||||||
|
return ImageBuild.LoadBitmapLoadBitmipImageFromUrl(imgUrl, out rst);
|
||||||
|
}
|
||||||
|
|
||||||
Image image = null;
|
Image image = null;
|
||||||
HttpWebResponse response = null;
|
HttpWebResponse response = null;
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ using System.Drawing.Drawing2D;
|
|||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace AllBase
|
namespace AllBase
|
||||||
{
|
{
|
||||||
@@ -587,6 +589,89 @@ namespace AllBase
|
|||||||
fs.Close();
|
fs.Close();
|
||||||
return imgBytes;
|
return imgBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Image LoadBitmapLoadBitmipImageFromUrl(string url, out string error)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BitmapImage bi = LoadBitmipImageFromUrl(url, out error);
|
||||||
|
return BitmapImageToSystemDrawingImage(bi);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
error = e.Message;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image BitmapImageToSystemDrawingImage(BitmapImage bitmapImage)
|
||||||
|
{
|
||||||
|
// 方法1 会乱码花屏
|
||||||
|
//int width = bitmapImage.PixelWidth;
|
||||||
|
//int height = bitmapImage.PixelHeight;
|
||||||
|
//int stride = width * ((bitmapImage.Format.BitsPerPixel + 7) / 8);
|
||||||
|
|
||||||
|
//byte[] pixels = new byte[stride * height];
|
||||||
|
//bitmapImage.CopyPixels(pixels, stride, 0);
|
||||||
|
|
||||||
|
//Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||||
|
//BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
|
||||||
|
|
||||||
|
//Marshal.Copy(pixels, 0, bmpData.Scan0, pixels.Length);
|
||||||
|
//bitmap.UnlockBits(bmpData);
|
||||||
|
|
||||||
|
//return bitmap;
|
||||||
|
|
||||||
|
// 方法2
|
||||||
|
using (MemoryStream stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
BitmapEncoder encoder = new BmpBitmapEncoder();
|
||||||
|
encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
|
||||||
|
encoder.Save(stream);
|
||||||
|
stream.Position = 0;
|
||||||
|
Bitmap bitmap = new Bitmap(stream);
|
||||||
|
stream.Close();
|
||||||
|
|
||||||
|
//// 现在你可以将这个Bitmap对象用于Windows Forms的PictureBox或其他图像显示控件
|
||||||
|
//PictureBox pictureBox = new PictureBox();
|
||||||
|
//pictureBox.Image = bitmap; // 或者如果你已经有了一个PictureBox控件,直接设置其Image属性
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BitmapImage LoadBitmipImageFromUrl(string url, out string error)
|
||||||
|
{
|
||||||
|
BitmapImage bitmap = new BitmapImage();
|
||||||
|
error = "";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (WebClient webClient = new WebClient())
|
||||||
|
{
|
||||||
|
// 下载图片数据到内存流
|
||||||
|
using (MemoryStream stream = new MemoryStream(webClient.DownloadData(url)))
|
||||||
|
{
|
||||||
|
stream.Position = 0; // 重置流的位置到开始处
|
||||||
|
bitmap.BeginInit();
|
||||||
|
bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
|
||||||
|
bitmap.CacheOption = BitmapCacheOption.OnLoad; // 或者使用 BitmapCacheOption.OnLoad 以减少内存使用
|
||||||
|
bitmap.UriSource = null; // 清除可能的旧UriSource,防止缓存问题
|
||||||
|
bitmap.StreamSource = stream;
|
||||||
|
bitmap.EndInit();
|
||||||
|
bitmap.Freeze(); // 防止后续更改,提高性能
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 处理异常,例如打印错误信息或设置一个默认图片等
|
||||||
|
//Console.WriteLine("Error loading image: " + ex.Message);
|
||||||
|
error = ex.Message;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class ImagePiex
|
public class ImagePiex
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace AllBase.Model.DBModel
|
|||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 变动类型,1:充值,2:采购花费,3:产品退款到账,4:运费退款到账,5:采购收款,6:产品退款扣除,7:运费退款扣除,16:礼物单话费,20:中转运费,23:作废运费返还
|
/// 变动类型,1:充值,2:采购花费,3:产品退款到账,4:运费退款到账,5:采购收款,6:产品退款扣除,7:运费退款扣除,16:礼物单话费,20:中转运费,23:作废运费返还 26退货包裹扣费
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? type { get; set; }
|
public int? type { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -76,10 +76,12 @@ namespace AllBase.Model.DBModel
|
|||||||
//采购收款 = 5,
|
//采购收款 = 5,
|
||||||
//产品退款扣除 = 6,
|
//产品退款扣除 = 6,
|
||||||
//运费退款扣除 = 7,
|
//运费退款扣除 = 7,
|
||||||
//礼物单支出 = 16,
|
礼物单支出 = 16,
|
||||||
中转仓扣费支出 = 20,
|
中转仓扣费支出 = 20,
|
||||||
中转仓作废返还收入 = 23,
|
中转仓作废返还收入 = 23,
|
||||||
中转仓超重支出 = 24,
|
中转仓超重支出 = 24,
|
||||||
|
退货包裹扣费支出 = 26,
|
||||||
支付宝在线充值 = 30,
|
支付宝在线充值 = 30,
|
||||||
|
云仓退货支出 = 31,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2137,6 +2137,12 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
return_order_status = row["return_order_status"].ParseToNullableInt(),
|
return_order_status = row["return_order_status"].ParseToNullableInt(),
|
||||||
sender_info = row["sender_info"].ParseToNullableString(),
|
sender_info = row["sender_info"].ParseToNullableString(),
|
||||||
sender_name = row["sender_name"].ParseToNullableString(),
|
sender_name = row["sender_name"].ParseToNullableString(),
|
||||||
|
sender_phone = row["sender_phone"].ParseToNullableString(),
|
||||||
|
shop_name = row["shop_name"].ParseToNullableString(),
|
||||||
|
updated_at = row["updated_at"].ParseToString().ParseToDateTime(),
|
||||||
|
warehouse_in_time = row["warehouse_in_time"].ParseToString().ParseToDateTime(),
|
||||||
|
warehouse_out_time = row["warehouse_out_time"].ParseToString().ParseToDateTime(),
|
||||||
|
warehouse_status = row["warehouse_status"].ParseToNullableInt(),
|
||||||
};
|
};
|
||||||
orderList.Add(order);
|
orderList.Add(order);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,14 +379,18 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
MysqlUtils mySql = new MysqlUtils(conn);
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
string sql = "delete from wxxd.user where id='"
|
string sql = "delete from wxxd.user where id='"
|
||||||
+ id + "'";
|
+ id + "' and balance=0";
|
||||||
|
|
||||||
var rst = mySql.ExecuteNonQuery(sql);
|
var rst = mySql.ExecuteAffectedRows(sql);
|
||||||
mySql.Close();
|
mySql.Close();
|
||||||
if (rst)
|
if (rst > 0)
|
||||||
{
|
{
|
||||||
return "{\"code\":200,\"msg\":\"success\"}";
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
}
|
}
|
||||||
|
if (rst == 0)
|
||||||
|
{
|
||||||
|
return "{\"code\":500,\"msg\":\"删除失败,请检查账户拍单余额是否还有剩余\"}";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return "{\"code\":500,\"msg\":\"删除失败,请稍后重试\"}";
|
return "{\"code\":500,\"msg\":\"删除失败,请稍后重试\"}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using AllBase;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -24,7 +25,15 @@ namespace TemuKJD.ToolForms
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(currentImgUrl))
|
if (!string.IsNullOrEmpty(currentImgUrl))
|
||||||
{
|
{
|
||||||
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
if (currentImgUrl.Contains("wxapp"))
|
||||||
|
{
|
||||||
|
string getImgError = "";
|
||||||
|
this.pictureBox1.Image = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(currentImgUrl, out getImgError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
||||||
|
}
|
||||||
|
|
||||||
//string getImgError = "";
|
//string getImgError = "";
|
||||||
//var image = AllBase.GetHtml.GetUrlImg(currentImgUrl, out getImgError);
|
//var image = AllBase.GetHtml.GetUrlImg(currentImgUrl, out getImgError);
|
||||||
@@ -45,7 +54,17 @@ namespace TemuKJD.ToolForms
|
|||||||
if (!string.IsNullOrEmpty(currentImgUrl))
|
if (!string.IsNullOrEmpty(currentImgUrl))
|
||||||
{
|
{
|
||||||
if (picDic != null)
|
if (picDic != null)
|
||||||
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
{
|
||||||
|
if (currentImgUrl.Contains("wxapp"))
|
||||||
|
{
|
||||||
|
string getImgError = "";
|
||||||
|
this.pictureBox1.Image = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(currentImgUrl, out getImgError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,30 +92,31 @@ namespace TemuKJD.ToolForms
|
|||||||
case Keys.Enter: break;
|
case Keys.Enter: break;
|
||||||
case Keys.Escape: this.Close(); break;
|
case Keys.Escape: this.Close(); break;
|
||||||
case Keys.Space:
|
case Keys.Space:
|
||||||
if (imgDic != null && imgDic.Keys.Count > 0)
|
//if (imgDic != null && imgDic.Keys.Count > 0)
|
||||||
{
|
//{
|
||||||
for (int i = 0; i < imgDic.Keys.ToList().Count; i++)
|
// for (int i = 0; i < imgDic.Keys.ToList().Count; i++)
|
||||||
{
|
// {
|
||||||
if (imgDic.Keys.ToList()[i] == currentImgUrl)
|
// if (imgDic.Keys.ToList()[i] == currentImgUrl)
|
||||||
{
|
// {
|
||||||
int index = i + 1;
|
// int index = i + 1;
|
||||||
if (index == imgDic.Keys.Count)
|
// if (index == imgDic.Keys.Count)
|
||||||
index = 0;
|
// index = 0;
|
||||||
currentImgUrl = imgDic.Keys.ToList()[index];
|
// currentImgUrl = imgDic.Keys.ToList()[index];
|
||||||
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
// this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
|
// if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
|
||||||
{
|
// {
|
||||||
int index = i + 1;
|
// int index = i + 1;
|
||||||
if (index == imgDic.Keys.Count)
|
// if (index == imgDic.Keys.Count)
|
||||||
index = 0;
|
// index = 0;
|
||||||
currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
|
// currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
|
||||||
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
// this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
pictureBox1_Click(null, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +195,15 @@ namespace TemuKJD.ToolForms
|
|||||||
if (index == imgDic.Keys.Count)
|
if (index == imgDic.Keys.Count)
|
||||||
index = 0;
|
index = 0;
|
||||||
currentImgUrl = imgDic.Keys.ToList()[index];
|
currentImgUrl = imgDic.Keys.ToList()[index];
|
||||||
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
if (currentImgUrl.Contains("wxapp"))
|
||||||
|
{
|
||||||
|
string getImgError = "";
|
||||||
|
this.pictureBox1.Image = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(currentImgUrl, out getImgError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
|
if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
|
||||||
@@ -184,7 +212,15 @@ namespace TemuKJD.ToolForms
|
|||||||
if (index == imgDic.Keys.Count)
|
if (index == imgDic.Keys.Count)
|
||||||
index = 0;
|
index = 0;
|
||||||
currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
|
currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
|
||||||
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
if (currentImgUrl.Contains("wxapp"))
|
||||||
|
{
|
||||||
|
string getImgError = "";
|
||||||
|
this.pictureBox1.Image = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(currentImgUrl, out getImgError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user