Esempio n. 1
0
        //登入按钮 Sign In
        async void Handle_SignIn(object sender, EventArgs e)
        {
            activity.IsEnabled      = true;
            activity.IsRunning      = true;
            activity.IsVisible      = true;
            signInloading.Text      = "Connecting...";
            signInloading.TextColor = Color.FromHex("#FF4E18");
            UserAccess userAccess = new UserAccess();
            Uac        uac        = new Uac();

            uac.ContactNo = GetCountryName(countryCodePicker.SelectedItem.ToString()) + PNumEntry.Text;

            //Internet Connection Check
            if (Connectivity.NetworkAccess != NetworkAccess.Internet)
            {
                await DisplayAlert("No Internet", "Try again later!", "OK");

                activity.IsEnabled = false;
                activity.IsRunning = false;
                activity.IsVisible = false;
                signInloading.Text = "";
                return;
            }

            //Empty Check
            if (PNumEntry.Text.IsNullOrEmpty())
            {
                await DisplayAlert("Error", "Try enter your Number and try again!", "OK");

                activity.IsEnabled = false;
                activity.IsRunning = false;
                activity.IsVisible = false;
                signInloading.Text = "";
                return;
            }

            //Validation Check
            if (!thelper.IsValidE164(uac.ContactNo, "US"))
            {
                await DisplayAlert("Not Valid", "Enter a real number and try again!", "OK");

                activity.IsEnabled = false;
                activity.IsRunning = false;
                activity.IsVisible = false;
                signInloading.Text = "";
                return;
            }

            //RememberMe = savename.IsToggled;
            if (userAccess.CheckPhoneNoExist(uac.ContactNo))
            {
                Settings.UserId    = userAccess.GetUserIDbyNo(uac.ContactNo);
                activity.IsEnabled = false;
                activity.IsRunning = false;
                activity.IsVisible = false;
                signInloading.Text = "";
                await Navigation.PushAsync(new SignInPasswordPage(uac.ContactNo));
            }
            else
            {
                if (uac.ContactNo.Remove(3) == "+86")
                {
                    userAccess.SendverifyCodeYP(uac.ContactNo.Substring(3), userAccess.GetVerificationCode());
                    activity.IsEnabled = false;
                    activity.IsRunning = false;
                    activity.IsVisible = false;
                    signInloading.Text = "";
                    await Navigation.PushAsync(new SignUpVerifyPage(uac.ContactNo));
                }
                else
                {
                    userAccess.TwilioVerifyService(uac.ContactNo);
                    activity.IsEnabled = false;
                    activity.IsRunning = false;
                    activity.IsVisible = false;
                    signInloading.Text = "";
                    await Navigation.PushAsync(new SignUpVerifyPage(uac.ContactNo));
                }
            }
        }