| | |
| | | /// <returns></returns>
|
| | | private bool GetBingData()
|
| | | {
|
| | | this.dicBindData = new Dictionary<string, OtherPartyResult>();
|
| | | //☆マーク☆ 绑定微信
|
| | | //this.dicBindData = new Dictionary<string, OtherPartyResult>();
|
| | |
|
| | | var result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetUserAuthItem", false, "");
|
| | | if (string.IsNullOrEmpty(result) == true)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var data = Newtonsoft.Json.JsonConvert.DeserializeObject<List<OtherPartyResult>>(result);
|
| | | foreach (var info in data)
|
| | | {
|
| | | this.dicBindData[info.Platform] = info;
|
| | | }
|
| | | //var result = HdlUserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetUserAuthItem", false, "");
|
| | | //if (string.IsNullOrEmpty(result) == true)
|
| | | //{
|
| | | // return false;
|
| | | //}
|
| | | //var data = Newtonsoft.Json.JsonConvert.DeserializeObject<List<OtherPartyResult>>(result);
|
| | | //foreach (var info in data)
|
| | | //{
|
| | | // this.dicBindData[info.Platform] = info;
|
| | | //}
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
|
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<AuthUserRes>(authStr);
|
| | | //绑定微信
|
| | | this.BindWechat(authRes.access_token, authRes.refresh_token, authRes.openid);
|
| | | };
|
| | |
| | | /// <param name="infoData"></param>
|
| | | private void BindWechat(string accessToken, string refreshToken, string openID)
|
| | | {
|
| | | //获取微信昵称
|
| | | var strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken;
|
| | | strUrl += "&openid=" + openID;
|
| | | var byteData = Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET");
|
| | | if (byteData == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var receipData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<NicknameInfo>(receipData);
|
| | | //☆マーク☆ 绑定微信
|
| | | ////获取微信昵称
|
| | | //var strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken;
|
| | | //strUrl += "&openid=" + openID;
|
| | | //var byteData = Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET");
|
| | | //if (byteData == null)
|
| | | //{
|
| | | // return;
|
| | | //}
|
| | | //var receipData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | //var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<NicknameInfo>(receipData);
|
| | |
|
| | | //先上传微信资料
|
| | | var pra = new { AccessToken = accessToken, RefreshToken = refreshToken, OpenID = openID, UserName = nickData.nickname };
|
| | | var listNotShow = new List<string>() { "UserNoBindAccount" };
|
| | | var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/InsertOrUpdateAuthUser", false, pra, listNotShow);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | ////先上传微信资料
|
| | | //var pra = new { AccessToken = accessToken, RefreshToken = refreshToken, OpenID = openID, UserName = nickData.nickname };
|
| | | //var listNotShow = new List<string>() { "UserNoBindAccount" };
|
| | | //var result = HdlUserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/InsertOrUpdateAuthUser", false, pra, listNotShow);
|
| | | //if (result == false)
|
| | | //{
|
| | | // return;
|
| | | //}
|
| | |
|
| | | //再执行绑定
|
| | | var pra2 = new { AccountGuid = Common.Config.Instance.Guid, OpenID = openID };
|
| | | result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/BindAuthUserToAccount", false, pra2);
|
| | | if (result == true)
|
| | | {
|
| | | //绑定成功!下次你可以用微信{0}账号快速登录啦
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uBindWebchatSuccessMsg);
|
| | | msg = msg.Replace("{0}", "\r\n");
|
| | | this.ShowMassage(ShowMsgType.Normal, msg, null, Language.StringByID(R.MyInternationalizationString.uWell));
|
| | | //重新刷新界面
|
| | | this.InitMiddleData();
|
| | | }
|
| | | ////再执行绑定
|
| | | //var pra2 = new { AccountGuid = Common.Config.Instance.Guid, OpenID = openID };
|
| | | //result = HdlUserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/BindAuthUserToAccount", false, pra2);
|
| | | //if (result == true)
|
| | | //{
|
| | | // //绑定成功!下次你可以用微信{0}账号快速登录啦
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uBindWebchatSuccessMsg);
|
| | | // msg = msg.Replace("{0}", "\r\n");
|
| | | // this.ShowMassage(ShowMsgType.Normal, msg, null, Language.StringByID(R.MyInternationalizationString.uWell));
|
| | | // //重新刷新界面
|
| | | // this.InitMiddleData();
|
| | | //}
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="infoData"></param>
|
| | | private void UnBindOtherParty(OtherPartyResult infoData)
|
| | | {
|
| | | var pra = new { DistributedMark = infoData.Id };
|
| | | var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UnBindUserAuth", false, pra);
|
| | | if (result == true)
|
| | | {
|
| | | //重新刷新界面
|
| | | this.InitMiddleData();
|
| | | }
|
| | | //☆マーク☆ 绑定微信
|
| | | //var pra = new { DistributedMark = infoData.Id };
|
| | | //var result = HdlUserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UnBindUserAuth", false, pra);
|
| | | //if (result == true)
|
| | | //{
|
| | | // //重新刷新界面
|
| | | // this.InitMiddleData();
|
| | | //}
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | public string UserName = string.Empty;
|
| | | }
|
| | |
|
| | | private class AuthUserRes
|
| | | {
|
| | | ///<summary>
|
| | | /// 第三方token
|
| | | /// </summary>
|
| | | public string access_token;
|
| | | /// <summary>
|
| | | /// 刷新token
|
| | | /// </summary>
|
| | | public string refresh_token;
|
| | | /// <summary>
|
| | | ///第三方用户唯一标识
|
| | | /// </summary>
|
| | | public string openid;
|
| | |
|
| | | public int expires_in;
|
| | | public string scope;
|
| | | public string unionid;
|
| | |
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|