Exemplo n.º 1
0
        public string Login(string back, int IsLogin = 1)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + ENBackuri(back);
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    string res = PostAPI("oauth2/access_token", sb.ToString());

                    JavaScriptSerializer jss   = new JavaScriptSerializer();
                    Model.Weibo.token    token = jss.Deserialize <Model.Weibo.token>(res);
                    string access_token        = token.access_token;
                    //获取uid
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    res = PostAPI("oauth2/get_token_info", sb.ToString());
                    Model.Weibo.tokeninfo tokeninfo = jss.Deserialize <Model.Weibo.tokeninfo>(res);
                    string uid = tokeninfo.uid;

                    //获取用户资料
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    sb.Append("&uid=" + uid);

                    res = GetAPI("2/users/show.json", sb.ToString());


                    Model.Weibo.userinfo model = jss.Deserialize <Model.Weibo.userinfo>(res);
                    string where = "bind_weibo_id='" + uid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = EX_User.CurrentUser();
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_weibo_id       = uid;
                        CurrentUser.bind_weibo_nickname = model.screen_name;
                        CurrentUser.bind_weibo_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.profile_image_url;//头像 50*50
                        }
                        CurrentUser.DT_id = DT_id;
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user = new Lebi_User();
                            user.bind_weibo_id       = uid;
                            user.bind_weibo_nickname = model.screen_name;
                            user.bind_weibo_token    = access_token;
                            user.Face              = model.profile_image_url;//头像 50*50
                            user.NickName          = model.screen_name;
                            user.UserName          = "******" + uid;
                            user.Password          = EX_User.MD5(uid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.gender == "f" ? "女" : "男";
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            user.DT_id = DT_id;
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_weibo_id       = uid;
                            user.bind_weibo_nickname = model.screen_name;
                            user.bind_weibo_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.profile_image_url;//头像
                            }
                            //user.Sex = model.gender == "f" ? "女" : "男";
                            user.DT_id = DT_id;
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Exemplo n.º 2
0
        public string Login(string back, int IsLogin = 1, int DT_id = 0)
        {
            string        code = RequestTool.RequestString("code");
            string        res  = "";
            StringBuilder sb;

            if (code != "")
            {
                try
                {
                    sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + ENBackuri(back);
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    res = PostAPI("oauth/access_token", sb.ToString());
                    res = res + "&";
                    string access_token      = RegexTool.GetRegValue(res, "access_token=(.*?)&");
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    //获取uid
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    res = GetAPI("me", sb.ToString());
                    Model.Facebook.userinfo model = jss.Deserialize <Model.Facebook.userinfo>(res);
                    string uid = model.id;
                    //return uid;
                    string where = "bind_facebook_id='" + uid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = EX_User.CurrentUser();
                    if (model == null)
                    {
                        model = new Model.Facebook.userinfo();
                    }
                    if (model.picture == null)
                    {
                        model.picture = new Model.Facebook.userinfo.picture_();
                    }
                    if (model.picture.data == null)
                    {
                        model.picture.data     = new Model.Facebook.userinfo.picture_.data_();
                        model.picture.data.url = "";
                    }
                    string username = model.last_name + model.first_name;
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_facebook_id       = uid;
                        CurrentUser.bind_facebook_nickname = username;
                        CurrentUser.bind_facebook_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.picture.data.url;//头像
                        }
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user = new Lebi_User();
                            user.bind_facebook_id       = uid;
                            user.bind_facebook_nickname = username;
                            user.bind_facebook_token    = access_token;
                            user.Face              = model.picture.data.url;
                            user.NickName          = username;
                            user.UserName          = "******" + uid;
                            user.Password          = EX_User.MD5(uid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.gender == "female" ? "女" : "男";
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_facebook_id       = uid;
                            user.bind_facebook_nickname = username;
                            user.bind_facebook_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.picture.data.url;
                            }
                            //user.Sex = model.gender == "female" ? "女" : "男";
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Exemplo n.º 3
0
        public string Login(string back, int IsLogin = 1, int DT_id = 0)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + back;
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    string res = API("oauth2.0/token", sb.ToString());
                    res = res + "&";
                    string access_token = RegexTool.GetRegValue(res, "access_token=(.*?)&");

                    //获取openid
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    res = API("oauth2.0/me", sb.ToString());
                    string openid = RegexTool.GetRegValue(res, "openid\":\"(.*?)\"}");

                    //获取用户资料
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    sb.Append("&oauth_consumer_key=" + appid);
                    sb.Append("&openid=" + openid);
                    res = API("user/get_user_info", sb.ToString());

                    JavaScriptSerializer jss   = new JavaScriptSerializer();
                    Model.QQ.userinfo    model = jss.Deserialize <Model.QQ.userinfo>(res);
                    string where = "bind_qq_id='" + openid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = EX_User.CurrentUser();
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_qq_id       = openid;
                        CurrentUser.bind_qq_nickname = model.nickname;
                        CurrentUser.bind_qq_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.figureurl_qq_1;//头像
                        }
                        CurrentUser.DT_id = DT_id;
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user                   = new Lebi_User();
                            user.bind_qq_id        = openid;
                            user.bind_qq_nickname  = model.nickname;
                            user.bind_qq_token     = access_token;
                            user.Face              = model.figureurl_qq_1;//头像
                            user.UserName          = "******" + openid;
                            user.NickName          = model.nickname;
                            user.Password          = EX_User.MD5(openid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.gender;
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            user.DT_id = DT_id;
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_qq_id       = openid;
                            user.bind_qq_nickname = model.nickname;
                            user.bind_qq_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.figureurl_qq_1;//头像
                            }
                            //user.Sex = model.gender;
                            user.DT_id = DT_id;
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Exemplo n.º 4
0
        public string Login(string back, int IsLogin = 1)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + ENBackuri(back);
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    string res = PostAPI("token", sb.ToString());

                    JavaScriptSerializer jss   = new JavaScriptSerializer();
                    Model.Taobao.token   token = jss.Deserialize <Model.Taobao.token>(res);
                    string access_token        = token.access_token;
                    string uid      = token.taobao_user_id;
                    string username = token.taobao_user_nick;
                    //获取详细个人信息

                    sb = new StringBuilder();
                    sb.Append("&access_token=" + access_token);
                    res = GetAPI("taobao.user.buyer.get", sb.ToString(), false);


                    Model.Taobao.userinfo model = jss.Deserialize <Model.Taobao.userinfo>(res);
                    if (model == null)
                    {
                        model = new Model.Taobao.userinfo();
                    }
                    if (model.user_buyer_get_response == null)
                    {
                        model.user_buyer_get_response = new Model.Taobao.userinfo.user_buyer_get_response_();
                    }
                    if (model.user_buyer_get_response.user == null)
                    {
                        model.user_buyer_get_response.user        = new Model.Taobao.userinfo.user_buyer_get_response_.user_();
                        model.user_buyer_get_response.user.sex    = "m";
                        model.user_buyer_get_response.user.avatar = "";
                    }
                    if (model.user_buyer_get_response.user.location == null)
                    {
                        model.user_buyer_get_response.user.location = new Model.Taobao.userinfo.user_buyer_get_response_.user_.location_();
                    }
                    string where = "bind_taobao_id='" + uid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = EX_User.CurrentUser();
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_taobao_id       = uid;
                        CurrentUser.bind_taobao_nickname = username;
                        CurrentUser.bind_taobao_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.user_buyer_get_response.user.avatar;//头像
                        }
                        CurrentUser.DT_id = DT_id;
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user = new Lebi_User();
                            user.bind_taobao_id       = uid;
                            user.bind_taobao_nickname = username;
                            user.bind_taobao_token    = access_token;
                            user.UserName             = "******" + uid;
                            user.NickName             = username;
                            user.Password             = EX_User.MD5(uid);
                            user.Language             = Language.CurrentLanguage().Code;
                            user.Sex               = model.user_buyer_get_response.user.sex == "f" ? "女" : "男";
                            user.Face              = model.user_buyer_get_response.user.avatar;//头像
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            user.DT_id = DT_id;
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_taobao_id       = uid;
                            user.bind_taobao_nickname = username;
                            user.bind_taobao_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.user_buyer_get_response.user.avatar;//头像
                            }
                            //user.Sex = model.user_buyer_get_response.user.sex == "f" ? "女" : "男";
                            user.DT_id = DT_id;
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Exemplo n.º 5
0
        public string Login(string back, int IsLogin = 1)
        {
            string        code = RequestTool.RequestString("code");
            string        res  = "";
            StringBuilder sb;

            if (code != "")
            {
                sb = new StringBuilder();
                sb.Append("?grant_type=authorization_code");
                sb.Append("&client_id=" + appid);
                sb.Append("&client_secret=" + appkey);
                sb.Append("&code=" + code);
                sb.Append("&redirect_uri=" + reurnurl);
                //res = APIURL("oauth/access_token", sb.ToString());
                res = PostAPI("oauth/access_token", sb.ToString());
                //access_token=
                //CAAGUzrOw7
                //AMBADkwUNj
                //HkI9FwLPHD
                //fUamZCSBH1
                //NbSFsKVVjF
                //D2QfmP0aXT
                //FtMTY8e8d5
                //yse93demVg
                //YwCfEWXApj
                //ZAsGqt3ugg
                //YiHSmFQeN2
                //EOwFindWuw
                //R9QHiTlAwr
                //kmuTmr1Qs4
                //mwtSAZC15m
                //wTpLWvZCaj
                //OkVC1zlTZB
                //B5gjRZBmCm
                //C2j&expires=5183999
                //HttpContext.Current.Response.Redirect(res);
                res = res + "&";
                string access_token = RegexTool.GetRegValue(res, "access_token=(.*?)&");

                JavaScriptSerializer jss = new JavaScriptSerializer();
                //获取uid
                sb = new StringBuilder();
                sb.Append("?access_token=" + access_token);
                res = GetAPI("me", sb.ToString());

                Model.Facebook.userinfo model = jss.Deserialize <Model.Facebook.userinfo>(res);
                string uid = model.id;
                //return uid;
                Shop.Model.Lebi_User user = B_Lebi_User.GetModel("bind_facebook_id='" + uid + "'");

                if (model == null)
                {
                    model = new Model.Facebook.userinfo();
                }
                if (model.picture == null)
                {
                    model.picture = new Model.Facebook.userinfo.picture_();
                }
                if (model.picture.data == null)
                {
                    model.picture.data     = new Model.Facebook.userinfo.picture_.data_();
                    model.picture.data.url = "";
                }
                string username = model.last_name + model.first_name;
                if (user == null)
                {
                    Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                    if (defaultlevel == null)
                    {
                        defaultlevel = new Lebi_UserLevel();
                    }
                    if (defaultlevel.RegisterType == 0) //关闭注册
                    {
                        return("会员注册已关闭");
                    }
                    user = new Lebi_User();
                    user.bind_facebook_id       = uid;
                    user.bind_facebook_nickname = username;
                    user.bind_facebook_token    = access_token;
                    user.Face              = model.picture.data.url;
                    user.UserName          = username;
                    user.Password          = EX_User.MD5(uid);
                    user.Language          = Language.CurrentLanguage().Code;
                    user.Sex               = model.gender == "female" ? "女" : "男";
                    user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                    user.IsPlatformAccount = 1;
                    if (CurrentSite != null)
                    {
                        user.Site_id = CurrentSite.id;
                    }
                    user.DT_id = DT_id;
                    B_Lebi_User.Add(user);
                    user.id = B_Lebi_User.GetMaxId();
                    EX_User.LoginOK(user);
                }
                else
                {
                    user.bind_facebook_id       = uid;
                    user.bind_facebook_nickname = username;
                    user.bind_facebook_token    = access_token;
                    user.Face     = model.picture.data.url;
                    user.Sex      = model.gender == "female" ? "女" : "男";
                    user.UserName = username;
                    user.DT_id    = DT_id;
                    B_Lebi_User.Update(user);
                    EX_User.LoginOK(user);
                }
                return("OK");
            }
            return("授权失败");
        }
Exemplo n.º 6
0
        /// <summary>
        /// 微信登录
        /// https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
        /// </summary>
        /// <param name="back"></param>
        /// <returns></returns>
        public string Login(string back, int IsLogin = 1)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    string uri    = reurnurl + "?backurl=" + ENBackuri(back);
                    int    userid = 0;
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    string res = Post("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + appkey + "&code=" + code + "&grant_type=authorization_code");
                    JavaScriptSerializer jss = new JavaScriptSerializer();

                    Model.weixin.tokeninfo tokeninfo = jss.Deserialize <Model.weixin.tokeninfo>(res);
                    string uid = tokeninfo.openid;
                    //SystemLog.Add(uid);
                    //获取用户资料
                    //https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
                    res = Post("https://api.weixin.qq.com/sns/userinfo?access_token=" + tokeninfo.access_token + "&openid=" + uid + "&lang=zh_CN");

                    Model.weixin.userinfo model = jss.Deserialize <Model.weixin.userinfo>(res);
                    string where = "bind_weixin_id='" + uid + "' and bind_weixin_id!=''";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = null;
                    string qrcodeid_ = RegexTool.GetRegValue((back + "&"), @"qrcodeid=(\d*)&");
                    int    qrid      = 0;
                    int.TryParse(qrcodeid_, out qrid);
                    if (qrid > 0)
                    {
                        //扫描二维码授权绑定当前账号
                        Lebi_weixin_qrcode qcode = B_Lebi_weixin_qrcode.GetModel(qrid);
                        CurrentUser = B_Lebi_User.GetModel(qcode.User_id);
                        if (IsLogin == 0)
                        {
                            if (user != null && CurrentUser != null)
                            {
                                return("已绑定其它帐号");
                            }
                        }
                    }

                    if (user == null)
                    {
                        Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                        if (defaultlevel == null)
                        {
                            defaultlevel = new Lebi_UserLevel();
                        }
                        if (defaultlevel.RegisterType == 0) //关闭注册
                        {
                            return("会员注册已关闭");
                        }
                        if (CurrentUser == null)
                        {
                            user = new Lebi_User();
                            user.bind_weixin_id       = uid;
                            user.bind_weixin_nickname = model.nickname;
                            user.bind_weixin_token    = tokeninfo.access_token;
                            try
                            {
                                user.Face = DownLoadImage(model.headimgurl);
                            }
                            catch
                            {
                                user.Face = model.headimgurl;
                            }
                            user.NickName          = model.nickname;
                            user.UserName          = "******" + uid;
                            user.Password          = EX_User.MD5(uid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.sex == "2" ? "女" : "男";
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            //B_Lebi_User.Add(user);
                            //user.id = B_Lebi_User.GetMaxId();
                            //userid = user.id;
                            user.DT_id = DT_id;
                            EX_User.UserReg(user);
                        }
                        else
                        {
                            CurrentUser.bind_weixin_id       = uid;
                            CurrentUser.bind_weixin_nickname = model.nickname;
                            CurrentUser.bind_weixin_token    = tokeninfo.access_token;

                            try
                            {
                                CurrentUser.Face = DownLoadImage(model.headimgurl);
                            }
                            catch
                            {
                                CurrentUser.Face = model.headimgurl;
                            }
                            //CurrentUser.Face = model.headimgurl;//头像 50*50

                            if (CurrentUser.NickName == "")
                            {
                                CurrentUser.NickName = model.nickname;
                            }
                            CurrentUser.DT_id = DT_id;
                            //B_Lebi_User.Update(CurrentUser);
                            EX_User.LoginOK(CurrentUser, 0);
                            userid = CurrentUser.id;
                        }
                    }
                    else
                    {
                        user.bind_weixin_id       = uid;
                        user.bind_weixin_nickname = model.nickname;
                        user.bind_weixin_token    = tokeninfo.access_token;;

                        try
                        {
                            user.Face = DownLoadImage(model.headimgurl);
                        }
                        catch (Exception ex)
                        {
                            user.Face = "";
                            SystemLog.Add(ex.Message);
                        }

                        if (user.NickName == "")
                        {
                            user.NickName = model.nickname;
                        }
                        user.DT_id = DT_id;
                        //user.Sex = model.gender == "f" ? "女" : "男";
                        //B_Lebi_User.Update(user);
                        EX_User.LoginOK(user, 0);
                        userid = user.id;
                    }


                    if (qrid > 0)
                    {
                        //扫描二维码登录
                        Lebi_weixin_qrcode qcode = B_Lebi_weixin_qrcode.GetModel(qrid);
                        qcode.User_id = userid;
                        B_Lebi_weixin_qrcode.Update(qcode);
                        //Log.Add(back);
                    }
                    return("OK");
                }
                catch (Exception ex)
                {
                    SystemLog.Add(ex.Message);
                    return("授权失败" + ex.Message);
                }
            }
            return("授权失败");
        }