Files
g.hnyhua.cn/Mtxfw.shop/apiajax.ashx.cs
2026-02-07 15:48:27 +08:00

873 lines
45 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Net;
using System.Web.SessionState;
using System.Text.RegularExpressions;
using System.Globalization;
using Newtonsoft.Json;
using System.Web.Script.Serialization;
using System.Drawing;
namespace Mtxfw.shop
{
/// <summary>
/// Ajax 处理页面
/// </summary>
public class apiajax : IHttpHandler, IRequiresSessionState
{
private Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
public void ProcessRequest(HttpContext context)
{
try
{
//context.Response.ContentType = "text/plain";
context.Response.ContentType = "application/json";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
/*using (var reader = new System.IO.StreamReader(context.Request.InputStream))
{
String xmlData = reader.ReadToEnd();
if (!string.IsNullOrEmpty(xmlData))
{
Mtxfw.Utility.Common.WriteHtml("/weixin/action.txt", context.Request["action"] + "|" + xmlData);
}
}*/
string data = "";
//方式
switch (context.Request["action"])
{
case "sendphonecode": data = sendphonecode(context); break;
case "register": data = register(context); break;
case "login": data = login(context); break;
case "uploadImage": data = uploadImage(context); break;
case "getuserinfo": data = getuserinfo(context); break;
case "updateUserInfo": data = updateUserInfo(context); break;
case "countNewest": data = countNewest(context); break;
case "getmessage": data = getmessage(context); break;
case "getmessagelist": data = getmessagelist(context); break;
}
Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxdata.txt", data);
Utility.Common.WriteJson(context, data);
}
catch (Exception err)
{
Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxerr.txt", err.ToString());
}
}
#region //发送手机验证码-----------------------------------------------------------------------------------------
/// <summary>
/// 发送手机验证码
/// </summary>
protected string sendphonecode(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["phone"]))
{
string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString());
bool b = true;
if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[3,4,5,7,8]+\d{9}"))
{
b = false;
data = "{'status':0,'msg':'手机号码格式填写不正确!'}";
}
if (b)
{
if (!new DAL.user_info().IsExists(phone))
{
if (new DAL.user_YZMs().GetCount("utype=0 And phone='" + phone + "' And DateDiff(mi,addtime,getdate())<2") == 0)
{
if (new DAL.user_YZMs().GetCount("utype=0 And phone='" + phone + "' And DateDiff(dy,addtime,getdate())=0") < 30)
{
string strYZM = new CheckCode().RandNum(4);
string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码30分钟内有效,请及时验证!";
try
{
Model.user_YZMs mymodel = new Model.user_YZMs();
mymodel.YZID = new Guid().ToString();
mymodel.phone = phone;
mymodel.YZM = strYZM;
mymodel.ip = Mtxfw.Utility.Common.GetIP;
mymodel.AddTime = DateTime.Now;
mymodel.utype = 0;
new DAL.user_YZMs().Add(mymodel);
Mtxfw.Utility.Common.sendsms(phone, strconent);
data = "{'status':1,'msg':'发送成功','yzid':'" + mymodel.YZID + "'}";
}
catch
{
data = "{'status':0,'msg':'发送验证码出现错误!'}";
}
}
else
{
data = "{'status':0,'msg':'操作太频繁2'}";
}
}
else
{
data = "{'status':0,'msg':'操作太频繁!'}";
}
}
else
{
data = "{'status':0,'msg':'此手机号码已经注册过!'}";
}
}
}
else
{
data = "{'status':0,'msg':'手机号码不能为空!'}";
}
return data;
}
#endregion
#region //注册会员-----------------------------------------------------------------------------------------
/// <summary>
/// 注册会员
/// </summary>
protected string register(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["YZID"]) && !String.IsNullOrEmpty(context.Request["phone"]) && !String.IsNullOrEmpty(context.Request["password"]) && !String.IsNullOrEmpty(context.Request["verifyCode"]))
{
string YZID = HttpUtility.UrlDecode(context.Request["YZID"].ToString());
string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString());
string password = HttpUtility.UrlDecode(context.Request["password"].ToString());
string verifyCode = HttpUtility.UrlDecode(context.Request["verifyCode"].ToString());
bool b = true;
if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[3,4,5,7,8]+\d{9}"))
{
b = false;
data = "{'status':0,'msg':'手机号码格式填写不正确!'}";
}
if (b)
{
if (new DAL.user_info().IsExists(phone))
{
b = false;
data = "{'status':0,'msg':'手机号码已经注册过!'}";
}
}
if (b)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(password, @"^[A-Za-z0-9_]+$") || password.Length < 6 || password.Length > 16)
{
b = false;
data = "{'status':0,'msg':'密码输入不正确密码由6-16位数字、字母、下划线组成'}";
}
}
if (b)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(verifyCode, @"^[0-9]+$") || verifyCode.Length != 6)
{
b = false;
data = "{'status':0,'msg':'手机验证码输入不正确!'}";
}
}
if (b)
{
if (new DAL.user_YZMs().GetCount("utype=0 And YZID='" + YZID + "' And phone='" + phone + "' And YZM='" + verifyCode + "'") == 0)
{
b = false;
data = "{'status':0,'msg':'手机验证码输入不正确!'}";
}
}
int ContactID = 0;
string ContactIDS = "";
if (b)
{
if (!String.IsNullOrEmpty(context.Request["inviteCode"]))
{
string inviteCode = HttpUtility.UrlDecode(context.Request["inviteCode"].ToString());
SqlDataReader dr = new Mtxfw.DAL.user_info().GetUserId(inviteCode);
if (dr.HasRows)
{
if (dr.Read())
{
ContactID = Convert.ToInt32(dr["id"].ToString());
ContactIDS = dr["ContactIDS"].ToString();
}
}
else
{
b = false;
data = "{'status':0,'msg':'邀请码不存在!'}";
}
dr.Close();
}
}
if (b)
{
new DAL.user_YZMs().UpdateIFEnable(1, phone);
string province = "", city = "", county = "", strMemberCard = (new Mtxfw.DAL.user_info().GetMaxMemberCard() + 1).ToString();
Mtxfw.Model.user_info model = new Mtxfw.Model.user_info();
model.MemberCard = strMemberCard;
model.UserName = phone;
model.Password = Mtxfw.Utility.Security.EncryptString(password);
model.Password2 = model.Password; //Mtxfw.Utility.Security.EncryptString(Text_Password2.Text);
model.RealName = "";
model.NCName = "";
model.UserPic = "";
model.Sex = "";
model.SFZ = "";
model.Mobile = "";
model.Phone = phone;
model.Email = "";
model.Province = province;
model.City = city;
model.County = county;
model.MailingAddress = "";
model.PostalCode = "";
model.QQ = "";
model.CompanyName = "";
model.CompanyNumber = "";
model.CompanyContact = "";
model.ProductName = "";
model.UserState = "正常";
model.RegTime = DateTime.Now;
model.RegTime2 = DateTime.Now;
/*SqlDataReader Dr = daoUser.GetUserId(Text_RememberID.Text);
if (Dr.Read())
{
RememberID = int.Parse(Dr["Id"].ToString());
RememberIDS = Dr["RememberIDS"].ToString();
}
Dr.Close();*/
model.RememberID = 0;
model.RememberIDS = "";
model.SuperiorsID = 0;
model.SuperiorsIDS = "";
model.ContactID = ContactID;
if (ContactIDS == "")
{
model.ContactIDS = "," + ContactID.ToString() + ",";
}
else
{
model.ContactIDS = ContactIDS + ContactID.ToString() + ",";
}
model.DLRememberID = 0;
model.DLRememberIDS = "";
model.SJRememberID = 0;
model.SJRememberIDS = "";
model.uLevel0 = 0;
model.uLevel1 = 0;
model.uLevel3 = 0;
int uLevel5 = 0;
model.uLevel5 = uLevel5;
model.utype = "0";
model.uutype = "1";
model.openid = "";
model.opentype = 0;
model.opentype2 = 0;
model.refresh_token = "";
model.refresh_token_time = "";
model.IFUpUserName = 0;
model.Id = new Mtxfw.DAL.user_info().Add(model);
data = "{'status':1,'msg':'登录成功!','userId':'" + Mtxfw.Utility.Security.EncryptString(model.Id.ToString()) + "'}";
}
}
else
{
data = "{'status':0,'msg':'参数不能为空!'}";
}
return data;
}
#endregion
#region //会员登录-----------------------------------------------------------------------------------------
/// <summary>
/// 会员登录
/// </summary>
protected string login(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["phone"]) && !String.IsNullOrEmpty(context.Request["password"]))
{
string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString());
string password = HttpUtility.UrlDecode(context.Request["password"].ToString());
bool b = true;
if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[3,4,5,7,8]+\d{9}"))
{
b = false;
data = "{'status':0,'msg':'手机号码格式填写不正确!'}";
}
if (b)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(password, @"^[A-Za-z0-9_]+$") || password.Length < 6 || password.Length > 16)
{
b = false;
data = "{'status':0,'msg':'密码输入不正确密码由6-16位数字、字母、下划线组成'}";
}
}
if (b)
{
Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
int MemberId = 0;
int IFStores = 0;
int IFUpUserName = 0;
int uutype = 0;
string MemberJS = "";
string NCName = "";
string avatar = "";
string gender = "";
string birthday = "";
int ContactID = 0;
int IFBecomeBusiness = 0;
int MemberuLevel = 0;
int MemberuLevel2 = 0;
if (daoUser.IsLoginWeb(phone, Mtxfw.Utility.Security.EncryptString(password), ref MemberId, ref ContactID, ref IFStores, ref NCName, ref avatar, ref gender, ref birthday, ref IFUpUserName, ref IFBecomeBusiness, ref uutype,ref MemberJS, ref MemberuLevel, ref MemberuLevel2))
{
if (IFBecomeBusiness == 0)
{
if (uutype > 0)
{
DateTime dt = DateTime.Now;
Model.User_OnLine model = new Model.User_OnLine();
model.SessionId = context.Session.SessionID;
model.MemberId = MemberId;
model.DLID = 1;
model.ZDLID = 0;
model.GDID = 0;
model.FGSID = 0;
model.InTime = dt;
model.IsOnline = 1;
model.IP = Mtxfw.Utility.Common.GetIP;
model.MAC = "";
model.UserType = 0;
new DAL.User_OnLine().Add(model);
daoUser.UpdateuLevel("opentype2", 0, MemberId);
string LoginId = new Guid().ToString();
daoUser.UpdateLogins(model.IP,LoginId, MemberId);
context.Session["MemberId"] = MemberId;
context.Session["MemberName"] = phone;
context.Session["MemberNCName"] = NCName;
context.Session["MemberIFStores"] = IFStores;
context.Session["MemberuLevel"] = MemberuLevel;
if (context.Session["returnurl"] != null)
{
string strurl = context.Session["returnurl"].ToString();
context.Session.Remove("returnurl");
data = "{'status':1,'msg':'登录成功!','user':{'_id':'" + Mtxfw.Utility.Security.EncryptString(MemberId.ToString()) + "','phone':'" + phone + "','nickname':'" + NCName + "','avatar':'" + avatar + "','gender':'" + gender + "','birthday':'" + birthday + "','inviteCode':'" + Mtxfw.Utility.Security.EncryptString(ContactID.ToString()) + "','LoginId':'" + LoginId + "'},'reurl':'" + strurl + "'}";
}
else
{
data = "{'status':1,'msg':'登录成功!','user':{'_id':'" + Mtxfw.Utility.Security.EncryptString(MemberId.ToString()) + "','phone':'" + phone + "','nickname':'" + NCName + "','avatar':'" + avatar + "','gender':'" + gender + "','birthday':'" + birthday + "','inviteCode':'" + Mtxfw.Utility.Security.EncryptString(ContactID.ToString()) + "','LoginId':'" + LoginId + "'},'reurl':'index.html'}";
}
}
else data = "{'status':0,'msg':'您的账户不能在此登录!'}";
}
else data = "{'status':0,'msg':'您的账户不能登录!'}";
}
else data = "{'status':0,'msg':'用户名或密码错误!'}";
}
}
else
{
data = "{'status':0,'msg':'手机号码不能为空!'}";
}
return data;
}
#endregion
#region //上传头像-----------------------------------------------------------------------------------------
/// <summary>
/// 上传头像
/// </summary>
protected string uploadImage(HttpContext context)
{
string data = "{'success':false}";
if (context.Request.Files["image"] != null && !String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]))
{
int userId = Convert.ToInt32(Mtxfw.Utility.Security.DecryptString(HttpUtility.UrlDecode(context.Request["userId"].ToString())));
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
System.IO.Stream stream = GetPostedFileSteam(context);//这是你获得的流
long intContentLength = stream.Length;
//if (strContentType.IndexOf("jpg") != -1 || strContentType.IndexOf("jpeg") != -1 || strContentType.IndexOf("gif") != -1 || strContentType.IndexOf("png") != -1 || strContentType.IndexOf("bmp") != -1)
//{
if (intContentLength <= 102400 * 2)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.IFUpUserName == 1)
{
if (model.LoginId == LoginId)
{
string FileName, FileType, Folders;
Folders = config.webUpPath;
Folders = "/Files/grimage/" + model.Id + "/";
//创建保存位置
if (!Directory.Exists(context.Server.MapPath(Folders)))
{
Directory.CreateDirectory(context.Server.MapPath(Folders));
}
FileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString();
FileType = context.Request.Files["image"].FileName.Substring(context.Request.Files["image"].FileName.LastIndexOf(".")).ToLower();
string strFilePath = Folders + FileName + FileType;
//context.Request.Files["image"].SaveAs(context.Server.MapPath(strFilePath));
using (var flieStream = new FileStream(context.Server.MapPath(strFilePath), FileMode.Create))
{
stream.CopyTo(flieStream);
}
/*using (FileStream fs = new FileStream(context.Server.MapPath(strFilePath), FileMode.Create))
{
byte[] bytes = new byte[stream.Length];
int numBytesRead = 0;
int numBytesToRead = (int)stream.Length;
stream.Position = 0;
while (numBytesToRead > 0)
{
int n = stream.Read(bytes, numBytesRead, Math.Min(numBytesToRead, int.MaxValue));
if (n <= 0)
{
break;
}
fs.Write(bytes, numBytesRead, n);
numBytesRead += n;
numBytesToRead -= n;
}
fs.Close();
}*/
/*if (!Mtxfw.Utility.Common.IsAllowedExtension(context.Server.MapPath(strFilePath)))
{
File.Delete(context.Server.MapPath(strFilePath));
data = "{'status':0,'msg':'只能上传图片2','url':'" + strFilePath + "'}";
}
else
{*/
data = "{'status':1,'msg':'上传成功!'}";
//}
}
else
{
data = "{'status':0,'msg':'您未登录!'}";
}
}
else
{
string FileName, FileType, Folders;
Folders = config.webUpPath;
Folders = "/Files/grimage/" + model.Id + "/";
//创建保存位置
if (!Directory.Exists(context.Server.MapPath(Folders)))
{
Directory.CreateDirectory(context.Server.MapPath(Folders));
}
FileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString();
FileType = context.Request.Files["image"].FileName.Substring(context.Request.Files["image"].FileName.LastIndexOf(".")).ToLower();
string strFilePath = Folders + FileName + FileType;
//context.Request.Files["image"].SaveAs(context.Server.MapPath(strFilePath));
using (var flieStream = new FileStream(context.Server.MapPath(strFilePath), FileMode.Create))
{
stream.CopyTo(flieStream);
}
/*using (FileStream fs = new FileStream(context.Server.MapPath(strFilePath), FileMode.Create))
{
byte[] bytes = new byte[stream.Length];
int numBytesRead = 0;
int numBytesToRead = (int)stream.Length;
stream.Position = 0;
while (numBytesToRead > 0)
{
int n = stream.Read(bytes, numBytesRead, Math.Min(numBytesToRead, int.MaxValue));
if (n <= 0)
{
break;
}
fs.Write(bytes, numBytesRead, n);
numBytesRead += n;
numBytesToRead -= n;
}
fs.Close();
}*/
/*if (!Mtxfw.Utility.Common.IsAllowedExtension(context.Server.MapPath(strFilePath)))
{
File.Delete(context.Server.MapPath(strFilePath));
data = "{'status':0,'msg':'只能上传图片2','url':'" + strFilePath + "'}";
}
else
{*/
data = "{'status':1,'msg':'上传成功!'}";
//}
}
}
else
{
data = "{'status':0,'msg':'参数错误!'}";
}
}
else
{
data = "{'status':0,'msg':'只能上传小于2M的图片'}";
}
/*}
else
{
data = "{'status':0,'msg':'只能上传图片" + strContentType + "'}";
}*/
}
else
{
data = "{'status':0,'msg':'参数不能为空!'}";
}
return data;
}
private Stream GetPostedFileSteam(HttpContext context)
{
if (context.Request.Browser.Browser == "IE"
&& context.Request.Files != null
&& context.Request.Files.Count > 0)
{
var postedFile = context.Request.Files[0];
return postedFile.InputStream;
}
else
{
return context.Request.InputStream;
}
}
/// <summary>
/// 字节流转换成图片
/// </summary>
/// <param name="byt">要转换的字节流</param>
/// <returns>转换得到的Image对象</returns>
public static Image BytToImg(byte[] byt)
{
MemoryStream ms = new MemoryStream(byt);
Image img = Image.FromStream(ms);
return img;
}
public byte[] StreamToBytes(Stream stream)
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
return bytes;
}
/*private System.Drawing.Imaging.ImageFormat GetImageFormat()
{
switch (FileUpload_Image.PostedFile.ContentType)
{
case "image/bmp":
return System.Drawing.Imaging.ImageFormat.Bmp;
case "image/gif":
return System.Drawing.Imaging.ImageFormat.Gif;
case "image/pjpeg":
case "image/jpeg":
return System.Drawing.Imaging.ImageFormat.Jpeg;
case "image/tiff":
return System.Drawing.Imaging.ImageFormat.Tiff;
case "image/x-png":
return System.Drawing.Imaging.ImageFormat.Png;
default:
return null;
}
}*/
#endregion
#region //获取会员信息-----------------------------------------------------------------------------------------
/// <summary>
/// 获取会员信息
/// </summary>
protected string getuserinfo(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]))
{
int userId = Convert.ToInt32(Mtxfw.Utility.Security.DecryptString(HttpUtility.UrlDecode(context.Request["userId"].ToString())));
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.IFUpUserName == 1)
{
if (model.LoginId == LoginId)
{
data = "{'status':1,'msg':'获取成功!','user':{'nickname':'" + model.NCName + "','avatar':'" + model.UserPic + "','gender':'" + model.Sex + "','birthday':'" + model.CSDate + "'}}";
}
else
{
data = "{'status':0,'msg':'您未登录!'}";
}
}
else
{
data = "{'status':0,'msg':'不是正常会员!'}";
}
}
else
{
data = "{'status':0,'msg':'参数错误!'}";
}
}
else
{
data = "{'status':0,'msg':'参数不能为空!'}";
}
return data;
}
#endregion
#region //更新信息-----------------------------------------------------------------------------------------
/// <summary>
/// 更新信息
/// </summary>
protected string updateUserInfo(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["nickname"]) && !String.IsNullOrEmpty(context.Request["gender"]) && !String.IsNullOrEmpty(context.Request["birthday"]) && !String.IsNullOrEmpty(context.Request["avatar"]))
{
int userId = Convert.ToInt32(Mtxfw.Utility.Security.DecryptString(HttpUtility.UrlDecode(context.Request["userId"].ToString())));
string nickname = HttpUtility.UrlDecode(context.Request["nickname"].ToString());
string gender = HttpUtility.UrlDecode(context.Request["gender"].ToString());
string birthday = HttpUtility.UrlDecode(context.Request["birthday"].ToString());
string avatar = HttpUtility.UrlDecode(context.Request["avatar"].ToString());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.IFUpUserName == 0)
{
model.NCName = nickname;
model.Sex = gender;
model.CSDate = birthday;
model.UserPic = avatar;
new Mtxfw.DAL.user_info().Update(model);
if (context.Session["returnurl"] != null)
{
string strurl = context.Session["returnurl"].ToString();
context.Session.Remove("returnurl");
data = "{'status':1,'msg':'更新成功!','user':{'_id':'" + Mtxfw.Utility.Security.EncryptString(model.Id.ToString()) + "','phone':'" + model.Phone + "','nickname':'" + model.NCName + "','avatar':'" + model.UserPic + "','gender':'" + model.Sex + "','birthday':'" + model.CSDate + "','inviteCode':'" + Mtxfw.Utility.Security.EncryptString(model.ContactID.ToString()) + "','LoginId':'" + model.LoginId + "'},'reurl':'" + strurl + "'}";
}
else
{
data = "{'status':1,'msg':'更新成功!','user':{'_id':'" + Mtxfw.Utility.Security.EncryptString(model.Id.ToString()) + "','phone':'" + model.Phone + "','nickname':'" + model.NCName + "','avatar':'" + model.UserPic + "','gender':'" + model.Sex + "','birthday':'" + model.CSDate + "','inviteCode':'" + Mtxfw.Utility.Security.EncryptString(model.ContactID.ToString()) + "','LoginId':'" + model.LoginId + "'},'reurl':'index.html'}";
}
}
else
{
if (!String.IsNullOrEmpty(context.Request["LoginId"]))
{
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
if (model.LoginId == LoginId)
{
model.NCName = nickname;
model.Sex = gender;
model.CSDate = birthday;
model.UserPic = avatar;
new Mtxfw.DAL.user_info().Update(model);
data = "{'status':1,'msg':'更新成功!'}";
}
else
{
data = "{'status':0,'msg':'您未登录!'}";
}
}
else
{
data = "{'status':0,'msg':'已更新过!'}";
}
}
}
}
else
{
data = "{'status':0,'msg':'参数不能为空!'}";
}
return data;
}
#endregion
#region //获取信息总数-----------------------------------------------------------------------------------------
/// <summary>
/// 获取信息总数
/// </summary>
protected string countNewest(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]))
{
int userId = Convert.ToInt32(Mtxfw.Utility.Security.DecryptString(HttpUtility.UrlDecode(context.Request["userId"].ToString())));
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.IFUpUserName == 1)
{
if (model.LoginId == LoginId)
{
int myCount1 = new Mtxfw.DAL.Article().GetCount("parentid=20 And hasRead=0 and receiverid=" + userId + "");
int myCount2 = new Mtxfw.DAL.order_info().GetCount("hasRead=0 and UserID=" + userId + "");
int myCount3 = new Mtxfw.DAL.user_Results().GetCount("utype=1 and hasRead=0 and MemberId=" + userId + "");
data = "{'status':1,'total':" + (myCount1 + myCount2 + myCount3) + "}";
}
}
}
}
return data;
}
#endregion
#region //获取分类信息-----------------------------------------------------------------------------------------
/// <summary>
/// 获取分类信息
/// </summary>
protected string getmessage(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]))
{
int userId = Convert.ToInt32(Mtxfw.Utility.Security.DecryptString(HttpUtility.UrlDecode(context.Request["userId"].ToString())));
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.IFUpUserName == 1)
{
if (model.LoginId == LoginId)
{
int myCount1 = new Mtxfw.DAL.Article().GetCount("parentid=20 And hasRead=0 and receiverid=" + userId + "");
int myCount2 = new Mtxfw.DAL.order_info().GetCount("hasRead=0 and UserID=" + userId + "");
int myCount3 = new Mtxfw.DAL.user_Results().GetCount("utype=1 and hasRead=0 and MemberId=" + userId + "");
string updateTime1 = new Mtxfw.DAL.Article().Getzd("addtime", "parentid=20 And hasRead=0 and receiverid=" + userId + " Order By addtime Desc").ToString();
string updateTime2 = new Mtxfw.DAL.order_info().Getzd("O_SubmitDate", "hasRead=0 and UserID=" + userId + " Order By O_SubmitDate Desc").ToString();
string updateTime3 = new Mtxfw.DAL.user_Results().Getzd("addtime", "utype=1 and hasRead=0 and MemberId=" + userId + " Order By addtime Desc").ToString();
data = "{'status':1,'data':{'system':{'ifshow',true,'content':'您有 " + myCount1 + " 条新信息','updateTime':'" + updateTime1 + "'},'order':{'ifshow',true,'content':'您有 " + myCount2 + " 条新信息','updateTime':'" + updateTime2 + "','ordernum':" + myCount2 + "},'money':{'ifshow',true,'content':'您有 " + myCount3 + " 条新信息','updateTime':'" + updateTime3 + "','moneynum':" + myCount3 + "}}}";
}
}
}
}
return data;
}
#endregion
#region //获取分类信息列表-----------------------------------------------------------------------------------------
/// <summary>
/// 获取分类信息列表
/// </summary>
protected string getmessagelist(HttpContext context)
{
string data = "{'success':false}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["t"]))
{
int userId = Convert.ToInt32(Mtxfw.Utility.Security.DecryptString(HttpUtility.UrlDecode(context.Request["userId"].ToString())));
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
int t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString()));
if (t == 0 || t == 1 || t == 2)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.IFUpUserName == 1)
{
if (model.LoginId == LoginId)
{
string strdata = "";
if (t == 0)
{
DataSet ds = new Mtxfw.DAL.Article().GetList1("id,hasRead,title,content,addtime", "parentid=20 and receiverid=" + userId + " Order By hasRead Desc,addtime Desc");
if (ds.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
int id = Convert.ToInt32(Dr["id"]);
int hasRead = Convert.ToInt32(Dr["hasRead"]);
string title = Dr["title"].ToString();
string content = Dr["content"].ToString();
string addtime = Dr["addtime"].ToString();
strdata += "{'hasRead':" + (hasRead == 1 ? false : true) + ",'id':'" + id + "','title':'" + title + "','content':'" + content.Replace("'", "\'") + "','createTime':'" + addtime + "'}";
if (i != ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
}
if (t == 1)
{
DataSet ds = new Mtxfw.DAL.order_info().GetList1("id,utype,hasRead,orderid,O_SubmitDate,O_Payed,O_Payed_Date,O_Shipped,O_Shipped_Date,O_received,O_received_Date,O_Return,O_Return_Date,O_Returned,O_Returned_Date,O_recReturn,O_recReturn_date", "hasRead=0 and UserID=" + userId + " Order By hasRead Desc,O_SubmitDate Desc");
if (ds.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
int id = Convert.ToInt32(Dr["id"]);
int hasRead = Convert.ToInt32(Dr["hasRead"]);
string utype = Dr["utype"].ToString();
string orderid = Dr["orderid"].ToString();
string O_SubmitDate = Dr["O_SubmitDate"].ToString();
string O_Payed = Dr["O_Payed"].ToString();
string O_Payed_Date = Dr["O_Payed_Date"].ToString();
string O_Shipped = Dr["O_Shipped"].ToString();
string O_Shipped_Date = Dr["O_Shipped_Date"].ToString();
string O_received = Dr["O_received"].ToString();
string O_received_Date = Dr["O_received_Date"].ToString();
string O_Return = Dr["O_Return"].ToString();
string O_Return_Date = Dr["O_Returned_Date"].ToString();
string O_Returned = Dr["O_Returned"].ToString();
string O_Returned_Date = Dr["O_Returned_Date"].ToString();
string O_recReturn = Dr["O_recReturn"].ToString();
string O_recReturn_Date = Dr["O_recReturn_Date"].ToString();
string [] OrderStatus = Mtxfw.Utility.Common.GetOrderStatus(utype, id.ToString(), O_SubmitDate, O_Payed, O_Payed_Date, 0);
strdata += "{'order':{'orderStatus':" + O_Payed + ",'orderId':" + id + ",'shoplive':{'backTime':'" + O_Payed_Date + "'}},'message':{'hasRead':" + (hasRead == 1 ? false : true) + ",'id':'" + id + "','title':'订单号:" + orderid + "','content':'" + OrderStatus[0] + "','createTime':'" + OrderStatus[2] + "'}}";
if (i != ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
}
data = "{'status':1,'data':[" + strdata + "]}";
}
}
}
}
}
return data;
}
#endregion
public bool IsReusable { get { return false; } }
}
}