Ejemplo n.º 1
0
        public LoginRequest(string data)
        {
            headCode = APIS.LOGIN_REQUEST;
            if (data == null)
            {
                LoginVo loginvo = new LoginVo();
                Random  ran     = new Random();
                string  str     = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000);
                loginvo.openId                                      = UIPanelLogin.TestId + "";
                loginvo.nickName                                    = UIPanelLogin.TestId + "";
                loginvo.headIcon                                    = "imgicon";
                loginvo.unionid                                     = UIPanelLogin.TestId + "";
                loginvo.province                                    = "21sfsd";
                loginvo.city                                        = "afafsdf";
                loginvo.sex                                         = 1;
                loginvo.IP                                          = GlobalDataScript.Instance.GetIpAddress();
                data                                                = JsonMapper.ToJson(loginvo);
                GlobalDataScript.loginVo                            = loginvo;
                GlobalDataScript.loginResponseData                  = new AvatarVO();
                GlobalDataScript.loginResponseData.account          = new Account();
                GlobalDataScript.loginResponseData.account.city     = loginvo.city;
                GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
                GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
                GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
                GlobalDataScript.loginResponseData.account.unionid  = loginvo.unionid;
                GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
                GlobalDataScript.loginResponseData.IP               = loginvo.IP;
            }

            messageContent = data;
        }
Ejemplo n.º 2
0
        public LoginRequest(string data)
        {
            headCode = APIS.LOGIN_REQUEST;
            if (data == null)
            {
                SimpleJSON.JSONObject jsonNode = new SimpleJSON.JSONObject();
                byte[] buffer         = new byte[1024];
                string user_json_path = FileIO.LOCAL_RES_PATH + "user.json";
                try {
                    FileStream stream = new FileStream(user_json_path, FileMode.Open);
                    stream.Read(buffer, 0, (int)stream.Length);
                    string user_json = Encoding.UTF8.GetString(buffer);
                    jsonNode = SimpleJSON.JSON.Parse(user_json).AsObject;
                } catch (Exception e) {
                    Debug.Log("Read user json not found. path(" + user_json_path + "), error(" + e + ")");
                    System.Random r       = new System.Random();
                    string        rand_id = r.Next(9999, 99999) + "" + r.Next(9999, 99999);
                    jsonNode ["openId"]   = rand_id;
                    jsonNode ["nickName"] = rand_id;
                    jsonNode ["unionid"]  = rand_id;
                    jsonNode ["sex"]      = 1;
                    FileStream stream = new FileStream(user_json_path, FileMode.CreateNew);
                    byte[]     resutl = Encoding.UTF8.GetBytes(jsonNode.ToString());
                    stream.Write(resutl, 0, (int)resutl.Length);
                    stream.Flush();
                    stream.Close();
                }

                jsonNode ["IP"] = GlobalDataScript.getInstance().getIpAddress();

                data = jsonNode.ToString();

                LoginVo loginvo = new LoginVo();
                loginvo.openId   = jsonNode ["openId"];
                loginvo.nickName = jsonNode ["nickName"];
                loginvo.unionid  = jsonNode ["unionid"];
                loginvo.headIcon = jsonNode ["headimgurl"];
                loginvo.province = jsonNode ["province"];
                loginvo.city     = jsonNode ["city"];
                loginvo.sex      = jsonNode ["sex"];
                loginvo.IP       = jsonNode ["IP"];

                GlobalDataScript.loginVo                            = loginvo;
                GlobalDataScript.loginResponseData                  = new AvatarVO();
                GlobalDataScript.loginResponseData.account          = new Account();
                GlobalDataScript.loginResponseData.account.city     = loginvo.city;
                GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
                GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
                GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
                GlobalDataScript.loginResponseData.account.unionid  = loginvo.city;
                GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
                GlobalDataScript.loginResponseData.IP               = loginvo.IP;
            }
            messageContent = data;
        }
Ejemplo n.º 3
0
        public LoginRequest(string data)
        {
            MyDebug.Log("----------------4------------------");
            headCode = APIS.LOGIN_REQUEST;

            LoginVo loginvo = new LoginVo();

            if (data == null)
            {
                System.Random ran = new System.Random();
                string        str = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000);
                loginvo.openId = "111111";
                MyDebug.Log("----------------5------------------");

                loginvo.nickName = "111111";
                loginvo.headIcon = "imgico221";
                loginvo.unionid  = "12732233";
                loginvo.province = "21sfsd";
                loginvo.city     = "afafsdf";
                loginvo.sex      = 1;
                loginvo.IP       = GlobalDataScript.getInstance().getIpAddress();
                data             = JsonMapper.ToJson(loginvo);

                PlayerPrefs.SetString("loginInfo", data);
            }
//			if(PlayerPrefs.HasKey ("loginInfo")){
//				PlayerPrefs.DeleteKey ("loginInfo");
//			}
            loginvo = new LoginVo();
            loginvo = JsonMapper.ToObject <LoginVo> (data);

            GlobalDataScript.loginVo                            = loginvo;
            GlobalDataScript.loginResponseData                  = new AvatarVO();
            GlobalDataScript.loginResponseData.account          = new Account();
            GlobalDataScript.loginResponseData.account.city     = loginvo.city;
            GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
            GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
            GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
            GlobalDataScript.loginResponseData.account.unionid  = loginvo.city;
            GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
            GlobalDataScript.loginResponseData.IP               = loginvo.IP;

            //加载头像
            if (GlobalDataScript.loginVo.sex == 2)
            {
                GlobalDataScript.getInstance().headSprite = Resources.Load("xianlai/public_ui/head_img_female", typeof(Sprite)) as Sprite;
            }
            else
            {
                GlobalDataScript.getInstance().headSprite = Resources.Load("xianlai/public_ui/head_img_male", typeof(Sprite)) as Sprite;
            }

            MyDebug.Log("----------------6------------------" + messageContent);
            messageContent = data;
        }
Ejemplo n.º 4
0
        public LoginRequest(string openid, string nickname)
        {
            MyDebug.Log("----------------4------------------");
            headCode = APIS.LOGIN_REQUEST;

            LoginVo loginvo = new LoginVo();


            System.Random ran = new System.Random();
            string        str = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000);

            loginvo.openId = openid;
            MyDebug.Log("----------------5------------------");

            loginvo.nickName = nickname;
            loginvo.headIcon = "imgico221";
            loginvo.unionid  = openid;
            loginvo.province = "21sfsd";
            loginvo.city     = "afafsdf";
            loginvo.sex      = 1;
            loginvo.IP       = GlobalDataScript.getInstance().getIpAddress();
            string data = JsonMapper.ToJson(loginvo);

            GlobalDataScript.loginVo                            = loginvo;
            GlobalDataScript.loginResponseData                  = new AvatarVO();
            GlobalDataScript.loginResponseData.account          = new Account();
            GlobalDataScript.loginResponseData.account.city     = loginvo.city;
            GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
            GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
            GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
            GlobalDataScript.loginResponseData.account.unionid  = loginvo.city;
            GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
            GlobalDataScript.loginResponseData.IP               = loginvo.IP;

            //加载头像
            if (GlobalDataScript.loginVo.sex == 2)
            {
                GlobalDataScript.getInstance().headSprite = Resources.Load("xianlai/public_ui/head_img_female", typeof(Sprite)) as Sprite;
            }
            else
            {
                GlobalDataScript.getInstance().headSprite = Resources.Load("xianlai/public_ui/head_img_male", typeof(Sprite)) as Sprite;
            }

            messageContent = data;
        }
Ejemplo n.º 5
0
        public LoginRequest(int id)
        {
            string data = null;

            MyDebug.Log("----------------4------------------");
            headCode = APIS.LOGIN_REQUEST;

            LoginVo loginvo = new LoginVo();
            Random  ran     = new Random();
            string  str     = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000);

            loginvo.openId = id.ToString();
            MyDebug.Log("----------------5------------------");

            loginvo.nickName = "test" + id;
            loginvo.headIcon = "imgico221";
            loginvo.unionid  = "12732" + id;
            loginvo.province = "21s" + id;
            loginvo.city     = "afafsdf";
            loginvo.sex      = 1;
            loginvo.IP       = GlobalDataScript.getInstance().getIpAddress();
            data             = JsonMapper.ToJson(loginvo);

            GlobalDataScript.loginVo                            = loginvo;
            GlobalDataScript.loginResponseData                  = new AvatarVO();
            GlobalDataScript.loginResponseData.account          = new Account();
            GlobalDataScript.loginResponseData.account.city     = loginvo.city;
            GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
            GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
            GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
            GlobalDataScript.loginResponseData.account.unionid  = loginvo.unionid;
            GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
            GlobalDataScript.loginResponseData.IP               = loginvo.IP;

            MyDebug.Log("----------------6------------------" + messageContent);
            messageContent = data;
        }
Ejemplo n.º 6
0
        public LoginRequest(string data)
        {
            MyDebug.Log("----------------4------------------");
            headCode = APIS.LOGIN_REQUEST;

            /**
             * LoginVo loginvo = new LoginVo ();
             * if (data != null) {
             *      MyDebug.Log (data.toJson());
             *      try {
             *
             *              loginvo.openId = (string)data ["openid"];
             *              loginvo.nickName = (string)data ["nickname"];
             *              loginvo.headIcon = (string)data ["headimgurl"];
             *              loginvo.unionid = (string)data ["unionid"];
             *              loginvo.province = (string)data ["province"];
             *              loginvo.city = (string)data ["city"];
             *              string sex = data ["sex"].ToString();
             *              loginvo.sex = int.Parse(sex);
             *              loginvo.IP = GlobalDataScript.getInstance().getIpAddress();
             *      } catch (Exception e) {
             *              MyDebug.Log ("微信接口有变动!" + e.Message);
             *              TipsManagerScript.getInstance ().setTips ("请先打开你的微信客户端");
             *              return;
             *      }
             * } else {
             *
             * }
             *
             *
             * MyDebug.Log ("loginvo.IP" + loginvo.IP);
             *
             **/

            if (data == null)
            {
                LoginVo loginvo = new LoginVo();
                Random  ran     = new Random();
                string  str     = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000);
                loginvo.openId = "133333333";
                MyDebug.Log("----------------5------------------");

                loginvo.nickName = "11112322444";
                loginvo.headIcon = "imgico221";
                loginvo.unionid  = "12732233";
                loginvo.province = "21sfsd";
                loginvo.city     = "afafsdf";
                loginvo.sex      = 1;
                loginvo.IP       = GlobalDataScript.getInstance().getIpAddress();
                data             = JsonMapper.ToJson(loginvo);

                GlobalDataScript.loginVo                            = loginvo;
                GlobalDataScript.loginResponseData                  = new AvatarVO();
                GlobalDataScript.loginResponseData.account          = new Account();
                GlobalDataScript.loginResponseData.account.city     = loginvo.city;
                GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
                GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
                GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
                GlobalDataScript.loginResponseData.account.unionid  = loginvo.city;
                GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
                GlobalDataScript.loginResponseData.IP               = loginvo.IP;
            }
            MyDebug.Log("----------------6------------------" + messageContent);
            messageContent = data;
        }
Ejemplo n.º 7
0
        public LoginRequest(string data)
        {
            headCode = APIS.LOGIN_REQUEST;

            LoginVo loginvo = new LoginVo();

            if (data != null)
            {
                MyDebug.Log(data);
                try {
                    loginvo = JsonMapper.ToObject <LoginVo>(data);

                    /*LitJson.JsonData dataJson = JsonMapper.ToObject<JsonData>(data);
                     *
                     * loginvo.openId = (string)dataJson ["openid"];
                     * loginvo.nickName = (string)dataJson ["nickname"];
                     * loginvo.headIcon = (string)dataJson ["headimgurl"];
                     * loginvo.unionid = (string)dataJson ["unionid"];
                     * loginvo.province = (string)dataJson ["province"];
                     * loginvo.city = (string)dataJson ["city"];
                     * string sex = dataJson ["sex"].ToString();
                     *                  loginvo.sex = int.Parse(sex);
                     *                  loginvo.IP = GlobalDataScript.getInstance().getIpAddress();
                     */
                } catch (Exception e) {
                    MyDebug.Log("微信接口有变动!" + e.Message);
                    TipsManagerScript.getInstance().setTips("请先打开你的微信客户端");
                    return;
                }
            }
            else
            {
            }

            MyDebug.Log("loginvo.IP" + loginvo.IP);

            if (data == null)
            {
                //LoginVo loginvo = new LoginVo ();
                System.Random ran = new System.Random();
                string        str = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000);
                loginvo.openId = SystemInfo.deviceUniqueIdentifier;

                loginvo.nickName = SystemInfo.deviceUniqueIdentifier;
                loginvo.headIcon = "imgicon";
                loginvo.unionid  = "127";
                loginvo.province = "21sfsd";
                loginvo.city     = "afafsdf";
                loginvo.sex      = 1;
                loginvo.IP       = GlobalDataScript.getInstance().getIpAddress();
                data             = JsonMapper.ToJson(loginvo);

                GlobalDataScript.loginVo                            = loginvo;
                GlobalDataScript.loginResponseData                  = new AvatarVO();
                GlobalDataScript.loginResponseData.account          = new Account();
                GlobalDataScript.loginResponseData.account.city     = loginvo.city;
                GlobalDataScript.loginResponseData.account.openid   = loginvo.openId;
                GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
                GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
                GlobalDataScript.loginResponseData.account.unionid  = loginvo.city;
                GlobalDataScript.loginResponseData.account.sex      = loginvo.sex;
                GlobalDataScript.loginResponseData.IP               = loginvo.IP;
            }
            messageContent = data;
        }