条件编译报错问题

This commit is contained in:
CaiYanPeng 2021-08-25 10:29:03 +08:00
parent f155b2b627
commit 88beff5b89

View File

@ -26,7 +26,7 @@ using ZenFulcrum.EmbeddedBrowser;
#endif
//记录小f 是-457和-681
public class QUserInfo
public class QUserInfo
{
public long Id { get; set; }
public string Phone { get; set; }
@ -34,12 +34,12 @@ public class QUserInfo
public string Avatar { get; set; }
public string Cookie { get; set; }
}
public class LoginForm
public class LoginForm
{
public InputField email { get; set; }
public InputField password { get; set; }
}
public class SignForm
public class SignForm
{
//页面1
public InputField email { get; set; }
@ -106,7 +106,7 @@ public class LoginController : MonoBehaviour
//其他
[SerializeField] RawImage loading;
Transform toolContainer;
Dictionary<string, Selectable> formDict,signFormDict;
Dictionary<string, Selectable> formDict, signFormDict;
public string avatarName { get; private set; }
public Texture avatar;
@ -134,7 +134,7 @@ public class LoginController : MonoBehaviour
EventTriggerType.PointerClick, (b) => goResetPassword());
//signPage1.Find("next").GetComponent<Button>().onClick.AddListener(() => { goRegNext(); });
UIManager.AddEvent(signPage1.Find("Captcha").Find("BtnGet").gameObject,
EventTriggerType.PointerClick,(b)=> GetCaptcha());
EventTriggerType.PointerClick, (b) => GetCaptcha());
//signPage1.Find("Captcha").Find("BtnGet").GetComponent<Button>().onClick.AddListener(GetCaptcha);
var email = signPage1.Find("Email").GetComponent<InputField>();
var captcha = signPage1.Find("Captcha").GetComponent<InputField>();
@ -247,18 +247,18 @@ public class LoginController : MonoBehaviour
UIManager.AddEvent(sign.gameObject, EventTriggerType.PointerClick, (b) => goSign());
remember = loginContainer.Find("rememberButton").GetComponent<Button>();
UIManager.AddEvent(remember.gameObject, EventTriggerType.PointerClick, (b) =>
{
var gou = remember.transform.Find("Gou");
if (gou.gameObject.activeSelf)
{
gou.gameObject.SetActive(false);
}
else
{
gou.gameObject.SetActive(true);
}
});
UIManager.AddEvent(loginContainer.Find("ForgetPassword").gameObject, EventTriggerType.PointerClick, (e) =>goSign(type:1));
{
var gou = remember.transform.Find("Gou");
if (gou.gameObject.activeSelf)
{
gou.gameObject.SetActive(false);
}
else
{
gou.gameObject.SetActive(true);
}
});
UIManager.AddEvent(loginContainer.Find("ForgetPassword").gameObject, EventTriggerType.PointerClick, (e) => goSign(type: 1));
#if !(UNITY_IOS || UNITY_ANDROID)
var wechatLogin = loginContainer.Find("otherContainer").Find("Wechat").GetComponent<Button>();
UIManager.AddEvent(wechatLogin.gameObject, EventTriggerType.PointerClick, (b) =>
@ -319,7 +319,7 @@ public class LoginController : MonoBehaviour
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", () =>
{
Application.Quit();
},2);
}, 2);
});
}
#if !(UNITY_IOS || UNITY_ANDROID)
@ -330,7 +330,6 @@ public class LoginController : MonoBehaviour
{
wxReturnLogin();
});
#if !(UNITY_IOS || UNITY_ANDROID)
wxBrowser = wxLogin1.Find("Browser (GUI)").GetComponent<Browser>();
if (wxBrowser != null)
{
@ -360,17 +359,17 @@ public class LoginController : MonoBehaviour
if (wxLogin2 != null)
{
UIManager.AddEvent(wxLogin2.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
{
{
#if !(UNITY_IOS || UNITY_ANDROID)
wxLogin1.gameObject.SetActive(false);
wxLogin1.GetComponent<RectTransform>().localPosition = new Vector3(0, -573, 0);
#endif
wxLogin2.gameObject.SetActive(false);
//wxLogin3.gameObject.SetActive(false);
pageNums = 4;
//Canvas.ForceUpdateCanvases();
StartScrollPanel(1);
});
wxLogin2.gameObject.SetActive(false);
//wxLogin3.gameObject.SetActive(false);
pageNums = 4;
//Canvas.ForceUpdateCanvases();
StartScrollPanel(1);
});
wxLogin2.Find("Next").GetComponent<Button>().onClick.AddListener(() =>
{
this.goSign(false);
@ -380,40 +379,40 @@ public class LoginController : MonoBehaviour
if (wxLogin3 != null)
{
UIManager.AddEvent(wxLogin3.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
{
if (signContainer.gameObject.activeSelf)
{
if (pageNums == 5)
{
StartScrollPanel(3);
}
else if (pageNums == 4)
{
StartScrollPanel(2);
}
else
{
StartScrollPanel(1);
}
}
else
{
signContainer.gameObject.SetActive(true);
{
if (signContainer.gameObject.activeSelf)
{
if (pageNums == 5)
{
StartScrollPanel(3);
}
else if (pageNums == 4)
{
StartScrollPanel(2);
}
else
{
StartScrollPanel(1);
}
}
else
{
signContainer.gameObject.SetActive(true);
#if !(UNITY_IOS || UNITY_ANDROID)
wxLogin1.gameObject.SetActive(false);
wxLogin1.GetComponent<RectTransform>().localPosition = new Vector3(0, -573, 0);
#endif
pageNums = 4;
//wxLogin3.gameObject.SetActive(false);
StartScrollPanel(1);
}
});
pageNums = 4;
//wxLogin3.gameObject.SetActive(false);
StartScrollPanel(1);
}
});
UIManager.AddEvent(wxLogin3.Find("rememberButton").gameObject, EventTriggerType.PointerClick, (b) =>
{
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
gou.SetActive(!gou.activeSelf);
});
UIManager.AddEvent(wxLogin3.Find("Next").gameObject, EventTriggerType.PointerClick, (b) =>
{
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
gou.SetActive(!gou.activeSelf);
});
UIManager.AddEvent(wxLogin3.Find("Next").gameObject, EventTriggerType.PointerClick, (b) =>
{
goMain(wxLogin3.Find("rememberButton").Find("Gou"));
});
@ -424,9 +423,9 @@ public class LoginController : MonoBehaviour
if (toolContainer != null)
{
UIManager.AddEvent(toolContainer.Find("Setting").gameObject, EventTriggerType.PointerClick, (b) =>
{
UIManager.ShowSettingModal();
});
{
UIManager.ShowSettingModal();
});
//toolContainer.Find("Setting").GetComponent<Button>().onClick.AddListener(() =>
//{
// UIManager.ShowSettingModal();
@ -464,7 +463,7 @@ public class LoginController : MonoBehaviour
}
});
#endif
signFormDict = new Dictionary<string, Selectable>
signFormDict = new Dictionary<string, Selectable>
{
{ "Phone",signForm.email},
{ "Captcha",signForm.captcha},
@ -481,7 +480,7 @@ public class LoginController : MonoBehaviour
transform.Find("Panel").Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
#endif
}
public void Test(string key)
public void Test(string key)
{
Debug.Log(key);
}
@ -498,18 +497,18 @@ public class LoginController : MonoBehaviour
var r = await ConfigHelper.userApi.GetNotify();
if (r.result)
{
//#if !UNITY_EDITOR
//#if !UNITY_EDITOR
var ver = r.data.Value<JObject>("Version").ToObject<UpdateModel>();
if (ver!=null && ver.HasUpdate)
if (ver != null && ver.HasUpdate)
{
App.UpdateObject = ver;
Debug.Log(Application.persistentDataPath + "/PowerFun.exe");
UIManager.ShowDownloadModal();
}
//#endif
//#endif
App.notifyContent = r.data.Value<string>("Content");
if (r.data.Value<int>("Id") != notifyId)
if (r.data.Value<int>("Id") != notifyId)
{
UIManager.ShowNewsModal();
PlayerPrefs.SetInt("notifyId", r.data.Value<int>("Id"));
@ -539,7 +538,7 @@ public class LoginController : MonoBehaviour
Debug.Log(JsonConvert.SerializeObject(locationInfo));
var i = await ConfigHelper.thirdPartApi.GetMapImage(locationInfo);
var t = new Texture2D(2, 2);
if (t.LoadImage(Utils.StreamToBytes(i)))
if (t.LoadImage(Utils.StreamToBytes(i)))
{
Debug.Log("成功");
App.TextureCache["rotateImage"] = t;
@ -648,7 +647,7 @@ public class LoginController : MonoBehaviour
{
}
#region
#region
int time = 0;
float timer = 0f;
bool startCaptcha = false;
@ -687,8 +686,8 @@ public class LoginController : MonoBehaviour
Utils.SetValidate(signFormDict, r.errFieldMsg);
}
}
#endregion
#endregion
void CaptchaTimerTick()
{
timer -= Time.deltaTime;
@ -762,7 +761,7 @@ public class LoginController : MonoBehaviour
Utils.showToast(gameObject, r.errMsg);
}
}
async void goRegNextWithoutPass()
{
var Email = signForm.email;
@ -775,7 +774,7 @@ public class LoginController : MonoBehaviour
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u,1);
RefreshWx3(u, 1);
StartScrollPanel(4);
}
else
@ -786,7 +785,7 @@ public class LoginController : MonoBehaviour
/// <summary>
/// 重置密码逻辑
/// </summary>
async void goResetPassword()
async void goResetPassword()
{
var Email = signForm.email;
var Captcha = signForm.captcha;
@ -805,15 +804,15 @@ public class LoginController : MonoBehaviour
var r = await ConfigHelper.userApi.ResetPassword(Email.text, Captcha.text, Password.text);
if (r.result)
{
Utils.showToast(gameObject, "Success",type:1);
Utils.showToast(gameObject, "Success", type: 1);
goLoginReturn2();
}
else
else
{
Utils.showToast(gameObject, r.errMsg);
}
}
void RefreshWx3(UserResultModel data,int type)
void RefreshWx3(UserResultModel data, int type)
{
Utils.DisplayHead(wxLogin3.Find("Avatar").GetComponent<RawImage>(),
data.WxHeadImg);
@ -874,7 +873,7 @@ public class LoginController : MonoBehaviour
/// 注册页2 修改信息
/// </summary>
/// <returns></returns>
bool UpdateInfo()
bool UpdateInfo()
{
if (userResult == null) return false;
var _days = signForm.days.GetComponent<PFUIDropdown>();
@ -889,9 +888,9 @@ public class LoginController : MonoBehaviour
{
userResult.Birthday = new DateTime(int.Parse(_years.SelectedItem), int.Parse(_months.SelectedItem), int.Parse(_days.SelectedItem));
}
else
else
{
Utils.SetValidate(signFormDict, JArray.FromObject(new object[]
Utils.SetValidate(signFormDict, JArray.FromObject(new object[]
{
new { Field = "Years", ErrMsg = "" },
new { Field = "Months", ErrMsg = "" },
@ -909,7 +908,7 @@ public class LoginController : MonoBehaviour
{
userResult.Nickname = userResult.Phone;
}
var r = ConfigHelper.userApi.Update(userResult,out string cookie,"");
var r = ConfigHelper.userApi.Update(userResult, out string cookie, "");
return r.result;
//userResult.Birthday.v
}
@ -942,9 +941,7 @@ public class LoginController : MonoBehaviour
void wxReturnLogin()
{
wxLock = true;
#if !(UNITY_IOS || UNITY_ANDROID)
wxBrowser.LoadHTML("<div/>");
#endif
//wxBrowser.Url = "chrome://version/";
wxLogin1.DOLocalMoveY(-573, 0.3f).onComplete = () =>
{
@ -956,7 +953,7 @@ public class LoginController : MonoBehaviour
/// <summary>
/// 立刻跳到登录页并且返回按钮强行失效
/// </summary>
private void goLoginImmediately()
private void goLoginImmediately()
{
#if !(UNITY_IOS || UNITY_ANDROID)
imagedf.localPosition = new Vector3(-580, -34, 0);
@ -1056,7 +1053,7 @@ public class LoginController : MonoBehaviour
/// </summary>
/// <param name="isAccount"></param>
/// <param name="type">0 注册 1 忘记密码</param>
void goSign(bool isAccount = true,int type = 0)
void goSign(bool isAccount = true, int type = 0)
{
#if UNITY_ANDROID || UNITY_IOS
imagedf.GetComponent<Image>().DOFade(0, .3f);
@ -1076,7 +1073,7 @@ public class LoginController : MonoBehaviour
this.StartScrollPanel(3);
this.StartScrollSign(0);
}
else
else
{
if (type == 0)
{
@ -1091,7 +1088,7 @@ public class LoginController : MonoBehaviour
this.StartScrollPanel(2);
this.StartScrollSign(0);
}
else
else
{
pageNums = 4;
signContainer.Find("signText").GetComponent<Text>().text = "RESET PASSWORD";
@ -1110,7 +1107,7 @@ public class LoginController : MonoBehaviour
/// 登录/注册完成,去首页
/// </summary>
/// <param name="gou"></param>
void goMain(Transform gou)
void goMain(Transform gou)
{
var data = userResult;
if (data == null) return;
@ -1120,10 +1117,10 @@ public class LoginController : MonoBehaviour
SaveInfo(data);
//PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
}
else
else
{
var u = userInfos.Find(x => x.Id == data.Id);
if (u != null)
if (u != null)
{
userInfos.Remove(u);
}
@ -1140,7 +1137,7 @@ public class LoginController : MonoBehaviour
/// 缓存打钩的用户信息
/// </summary>
/// <param name="data"></param>
public void SaveInfo(UserResultModel data)
public void SaveInfo(UserResultModel data)
{
var index = userInfos.FindIndex(x => x.Id == data.Id);
if (index == -1)
@ -1178,7 +1175,7 @@ public class LoginController : MonoBehaviour
/// <summary>
/// 登录提交
/// </summary>
async void Submit()
async void Submit()
{
var res = await ConfigHelper.userApi.LoginV1(loginForm.email.text, loginForm.password.text, "");
//var res = await NoAuthApi.Login(phone.text, pwd.text);
@ -1187,9 +1184,9 @@ public class LoginController : MonoBehaviour
userResult = JObject.FromObject(res.data).ToObject<UserResultModel>();
goMain(remember.transform.Find("Gou"));
}
else
else
{
if (res.data != null)
if (res.data != null)
{
var errorList = JArray.FromObject(res.data);
Utils.SetValidate(formDict, errorList);
@ -1203,13 +1200,13 @@ public class LoginController : MonoBehaviour
//Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
if (Input.GetKeyDown(KeyCode.Tab))
{
if (loginForm != null && loginForm.email.isFocused && loginForm.password != null)
if (loginForm != null && loginForm.email.isFocused && loginForm.password != null)
{
loginForm.password.ActivateInputField();
}
if (signForm != null)
if (signForm != null)
{
if (signForm.email.isFocused)
if (signForm.email.isFocused)
{
signForm.captcha.ActivateInputField();
}
@ -1227,18 +1224,18 @@ public class LoginController : MonoBehaviour
}
}
}
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
{
if (loginForm != null && !string.IsNullOrEmpty(loginForm.email.text) && !string.IsNullOrEmpty(loginForm.password.text))
{
Submit();
}
}
if (startCaptcha)
if (startCaptcha)
{
CaptchaTimerTick();
}
//if (wxLogin1.gameObject.activeInHierarchy)
//{
// adjTime += Time.deltaTime;
@ -1257,7 +1254,7 @@ public class LoginController : MonoBehaviour
}
//float adjTime = 0;
//bool startJs = false;
#region
#region
private int tmpImdex = 0;
private int scrollPanelIndex = 2;
//private float scrollValue = 0.5f;
@ -1272,20 +1269,20 @@ public class LoginController : MonoBehaviour
private void goScrollPanel()
{
var index = scrollPanelIndex;
var scrollValue = 1f/(pageNums - 1);
var scrollValue = 1f / (pageNums - 1);
var value = index * scrollValue;
if (scrollPanel != null && startScrollPanel)
if (scrollPanel != null && startScrollPanel)
{
if (scrollPanel.horizontalNormalizedPosition >= value)
{
scrollPanel.horizontalNormalizedPosition -= (scrollValue / 10);
if (scrollPanel.horizontalNormalizedPosition <= value)
if (scrollPanel.horizontalNormalizedPosition <= value)
{
scrollPanel.horizontalNormalizedPosition = value;
startScrollPanel = false;
}
}
else
else
{
scrollPanel.horizontalNormalizedPosition += (scrollValue / 10);
if (scrollPanel.horizontalNormalizedPosition >= value)
@ -1296,31 +1293,31 @@ public class LoginController : MonoBehaviour
}
}
}
#endregion
#region
#endregion
#region
private bool startScrollSign = false;
private int scrollSignIndex = 0;
private void StartScrollSign(int index)
{
if (startScrollSign) return;
scrollSignIndex = index;
startScrollSign = true;
Debug.Log($"{index},{index * 160}");
if (index == 1)
if (index == 1)
{
if (signForm.years.value!=-1) signForm.years.value = 0;
if (signForm.years.value != -1) signForm.years.value = 0;
if (signForm.months.value != -1) signForm.months.value = 0;
if (signForm.days.value != -1) signForm.days.value = 0;
if (signForm.countrys.value != -1) signForm.countrys.value = regOptions.countryDefaultValue;
if (signForm.genders.value != -1) signForm.genders.value = 0;
if (signForm.units.value != -1) signForm.units.value = 0;
if (pageNums == 5 && wxInfoJson != null)
if (pageNums == 5 && wxInfoJson != null)
{
var sex = wxInfoJson.Value<int>("sex");
if (sex > 0)
if (sex > 0)
{
signForm.genders.value = sex - 1;
}
@ -1352,7 +1349,7 @@ public class LoginController : MonoBehaviour
{
scrollSign.horizontalNormalizedPosition = 0;
startScrollSign = false;
}
}
else if (scrollSignIndex == 1)
@ -1366,5 +1363,5 @@ public class LoginController : MonoBehaviour
}
}
}
#endregion
#endregion
}