Exemplo n.º 1
0
    /// <summary>
    /// 登入消息
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public SocketMsg ReqPWLoginMsg(object msg)
    {
        //登入检验TODO
        LoginInfo loginInfo = msg as LoginInfo;

        if (loginInfo.UserName == "" || loginInfo.Password == "")
        {
            promptMsg.Change("请输入用户名和密码", Color.red);
            Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
            return(null);
        }
        if (!MsgTool.CheckMobile(loginInfo.UserName))
        {
            promptMsg.Change("请输入正确的手机号码", Color.red);
            Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
            return(null);
        }
        MessageData messageData = new MessageData();
        string      userpass    = loginInfo.Password;

        //string userpass= MsgTool.MD5Encrypt(loginInfo.Password);
        messageData.t = new Dictionary <string, string>
        {
            // ["IsIdentityLog"] = loginInfo.Identity,
            ["username"] = loginInfo.UserName,
            ["userpass"] = userpass,
            //["Identity"] = loginInfo.Identity
        };
        messageData.model = "consumer";
        messageData.type  = "pwlog";
        SocketMsg socketMsg = new SocketMsg(LoginInfo.ClientId, "登入操作", messageData);

        PlayerPrefs.SetString("username", loginInfo.UserName);
        return(socketMsg);
    }
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="value"></param>
 private void expwRespon(string value)
 {
     promptMsg.Change(LanguageService.Instance.GetStringByKey(value, String.Empty), Color.white);
     if (value == "200")
     {
         //promptMsg.Change("modify", Color.white);
         promptMsg.Change(LanguageService.Instance.GetStringByKey("modify", String.Empty), Color.white);
     }
     Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
 }
 private void expwRespon(string value)
 {
     promptMsg.Change(value, Color.red);
     Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
     if (value == "修改成功")
     {
         promptMsg.Change(value.ToString(), Color.green);
         // Dispatch(AreaCode.UI, UIEvent.LOG_ACTIVE, null);
     }
 }
Exemplo n.º 4
0
        void Start()
        {
            promptMsg    = new HintMsg();
            btnClose     = transform.Find("bg/BtnClose").GetComponent <Button>();
            imageQRecode = transform.Find("bg/ImageQRecode").GetComponent <RawImage>();
            BG           = transform.Find("bg").GetComponent <Image>();
            DetermineBtn = transform.Find("bg/ConfrimButton").GetComponent <Button>();
            CopyBtn      = transform.Find("bg/CopyButton").GetComponent <Button>();
            siteText     = transform.Find("bg/Site").GetComponent <Text>();
            CopyBtn.onClick.AddListener(() =>
            {
                if (!PermissionsRationaleDialog.IsPermitted(AndroidPermission.WRITE_EXTERNAL_STORAGE))
                {
                    PermissionsRationaleDialog.RequestPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE);
                    Debug.Log("No WRITE_EXTERNAL_STORAGE Permission");
                }
#if UNITY_ANDROID
                if (!string.IsNullOrEmpty(siteText.text))
                {
                    //"com.inode.dreamcity.SaveImageActivity"
                    using (var test = new AndroidJavaObject("com.inode.dreamcity.SaveImageActivity"))
                    {
                        if (test.Call <bool>("CopyText", siteText.text))
                        {
                            promptMsg.Change(LanguageService.Instance.GetStringByKey("复制成功", string.Empty), Color.white);
                            Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                        }
                    }
                }
#endif
            });
            btnClose.onClick.AddListener(clickClose);
            setPanelActive(false);
            Multilingual();
        }
 /// <summary>
 /// 第一类物业点赞
 /// </summary>
 private void clickLike0()
 {
     Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_CLICK_AUDIO, "ClickVoice");
     Dispatch(AreaCode.NET, ReqEventType.GetLike, friendId);
     promptMsg.Change(LanguageService.Instance.GetStringByKey("点赞成功", string.Empty), Color.white);
     GvieLike0.SetActive(false);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 修改密码消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public SocketMsg <Dictionary <string, string> > ReqPWChangeMsg(object msg)
        {
            Dictionary <string, string> t = msg as Dictionary <string, string>;

            //todo配置
            if (t["oldpw"] == null || t["oldpw"].Equals(""))
            {
                promptMsg.Change("请输入当前密码", Color.red);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return(null);
            }
            if (t["newpw"] == null || t["newpw"].Equals(""))
            {
                promptMsg.Change("请输入新密码", Color.red);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return(null);
            }
            if (t["code"] == null || t["code"].Equals(""))
            {
                promptMsg.Change("请输入验证码", Color.red);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return(null);
            }
            t.Add("username", PlayerPrefs.GetString("username"));
            t.Add("token", PlayerPrefs.GetString("token"));
            messageData.Change("consumer/player", "expw", t);
            socketMsg.Change(LoginInfo.ClientId, "修改登入密码操作", messageData);
            return(socketMsg);
        }
 /// <summary>
 /// 商会升级
 /// </summary>
 private void CommercePromptRespon(string code)
 {
     if (code.Equals("666"))
     {
         promptMsg.Change(LanguageService.Instance.GetStringByKey("666", String.Empty), Color.white);
         Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
     }
 }
Exemplo n.º 8
0
 private void OnLongPress()
 {
     Debug.Log("Haha");
     SaveImages(GetComponent <RawImage>().texture as Texture2D);
     //弹出保存成功提示
     promptMsg.Change("保存成功", Color.white);
     Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
     gameObject.SetActive(false);
     transform.parent.gameObject.SetActive(false);
 }
    //private bool initResponse(string  msg)
    //{
    //    PlayerPrefs.SetString("ClientId", msg);
    //    Debug.LogError("initResponse"+msg);
    //    return true;
    //}

    /// <summary>
    /// 登录响应
    /// </summary>
    private bool loginResponse(string result)
    {
        promptMsg.Change(result, Color.red);
        Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
        if (result == "登入成功")
        {
            //跳转场景 TODO
            SceneMsg msg = new SceneMsg("menu",
                                        delegate() {
                Debug.Log("场景加载完成");
            });
            //
            Dispatch(AreaCode.SCENE, SceneEvent.MENU_PLAY_SCENE, msg);
            return(true);
        }
        return(false);
        //登录错误
        //promptMsg.Change(result.ToString(), Color.red);
        //Dispatch(AreaCode.UI, UIEvent.PROMPT_MSG, promptMsg);
    }
Exemplo n.º 10
0
 /// <summary>
 ///申请好友同意与否响应
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 private bool isAgreedResonse(string result)
 {
     if (result == "agreed")
     {
         promptMsg.Change(result.ToString(), Color.green);
         Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
         Dispatch(AreaCode.UI, UIEvent.Forget_ACTIVE, false);
         Dispatch(AreaCode.UI, UIEvent.LOG_ACTIVE, true);
         return(true);
     }
     return(false);
 }
Exemplo n.º 11
0
        /// <summary>
        /// 确定按钮
        /// </summary>
        private void clickConfirm()
        {
            string money   = TransactionMoney.text;
            string address = TransferTheAddress.text;

            transferInfo.money   = System.Convert.ToDouble(money);
            transferInfo.accAddr = address;
            if (string.IsNullOrEmpty(money))
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("请输入转账金额", String.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return;
            }
            if (string.IsNullOrEmpty(address))
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("请输入钱包地址", String.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return;
            }
            Dispatch(AreaCode.UI, UIEvent.TRANSACTIONCODE_ACTIVE, transferInfo);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 商会请求加入消息
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public SocketMsg <ReqCommerceInfo> ReqComeCommerceMsg(object msg)
 {
     if (msg == null || msg.Equals(""))
     {
         //TODO提示
         promptMsg.Change("null", Color.white);
         return(null);
     }
     reqCommerceInfo.Change(null, null, msg.ToString(), null, null);
     //t.Add("commerce_name");
     //t.Add("username", PlayerPrefs.GetString("username"));
     //t.Add("token",PlayerPrefs.GetString("token"));
     messageData.Change("consumer/tree", "commerce_in", reqCommerceInfo);
     socketMsg.Change(LoginInfo.ClientId, "商会请求加入消息", messageData);
     return(socketMsg);
 }
        /// <summary>
        /// 复制邀请码
        /// </summary>
        private void clickCopyInvitationCode()
        {
            Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_CLICK_AUDIO, "ClickVoice");
#if UNITY_ANDROID
            if (!string.IsNullOrEmpty(InviteCode.text))
            {
                //"com.inode.dreamcity.SaveImageActivity"
                using (var test = new AndroidJavaObject("com.inode.dreamcity.SaveImageActivity"))
                {
                    if (test.Call <bool>("CopyText", InviteCode.text))
                    {
                        promptMsg.Change(LanguageService.Instance.GetStringByKey("复制成功", string.Empty), Color.white);
                        Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                    }
                }
            }
#endif
        }
        private void clickSearch()
        {
            Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_CLICK_AUDIO, "ClickVoice");
            nickName = inputSearch.text;
            if (string.IsNullOrEmpty(nickName))
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("search", string.Empty), Color.white);
                return;
            }
            //TODO
            //if ()
            //{

            //}
            //else
            //{
            Dispatch(AreaCode.NET, ReqEventType.searchfriend, nickName);
            //}
        }
        private void clickRegist()
        {
            phone      = inputUserName.text;
            passWord   = inputPassWord.text;
            inviteCode = inputInviteCode.text;
            nickName   = inputNickName.text;
            identify   = inputIdentify.text;
            UserInfo userinfo = new UserInfo(phone, passWord, identify, inviteCode, nickName);

            if (togAgreement.isOn)
            {
                Dispatch(AreaCode.NET, ReqEventType.regist, userinfo);
            }
            else
            {
                HintMsg hintMsg = new HintMsg();
                hintMsg.Change(LanguageService.Instance.GetStringByKey("协议", String.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, hintMsg);
            }
        }
        //    /// <summary>
        //    /// 保存Png图片
        //    /// </summary>
        //    /// <param name="texture"></param>
        //    /// <returns></returns>
        IEnumerator SaveImages(Texture2D texture, string name)
        {
            string path = Application.persistentDataPath;

            Debug.Log(path);
#if UNITY_ANDROID
            path = "/storage/emulated/0/DCIM/DreamCity"; //设置图片保存到设备的目.
#endif
            Debug.Log(path);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string savePath = $"{path}/{name}.png";
            byte[] bytex    = texture.EncodeToPNG();
            File.WriteAllBytes(savePath, bytex);
            if (savePngAndUpdate(path))
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("保存成功", string.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
            }
            yield return(new WaitForEndOfFrame());
        }
        /// <summary>
        /// 断线重连
        /// </summary>
        public IEnumerator ReConnect()
        {
            ReConnectState = true;
            while (WebData.Instance().RecTimes <= 5)
            {
                yield return(new WaitForSeconds(1));

                if (!WebData.Instance().IsReconnect)
                {
                    Debug.Log("第" + WebData.Instance().RecTimes + "次重连尝试");
                    //WebData.Instance().OpenWebSocket();
                }
                else
                {
                    ReConnectState = false;
                    break;
                }
                WebData.Instance().RecTimes += 1;
            }
            if (WebData.Instance().RecTimes > 5)
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("与服务器断开连接", string.Empty), Color.white);
                Debug.LogError("网络断开");
                //SceneMsg msg = new SceneMsg("login",
                //    delegate ()
                //    {
                //        Debug.Log("场景加载完成");
                //        Dispatch(AreaCode.UI, UIEvent.LOGINSELECT_PANEL_ACTIVE, true);
                //    });
                WebData.isLogin = false;
                //Dispatch(AreaCode.SCENE, SceneEvent.MENU_PLAY_SCENE, msg);
                StopCoroutine(ReConnect());
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                WebData.Instance().RecTimes = 0;
            }
        }
        protected internal override void Execute(int eventCode, object message)
        {
            switch (eventCode)
            {
            ////如果没有加入商会
            //case UIEvent.COMMERCE_NOJIONPANEL_ACTIVE:
            //    setPanelActive((bool)message);
            //    break;
            //加入商会
            case UIEvent.COMMERCE_PANEL_ACTIVE:
                setPanelActive((bool)message);
                LVNum.text          = CacheData.Instance().CommerceLevel.ToString();
                ConversionRate.text =
                    ConversionRate.text.Replace("rate", CacheData.Instance().ExchangeRate.ToString());
                ConversionRateText = ConversionRate.text;
                Chamber.gameObject.SetActive((bool)message);
                inputConversion.text = "";
                break;

            case UIEvent.COMMERCE_PANEL_VIEW:
                CommerceInfo memberdata = message as CommerceInfo;
                if (memberdata == null)
                {
                    throw new ArgumentNullException(nameof(memberdata));
                }
                for (int i = coreNumber; i < memberdata.members.Count; i++)
                {
                    listMyMember.Add(memberdata.members[i]);
                }
                coreNumber = memberdata.members.Count;
                //listMyMember = memberdata.members;
                count      = memberdata.num;
                memberdata = null;
                UpdataMembers();
                break;

            case UIEvent.EXCHANGECENTER_STATE_VIEW:
                //深复制缓存处理
                //listConversion.ForEach(i => CacheData.Instance().CommerceExchangeMembers.Add(i));
                // UpdateBtnState();
                //listConversion = message as List<ExchangeInfo>;
                UpdateExchangeList(message as List <ExchangeInfo>);
                break;

            case UIEvent.EXECHANGECENTER_PANEL_ACTIVE:
                setPanelActive(true);
                _exchangeInfo = message as List <ExchangeInfo>;
                foreach (var item in _exchangeInfo)
                {
                    if ((OrderState)item.state == OrderState.TOBESHIPPED)
                    {
                        // UpdateBtnState(item.orderId);
                    }
                }
                ExchangeCenterBG.SetActive(true);
                break;

            case UIEvent.EnterTradeCode_Panel_Active:
                setPanelActive(true);
                if ((bool)message)
                {
                    EnterTradeCode.SetActive(true);
                }
                else
                {
                    //Chamber.SetActive(false);
                    EnterTradeCode.SetActive(false);
                    //TopUpRequest.SetActive(true);
                    promptMsg.Change(LanguageService.Instance.GetStringByKey("ExchangeAction", String.Empty), Color.white);
                    Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                }
                break;

            case UIEvent.BusinessesAreUnderfunded_Panle_Active:
                BusinessesAreUnderfunded.SetActive(true);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// 登录响应
        /// </summary>
        private bool loginResponse(string result)
        {
            promptMsg.Change(LanguageService.Instance.GetStringByKey(result, String.Empty), Color.white);
            if (result == "200")
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("login", String.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                //跳转场景 TODO
                Dispatch(AreaCode.UI, UIEvent.LOG_ACTIVE, false);

                return(true);
            }
            else if (result == "301")
            {
                SceneManager.LoadSceneAsync("login");
            }
            Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
            return(false);
            //登录错误
            //promptMsg.Change(result.ToString(), Color.white);
            //Dispatch(AreaCode.UI, UIEvent.PROMPT_MSG, promptMsg);
        }
        /// <summary>
        /// 设置交易密码
        /// </summary>
        /// <returns></returns>
        public SocketMsg <Dictionary <string, string> > ReqExPwShopMsg(object msg)
        {
            string pass = msg.ToString();

            if (!MsgTool.CheckExPass(pass))
            {
                promptMsg.Change(LanguageService.Instance.GetStringByKey("417", string.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return(null);
            }
            Dictionary <string, string> t = new Dictionary <string, string>
            {
                ["newpwshop"] = MsgTool.MD5Encrypt(pass),
            };

            t.Add("username", PlayerPrefs.GetString("username"));
            t.Add("token", PlayerPrefs.GetString("token"));
            t.Add("playerId", PlayerPrefs.GetString("playerId"));
            messageData.Change("consumer/player", SocketEventType.ChangeShopPass, t);
            socketMsg.Change(LoginInfo.ClientId, "设置交易密码", messageData);
            return(socketMsg);
        }
        /// <summary>
        /// 密码登入消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public SocketMsg <Dictionary <string, string> > ReqPWLoginMsg(object msg)
        {
            //登入检验TODO
            LoginInfo loginInfo = msg as LoginInfo;

            if (loginInfo.UserName == "" || loginInfo.Password == "")
            {
                //promptMsg.Change("请输入用户名和密码", Color.white);
                promptMsg.Change(LanguageService.Instance.GetStringByKey("401", String.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return(null);
            }
            if (!MsgTool.CheckMobile(loginInfo.UserName))
            {
                //promptMsg.Change("请输入正确的手机号码", Color.white);
                promptMsg.Change(LanguageService.Instance.GetStringByKey("402", String.Empty), Color.white);
                Dispatch(AreaCode.UI, UIEvent.HINT_ACTIVE, promptMsg);
                return(null);
            }
            //string userpass = loginInfo.Password;
            string userpass = MsgTool.MD5Encrypt(loginInfo.Password);
            Dictionary <string, string> t = new Dictionary <string, string>
            {
                // ["IsIdentityLog"] = loginInfo.Identity,
                ["username"] = loginInfo.UserName,
                ["userpass"] = userpass,
                //["Identity"] = loginInfo.Identity
            };

            messageData.Change("consumer/player", SocketEventType.PassWordLogin, t);
            socketMsg.Change(LoginInfo.ClientId, "登入操作", messageData);
            PlayerPrefs.SetString("username", loginInfo.UserName);
            CacheData.Instance().Username = loginInfo.UserName;
            if (PlayerPrefs.HasKey("token"))
            {
                PlayerPrefs.DeleteKey("token");
            }
            return(socketMsg);
        }