调整微信登录

This commit is contained in:
Caiyanpeng committed 2021-06-07 14:48:09 +08:00
1 parent 5671b35dce
commit 432e02e3de
4 files changed
+44 -41

No files matched your search

+20 -26
View File
@@ -254,8 +254,8 @@ public class LoginController : MonoBehaviour
{
if (wxLock) return;
wxLock = true;
wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1, 5)).ToString();
wxBrowser.Url = $"https://open.weixin.qq.com/connect/qrconnect?appid={App.WxAppId}&redirect_uri=https%3A%2F%2Fwx.powerfun.com.cn%2FNoAuth%2Fv1%2FWxWebLogin&response_type=code&scope=snsapi_login&state={wxState}#wechat_redirect";
//wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1, 5)).ToString();
wxBrowser.Url = $"https://open.weixin.qq.com/connect/qrconnect?appid={App.WxAppId}&redirect_uri=https%3A%2F%2Fwx.powerfun.com.cn%2FNoAuth%2Fv1%2FWxWebLogin&response_type=code&scope=snsapi_login&state=unity#wechat_redirect";
AdjustWxQrCode();
//wxBrowser.RegisterFunction("isFinish", args =>
//{
@@ -536,28 +536,28 @@ public class LoginController : MonoBehaviour
{
//AdjustWxQrCode();
}
//Debug.Log(wxBrowser.Url);
var rgx = Regex.Match(wxBrowser.Url, @"https\:\/\/wx.powerfun.com.cn/NoAuth/v1/WxWebLogin\?code=(.*?)&state=(.*?)$");
var groups = rgx.Groups;
if (groups.Count == 3)
{
wxBrowser.LoadHTML("<div />");
//wxBrowser.LoadHTML("<div />");
var state = groups[2].Value;
if (state == wxState)
if (state == "unity")
{
var acjson = await ConfigHelper.thirdPartApi.GetWxAccessToken(groups[1].Value);
var infojson = await ConfigHelper.thirdPartApi.GetWxUserInfo(
acjson.Value<string>("access_token"), acjson.Value<string>("openid"));
wxInfoJson = infojson;
string unionId = wxInfoJson.Value<string>("unionid"),
openId = wxInfoJson.Value<string>("openid");
var r = await ConfigHelper.userApi.OnWebWxLoginCheckUnionId(unionId, openId);
//wxBrowser.
//var acjson = await ConfigHelper.thirdPartApi.GetWxAccessToken(groups[1].Value);
//var infojson = await ConfigHelper.thirdPartApi.GetWxUserInfo(
// acjson.Value<string>("access_token"), acjson.Value<string>("openid"));
//string unionId = wxInfoJson.Value<string>("unionid"),
// openId = wxInfoJson.Value<string>("openid");
var r = await ConfigHelper.userApi.OnWebWxLoginCheckUnionIdByCode(groups[1].Value, groups[2].Value);
if (r.result)
{
JObject data = JObject.FromObject(r.data);
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
wxInfoJson = data;
wxLogin2.gameObject.SetActive(true);
Utils.DisplayImage(wxLogin2.Find("Avatar").GetComponent<RawImage>(),
wxInfoJson.Value<string>("headimgurl"));
@@ -572,7 +572,7 @@ public class LoginController : MonoBehaviour
}
else
{
RefreshWx3(data.ToObject<UserResultModel>(),1);
RefreshWx3(data.ToObject<UserResultModel>(), 1);
wxLogin3.gameObject.SetActive(true);
//Utils.DisplayImage(StartCoroutine,
//wxLogin3.Find("Avatar").GetComponent<RawImage>(),
@@ -701,12 +701,9 @@ public class LoginController : MonoBehaviour
{
r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
Captcha.text,
wxInfoJson.Value<string>("unionid"),
wxInfoJson.Value<string>("openid"),
wxInfoJson.Value<string>("headimgurl"),
wxInfoJson.Value<string>("nickname"),
wxInfoJson.Value<int>("sex"),
Password.text);
Password.text,
wxInfoJson.Value<string>("unionId"),
wxInfoJson.Value<string>("openId"));
}
if (r != null && r.result)
{
@@ -729,12 +726,9 @@ public class LoginController : MonoBehaviour
var Captcha = signForm.captcha;
var r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
Captcha.text,
wxInfoJson.Value<string>("unionid"),
wxInfoJson.Value<string>("openid"),
wxInfoJson.Value<string>("headimgurl"),
wxInfoJson.Value<string>("nickname"),
wxInfoJson.Value<int>("sex"),
"");
"",
wxInfoJson.Value<string>("unionId"),
wxInfoJson.Value<string>("openId"));
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();