Exemplo n.º 1
0
        private void Loginbutton2_Click(object sender, RoutedEventArgs e)
        {
            this.appKey     = "SK5S68F7DZKKWIL3";
            this.appSecret  = "IHL982FMLT1GTJYU5VNDNSS9N7T8EZIA";
            this.verifycode = this.VerifyBox.Text;
            string serverUrl = "http://client.blackbirdsport.com/api/bikeConnect";
            string sign2     = RejisterPage.getSignature(new SortedDictionary <string, string>
            {
                {
                    "ak",
                    this.appKey
                },
                {
                    "userId",
                    this.phoneNumber
                },
                {
                    "verifyCode",
                    this.verifycode
                }
            }, this.appSecret);

            this.Secret = sign2;
            string postData = string.Format("ak={0}&userId={1}&verifyCode={2}&sign={3}", new object[]
            {
                this.appKey,
                this.phoneNumber,
                this.verifycode,
                this.Secret
            });
            string return2 = RejisterPage.HttpGetConnectToServer(serverUrl, postData);
            string flag    = return2.Substring(11, 2);
            bool   flag2   = flag == "ok";

            if (flag2)
            {
                MessageBox.Show("登陆成功!");
                this.PhoneNumbertextBox.IsEnabled = false;
                this.VerifyBox.IsEnabled          = false;
                this.SendVerifyButton.IsEnabled   = false;
                GlobalData.BBRejisterflag         = true;
                GlobalData.phoneNumber            = this.phoneNumber;
                GlobalData.verifycode             = this.verifycode;
                for (int i = 57; i <= 60; i++)
                {
                    bool flag3 = return2.Substring(i, 1) == ",";
                    if (flag3)
                    {
                        GlobalData.weight = return2.Substring(57, i - 57);
                    }
                }
                GlobalData.openId = return2.Substring(return2.Length - 9, 6);
                XMLHelper.BBUsersWriter("BBUsersFile");
            }
            else
            {
                string error = return2.Substring(52, 6);
                string a     = error;
                if (!(a == "000001"))
                {
                    if (!(a == "010001"))
                    {
                        if (!(a == "010007"))
                        {
                            if (a == "010010")
                            {
                                MessageBox.Show("用户不存在");
                            }
                        }
                        else
                        {
                            MessageBox.Show("验证码错误");
                        }
                    }
                    else
                    {
                        MessageBox.Show("ak或签名错误");
                    }
                }
                else
                {
                    MessageBox.Show("未知其他错误");
                }
            }
        }