예제 #1
0
 /// <summary>
 ///退出登录
 /// </summary>
 /// <returns></returns>
 public JsonResult <Result <int> > GetProcessLogout(string openId)
 {
     if (!string.IsNullOrEmpty(openId))
     {
         var member = MemberApplication.GetMemberByOpenId(SmallProgServiceProvider, openId);
         if (member == CurrentUser)
         {
             var cacheKey = WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER);
             if (!string.IsNullOrWhiteSpace(cacheKey))
             {
                 //_iMemberService.DeleteMemberOpenId(userid, string.Empty);
                 WebHelper.DeleteCookie(CookieKeysCollection.HIMALL_USER);
                 WebHelper.DeleteCookie(CookieKeysCollection.SELLER_MANAGER);
                 //记录主动退出符号
                 WebHelper.SetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT, "1", DateTime.MaxValue);
                 return(JsonResult <int>());
             }
         }
     }
     return(JsonResult <int>());
 }
예제 #2
0
        /// <summary>
        /// 根据OpenId判断是否有账号,根据OpenId进行登录
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLoginByOpenId(string openId = "")
        {
            //string oauthType = "Himall.Plugin.OAuth.WeiXin";//默认小程序微信端登录
            string unionid    = "";
            var    wxuserinfo = ApiHelper.GetAppletUserInfo(Request);

            if (wxuserinfo != null)
            {
                unionid = wxuserinfo.unionId;
            }
            if (!string.IsNullOrEmpty(openId))
            {
                MemberInfo member = new MemberInfo();
                if (!string.IsNullOrWhiteSpace(unionid))
                {
                    member = MemberApplication.GetMemberByUnionIdAndProvider(SmallProgServiceProvider, unionid) ?? new MemberInfo();
                }

                if (member.Id == 0)
                {
                    member = MemberApplication.GetMemberByOpenId(SmallProgServiceProvider, openId) ?? new MemberInfo();
                }
                if (member.Id > 0)
                {
                    //信任登录并且已绑定
                    string memberId = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER);
                    MemberApplication.AddIntegel(member);//给用户加积分//执行登录后初始化相关操作
                    return(GetMember(member, openId));
                }
                else
                {
                    //信任登录未绑定
                    return(Json(ErrorResult <dynamic>("未绑定商城帐号")));
                }
            }
            return(Json(ErrorResult <dynamic>(string.Empty)));
        }