wexinjs 调用
public class Utils
{
static string appid = GetAppSettingValue("appid");
static string appserct = XpVShop.MyFuc.Utils.GetAppSettingValue("sercret");
#region 系统版本
/// <summary>
/// 版本信息类
/// </summary>
public class VersionInfo
{
public int FileMajorPart
{
get { return 3; }
}
public int FileMinorPart
{
get { return 0; }
}
public int FileBuildPart
{
get { return 7; }
}
public string ProductName
{
get { return "MxWeiXinPF"; }
}
public int ProductType
{
get { return 1; }
}
}
public static string GetVersion()
{
return "";
}
#endregion
#region MD5加密
public static string MD5(string pwd)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = System.Text.Encoding.Default.GetBytes(pwd);
byte[] md5data = md5.ComputeHash(data);
md5.Clear();
string str = "";
for (int i = 0; i < md5data.Length; i++)
{
str += md5data[i].ToString("x").PadLeft(2, '0');
}
return str;
}
#endregion
#region 对象转换处理
/// <summary>
/// 判断对象是否为Int32类型的数字
/// </summary>
/// <param name="Expression"></param>
/// <returns></returns>
public static bool IsNumeric(object expression)
{
if (expression != null)
return IsNumeric(expression.ToString());
return false;
}
/// <summary>
/// 判断对象是否为Int32类型的数字
/// </summary>
/// <param name="Expression"></param>
/// <returns></returns>
public static bool IsNumeric(string expression)
{
if (expression != null)
{
string str = expression;
if (str.Length > 0 && str.Length <= 11 && Regex.IsMatch(str, @"^[-]?[0-9]*[.]?[0-9]*$"))
{
if ((str.Length < 10) || (str.Length == 10 && str[0] == '1') || (str.Length == 11 && str[0] == '-' && str[1] == '1'))
return true;
}
}
return false;
}
/// <summary>
/// 是否为Double类型
/// </summary>
/// <param name="expression"></param>
/// <returns></returns>
public static bool IsDouble(object expression)
{
if (expression != null)
return Regex.IsMatch(expression.ToString(), @"^([0-9])[0-9]*(\.\w*)?$");
return false;
}
/// <summary>
/// 检测是否符合email格式
/// </summary>
/// <param name="strEmail">要判断的email字符串</param>
/// <returns>判断结果</returns>
public static bool IsValidEmail(string strEmail)
{
return Regex.IsMatch(strEmail, @"^[\w\.]+([-]\w+)*@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]");
}
public static bool IsValidDoEmail(string strEmail)
{
return Regex.IsMatch(strEmail, @"^@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}
/// <summary>
/// 检测是否是正确的Url
/// </summary>
/// <param name="strUrl">要验证的Url</param>
/// <returns>判断结果</returns>
public static bool IsURL(string strUrl)
{
return Regex.IsMatch(strUrl, @"^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
}
/// <summary>
/// 将字符串转换为数组
/// </summary>
/// <param name="str">字符串</param>
/// <returns>字符串数组</returns>
public static string[] GetStrArray(string str)
{
return str.Split(new char[',']);
}
/// <summary>
/// 将数组转换为字符串
/// </summary>
/// <param name="list">List</param>
/// <param name="speater">分隔符</param>
/// <returns>String</returns>
public static string GetArrayStr(List<string> list, string speater)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.Count; i++)
{
if (i == list.Count - 1)
{
sb.Append(list[i]);
}
else
{
sb.Append(list[i]);
sb.Append(speater);
}
}
return sb.ToString();
}
/// <summary>
/// object型转换为bool型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的bool类型结果</returns>
public static bool StrToBool(object expression, bool defValue)
{
if (expression != null)
return StrToBool(expression, defValue);
return defValue;
}
/// <summary>
/// string型转换为bool型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的bool类型结果</returns>
public static bool StrToBool(string expression, bool defValue)
{
if (expression != null)
{
if (string.Compare(expression, "true", true) == 0)
return true;
else if (string.Compare(expression, "false", true) == 0)
return false;
}
return defValue;
}
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="expression">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int ObjToInt(object expression, int defValue)
{
if (expression != null)
return StrToInt(expression.ToString(), defValue);
return defValue;
}
/// <summary>
/// 将字符串转换为Int32类型
/// </summary>
/// <param name="expression">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int StrToInt(string expression, int defValue)
{
if (string.IsNullOrEmpty(expression) || expression.Trim().Length >= 11 || !Regex.IsMatch(expression.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$"))
return defValue;
int rv;
if (Int32.TryParse(expression, out rv))
return rv;
return Convert.ToInt32(StrToFloat(expression, defValue));
}
/// <summary>
/// Object型转换为decimal型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的decimal类型结果</returns>
public static decimal ObjToDecimal(object expression, decimal defValue)
{
if (expression != null)
return StrToDecimal(expression.ToString(), defValue);
return defValue;
}
/// <summary>
/// string型转换为decimal型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的decimal类型结果</returns>
public static decimal StrToDecimal(string expression, decimal defValue)
{
if ((expression == null) || (expression.Length > 10))
return defValue;
decimal intValue = defValue;
if (expression != null)
{
bool IsDecimal = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$");
if (IsDecimal)
decimal.TryParse(expression, out intValue);
}
return intValue;
}
/// <summary>
/// Object型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float ObjToFloat(object expression, float defValue)
{
if (expression != null)
return StrToFloat(expression.ToString(), defValue);
return defValue;
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(string expression, float defValue)
{
if ((expression == null) || (expression.Length > 10))
return defValue;
float intValue = defValue;
if (expression != null)
{
bool IsFloat = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$");
if (IsFloat)
float.TryParse(expression, out intValue);
}
return intValue;
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime StrToDateTime(string str, DateTime defValue)
{
if (!string.IsNullOrEmpty(str))
{
DateTime dateTime;
if (DateTime.TryParse(str, out dateTime))
return dateTime;
}
return defValue;
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime StrToDateTime(string str)
{
return StrToDateTime(str, DateTime.Now);
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime ObjectToDateTime(object obj)
{
return StrToDateTime(obj.ToString());
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime ObjectToDateTime(object obj, DateTime defValue)
{
return StrToDateTime(obj.ToString(), defValue);
}
/// <summary>
/// 将对象转换为字符串
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <returns>转换后的string类型结果</returns>
public static string ObjectToStr(object obj)
{
if (obj == null)
return "";
return obj.ToString().Trim();
}
/// <summary>
/// 取该日期的星期几
/// </summary>
/// <param name="dayTimes">日期</param>
/// <returns></returns>
public static string GetDayName(DateTime dayTimes)
{
string result = "";
if (dayTimes.DayOfWeek == DayOfWeek.Monday)
{
result = "星期一";
}
else if (dayTimes.DayOfWeek == DayOfWeek.Tuesday)
{
result = "星期二";
}
else if (dayTimes.DayOfWeek == DayOfWeek.Wednesday)
{
result = "星期三";
}
else if (dayTimes.DayOfWeek == DayOfWeek.Thursday)
{
result = "星期四";
}
else if (dayTimes.DayOfWeek == DayOfWeek.Friday)
{
result = "星期五";
}
else if (dayTimes.DayOfWeek == DayOfWeek.Saturday)
{
result = "星期六";
}
else if (dayTimes.DayOfWeek == DayOfWeek.Sunday)
{
result = "星期日";
}
return result;
}
#endregion
#region 分割字符串
/// <summary>
/// 分割字符串
/// </summary>
public static string[] SplitString(string strContent, string strSplit)
{
if (!string.IsNullOrEmpty(strContent))
{
if (strContent.IndexOf(strSplit) < 0)
return new string[] { strContent };
return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase);
}
else
return new string[0] { };
}
/// <summary>
/// 分割字符串
/// </summary>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit, int count)
{
string[] result = new string[count];
string[] splited = SplitString(strContent, strSplit);
for (int i = 0; i < count; i++)
{
if (i < splited.Length)
result[i] = splited[i];
else
result[i] = string.Empty;
}
return result;
}
#endregion
#region 删除最后结尾的一个逗号
/// <summary>
/// 删除最后结尾的一个逗号
/// </summary>
public static string DelLastComma(string str)
{
if (str.Length < 1)
{
return "";
}
return str.Substring(0, str.LastIndexOf(","));
}
#endregion
#region 删除最后结尾的指定字符后的字符
/// <summary>
/// 删除最后结尾的指定字符后的字符
/// </summary>
public static string DelLastChar(string str, string strchar)
{
if (string.IsNullOrEmpty(str))
return "";
if (str.LastIndexOf(strchar) >= 0 && str.LastIndexOf(strchar) == str.Length - 1)
{
return str.Substring(0, str.LastIndexOf(strchar));
}
return str;
}
#endregion
#region 生成指定长度的字符串
/// <summary>
/// 生成指定长度的字符串,即生成strLong个str字符串
/// </summary>
/// <param name="strLong">生成的长度</param>
/// <param name="str">以str生成字符串</param>
/// <returns></returns>
public static string StringOfChar(int strLong, string str)
{
string ReturnStr = "";
for (int i = 0; i < strLong; i++)
{
ReturnStr += str;
}
return ReturnStr;
}
#endregion
#region 生成日期随机码
/// <summary>
/// 生成日期随机码
/// </summary>
/// <returns></returns>
public static string GetRamCode()
{
#region
return DateTime.Now.ToString("yyyyMMddHHmmssffff");
#endregion
}
#endregion
#region 生成随机字母或数字
/// <summary>
/// 生成随机数字
/// </summary>
/// <param name="length">生成长度</param>
/// <returns></returns>
public static string Number(int Length)
{
return Number(Length, false);
}
/// <summary>
/// 生成随机数字
/// </summary>
/// <param name="Length">生成长度</param>
/// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param>
/// <returns></returns>
public static string Number(int Length, bool Sleep)
{
if (Sleep)
System.Threading.Thread.Sleep(3);
string result = "";
System.Random random = new Random();
for (int i = 0; i < Length; i++)
{
result += random.Next(10).ToString();
}
return result;
}
/// <summary>
/// 生成随机字母字符串(数字字母混和)
/// </summary>
/// <param name="codeCount">待生成的位数</param>
public static string GetCheckCode(int codeCount)
{
string str = string.Empty;
int rep = 0;
long num2 = DateTime.Now.Ticks + rep;
rep++;
Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> rep)));
for (int i = 0; i < codeCount; i++)
{
char ch;
int num = random.Next();
if ((num % 2) == 0)
{
ch = (char)(0x30 + ((ushort)(num % 10)));
}
else
{
ch = (char)(0x41 + ((ushort)(num % 0x1a)));
}
str = str + ch.ToString();
}
return str;
}
/// <summary>
/// 生成随机字母和数据字符串(字母和数字混合)
/// author:李朴 datetime:2013-12-4
/// </summary>
/// <param name="Length"></param>
/// <returns></returns>
public static string GetLetterOrNumberRandom(int Length)
{
System.Threading.Thread.Sleep(3);
long tick = DateTime.Now.Ticks;//1个以0.1纳秒为单位的时间戳,18位
char[] constant = { '2', '3', '4', '5', '6', '8', '9', 'a', 'b', 'd', 'e', 'f', 'h', 'k', 'm', 'n', 'r', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };
System.Text.StringBuilder newRandom = new System.Text.StringBuilder(constant.Length);
Random rd = new Random(unchecked((int)tick));
for (int i = 0; i < Length; i++)
{
newRandom.Append(constant[rd.Next(constant.Length)]);
}
return newRandom.ToString();
}
/// <summary>
/// 根据日期和随机码生成订单号
/// </summary>
/// <returns></returns>
public static string GetOrderNumber()
{
string num = DateTime.Now.ToString("yyMMddHHmmss");//yyyyMMddHHmmssms
return num + Number(2, true).ToString();
}
private static int Next(int numSeeds, int length)
{
byte[] buffer = new byte[length];
System.Security.Cryptography.RNGCryptoServiceProvider Gen = new System.Security.Cryptography.RNGCryptoServiceProvider();
Gen.GetBytes(buffer);
uint randomResult = 0x0;//这里用uint作为生成的随机数
for (int i = 0; i < length; i++)
{
randomResult |= ((uint)buffer[i] << ((length - 1 - i) * 8));
}
return (int)(randomResult % numSeeds);
}
#endregion
#region 截取字符长度
/// <summary>
/// 截取字符长度
/// </summary>
/// <param name="inputString">字符</param>
/// <param name="len">长度</param>
/// <returns></returns>
public static string CutString(string inputString, int len)
{
if (string.IsNullOrEmpty(inputString))
return "";
inputString = DropHTML(inputString);
ASCIIEncoding ascii = new ASCIIEncoding();
int tempLen = 0;
string tempString = "";
byte[] s = ascii.GetBytes(inputString);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
try
{
tempString += inputString.Substring(i, 1);
}
catch
{
break;
}
if (tempLen > len)
break;
}
//如果截过则加上半个省略号
byte[] mybyte = System.Text.Encoding.Default.GetBytes(inputString);
if (mybyte.Length > len)
tempString += "…";
return tempString;
}
#endregion
#region 清除HTML标记
public static string DropHTML(string Htmlstring)
{
if (string.IsNullOrEmpty(Htmlstring)) return "";
//删除脚本
Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
//删除HTML
Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
Htmlstring.Replace("<", "");
Htmlstring.Replace(">", "");
Htmlstring.Replace("\r\n", "");
Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
return Htmlstring;
}
#endregion
#region 去除HTML标记
///<summary>
///去除HTML标记
///</summary>
///<param name="NoHTML">包括HTML的源码</param>
///<returns>已经去除后的文字</returns>
public static string NoHTML(string Htmlstring)
{
//Regex myReg = new Regex(@"(\<.[^\<]*\>)", RegexOptions.IgnoreCase);
//Htmlstring = myReg.Replace(Htmlstring, "");
//myReg = new Regex(@"(\<\/[^\<]*\>)", RegexOptions.IgnoreCase);
//Htmlstring = myReg.Replace(Htmlstring, "");
//return Htmlstring;
//删除脚本
Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
//删除HTML
Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
//Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"“", "“", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"”", "”", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
Htmlstring = Htmlstring.Replace("<", "<");
Htmlstring = Htmlstring.Replace(">", ">");
return Htmlstring;
}
#endregion
/// <summary>
/// 替换html中的特殊字符
/// </summary>
/// <param name="theString">需要进行替换的文本。</param>
/// <returns>替换完的文本。</returns>
public static string HtmlEncode(string theString)
{
theString = theString.Replace(">", ">");
theString = theString.Replace("<", "<");
theString = theString.Replace(" ", " ");
theString = theString.Replace("\"", """);
theString = theString.Replace("'", "'");
theString = theString.Replace("\r\n", "<br/> ");
return theString;
}
/// <summary>
/// 恢复html中的特殊字符
/// </summary>
/// <param name="theString">需要恢复的文本。</param>
/// <returns>恢复好的文本。</returns>
public static string HtmlDecode(string theString)
{
theString = theString.Replace(">", ">");
theString = theString.Replace("<", "<");
theString = theString.Replace(" ", " ");
theString = theString.Replace(""", "\"");
theString = theString.Replace("'", "'");
theString = theString.Replace("<br/> ", "\r\n");
theString = theString.Replace("—", "—");//2012-05-07新加的
return theString;
}
#region 清除HTML标记且返回相应的长度
public static string DropHTML(string Htmlstring, int strLen)
{
return CutString(DropHTML(Htmlstring), strLen);
}
#endregion
#region TXT代码转换成HTML格式
/// <summary>
/// 字符串字符处理
/// </summary>
/// <param name="chr">等待处理的字符串</param>
/// <returns>处理后的字符串</returns>
/// //把TXT代码转换成HTML格式
public static String ToHtml(string Input)
{
StringBuilder sb = new StringBuilder(Input);
sb.Replace("&", "&");
sb.Replace("<", "<");
sb.Replace(">", ">");
sb.Replace("\r\n", "<br />");
sb.Replace("\n", "<br />");
sb.Replace("\t", " ");
//sb.Replace(" ", " ");
return sb.ToString();
}
#endregion
#region HTML代码转换成TXT格式
/// <summary>
/// 字符串字符处理
/// </summary>
/// <param name="chr">等待处理的字符串</param>
/// <returns>处理后的字符串</returns>
/// //把HTML代码转换成TXT格式
public static String ToTxt(String Input)
{
StringBuilder sb = new StringBuilder(Input);
sb.Replace(" ", " ");
sb.Replace("<br>", "\r\n");
sb.Replace("<br>", "\n");
sb.Replace("<br />", "\n");
sb.Replace("<br />", "\r\n");
sb.Replace("<", "<");
sb.Replace(">", ">");
sb.Replace("&", "&");
return sb.ToString();
}
#endregion
#region 检测是否有Sql危险字符
/// <summary>
/// 检测是否有Sql危险字符
/// </summary>
/// <param name="str">要判断字符串</param>
/// <returns>判断结果,如果安全,则返回true,否则返回false</returns>
public static bool IsSafeSqlString(string str)
{
return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
}
/// <summary>
/// 检查危险字符
/// </summary>
/// <param name="Input"></param>
/// <returns></returns>
public static string Filter(string sInput)
{
if (sInput == null || sInput == "")
return null;
string sInput1 = sInput.ToLower();
string output = sInput;
string pattern = @"*|and|exec|insert|select|delete|update|count|master|truncate|declare|char(|mid(|chr(|'";
if (Regex.Match(sInput1, Regex.Escape(pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase).Success)
{
throw new Exception("字符串中含有非法字符!");
}
else
{
output = output.Replace("'", "''");
}
return output;
}
/// <summary>
/// 检查过滤设定的危险字符
/// </summary>
/// <param name="InText">要过滤的字符串 </param>
/// <returns>如果参数存在不安全字符,则返回true </returns>
public static bool SqlFilter(string word, string InText)
{
if (InText == null)
return false;
foreach (string i in word.Split('|'))
{
if ((InText.ToLower().IndexOf(i + " ") > -1) || (InText.ToLower().IndexOf(" " + i) > -1))
{
return true;
}
}
return false;
}
#endregion
#region 过滤特殊字符
/// <summary>
/// 过滤特殊字符
/// </summary>
/// <param name="Input"></param>
/// <returns></returns>
public static string Htmls(string Input)
{
if (Input != string.Empty && Input != null)
{
string ihtml = Input.ToLower();
ihtml = ihtml.Replace("<script", "<script");
ihtml = ihtml.Replace("script>", "script>");
ihtml = ihtml.Replace("<%", "<%");
ihtml = ihtml.Replace("%>", "%>");
ihtml = ihtml.Replace("<$", "<$");
ihtml = ihtml.Replace("$>", "$>");
return ihtml;
}
else
{
return string.Empty;
}
}
#endregion
#region 检查是否为IP地址
/// <summary>
/// 是否为ip
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public static bool IsIP(string ip)
{
return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
}
#endregion
#region 获得配置文件节点XML文件的绝对路径
public static string GetXmlMapPath(string xmlName)
{
return GetMapPath(ConfigurationManager.AppSettings[xmlName].ToString());
}
/// <summary>
/// datetime:2013-11-20
/// author:lipu
/// function:获得webconfig文件里,appSettings节点里的值
/// </summary>
/// <param name="keyStr"></param>
/// <returns></returns>
public static string GetAppSettingValue(string keyStr)
{
if (ConfigurationManager.AppSettings[keyStr] == null)
{
return "";
}
else
{
return ConfigurationManager.AppSettings[keyStr].ToString();
}
}
#endregion
#region 获得当前绝对路径
/// <summary>
/// 获得当前绝对路径
/// </summary>
/// <param name="strPath">指定的路径</param>
/// <returns>绝对路径</returns>
public static string GetMapPath(string strPath)
{
if (strPath.ToLower().StartsWith("http://"))
{
return strPath;
}
if (HttpContext.Current != null)
{
return HttpContext.Current.Server.MapPath(strPath);
}
else //非web程序引用
{
strPath = strPath.Replace("/", "\\");
if (strPath.StartsWith("\\"))
{
strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\');
}
return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
}
}
#endregion
#region 文件操作
/// <summary>
/// 删除单个文件
/// </summary>
/// <param name="_filepath">文件相对路径</param>
public static bool DeleteFile(string _filepath)
{
if (string.IsNullOrEmpty(_filepath))
{
return false;
}
string fullpath = GetMapPath(_filepath);
if (File.Exists(fullpath))
{
File.Delete(fullpath);
return true;
}
return false;
}
/// <summary>
/// 删除上传的文件(及缩略图)
/// </summary>
/// <param name="_filepath"></param>
public static void DeleteUpFile(string _filepath)
{
if (string.IsNullOrEmpty(_filepath))
{
return;
}
string fullpath = GetMapPath(_filepath); //原图
if (File.Exists(fullpath))
{
File.Delete(fullpath);
}
if (_filepath.LastIndexOf("/") >= 0)
{
string thumbnailpath = _filepath.Substring(0, _filepath.LastIndexOf("/")) + "mall_" + _filepath.Substring(_filepath.LastIndexOf("/") + 1);
string fullTPATH = GetMapPath(thumbnailpath); //宿略图
if (File.Exists(fullTPATH))
{
File.Delete(fullTPATH);
}
}
}
/// <summary>
/// 删除指定文件夹
/// </summary>
/// <param name="_dirpath">文件相对路径</param>
public static bool DeleteDirectory(string _dirpath)
{
if (string.IsNullOrEmpty(_dirpath))
{
return false;
}
string fullpath = GetMapPath(_dirpath);
if (Directory.Exists(fullpath))
{
Directory.Delete(fullpath, true);
return true;
}
return false;
}
/// <summary>
/// 修改指定文件夹名称
/// </summary>
/// <param name="old_dirpath">旧相对路径</param>
/// <param name="new_dirpath">新相对路径</param>
/// <returns>bool</returns>
public static bool MoveDirectory(string old_dirpath, string new_dirpath)
{
if (string.IsNullOrEmpty(old_dirpath))
{
return false;
}
string fulloldpath = GetMapPath(old_dirpath);
string fullnewpath = GetMapPath(new_dirpath);
if (Directory.Exists(fulloldpath))
{
Directory.Move(fulloldpath, fullnewpath);
return true;
}
return false;
}
/// <summary>
/// 返回文件大小KB
/// </summary>
/// <param name="_filepath">文件相对路径</param>
/// <returns>int</returns>
public static int GetFileSize(string _filepath)
{
if (string.IsNullOrEmpty(_filepath))
{
return 0;
}
string fullpath = GetMapPath(_filepath);
if (File.Exists(fullpath))
{
FileInfo fileInfo = new FileInfo(fullpath);
return ((int)fileInfo.Length) / 1024;
}
return 0;
}
/// <summary>
/// 返回文件扩展名,不含“.”
/// </summary>
/// <param name="_filepath">文件全名称</param>
/// <returns>string</returns>
public static string GetFileExt(string _filepath)
{
if (string.IsNullOrEmpty(_filepath))
{
return "";
}
if (_filepath.LastIndexOf(".") > 0)
{
return _filepath.Substring(_filepath.LastIndexOf(".") + 1); //文件扩展名,不含“.”
}
return "";
}
/// <summary>
/// 返回文件名,不含路径
/// </summary>
/// <param name="_filepath">文件相对路径</param>
/// <returns>string</returns>
public static string GetFileName(string _filepath)
{
return _filepath.Substring(_filepath.LastIndexOf(@"/") + 1);
}
/// <summary>
/// 文件是否存在
/// </summary>
/// <param name="_filepath">文件相对路径</param>
/// <returns>bool</returns>
public static bool FileExists(string _filepath)
{
string fullpath = GetMapPath(_filepath);
if (File.Exists(fullpath))
{
return true;
}
return false;
}
/// <summary>
/// 获得远程字符串
/// </summary>
public static string GetDomainStr(string key, string uriPath)
{
string result = CacheHelper.Get(key) as string;
if (result == null)
{
System.Net.WebClient client = new System.Net.WebClient();
try
{
client.Encoding = System.Text.Encoding.UTF8;
result = client.DownloadString(uriPath);
}
catch
{
result = "";
}
CacheHelper.Insert(key, result, 60);
}
return result;
}
#endregion
#region 读取或写入cookie
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
public static void WriteCookie(string strName, string strValue)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
if (cookie == null)
{
cookie = new HttpCookie(strName);
}
cookie.Value = UrlEncode(strValue);
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
public static void WriteCookie(string strName, string key, string strValue)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
if (cookie == null)
{
cookie = new HttpCookie(strName);
}
cookie[key] = UrlEncode(strValue);
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
public static void WriteCookie(string strName, string key, string strValue, int expires)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
if (cookie == null)
{
cookie = new HttpCookie(strName);
}
cookie[key] = UrlEncode(strValue);
cookie.Expires = DateTime.Now.AddMinutes(expires);
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
/// <param name="strValue">过期时间(分钟)</param>
public static void WriteCookie(string strName, string strValue, int expires)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
if (cookie == null)
{
cookie = new HttpCookie(strName);
}
cookie.Value = UrlEncode(strValue);
cookie.Expires = DateTime.Now.AddMinutes(expires);
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 读cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <returns>cookie值</returns>
public static string GetCookie(string strName)
{
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null)
return UrlDecode(HttpContext.Current.Request.Cookies[strName].Value.ToString());
return "";
}
/// <summary>
/// 读cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <returns>cookie值</returns>
public static string GetCookie(string strName, string key)
{
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null && HttpContext.Current.Request.Cookies[strName][key] != null)
return UrlDecode(HttpContext.Current.Request.Cookies[strName][key].ToString());
return "";
}
#endregion
#region 替换指定的字符串
/// <summary>
/// 替换指定的字符串
/// </summary>
/// <param name="originalStr">原字符串</param>
/// <param name="oldStr">旧字符串</param>
/// <param name="newStr">新字符串</param>
/// <returns></returns>
public static string ReplaceStr(string originalStr, string oldStr, string newStr)
{
if (string.IsNullOrEmpty(oldStr))
{
return "";
}
return originalStr.Replace(oldStr, newStr);
}
#endregion
#region 显示分页
/// <summary>
/// 返回分页页码
/// </summary>
/// <param name="pageSize">页面大小</param>
/// <param name="pageIndex">当前页</param>
/// <param name="totalCount">总记录数</param>
/// <param name="linkUrl">链接地址,__id__代表页码</param>
/// <param name="centSize">中间页码数量</param>
/// <returns></returns>
public static string OutPageList(int pageSize, int pageIndex, int totalCount, string linkUrl, int centSize)
{
//计算页数
if (totalCount < 1 || pageSize < 1)
{
return "";
}
int pageCount = totalCount / pageSize;
if (pageCount < 1)
{
return "";
}
if (totalCount % pageSize > 0)
{
pageCount += 1;
}
if (pageCount <= 1)
{
return "";
}
StringBuilder pageStr = new StringBuilder();
string pageId = "__id__";
string firstBtn = "<a href=\"" + ReplaceStr(linkUrl, pageId, (pageIndex - 1).ToString()) + "\">«上一页</a>";
string lastBtn = "<a href=\"" + ReplaceStr(linkUrl, pageId, (pageIndex + 1).ToString()) + "\">下一页»</a>";
string firstStr = "<a href=\"" + ReplaceStr(linkUrl, pageId, "1") + "\">1</a>";
string lastStr = "<a href=\"" + ReplaceStr(linkUrl, pageId, pageCount.ToString()) + "\">" + pageCount.ToString() + "</a>";
if (pageIndex <= 1)
{
firstBtn = "<span class=\"disabled\">«上一页</span>";
}
if (pageIndex >= pageCount)
{
lastBtn = "<span class=\"disabled\">下一页»</span>";
}
if (pageIndex == 1)
{
firstStr = "<span class=\"current\">1</span>";
}
if (pageIndex == pageCount)
{
lastStr = "<span class=\"current\">" + pageCount.ToString() + "</span>";
}
int firstNum = pageIndex - (centSize / 2); //中间开始的页码
if (pageIndex < centSize)
firstNum = 2;
int lastNum = pageIndex + centSize - ((centSize / 2) + 1); //中间结束的页码
if (lastNum >= pageCount)
lastNum = pageCount - 1;
pageStr.Append("<span>共" + totalCount + "记录</span>");
pageStr.Append(firstBtn + firstStr);
if (pageIndex >= centSize)
{
pageStr.Append("<span>...</span>\n");
}
for (int i = firstNum; i <= lastNum; i++)
{
if (i == pageIndex)
{
pageStr.Append("<span class=\"current\">" + i + "</span>");
}
else
{
pageStr.Append("<a href=\"" + ReplaceStr(linkUrl, pageId, i.ToString()) + "\">" + i + "</a>");
}
}
if (pageCount - pageIndex > centSize - ((centSize / 2)))
{
pageStr.Append("<span>...</span>");
}
pageStr.Append(lastStr + lastBtn);
return pageStr.ToString();
}
#endregion
#region URL处理
/// <summary>
/// URL字符编码
/// </summary>
public static string UrlEncode(string str)
{
if (string.IsNullOrEmpty(str))
{
return "";
}
str = str.Replace("'", "");
return HttpContext.Current.Server.UrlEncode(str);
}
/// <summary>
/// URL字符解码
/// </summary>
public static string UrlDecode(string str)
{
if (string.IsNullOrEmpty(str))
{
return "";
}
return HttpContext.Current.Server.UrlDecode(str);
}
/// <summary>
/// 组合URL参数
/// </summary>
/// <param name="_url">页面地址</param>
/// <param name="_keys">参数名称</param>
/// <param name="_values">参数值</param>
/// <returns>String</returns>
public static string CombUrlTxt(string _url, string _keys, params string[] _values)
{
StringBuilder urlParams = new StringBuilder();
try
{
string[] keyArr = _keys.Split(new char[] { '&' });
for (int i = 0; i < keyArr.Length; i++)
{
if (!string.IsNullOrEmpty(_values[i]) && _values[i] != "0")
{
_values[i] = UrlEncode(_values[i]);
urlParams.Append(string.Format(keyArr[i], _values) + "&");
}
}
if (!string.IsNullOrEmpty(urlParams.ToString()) && _url.IndexOf("?") == -1)
urlParams.Insert(0, "?");
//李朴-----add 2014-3-30 begin ----
if (!string.IsNullOrEmpty(urlParams.ToString()) && _url.Contains("&") && _url.LastIndexOf("&") < (_url.Length - 1))
{
_url += "&";
}
//李朴-----add 2014-3-30 end ----
}
catch
{
return _url;
}
return _url + DelLastChar(urlParams.ToString(), "&");
}
#endregion
#region URL请求数据
/// <summary>
/// HTTP POST方式请求数据
/// </summary>
/// <param name="url">URL.</param>
/// <param name="param">POST的数据</param>
/// <returns></returns>
public static string HttpPost(string url, string param)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.Timeout = 15000;
request.AllowAutoRedirect = false;
StreamWriter requestStream = null;
WebResponse response = null;
string responseStr = null;
try
{
requestStream = new StreamWriter(request.GetRequestStream());
requestStream.Write(param);
requestStream.Close();
response = request.GetResponse();
if (response != null)
{
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
responseStr = reader.ReadToEnd();
reader.Close();
}
}
catch (Exception)
{
throw;
}
finally
{
request = null;
requestStream = null;
response = null;
}
return responseStr;
}
/// <summary>
/// HTTP GET方式请求数据.
/// </summary>
/// <param name="url">URL.</param>
/// <returns></returns>
public static string HttpGet(string url)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
//request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.Timeout = 15000;
request.AllowAutoRedirect = false;
WebResponse response = null;
string responseStr = null;
try
{
response = request.GetResponse();
if (response != null)
{
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
responseStr = reader.ReadToEnd();
reader.Close();
}
}
catch (Exception)
{
throw;
}
finally
{
request = null;
response = null;
}
return responseStr;
}
/// <summary>
/// 执行URL获取页面内容
/// </summary>
public static string UrlExecute(string urlPath)
{
if (string.IsNullOrEmpty(urlPath))
{
return "error";
}
StringWriter sw = new StringWriter();
try
{
HttpContext.Current.Server.Execute(urlPath, sw);
return sw.ToString();
}
catch (Exception)
{
return "error";
}
finally
{
sw.Close();
sw.Dispose();
}
}
#endregion
#region 操作权限菜单
/// <summary>
/// 获取操作权限
/// </summary>
/// <returns>Dictionary</returns>
public static Dictionary<string, string> ActionType()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("Show", "显示");
dic.Add("View", "查看");
dic.Add("Add", "添加");
dic.Add("Edit", "修改");
dic.Add("Delete", "删除");
dic.Add("Audit", "审核");
dic.Add("Reply", "回复");
dic.Add("Confirm", "确认");
dic.Add("Cancel", "取消");
dic.Add("Invalid", "作废");
dic.Add("Build", "生成");
dic.Add("Instal", "安装");
dic.Add("Unload", "卸载");
dic.Add("Back", "备份");
dic.Add("Restore", "还原");
dic.Add("Replace", "替换");
return dic;
}
#endregion
#region 替换URL
/// <summary>
/// 替换扩展名
/// </summary>
public static string GetUrlExtension(string urlPage, string staticExtension)
{
int indexNum = urlPage.LastIndexOf('.');
if (indexNum > 0)
{
return urlPage.Replace(urlPage.Substring(indexNum), "." + staticExtension);
}
return urlPage;
}
/// <summary>
/// 替换扩展名,如没有扩展名替换默认首页
/// </summary>
public static string GetUrlExtension(string urlPage, string staticExtension, bool defaultVal)
{
int indexNum = urlPage.LastIndexOf('.');
if (indexNum > 0)
{
return urlPage.Replace(urlPage.Substring(indexNum), "." + staticExtension);
}
if (defaultVal)
{
if (urlPage.EndsWith("/"))
{
return urlPage + "index." + staticExtension;
}
else
{
return urlPage + "/index." + staticExtension;
}
}
return urlPage;
}
#endregion
/// <summary>
/// 获取JSTicket
/// </summary>
/// <returns></returns>
public static PostModel o = null;
public static string JSTicket()
{
string ticket="";
//string access_token = GetAccess_Token();
bool c = XpVShop.MyFuc.CacheHelper.IsExistCache("jsTicket");
if(c) ticket=XpVShop.MyFuc.CacheHelper.Get("jsTicket").ToString();
else
{
//JsApiTicketResult j = CommonApi.GetTicket(appid, appserct);
// ticket = j.ticket;
string token = GetAccess_Token();
string url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + token + "&type=jsapi";
string data = HttpGet(url);
JObject j = (JObject)JsonConvert.DeserializeObject(data);
ticket = j["ticket"].ToString();
XpVShop.MyFuc.CacheHelper.SetAccess_TokenCache("jsTicket", ticket);
}
return ticket;
}
/// <summary>
/// 获取签名
/// </summary>
/// <returns></returns>
public static string GetSignature(string url)
{
o = (PostModel)CacheHelper.Obtain("jsapi");
if (o == null)
{
LogHelper.Write("PostModel为空");
o = new PostModel();
o.Signature = "1";
o.AppId = "1";
o.Nonce = "1";
o.Timestamp = "1";
}
string jsticket = JSTicket();
string str1 = "jsapi_ticket={0}&noncestr={1}×tamp={2}&url={3}";
str1 = string.Format(str1, jsticket, o.Nonce, o.Timestamp, url);
string sig=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str1, "SHA1") ;
LogHelper.Write("str1:"+str1+"jsticket:" + jsticket+"sinature:"+sig);
return sig;
}
/// <summary>
/// 产生weixin js的作用域
/// </summary>
/// <returns></returns>
public static string JSApi(string url)
{
o.Signature= GetSignature(url);
// PostModel o = (PostModel)CacheHelper.Obtain("jsapi");
//if (o == null) {
// LogHelper.Write("PostModel为空");
// o = new PostModel();
// o.Signature = "1";
// o.AppId = "1";
// o.Nonce = "1";
// o.Timestamp = "1";
//}
LogHelper.Write("Signature:" + o.Signature + ",appid:" + o.AppId + ",Nonce:" + o.Nonce + ",Timestamp:" + o.Timestamp);
string appid = o.AppId;
string timestamp = o.Timestamp;
string nonceStr = o.Nonce;
string signature = o.Signature;
string jsapi = "<script type='text/javascript'>";
jsapi += "wx.config({" +
// "debug: true," + // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印.
"appId: '"+appid+"'," + // 必填,公众号的唯一标识"
"timestamp:'"+timestamp+"' ," +// 必填,生成签名的时间戳
"nonceStr: '" + nonceStr + "'," + // 必填,生成签名的随机串
"signature: '" + signature + "'," +// 必填,签名,见附录1
"jsApiList: [ 'checkJsApi', 'onMenuShareTimeline','onMenuShareAppMessage', 'onMenuShareQQ','onMenuShareWeibo','hideMenuItems',"+
"'showMenuItems','hideAllNonBaseMenuItem','showAllNonBaseMenuItem', 'translateVoice', 'startRecord', 'stopRecord','onRecordEnd',"+
"'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice','chooseImage','previewImage', 'uploadImage', 'downloadImage',"+
"'getNetworkType', 'openLocation', 'getLocation','hideOptionMenu', 'showOptionMenu', 'closeWindow', 'scanQRCode', 'chooseWXPay',"+
"'openProductSpecificView','addCard','chooseCard', 'openCard'] });</script> "; // 必填,需要使用的JS接口列表,所有JS接口列表见附录2+
//jsapi = string.Format(jsapi, appid,timestamp,nonceStr,signature);
return jsapi;
}
public static string GetAccess_Token()
{
string accessToken = "";
bool c = XpVShop.MyFuc.CacheHelper.IsExistCache("access_Token");
if (c)
{
accessToken = XpVShop.MyFuc.CacheHelper.Get("access_Token").ToString();
}
else
{
AccessTokenResult access = CommonApi.GetToken(appid, appserct);
accessToken = access.access_token;
XpVShop.MyFuc.CacheHelper.SetAccess_TokenCache("access_Token", access.access_token);
}
return accessToken;
}
}
}
wexinjs 调用的更多相关文章
- 黑马毕向东Java基础知识总结
Java基础知识总结(超级经典) 转自:百度文库 黑马毕向东JAVA基础总结笔记 侵删! 写代码: 1,明确需求.我要做什么? 2,分析思路.我要怎么做?1,2,3. 3,确定步骤.每一个思路部 ...
- 《果壳中的C# C# 5.0 权威指南》 - 学习笔记
<果壳中的C# C# 5.0 权威指南> ========== ========== ==========[作者] (美) Joseph Albahari (美) Ben Albahari ...
- JS调用Android、Ios原生控件
在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...
- 【原创分享·支付宝支付】HBuilder打包APP调用支付宝客户端支付
前言 最近有点空余时间,所以,就研究了一下APP支付.前面很早就搞完APP的微信支付了,但是由于时间上和应用上的情况,支付宝一直没空去研究.然后等我空了的时候,发现支付宝居然升级了支付逻辑,虽然目前还 ...
- 操作系统篇-调用门与特权级(CPL、DPL和RPL)
|| 版权声明:本文为博主原创文章,未经博主允许不得转载. 一.前言 在前两篇文章(<操作系统篇-浅谈实模式与保护模式>和<操作系统篇-分段机制与GDT|LDT>)中,我们提到 ...
- 架构设计:远程调用服务架构设计及zookeeper技术详解(下篇)
一.下篇开头的废话 终于开写下篇了,这也是我写远程调用框架的第三篇文章,前两篇都被博客园作为[编辑推荐]的文章,很兴奋哦,嘿嘿~~~~,本人是个很臭美的人,一定得要截图为证: 今天是2014年的第一天 ...
- django server之间通过remote user 相互调用
首先,场景是这样的:存在两个django web应用,并且两个应用存在一定的联系.某些情况下彼此需要获取对方的数据. 但是我们的应用肯经都会有对应的鉴权机制.不会让人家随随便便就访问的对吧.好比上车要 ...
- 调用AJAX做登陆和注册
先建立一个页面来检测一下我们建立的用户名能不能用,看一下有没有已经存在的用户名吗 可以通过ajax提示一下 $("#uid").blur(function(){ //取用户名 va ...
- nodejs进阶(2)—函数模块调用
函数调用 1. 文件内普通函数调用 创建一个js文件命名为2_callFunction.js,其中定义一个函数fun1,向返回对象输出了一段字符串“你好,我是fun1”. //------------ ...
随机推荐
- Ajax (一)
Ajax:即异步的XML和Javascript,在不刷新和提交的情况下,页面局部更新,实现前后端分离. Ajax的核心对象是XMLHttpRequest,服务器通过xhr对象与浏览器异步通信 关于HT ...
- XAMPP(Linux版-x86兼容)官网下载
欢迎光临 XAMPP 的 Linux 版 (x86 兼容处理器版)顺便提一下:该软件以前被称作 LAMPP,但为了避免误解,我们将其重名命为 »XAMPP 的 Linux 版«.所以,如果您在寻找 L ...
- 用Visual Studio调试Windows和驱动程序
由于本人能力有限,翻译不足之处敬请谅解,欢迎批评指正:sunylat@163.com Visual Studio版本:Visual Studio 2015企业版,中文环境. MSDN原文:https: ...
- 更改RAC日志组
alter database add logfile thread 1 group 5 ('+DATA/idb/onlinelog/group5.log') size 256m;alter datab ...
- Python绑定方法,未绑定方法,类方法,实例方法,静态方法
>>> class foo(): clssvar=[1,2] def __init__(self): self.instance=[1,2,3] def hehe(self): pr ...
- Sql语句查看表结构
快速查看表对的就说明,及表字段描述及字段类型 --表描述 SELECT tbs.name 表名,ds.value 描述 FROM sys.extended_properties ds LEFT JOI ...
- python3实现简单爬虫功能
本文参考虫师python2实现简单爬虫功能,并增加自己的感悟. #coding=utf-8 import re import urllib.request def getHtml(url): page ...
- 【T电商 1】Nginx服务器搭建
在项目中,首先是需要Nginx服务器作为一个图片服务器来使用.那么,久涉及到服务器的搭建.这次服务器的搭建,主要是在三个环境上进行了学习:CentOS6.2,CentOS7,和Ubuntu16.那么本 ...
- PDF 生成插件 flying saucer 和 iText
最近的项目中遇到了需求,用户在页面点击下载,将页面以PDF格式下载完成供用户浏览,所以上网找了下实现方案. 在Java世界,要想生成PDF,方案不少,所以简单做一个小结吧. 在此之前,先来勾画一下我心 ...
- VBS编辑字段
'为已经创建好的数据表添加字段'参数:strDBPath 字符串型 数据库路径'参数:strTableName 字符串型 需要创建的数据表的名称'参数:strColumnName 字符串型 需要添加的 ...