Commit 771e5b59 authored by 黄奎's avatar 黄奎

页面修改

parent 72b93555
...@@ -18,8 +18,6 @@ namespace Mall.Common.Plugin ...@@ -18,8 +18,6 @@ namespace Mall.Common.Plugin
/// </summary> /// </summary>
public class HttpHelper public class HttpHelper
{ {
/// <summary> /// <summary>
/// Post提交数据 /// Post提交数据
/// </summary> /// </summary>
...@@ -29,7 +27,6 @@ namespace Mall.Common.Plugin ...@@ -29,7 +27,6 @@ namespace Mall.Common.Plugin
/// <returns></returns> /// <returns></returns>
public static string HttpPost(string url, string body, string contenttype = "") public static string HttpPost(string url, string body, string contenttype = "")
{ {
LogHelper.Write("测试超时S:" + DateTime.Now);
try try
{ {
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
...@@ -45,10 +42,9 @@ namespace Mall.Common.Plugin ...@@ -45,10 +42,9 @@ namespace Mall.Common.Plugin
byte[] buffer = encoding.GetBytes(body); byte[] buffer = encoding.GetBytes(body);
request.ContentLength = buffer.Length; request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length); request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding)) using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
{ {
LogHelper.Write("测试超时E:" + DateTime.Now);
return reader.ReadToEnd(); return reader.ReadToEnd();
} }
} }
...@@ -70,7 +66,7 @@ namespace Mall.Common.Plugin ...@@ -70,7 +66,7 @@ namespace Mall.Common.Plugin
/// <param name="encode">编码方式</param> /// <param name="encode">编码方式</param>
/// <param name="Source">来源</param> /// <param name="Source">来源</param>
/// <returns></returns> /// <returns></returns>
public static string HttpGet(string url, Encoding encode, string Source, string cookie="") public static string HttpGet(string url, Encoding encode, string Source, string cookie = "")
{ {
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
if (!string.IsNullOrEmpty(Source)) if (!string.IsNullOrEmpty(Source))
...@@ -138,7 +134,7 @@ namespace Mall.Common.Plugin ...@@ -138,7 +134,7 @@ namespace Mall.Common.Plugin
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST"; req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded"; req.ContentType = "application/x-www-form-urlencoded";
//req.Headers.Add("Accept", "application/json"); //req.Headers.Add("Accept", "application/json");
//req.Headers.Add("Content-Type", "application/json"); //req.Headers.Add("Content-Type", "application/json");
byte[] data = Encoding.UTF8.GetBytes(postDataStr); byte[] data = Encoding.UTF8.GetBytes(postDataStr);
...@@ -151,7 +147,7 @@ namespace Mall.Common.Plugin ...@@ -151,7 +147,7 @@ namespace Mall.Common.Plugin
reqStream.Close(); reqStream.Close();
} }
HttpWebResponse rsp = (HttpWebResponse)req.GetResponse(); HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
if (string.IsNullOrWhiteSpace(rsp.CharacterSet)) if (string.IsNullOrWhiteSpace(rsp.CharacterSet))
...@@ -255,8 +251,9 @@ namespace Mall.Common.Plugin ...@@ -255,8 +251,9 @@ namespace Mall.Common.Plugin
/// </summary> /// </summary>
/// <param name="latlng"></param> /// <param name="latlng"></param>
/// <returns></returns> /// <returns></returns>
public static string GetGeocoderAddress(string latlng) { public static string GetGeocoderAddress(string latlng)
string apiKey = "7d9fbeb43e975cd1e9477a7e5d5e192a"; {
string apiKey = "7d9fbeb43e975cd1e9477a7e5d5e192a";
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();
string url = "http://api.map.baidu.com/geocoder?location=" + latlng + "&output=json&key=" + apiKey; string url = "http://api.map.baidu.com/geocoder?location=" + latlng + "&output=json&key=" + apiKey;
try try
...@@ -311,7 +308,7 @@ namespace Mall.Common.Plugin ...@@ -311,7 +308,7 @@ namespace Mall.Common.Plugin
/// <param name="url">请求地址</param> /// <param name="url">请求地址</param>
/// <param name="postDataStr">请求地址</param> /// <param name="postDataStr">请求地址</param>
/// <returns>HTTP响应</returns> /// <returns>HTTP响应</returns>
public static string HttpPostForGetWXQRCodePath(string url, string postDataStr,string path) public static string HttpPostForGetWXQRCodePath(string url, string postDataStr, string path)
{ {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST"; req.Method = "POST";
...@@ -341,7 +338,7 @@ namespace Mall.Common.Plugin ...@@ -341,7 +338,7 @@ namespace Mall.Common.Plugin
/// <param name="postDataStr"></param> /// <param name="postDataStr"></param>
/// <param name="path"></param> /// <param name="path"></param>
/// <returns></returns> /// <returns></returns>
public static string HttpPostForGetWXQRCodePathSmallShops(string url, string postDataStr, string path,string ssPhoto) public static string HttpPostForGetWXQRCodePathSmallShops(string url, string postDataStr, string path, string ssPhoto)
{ {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST"; req.Method = "POST";
...@@ -407,7 +404,7 @@ namespace Mall.Common.Plugin ...@@ -407,7 +404,7 @@ namespace Mall.Common.Plugin
stream = rsp.GetResponseStream(); stream = rsp.GetResponseStream();
return ReadImageForStream_V2(stream, path); return ReadImageForStream_V2(stream, path);
} }
catch(Exception ex) catch (Exception ex)
{ {
LogHelper.Write(ex, "GetResponseAsStringBase64_V2"); LogHelper.Write(ex, "GetResponseAsStringBase64_V2");
return ""; return "";
...@@ -426,7 +423,7 @@ namespace Mall.Common.Plugin ...@@ -426,7 +423,7 @@ namespace Mall.Common.Plugin
/// <param name="rsp"></param> /// <param name="rsp"></param>
/// <param name="encoding"></param> /// <param name="encoding"></param>
/// <returns></returns> /// <returns></returns>
private static string GetResponseAsStringBase64_V3(HttpWebResponse rsp, Encoding encoding, string path,string ssPhoto) private static string GetResponseAsStringBase64_V3(HttpWebResponse rsp, Encoding encoding, string path, string ssPhoto)
{ {
System.IO.Stream stream = null; System.IO.Stream stream = null;
try try
...@@ -453,7 +450,7 @@ namespace Mall.Common.Plugin ...@@ -453,7 +450,7 @@ namespace Mall.Common.Plugin
/// </summary> /// </summary>
/// <param name="imgstream"></param> /// <param name="imgstream"></param>
/// <returns></returns> /// <returns></returns>
public static string ReadImageForStream_V2(Stream imgstream,string path) public static string ReadImageForStream_V2(Stream imgstream, string path)
{ {
System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream); System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream);
System.Drawing.Bitmap bit = new System.Drawing.Bitmap(result); System.Drawing.Bitmap bit = new System.Drawing.Bitmap(result);
...@@ -507,7 +504,8 @@ namespace Mall.Common.Plugin ...@@ -507,7 +504,8 @@ namespace Mall.Common.Plugin
public static string ReadImageForStream_V3(Stream imgstream, string path, string ssPhoto) public static string ReadImageForStream_V3(Stream imgstream, string path, string ssPhoto)
{ {
System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream); System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream);
if (!string.IsNullOrEmpty(ssPhoto)) { if (!string.IsNullOrEmpty(ssPhoto))
{
WebRequest wreq = WebRequest.Create(ssPhoto); WebRequest wreq = WebRequest.Create(ssPhoto);
HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse(); HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
Stream s = wresp.GetResponseStream(); Stream s = wresp.GetResponseStream();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment