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

页面修改

parent 72b93555
......@@ -18,8 +18,6 @@ namespace Mall.Common.Plugin
/// </summary>
public class HttpHelper
{
/// <summary>
/// Post提交数据
/// </summary>
......@@ -29,7 +27,6 @@ namespace Mall.Common.Plugin
/// <returns></returns>
public static string HttpPost(string url, string body, string contenttype = "")
{
LogHelper.Write("测试超时S:" + DateTime.Now);
try
{
Encoding encoding = Encoding.UTF8;
......@@ -45,10 +42,9 @@ namespace Mall.Common.Plugin
byte[] buffer = encoding.GetBytes(body);
request.ContentLength = 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))
{
LogHelper.Write("测试超时E:" + DateTime.Now);
return reader.ReadToEnd();
}
}
......@@ -70,7 +66,7 @@ namespace Mall.Common.Plugin
/// <param name="encode">编码方式</param>
/// <param name="Source">来源</param>
/// <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);
if (!string.IsNullOrEmpty(Source))
......@@ -138,7 +134,7 @@ namespace Mall.Common.Plugin
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
//req.Headers.Add("Accept", "application/json");
//req.Headers.Add("Content-Type", "application/json");
byte[] data = Encoding.UTF8.GetBytes(postDataStr);
......@@ -151,7 +147,7 @@ namespace Mall.Common.Plugin
reqStream.Close();
}
HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
if (string.IsNullOrWhiteSpace(rsp.CharacterSet))
......@@ -255,8 +251,9 @@ namespace Mall.Common.Plugin
/// </summary>
/// <param name="latlng"></param>
/// <returns></returns>
public static string GetGeocoderAddress(string latlng) {
string apiKey = "7d9fbeb43e975cd1e9477a7e5d5e192a";
public static string GetGeocoderAddress(string latlng)
{
string apiKey = "7d9fbeb43e975cd1e9477a7e5d5e192a";
HttpClient client = new HttpClient();
string url = "http://api.map.baidu.com/geocoder?location=" + latlng + "&output=json&key=" + apiKey;
try
......@@ -311,7 +308,7 @@ namespace Mall.Common.Plugin
/// <param name="url">请求地址</param>
/// <param name="postDataStr">请求地址</param>
/// <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);
req.Method = "POST";
......@@ -341,7 +338,7 @@ namespace Mall.Common.Plugin
/// <param name="postDataStr"></param>
/// <param name="path"></param>
/// <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);
req.Method = "POST";
......@@ -407,7 +404,7 @@ namespace Mall.Common.Plugin
stream = rsp.GetResponseStream();
return ReadImageForStream_V2(stream, path);
}
catch(Exception ex)
catch (Exception ex)
{
LogHelper.Write(ex, "GetResponseAsStringBase64_V2");
return "";
......@@ -426,7 +423,7 @@ namespace Mall.Common.Plugin
/// <param name="rsp"></param>
/// <param name="encoding"></param>
/// <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;
try
......@@ -453,7 +450,7 @@ namespace Mall.Common.Plugin
/// </summary>
/// <param name="imgstream"></param>
/// <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.Bitmap bit = new System.Drawing.Bitmap(result);
......@@ -507,7 +504,8 @@ namespace Mall.Common.Plugin
public static string ReadImageForStream_V3(Stream imgstream, string path, string ssPhoto)
{
System.Drawing.Image result = System.Drawing.Image.FromStream(imgstream);
if (!string.IsNullOrEmpty(ssPhoto)) {
if (!string.IsNullOrEmpty(ssPhoto))
{
WebRequest wreq = WebRequest.Create(ssPhoto);
HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
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