Ejemplo n.º 1
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this.txtPassword.Value))
     {
         this.message.Text = "密码不能为空";
     }
     else if (this.txtPassword.Value != this.txtPassword2.Value)
     {
         this.message.Text = "两次密码输入不一致,请重新输入";
     }
     else
     {
         MemberDao  memberDao  = new MemberDao();
         bool       flag       = true;
         MemberInfo memberInfo = memberDao.FindMemberByCellphone(this.username);
         if (memberInfo == null)
         {
             memberInfo = memberDao.FindMemberByEmail(this.username);
         }
         if (DataHelper.IsEmail(this.username))
         {
             flag = false;
         }
         if (memberInfo != null)
         {
             string value = this.txtNumber.Value;
             string text  = "验证码错误";
             if ((flag && HiContext.Current.CheckPhoneVerifyCode(value, memberInfo.CellPhone, out text)) || (!flag && HiContext.Current.CheckVerifyCode(value, "")))
             {
                 if (MemberProcessor.ChangePassword(memberInfo, this.txtPassword2.Value))
                 {
                     Messenger.UserPasswordChanged(memberInfo, this.txtPassword2.Value);
                     Users.SetCurrentUser(memberInfo.UserId, 1, true, false);
                     ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                     if (cookieShoppingCart != null)
                     {
                         ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                         ShoppingCartProcessor.ClearCookieShoppingCart();
                     }
                     this.Page.Response.Redirect("MemberCenter.aspx", true);
                 }
             }
             else
             {
                 this.message.Text = text;
             }
         }
         else
         {
             this.message.Text = "密码修改失败,错误的用户名";
         }
     }
 }
Ejemplo n.º 2
0
        private string UserLogin(string userName, string password)
        {
            string result = string.Empty;
            Member member = Users.GetUser(0, userName, false, true) as Member;

            if (member == null || member.IsAnonymous)
            {
                return("用户名或密码错误");
            }
            if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
            {
                return("您不是本站会员,请您进行注册");
            }
            member.Password = password;
            LoginUserStatus loginUserStatus = MemberProcessor.ValidLogin(member);

            if (loginUserStatus == LoginUserStatus.Success)
            {
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                IUserCookie           userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                HiContext.Current.User = member;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                member.OnLogin();
            }
            else
            {
                if (loginUserStatus == LoginUserStatus.AccountPending)
                {
                    result = "用户账号还没有通过审核";
                }
                else
                {
                    if (loginUserStatus == LoginUserStatus.InvalidCredentials)
                    {
                        result = "用户名或密码错误";
                    }
                    else
                    {
                        result = "未知错误";
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        private void UserLogin(string userName, string password)
        {
            userName = Globals.StripAllTags(userName);
            MemberInfo memberInfo = MemberProcessor.ValidLogin(userName, password);

            if (memberInfo != null)
            {
                Users.SetCurrentUser(memberInfo.UserId, 0, true, true);
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
            }
        }
Ejemplo n.º 4
0
        private void SetLoginState(MemberInfo member)
        {
            string           text         = this.parameters["HIGW"];
            string           openId       = this.parameters["CurrentOpenId"];
            MemberOpenIdInfo memberOpenId = MemberProcessor.GetMemberOpenId(text, openId);

            if (memberOpenId == null)
            {
                memberOpenId            = new MemberOpenIdInfo();
                memberOpenId.UserId     = member.UserId;
                memberOpenId.OpenIdType = text;
                memberOpenId.OpenId     = openId;
                MemberProcessor.AddMemberOpenId(memberOpenId);
            }
            Users.SetCurrentUser(member.UserId, 30, false, false);
            HiContext.Current.User = member;
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                HttpCookie httpCookie = new HttpCookie("Token_" + HiContext.Current.UserId.ToString());
                httpCookie.HttpOnly = true;
                httpCookie.Expires  = DateTime.Now.AddMinutes(30.0);
                httpCookie.Value    = this.parameters["token"];
                HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            if (!string.IsNullOrEmpty(this.parameters["target_url"]))
            {
                this.Page.Response.Redirect(this.parameters["target_url"], true);
            }
            this.Page.Response.Redirect("/");
        }
Ejemplo n.º 5
0
        private string UserLogin(string userName, string password)
        {
            string result = string.Empty;

            userName = Globals.StripAllTags(userName);
            MemberInfo memberInfo = MemberProcessor.ValidLogin(userName, password);

            if (memberInfo != null)
            {
                Users.SetCurrentUser(memberInfo.UserId, (this.chkSaveLoginInfo != null && this.chkSaveLoginInfo.Checked) ? 7 : 0, true, true);
                HiContext.Current.User = memberInfo;
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
            }
            else
            {
                result = "用户名或密码错误";
            }
            return(result);
        }
Ejemplo n.º 6
0
        private void SetLoginState(MemberInfo member, int iSendCouponCount = 0)
        {
            string text = Globals.StripAllTags(this.Parameters["CurrentOpenId"]);

            if (!string.IsNullOrEmpty(text))
            {
                MemberOpenIdInfo memberOpenIdInfo = MemberProcessor.GetMemberOpenIdInfo(member.UserId, this.openIdType);
                if (memberOpenIdInfo != null && memberOpenIdInfo.OpenId != text)
                {
                    this.ShowMessage("该账号已被绑定,请绑定其他帐号。", false, "", 1);
                    return;
                }
                MemberOpenIdInfo memberOpenId = MemberProcessor.GetMemberOpenId(this.openIdType, text);
                if (memberOpenId == null)
                {
                    memberOpenId            = new MemberOpenIdInfo();
                    memberOpenId.UserId     = member.UserId;
                    memberOpenId.OpenIdType = this.openIdType;
                    memberOpenId.OpenId     = text;
                    try
                    {
                        MemberProcessor.AddMemberOpenId(memberOpenId);
                    }
                    catch (Exception ex)
                    {
                        NameValueCollection param = new NameValueCollection
                        {
                            this.Page.Request.QueryString,
                            this.Page.Request.Form
                        };
                        Globals.WriteExceptionLog_Page(ex, param, "AddMemberOpenId");
                    }
                }
            }
            Users.SetCurrentUser(member.UserId, 0, true, true);
            HiContext.Current.User = member;
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }
            if (!string.IsNullOrEmpty(this.Parameters["token"]))
            {
                HttpCookie httpCookie = new HttpCookie("Token_" + member.UserId);
                httpCookie.HttpOnly = true;
                httpCookie.Expires  = DateTime.Now.AddMinutes(30.0);
                httpCookie.Value    = this.Parameters["token"];
                HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            if (!string.IsNullOrEmpty(this.Parameters["target_url"]))
            {
                this.Page.Response.Redirect(this.Parameters["target_url"], true);
            }
            string text2 = this.Parameters["HITO"];
            string text3 = this.Parameters["target_url"].ToNullString();

            if (string.IsNullOrEmpty(text3))
            {
                text3 = "/Default";
            }
            if (iSendCouponCount > 0)
            {
                this.ShowMessage("恭喜您注册成功," + iSendCouponCount + " 张优惠券已经放入您的账户,可在会员中心我的优惠券中进行查看", true, text3, 1);
            }
            else
            {
                this.ShowMessage("恭喜您注册/登录成功", true, text3, 1);
            }
        }
Ejemplo n.º 7
0
        private void btnBindingLogin_Click(object sender, EventArgs e)
        {
            string text  = Globals.StripAllTags(this.Parameters["CurrentOpenId"].ToNullString());
            string text2 = Globals.StripAllTags(base.GetParameter("HIGW", false).ToNullString().Replace("_", "."));

            if (this.Page.IsValid)
            {
                string text3 = Globals.StripAllTags(this.txtBindUserName.Text.Trim());
                if (string.IsNullOrEmpty(text3))
                {
                    this.ShowMessage("用户名不能为空", false, "", 1);
                }
                else
                {
                    MemberInfo memberInfo = MemberProcessor.ValidLogin(text3, this.txtBindPassword.Text);
                    if (memberInfo != null)
                    {
                        if (!string.IsNullOrEmpty(memberInfo.UnionId) && text2.ToLower() == "hishop.plugins.openid.weixin.weixinservice" && memberInfo.UnionId != text)
                        {
                            this.ShowMessage("该用户已存在信任登录绑定关系,请选择其它帐号", false, "", 1);
                        }
                        else
                        {
                            MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(text2, text);
                            if (memberByOpenId != null && memberByOpenId.UserId != memberInfo.UserId)
                            {
                                this.ShowMessage("该用户已存在信任登录绑定关系,请选择其它帐号", false, "", 1);
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(memberInfo.NickName))
                                {
                                    memberInfo.NickName = this.hidNickName.Value;
                                    MemberProcessor.UpdateMember(memberInfo);
                                }
                                Users.SetCurrentUser(memberInfo.UserId, 0, true, true);
                                HiContext.Current.User = memberInfo;
                                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                                if (cookieShoppingCart != null)
                                {
                                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                                    ShoppingCartProcessor.ClearCookieShoppingCart();
                                }
                                if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text))
                                {
                                    if (text2.ToLower() == "hishop.plugins.openid.weixin.weixinservice" && MemberProcessor.GetMemberByUnionId(text) == null)
                                    {
                                        memberInfo.UnionId = text;
                                        MemberProcessor.UpdateMember(memberInfo);
                                    }
                                    MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo();
                                    memberOpenIdInfo.UserId     = memberInfo.UserId;
                                    memberOpenIdInfo.OpenIdType = text2;
                                    memberOpenIdInfo.OpenId     = text;
                                    if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo.OpenIdType, memberOpenIdInfo.OpenId) == null)
                                    {
                                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo);
                                    }
                                }
                                this.SetLoginState(memberInfo, 0);
                            }
                        }
                    }
                    else
                    {
                        this.ShowMessage("用户名或密码不正确", false, "", 1);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void Login()
        {
            string userid    = Request["userid"];
            string userdata  = Request["userdata"];
            string timestamp = Request["timestamp"];
            string source    = Request["source"];

            if (string.IsNullOrWhiteSpace(userid) ||
                string.IsNullOrWhiteSpace(userdata) ||
                string.IsNullOrWhiteSpace(timestamp) ||
                string.IsNullOrWhiteSpace(source))
            {
                Response.Write("fail,缺少必要参数");
                Response.End();
            }

            string key = ConfigurationManager.AppSettings["Key_CCB"];
            string iv  = ConfigurationManager.AppSettings["IV_CCB"];

            string dataKey     = Cryptographer.DESDecrypt(userdata, key, iv);
            string deUserId    = Cryptographer.DESDecrypt(userid, dataKey, iv);
            string deTimestamp = Cryptographer.DESDecrypt(timestamp, dataKey, iv);

            if (string.IsNullOrWhiteSpace(dataKey) ||
                string.IsNullOrWhiteSpace(deUserId) ||
                string.IsNullOrWhiteSpace(deTimestamp))
            {
                Response.Write("fail,请求参数无效");
                Response.End();
            }

            DateTime time = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(new TimeSpan(long.Parse(deTimestamp + "0000000")));
            TimeSpan span = DateTime.Now - time;

            if (span.TotalSeconds > 60)
            {
                Response.Write("fail,请求已过期");
                Response.End();
            }

            Member member = Users.GetUserByCcbOpenId(deUserId) as Member;

            if (member == null)
            {
                // fail,返回原因
                Response.Write("fail,用户不存在");
                Response.End();
            }

            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }

            // 登录成功跳转到海美生活用户中心
            Response.Redirect("/User/UserDefault.aspx");
        }
Ejemplo n.º 9
0
        protected override void AttachChildControls()
        {
            PageTitle.AddSiteNameTitle("会员中心");
            Member member = HiContext.Current.User as Member;

            if (member == null)
            {
                this.Page.Response.Redirect("/Vshop/Login.aspx");
            }
            this.litUserLink       = (System.Web.UI.WebControls.Literal) this.FindControl("litUserLink");
            this.litUserName       = (System.Web.UI.WebControls.Literal) this.FindControl("litUserName");
            this.litPaymentBalance = (System.Web.UI.WebControls.Literal) this.FindControl("litPaymentBalance");
            this.litExpenditure    = (System.Web.UI.WebControls.Literal) this.FindControl("litExpenditure");
            this.litExpenditure.SetWhenIsNotNull(member.Expenditure.ToString("F2"));
            this.litPaymentBalance.SetWhenIsNotNull(member.Balance.ToString("F2"));
            this.litPoints         = (System.Web.UI.WebControls.Literal) this.FindControl("litPoints");
            this.referralLink      = (System.Web.UI.WebControls.HyperLink) this.FindControl("referralLink");
            this.bindAccountLink   = (System.Web.UI.WebControls.HyperLink) this.FindControl("bindAccountLink");
            this.litAllOrderCount  = (System.Web.UI.WebControls.Literal) this.FindControl("litAllOrderCount");
            this.litRefundCount    = (System.Web.UI.WebControls.Literal) this.FindControl("litRefundCount");
            this.litReturnCount    = (System.Web.UI.WebControls.Literal) this.FindControl("litReturnCount");
            this.litReplaceCount   = (System.Web.UI.WebControls.Literal) this.FindControl("litReplaceCount");
            this.switchAccountLink = (System.Web.UI.WebControls.HyperLink) this.FindControl("switchAccountLink");
            this.litCoupons        = (System.Web.UI.WebControls.Literal) this.FindControl("litCoupons");
            this.litVoucher        = (System.Web.UI.WebControls.Literal) this.FindControl("litVoucher");
            this.litBindPhone      = (System.Web.UI.HtmlControls.HtmlAnchor) this.FindControl("litBindPhone");
            Regex regMobile = new Regex("^(13|14|15|17|18)\\d{9}$");

            if (!regMobile.IsMatch(member.Username))
            {
                this.litBindPhone.Visible = true;
            }
            else
            {
                this.litBindPhone.Visible = false;
            }
            if (this.litPoints != null)
            {
                this.litPoints.SetWhenIsNotNull(member.Points.ToString("F2"));
            }
            this.litMemberGrade = (System.Web.UI.WebControls.Literal) this.FindControl("litMemberGrade");
            MemberGradeInfo memberGrade = MemberProcessor.GetMemberGrade(member.GradeId);

            if (memberGrade != null)
            {
                this.litMemberGrade.SetWhenIsNotNull(memberGrade.Name);
            }
            this.litUserName.Text       = (string.IsNullOrEmpty(member.RealName) ? member.Username : member.RealName);
            this.litWaitForRecieveCount = (System.Web.UI.WebControls.Literal) this.FindControl("litWaitForRecieveCount");
            this.litWaitForPayCount     = (System.Web.UI.WebControls.Literal) this.FindControl("litWaitForPayCount");
            OrderQuery orderQuery = new OrderQuery();

            orderQuery.Status = OrderStatus.WaitBuyerPay;
            int userOrderCount = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery);
            //
            HttpCookie httpCookieMember = new HttpCookie("wait");

            httpCookieMember.Value   = userOrderCount.ToString();
            httpCookieMember.Expires = System.DateTime.Now.AddYears(1);
            HttpContext.Current.Response.Cookies.Add(httpCookieMember);

            #region 处理cookie中的购物车和收藏信息
            Member curMember = HiContext.Current.User as Member;
            if (curMember != null && !curMember.IsAnonymous)
            {
                //修改TopRegionId
                if (curMember.TopRegionId == 0)
                {
                    long ip = 0;
                    try
                    {
                        ip = Globals.IpToInt(Globals.IPAddress);
                    }
                    catch
                    {
                    }
                    if (ip != 0)
                    {
                        string provinceName = TradeHelper.GetProvinceName(ip);
                        int    ProvinceId   = 0;
                        if (!string.IsNullOrEmpty(provinceName))
                        {
                            provinceName = provinceName.Replace("市", "");
                            ProvinceId   = RegionHelper.GetProvinceId(provinceName);
                            ErrorLog.Write(string.Format("更新会员的ProvinceId:{0}", ProvinceId));
                            if (ProvinceId != 0)
                            {
                                UserHelper.UpdateUserTopRegionId(curMember.UserId, ProvinceId);
                            }
                        }
                    }
                }
                //
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }

                System.Web.HttpCookie cookieFavorite = HiContext.Current.Context.Request.Cookies["Hid_Ecshop_Favorite_Data_New"];
                if (cookieFavorite != null && !string.IsNullOrEmpty(cookieFavorite.Value))
                {
                    string[] favoriteProductIds = cookieFavorite.Value.Split('|');
                    int      productId          = 0;
                    foreach (string fav in favoriteProductIds)
                    {
                        try
                        {
                            productId = int.Parse(fav);
                            int favoriteId;
                            ProductBrowser.AddProductToFavorite(productId, curMember.UserId, out favoriteId);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    cookieFavorite.Expires = DateTime.Now.AddDays(-1);
                    HttpContext.Current.Response.Cookies.Add(cookieFavorite);
                }
            }
            #endregion

            //购物车商品数量
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();
            string           quantity     = "0";
            if (shoppingCart != null)
            {
                quantity = shoppingCart.GetQuantity().ToString();
            }
            HttpCookie httpCookieShoppingCart = new HttpCookie("cn");
            httpCookieShoppingCart.Value   = quantity;
            httpCookieShoppingCart.Expires = System.DateTime.Now.AddYears(1);
            HttpContext.Current.Response.Cookies.Add(httpCookieShoppingCart);

            this.litWaitForPayCount.SetWhenIsNotNull(userOrderCount.ToString());
            orderQuery.Status = OrderStatus.SellerAlreadySent;
            userOrderCount    = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery);
            this.litWaitForRecieveCount.SetWhenIsNotNull(userOrderCount.ToString());
            //
            orderQuery.Status = OrderStatus.All;
            userOrderCount    = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery);
            this.litAllOrderCount.SetWhenIsNotNull(userOrderCount.ToString());

            userOrderCount = MemberProcessor.GetRefundCount(HiContext.Current.User.UserId);
            this.litRefundCount.SetWhenIsNotNull(userOrderCount.ToString());
            userOrderCount = MemberProcessor.GetReturnCount(HiContext.Current.User.UserId);
            this.litReturnCount.SetWhenIsNotNull(userOrderCount.ToString());
            userOrderCount = MemberProcessor.GetReplaceCount(HiContext.Current.User.UserId);
            this.litReplaceCount.SetWhenIsNotNull(userOrderCount.ToString());

            int UserNotReadCoupons = MemberProcessor.GetUserNotReadCoupons(HiContext.Current.User.UserId);
            this.litCoupons.SetWhenIsNotNull(UserNotReadCoupons.ToString());

            int UserNotReadlitVoucher = MemberProcessor.GetUserNotReadVoucher(HiContext.Current.User.UserId);
            if (this.litVoucher != null)
            {
                this.litVoucher.SetWhenIsNotNull(UserNotReadlitVoucher.ToString());
            }

            if (this.litUserLink != null)
            {
                System.Uri url  = System.Web.HttpContext.Current.Request.Url;
                string     text = (url.Port == 80) ? string.Empty : (":" + url.Port.ToString(System.Globalization.CultureInfo.InvariantCulture));
                this.litUserLink.Text = string.Concat(new object[]
                {
                    string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}://{1}{2}", new object[]
                    {
                        url.Scheme,
                        url.Host,
                        text
                    }),
                    Globals.ApplicationPath,
                    "/VShop/?ReferralUserId=",
                    HiContext.Current.User.UserId
                });
            }
            if (this.referralLink != null)
            {
                this.referralLink.CssClass = "list-group-item";
                if (member.ReferralStatus == 0 || member.ReferralStatus == 1 || member.ReferralStatus == 3)
                {
                    this.referralLink.Text = "申请成为推广员";
                    if (member.ReferralStatus == 1 || member.ReferralStatus == 3)
                    {
                        this.referralLink.NavigateUrl = "/VShop/ReferralRegisterresults.aspx";
                    }
                    else
                    {
                        this.referralLink.NavigateUrl = "/VShop/ReferralRegisterAgreement.aspx";
                    }
                }
                if (member.ReferralStatus == 2)
                {
                    this.referralLink.Text        = "推广员";
                    this.referralLink.NavigateUrl = "/VShop/Referral.aspx";
                }
            }

            if (bindAccountLink != null)
            {
                this.bindAccountLink.CssClass    = "list-group-item";
                this.bindAccountLink.Text        = "绑定PC端会员帐号";
                this.bindAccountLink.NavigateUrl = "/VShop/BindPCAccount.aspx";
            }

            int    totalCount = 0;
            string opernId    = member.OpenId;
            if (!string.IsNullOrEmpty(opernId))
            {
                totalCount = UserHelper.GetToalCountByOpenId(opernId);
            }

            if (switchAccountLink != null && totalCount >= 2)
            {
                this.switchAccountLink.CssClass    = "list-group-item";
                this.switchAccountLink.Text        = "切换帐号";
                this.switchAccountLink.NavigateUrl = "/VShop/SwitchAccount.aspx";
            }
        }
Ejemplo n.º 10
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            bool flag = false;

            if (this.hidToken != null)
            {
                this.hidToken.Value = Globals.StripAllTags(this.parameters["token"]);
            }
            if (this.hidUserId != null)
            {
                this.hidUserId.Value = Globals.StripAllTags(this.parameters["user_id"]);
            }
            if (this.hidEmail != null)
            {
                this.hidEmail.Value = Globals.StripAllTags(this.parameters["email"]);
            }
            string text = "";

            switch (this.openIdType.ToLower())
            {
            case "hishop.plugins.openid.alipay.alipayservice":
                text = (string.IsNullOrEmpty(this.parameters["real_name"]) ? string.Empty : this.parameters["real_name"].ToNullString().Trim());
                break;

            case "hishop.plugins.openid.qq.qqservice":
            {
                HttpCookie httpCookie3 = HttpContext.Current.Request.Cookies["NickName"];
                if (httpCookie3 != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie3.Value).Trim();
                }
                break;
            }

            case "hishop.plugins.openid.taobao.taobaoservice":
            {
                HttpCookie httpCookie4 = HttpContext.Current.Request.Cookies["NickName"];
                if (httpCookie4 != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie4.Value).Trim();
                }
                break;
            }

            case "hishop.plugins.openid.sina.sinaservice":
            {
                HttpCookie httpCookie2 = HttpContext.Current.Request.Cookies["SinaNickName"];
                if (httpCookie2 != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie2.Value).Trim();
                }
                break;
            }

            case "hishop.plugins.openid.weixin.weixinservice":
            {
                HttpCookie httpCookie = HttpContext.Current.Request.Cookies["NickName"];
                if (text != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie.Value).Trim();
                }
                break;
            }

            default:
                this.Page.Response.Redirect("/", true);
                break;
            }
            this.hidRealName.Value = text;
            this.labNickName.Text  = text;
            this.labNickName1.Text = text;
            this.labNickName2.Text = text;
            string text2 = this.Page.Request.QueryString["headimage"].ToNullString();

            if (string.IsNullOrEmpty(text2))
            {
                text2 = "/Templates/common/images/headerimg.png";
            }
            this.userPicture.Src = text2;
            this.parameters.Add("CurrentOpenId", e.OpenId);
            HiContext current = HiContext.Current;

            this.openId = e.OpenId;
            if (!string.IsNullOrEmpty(this.openId))
            {
                HttpCookie httpCookie5 = new HttpCookie("openId");
                httpCookie5.HttpOnly = true;
                httpCookie5.Value    = this.openId;
                httpCookie5.Expires  = DateTime.MaxValue;
                HttpContext.Current.Response.Cookies.Add(httpCookie5);
            }
            MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(this.openIdType, this.openId);

            if (memberByOpenId != null)
            {
                Users.SetCurrentUser(memberByOpenId.UserId, 1, true, false);
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                current.User = memberByOpenId;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    HttpCookie httpCookie6 = new HttpCookie("Token_" + HiContext.Current.UserId.ToString());
                    httpCookie6.HttpOnly = true;
                    httpCookie6.Expires  = DateTime.Now.AddMinutes(30.0);
                    httpCookie6.Value    = Globals.StripAllTags(this.parameters["token"]);
                    HttpContext.Current.Response.Cookies.Add(httpCookie6);
                }
            }
            else
            {
                this.AuthMsg = "Auth_Sucess";
            }
        }
Ejemplo n.º 11
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            this.parameters.Add("CurrentOpenId", e.OpenId);
            HiContext current            = HiContext.Current;
            string    usernameWithOpenId = UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType);

            if (!string.IsNullOrEmpty(usernameWithOpenId))
            {
                Member member = Users.GetUser(0, usernameWithOpenId, false, true) as Member;
                if (member == null)
                {
                    base.Response.Write("登录失败,信任登录只能用于会员登录。");
                    return;
                }
                if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
                {
                    base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                    return;
                }
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                IUserCookie           userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                HiContext.Current.User = member;
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                current.User = member;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                    httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    httpCookie.Value   = this.parameters["token"];
                    System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
            }
            else
            {
                string a;
                if ((a = this.openIdType.ToLower()) != null)
                {
                    if (a == "Ecdev.plugins.openid.alipay.alipayservice")
                    {
                        this.SkipAlipayOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.qq.qqservice")
                    {
                        this.SkipQQOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.taobao.taobaoservice")
                    {
                        this.SkipTaoBaoOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.sina.sinaservice")
                    {
                        this.SkipSinaOpenId();
                        goto IL_1EF;
                    }
                }
                this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }
IL_1EF:
            string a2 = this.parameters["HITO"];

            if (a2 == "1")
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder"));
                return;
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Ejemplo n.º 12
0
        protected void SkipSinaOpenId()
        {
            Member member = new Member(UserRole.Member);

            if (HiContext.Current.ReferralUserId > 0)
            {
                member.ReferralUserId = new int?(HiContext.Current.ReferralUserId);
            }
            member.GradeId  = MemberProcessor.GetDefaultMemberGrade();
            member.Username = this.parameters["CurrentOpenId"];
            if (string.IsNullOrEmpty(member.Username))
            {
                member.Username = "******" + this.GenerateUsername(8);
            }
            member.Email = this.GenerateUsername() + "@localhost.com";
            string text = this.GeneratePassword();

            member.Password            = text;
            member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword       = text;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
            {
                member.Username = "******" + this.GenerateUsername(9);
                member.Password = (member.TradePassword = text);
                if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                {
                    member.Username = this.GenerateUsername();
                    member.Email    = this.GenerateUsername() + "@localhost.com";
                    member.Password = (member.TradePassword = text);
                    if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]);
            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                httpCookie.Value   = this.parameters["token"];
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Ejemplo n.º 13
0
        protected int SkipWeixinOpenId(string openId, string weixinNickName, string unionId, string headimgurl, string ReferralUserId, bool isSubscribe)
        {
            int        num        = 1;
            MemberInfo memberInfo = MemberProcessor.GetMemberByOpenId("hishop.plugins.openid.weixin", openId);
            bool       flag       = false;

            if (memberInfo == null)
            {
                memberInfo = MemberProcessor.GetMemberByUnionId(unionId);
                flag       = true;
            }
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings();
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
            bool             flag2 = false;

            if (memberInfo != null)
            {
                num = 2;
                if (memberInfo.IsSubscribe != isSubscribe)
                {
                    memberInfo.IsSubscribe = isSubscribe;
                    flag2 = true;
                }
                bool flag3 = MemberProcessor.IsBindedWeixin(memberInfo.UserId, "hishop.plugins.openid.weixin");
                memberInfo.Picture = headimgurl;
                if (!string.IsNullOrEmpty(unionId) && memberInfo.UnionId != unionId && !flag)
                {
                    memberInfo.UnionId = unionId;
                    flag2 = true;
                }
                if (flag)
                {
                    if (!flag3)
                    {
                        MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo();
                        memberOpenIdInfo.UserId     = memberInfo.UserId;
                        memberOpenIdInfo.OpenIdType = "hishop.plugins.openid.weixin";
                        memberOpenIdInfo.OpenId     = openId;
                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo);
                        memberInfo.IsQuickLogin = true;
                        flag2 = true;
                    }
                    else
                    {
                        MemberOpenIdInfo memberOpenIdInfo2 = new MemberOpenIdInfo();
                        memberOpenIdInfo2.UserId     = memberInfo.UserId;
                        memberOpenIdInfo2.OpenIdType = "hishop.plugins.openid.weixin";
                        memberOpenIdInfo2.OpenId     = openId;
                        MemberProcessor.UpdateMemberOpenId(memberOpenIdInfo2);
                    }
                }
                if (flag2)
                {
                    MemberProcessor.UpdateMember(memberInfo);
                }
                Users.SetCurrentUser(memberInfo.UserId, 30, true, false);
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    HttpCookie httpCookie = new HttpCookie("openId");
                    httpCookie.HttpOnly = true;
                    httpCookie.Value    = openId;
                    httpCookie.Expires  = DateTime.MaxValue;
                    HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
                lock (this.lockCopyRedEnvelope)
                {
                    this.CopyRedEnvelope(openId, memberInfo);
                }
                return(num);
            }
            memberInfo             = new MemberInfo();
            memberInfo.Picture     = headimgurl;
            memberInfo.IsSubscribe = isSubscribe;
            int num2 = 0;

            if (ReferralUserId.ToInt(0) > 0)
            {
                memberInfo.ReferralUserId = ReferralUserId.ToInt(0);
            }
            MemberWXReferralInfo wXReferral = VShopHelper.GetWXReferral(openId.Trim());

            if (wXReferral != null)
            {
                VShopHelper.DeleteWXReferral(openId.Trim());
            }
            memberInfo.GradeId = MemberProcessor.GetDefaultMemberGrade();
            if (!string.IsNullOrEmpty(weixinNickName))
            {
                MemberInfo memberInfo2 = memberInfo;
                MemberInfo memberInfo3 = memberInfo;
                string     text3       = memberInfo2.UserName = (memberInfo3.NickName = HttpUtility.UrlDecode(weixinNickName));
            }
            if (string.IsNullOrEmpty(memberInfo.UserName))
            {
                memberInfo.UserName = "******" + this.GenerateUsername(8);
            }
            if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
            {
                memberInfo.UserName = "******" + this.GenerateUsername(9);
                if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                {
                    memberInfo.UserName = this.GenerateUsername();
                    if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                    {
                        num = -1;
                    }
                }
            }
            if (num == 1)
            {
                string text4 = this.GeneratePassword();
                string text5 = "Open";
                string text6 = text4;
                text4 = (memberInfo.Password = Users.EncodePassword(text4, text5));
                memberInfo.PasswordSalt     = text5;
                memberInfo.RegisteredSource = 3;
                memberInfo.CreateDate       = DateTime.Now;
                memberInfo.IsQuickLogin     = true;
                memberInfo.IsLogined        = true;
                memberInfo.UnionId          = unionId;
                num2 = MemberProcessor.CreateMember(memberInfo);
                if (num2 <= 0)
                {
                    num = -1;
                }
            }
            if (num == 1)
            {
                memberInfo.UserId   = num2;
                memberInfo.UserName = MemberHelper.GetUserName(memberInfo.UserId);
                MemberHelper.Update(memberInfo, true);
                Users.SetCurrentUser(memberInfo.UserId, 30, false, false);
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    MemberOpenIdInfo memberOpenIdInfo3 = new MemberOpenIdInfo();
                    memberOpenIdInfo3.UserId     = memberInfo.UserId;
                    memberOpenIdInfo3.OpenIdType = "hishop.plugins.openid.weixin";
                    memberOpenIdInfo3.OpenId     = openId;
                    if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo3.OpenIdType, openId) == null)
                    {
                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo3);
                    }
                    if (!string.IsNullOrEmpty(openId))
                    {
                        HttpCookie httpCookie2 = new HttpCookie("openId");
                        httpCookie2.HttpOnly = true;
                        httpCookie2.Value    = openId;
                        httpCookie2.Expires  = DateTime.MaxValue;
                        HttpContext.Current.Response.Cookies.Add(httpCookie2);
                    }
                    lock (this.lockCopyRedEnvelope)
                    {
                        this.CopyRedEnvelope(openId, memberInfo);
                    }
                }
            }
            return(num);
        }
Ejemplo n.º 14
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            this.parameters.Add("CurrentOpenId", e.OpenId);
            HiContext  current        = HiContext.Current;
            MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(this.openIdType, e.OpenId);

            if (memberByOpenId != null)
            {
                Users.SetCurrentUser(memberByOpenId.UserId, 30, true, false);
                HiContext.Current.User = memberByOpenId;
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    HttpCookie httpCookie = new HttpCookie("Token_" + memberByOpenId.UserId);
                    httpCookie.HttpOnly = true;
                    httpCookie.Expires  = DateTime.Now.AddMinutes(30.0);
                    httpCookie.Value    = this.parameters["token"];
                    HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
            }
            else
            {
                switch (this.openIdType.ToLower())
                {
                case "hishop.plugins.openid.alipay.alipayservice":
                    this.SkipAlipayOpenId();
                    break;

                case "hishop.plugins.openid.qq.qqservice":
                    this.SkipQQOpenId();
                    break;

                case "hishop.plugins.openid.taobao.taobaoservice":
                    this.SkipTaoBaoOpenId();
                    break;

                case "hishop.plugins.openid.sina.sinaservice":
                    this.SkipSinaOpenId();
                    break;

                default:
                    this.Page.Response.Redirect("/");
                    break;
                }
            }
            string a = this.parameters["HITO"];

            if (a == "1")
            {
                this.Page.Response.Redirect("/SubmmitOrder");
            }
            else
            {
                this.Page.Response.Redirect("/");
            }
        }
Ejemplo n.º 15
0
        protected override void AttachChildControls()
        {
            this.litProductTotalPrice = (System.Web.UI.WebControls.Literal) this.FindControl("litProductTotalPrice");
            this.litTotalTax          = (System.Web.UI.WebControls.Literal) this.FindControl("litTotalTax");


            this.listOrders = (EcShop.UI.SaleSystem.Tags.Common_CartSupplierProducts) this.FindControl("common_cartsupplierproducts");

            this.listOrders.ItemDataBound += new EcShop.UI.SaleSystem.Tags.Common_CartSupplierProducts.DataBindEventHandler(this.listOrders_ItemDataBound);

            this.litTotal = (System.Web.UI.WebControls.Literal) this.FindControl("litTotal");

            #region 处理cookie中的购物车和收藏信息
            Member curMember = HiContext.Current.User as Member;
            if (curMember != null && !curMember.IsAnonymous)
            {
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }

                System.Web.HttpCookie cookieFavorite = HiContext.Current.Context.Request.Cookies["Hid_Ecshop_Favorite_Data_New"];
                if (cookieFavorite != null && !string.IsNullOrEmpty(cookieFavorite.Value))
                {
                    string[] favoriteProductIds = cookieFavorite.Value.Split('|');
                    int      productId          = 0;
                    foreach (string fav in favoriteProductIds)
                    {
                        try
                        {
                            productId = int.Parse(fav);
                            int favoriteId;
                            ProductBrowser.AddProductToFavorite(productId, curMember.UserId, out favoriteId);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    cookieFavorite.Expires = DateTime.Now.AddDays(-1);
                    HttpContext.Current.Response.Cookies.Add(cookieFavorite);
                }
            }
            #endregion

            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();
            if (shoppingCart != null)
            {
                //foreach (ShoppingCartItemInfo item in shoppingCart.LineItems)
                //{
                //    item.TaxRate = Math.Round(item.TaxRate * 100, 0);
                //}

                IList <ShoppingCartItemInfo>      list          = shoppingCart.LineItems;
                IQueryable <ShoppingCartItemInfo> queryableList = new EnumerableQuery <ShoppingCartItemInfo>(list);

                var query = from q in queryableList
                            group q by new { id = q.SupplierId }
                into q1
                    select new
                {
                    SupplierId = q1.FirstOrDefault().SupplierId,
                    //Amount = q1.Sum(x => x.SupplierId)
                    SupplierName = q1.FirstOrDefault().SupplierName,
                    SupplierLogo = q1.FirstOrDefault().Logo
                };

                this.listOrders.DataSource = query;
                this.listOrders.DataBind();

                this.litTotal.Text = shoppingCart.GetNewAmount().ToString("F2");

                decimal totaltax = shoppingCart.CalTotalTax();// shoppingCart.CalTotalTax();
                //this.litTotalTax.Text = (totaltax < 50 ? "0.00" : totaltax.ToString("F2"));
                if (totaltax <= 50)
                {
                    this.litTotalTax.Text = string.Format("<span style='text-decoration: line-through;'>{0}</span>", totaltax.ToString("F2"));
                }
                else
                {
                    this.litTotalTax.Text = string.Format("{0}", totaltax.ToString("F2"));
                }
                this.litProductTotalPrice.Text = shoppingCart.GetNewAmount().ToString("F2"); //shoppingCart.GetTotal().ToString("F2");
            }



            HttpCookie httpCookieShoppingCart = new HttpCookie("cn");
            string     quantity = "0";
            if (shoppingCart != null)
            {
                quantity = shoppingCart.GetQuantity().ToString();
            }
            httpCookieShoppingCart.Value   = quantity;
            httpCookieShoppingCart.Expires = System.DateTime.Now.AddYears(1);
            HttpContext.Current.Response.Cookies.Add(httpCookieShoppingCart);


            HttpCookie cookieSkuIds = this.Page.Request.Cookies["UserSession-SkuIds"];
            if (cookieSkuIds != null)
            {
                cookieSkuIds.Expires = DateTime.Now.AddDays(-1);
                cookieSkuIds.Values.Clear();
                HttpContext.Current.Response.AppendCookie(cookieSkuIds);
            }
            PageTitle.AddSiteNameTitle("购物车");
        }