protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as SettingPanelData ?? new SettingPanelData();
            // please add init code here

            if (PlayerPrefsUtil.GetDeviceId().IsNullOrEmpty())
            {
                ToggleDevice.gameObject.SetActive(false);
            }
            else
            {
                ToggleDevice.gameObject.SetActive(true);
            }
            BtnBack.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });
            BtnLogout.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                {
                    action   = TipAction.Logout,
                    message  = "确定退出登录吗?",
                    strTitle = "dola提示"
                });
            });

            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.Logout)
                {
                    // 弹窗提示,确定后,清除本地用户信息、清空list,打开login
                    CommonUtil.logout();
                }
            }).AddTo(this);
            BtnShare.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (Application.platform == RuntimePlatform.Android)
                {
                    Dictionary <string, object> param    = new Dictionary <string, object>();
                    Dictionary <string, object> subParam = new Dictionary <string, object>();
                    param.Add("target", AppConst.Share);
                    param.Add("params", subParam);
                    AndroidForUnity.CallAndroidStartActivity(param.ToJson());
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    Dictionary <string, object> paramDic = new Dictionary <string, object>();
                    Dictionary <string, object> subParam = new Dictionary <string, object>();
                    paramDic.Add("method", IOSClientUtil.SettingShare);
                    paramDic.Add("params", subParam);
                    IOSClientUtil.CommonMethodCallIOSClient(paramDic.ToJson());
                }
            });
        }
Exemple #2
0
        // Use this for initialization
        void Start()
        {
            SimpleEventSystem.GetEvent <A>()
            .Subscribe(a => Log.I("a message"));

            SimpleEventSystem.GetEvent <B>()
            .Subscribe(b => Log.I("b message"));
        }
Exemple #3
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as DeviceStatusPanelData ?? new DeviceStatusPanelData();
            Meteors.transform.DOLocalMoveX(-2370, 5f).SetLoops(-1, LoopType.Restart);
            Meteors.transform.DOLocalMoveY(-470, 5f).SetLoops(-1, LoopType.Restart);
            ResquestDeviceStatus(-1);

            BtnConnect.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <BindConfirmBootPanel>(new BindConfirmBootPanelData(), UITransitionType.CIRCLE, this);
            }).AddTo(this);

            BtnBack.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            }).AddTo(this);
            SimpleEventSystem.GetEvent <UpdateVol>()
            .Subscribe(_ =>
            {
                if (_.Message.IsNotNullAndEmpty())
                {
                    DeviceConnectStatus(true);
                    DeviceVolModel model = SerializeHelper.FromJson <DeviceVolModel>(_.Message);
                    if (model.isUpdate)
                    {
                        SliderDeviceVoice.Slider.value = model.progress;
                        TextProgress.text = string.Format("{0}%", model.progress);
                    }
                    else
                    {
                        UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                        {
                            action                = TipAction.DeviceLostControl,
                            message               = "家庭组内" + model.babyRelation + "正在控制此设备",
                            isHideCancelButton    = true,
                            removeConfirmCallback = true,
                            strConfirm            = "知道了"
                        });
                    }
                }
            }).AddTo(this);
            if (Application.platform == RuntimePlatform.Android)
            {
                AndroidForUnity.CallAndroidForQueryVol();
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                Dictionary <string, object> param    = new Dictionary <string, object>();
                Dictionary <string, object> subParam = new Dictionary <string, object>();
                param.Add("method", IOSClientUtil.QueryDeviceVolume);
                param.Add("params", subParam);
                Debug.Log("params ========" + subParam);
                IOSClientUtil.CommonMethodCallIOSClient(param.ToJson());
            }
            SliderDeviceVoice.setIOnValueChange(this);
        }
 protected override void OnInit(QFramework.IUIData uiData)
 {
     mData = uiData as FamilySettingPanelData ?? new FamilySettingPanelData();
     // please add init code here
     StartRequestForFindMemberInfo();
     BtnConfirm.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         Log.I("mFamilyId: " + mFamilyModel.id);
         if (mFamilyModel.IsNull())
         {
             CommonUtil.toast("请选择成员");
         }
         else
         {
             if (mData.type == 0)
             {
                 UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                 {
                     action  = TipAction.FamilySubtract,
                     message = "确定移除该家长?"
                 });
             }
             else
             {
                 UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                 {
                     action  = TipAction.FamilyTransfer,
                     message = "确定将管理员转让给所选对象?"
                 });
             }
         }
     });
     BtnCancel.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         Back();
     });
     SimpleEventSystem.GetEvent <TipConfirmClick>()
     .Subscribe(_ =>
     {
         if (_.GetAction == TipAction.FamilySubtract)
         {
             StartRequestForDoRejectMember();
         }
     }).AddTo(this);
     SimpleEventSystem.GetEvent <TipConfirmClick>()
     .Subscribe(_ =>
     {
         if (_.GetAction == TipAction.FamilyTransfer)
         {
             StartRequestForDoTransferManager();
         }
     }).AddTo(this);
 }
    public A()
    {
        SimpleEventSystem.GetEvent <OnAnimationDone>()
        .Subscribe(_ => {
            // ...
        });

        var b = new B();

        b.PlayAnimation();
    }
 private void Awake()
 {
     MainCamera      = transform.Find("MainCamera").GetComponent <CameraMove>();
     MasterCamera    = transform.Find("MasterCamera").GetComponent <CameraMove>();
     Master          = transform.Find("Master");
     MasterAnimation = Master.GetComponent <MasterAnimation>();
     InitItemPosition();
     SimpleEventSystem.GetEvent <CanvasCanMove>()
     .Subscribe(_ => { SetItemActive(true); }).AddTo(this);
     SimpleEventSystem.GetEvent <CanvasDotMove>()
     .Subscribe(_ => { SetItemActive(false); }).AddTo(this);
 }
Exemple #7
0
 private void Awake()
 {
     SimpleEventSystem.GetEvent <UpdateAddressDate>()
     .Subscribe(_ =>
     {
         Log.I("_.GetDate: " + _.GetIsUpdate);
         if (_.GetIsUpdate)
         {
             StartRequestForGetAddress();
         }
     }).AddTo(this);
     StartRequestForGetAddress();
 }
Exemple #8
0
        // Use this for initialization
        void Start()
        {
            SimpleEventSystem.GetEvent <A> ()
            .Subscribe(a => Log.I("a message"))
            .AddTo(this);      // 可以与 MonoBehavour 绑定生命周期,即 MonoBehaviour 销毁时,自动取消订阅。

            SimpleEventSystem.GetEvent <B> ()
            .Subscribe(b => {
                if (b.Key == "say")
                {
                    Log.I("b message");
                }
            });
        }
 protected override void OnInit(QFramework.IUIData uiData)
 {
     mData = uiData as BindCheckWIFIPanelData ?? new BindCheckWIFIPanelData();
     BtnBack.OnClickAsObservable().Subscribe(_ =>
     {
         AudioManager.PlaySound("Button_Audio");
         Back();
     }).AddTo(this);
     BtnDetermineWiFi.OnClickAsObservable().Subscribe(_ =>
     {
         AudioManager.PlaySound("Button_Audio");
         Back();
     }).AddTo(this);
     SimpleEventSystem.GetEvent <CloseBindCheckWIFI>().Subscribe(_ => { Back(); }).AddTo(this);
 }
 protected override void OnInit(QFramework.IUIData uiData)
 {
     mData = uiData as AddressListPanelData ?? new AddressListPanelData();
     // please add init code here
     BtnBack.onClick.AddListener(() => { Back(); });
     StartRequestForGetAddress();
     SimpleEventSystem.GetEvent <UpdateAddressDate>()
     .Subscribe(_ =>
     {
         Log.I("_.GetDate: " + _.GetIsUpdate);
         if (_.GetIsUpdate)
         {
             StartRequestForGetAddress();
         }
     }).AddTo(this);
 }
Exemple #11
0
 void Start()
 {
     GetComponent <Button>().onClick.AddListener(ButtonClick);
     mAnimator = GetComponent <Animator>();
     IsBig.Subscribe(_ =>
     {
         if (IsBig.Value)
         {
             mAnimator.Play("ItemClickAnimation", 0, 0f);
         }
         else
         {
             mAnimator.Play("NarrowAnimation", 0, 0f);
         }
     });
     SimpleEventSystem.GetEvent <ListItemButton>().Subscribe(_ => { IsBig.Value = false; }).AddTo(this);
 }
Exemple #12
0
 private void Awake()
 {
     BtnClearCache.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         UIMgr.OpenPanel <TipPanel>(new TipPanelData()
         {
             action   = TipAction.ClearCache,
             message  = "本操作将会清除下载的图片视频音频内容",
             strTitle = "清除缓存提示"
         });
     });
     SimpleEventSystem.GetEvent <TipConfirmClick>()
     .Subscribe(_ =>
     {
         if (_.GetAction == TipAction.ClearCache)
         {
             if (Application.platform == RuntimePlatform.Android)
             {
                 NativeGallery.GetSomethingFromNative((json, action) =>
                 {
                     TextCache.text = "0KB";
                     CommonUtil.toast("清除缓存成功");
                 }, (int)NativeAction.ClearCache);
             }
             else if (Application.platform == RuntimePlatform.IPhonePlayer)
             {
                 IOSClientUtil.ClearCacheCallIOSClient();
                 TextCache.text = "0KB";
                 CommonUtil.toast("清除缓存成功");
             }
         }
     }).AddTo(this);
     if (Application.platform == RuntimePlatform.Android)
     {
         NativeGallery.GetSomethingFromNative((json, action) => { TextCache.text = json; }, (int)NativeAction.Cache);
     }
     else if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         NativeGallery.GetSomethingFromIPhone(res => { TextCache.text = res; }, 5);
     }
 }
Exemple #13
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as CreateOrderPanelData ?? new CreateOrderPanelData();
            ShowOrderORCreatOrder();
            BtnBack.onClick.AddListener(() => { Back(); });
            BtnPlusAddress.OnClickAsObservable().Subscribe(_ =>
            {
                UIMgr.OpenPanel <AddressEditPanel>(new AddressEditPanelData(), UITransitionType.CIRCLE);
            }).AddTo(this);
            BtnEditAddress.OnClickAsObservable().Subscribe(_ =>
            {
                UIMgr.OpenPanel <AddressListPanel>(new AddressListPanelData(), UITransitionType.CIRCLE);
            }).AddTo(this);

            BtnConfirm.OnClickAsObservable().Subscribe(_ =>
            {
                if (!IsCreatingOrder)
                {
                    RequestCreatOrder();
                }
            }).AddTo(this);

            SimpleEventSystem.GetEvent <ExchangeOrderAddress>().Subscribe(exchangeOrderAddress =>
            {
                AddressInfoData(exchangeOrderAddress.AddressInfo);
            }).AddTo(this);

            SimpleEventSystem.GetEvent <UpdateAddressDate>().Subscribe(result =>
            {
                RequestAddressList();
            }).AddTo(this);

            SimpleEventSystem.GetEvent <CollectGiftBoxPanelClosed>().Subscribe(res =>
            {
                if (res.CollectGiftBoxType == CollectGiftBoxType.Exchange)
                {
                    ShowOrderORCreatOrder();
                }
            }).AddTo(this);
        }
Exemple #14
0
 private void Awake()
 {
     if (PlayerPrefsUtil.GetDeviceId().IsNullOrEmpty())
     {
         BtnUnbind.gameObject.SetActive(true);
     }
     else
     {
         TextID.text = PlayerPrefsUtil.GetDeviceId();
         StartResquestForCheckDeviceVersion();
         StartResquestForGetDeviceStatus();
         BtnUnbind.gameObject.SetActive(true);
     }
     if (Application.platform == RuntimePlatform.Android)
     {
         NativeGallery.GetSomethingFromNative((json, action1) => { TextAppVersion.text = json; }, (int)NativeAction.Version);
     }
     else if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         NativeGallery.GetSomethingFromIPhone(res => { TextAppVersion.text = res; }, 2);
     }
     BtnUnbind.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         UIMgr.OpenPanel <TipPanel>(new TipPanelData()
         {
             action   = TipAction.Unbind,
             message  = "确定解除绑定 Dola 设备吗?\n解绑后,将删除此设备的历史学习记录",
             strTitle = "解绑提示"
         });
     });
     SimpleEventSystem.GetEvent <TipConfirmClick>()
     .Subscribe(_ =>
     {
         if (_.GetAction == TipAction.Unbind)
         {
             StartResquestForUnbind();
         }
     }).AddTo(this);
 }
        //ItemFamily

        private void Awake()
        {
            SimpleEventSystem.GetEvent <UpdateUserDate>()
            .Subscribe(_ =>
            {
                Log.I("_.GetDate: " + _.GetIsUpdate);
                if (_.GetIsUpdate)
                {
                    InitData();
                }
            }).AddTo(this);

            SimpleEventSystem.GetEvent <UpdateBaseInfoDate>()
            .Subscribe(_ =>
            {
                Log.I("_.GetDate: " + _.GetIsUpdate);
                if (_.GetIsUpdate)
                {
                    InitData();
                }
            }).AddTo(this);
            mToggleGroup = GetComponentInChildren <ToggleGroup>();
            InitData();
        }
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as AttendanceSharePanelData ?? new AttendanceSharePanelData();
            // please add init code here
            BtnBack.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });
            // ImageDownloadUtils.Instance.SetAsyncImage("http://test.i.hqkid.cn/robot-mobile/api/file/babypunch/2020/05/14/1589450722841.jpg", ImageContent);
            mTexture2DHBoy  = mResLoader.LoadSync <Texture2D>("ic_head_boy");
            mTexture2DHGirl = mResLoader.LoadSync <Texture2D>("ic_head_girl");
            UserInfoModel userInfoModel = PlayerPrefsUtil.UserInfo;

            if (userInfoModel.babyInfoVo.babyLogoUrl.IsNotNullAndEmpty())
            {
                ImageDownloadUtils.Instance.SetAsyncImage(userInfoModel.babyInfoVo.babyLogoUrl, ImageHead);
            }
            else if (userInfoModel.babyInfoVo.sex == 1)
            {
                ImageHead.sprite = Sprite.Create(mTexture2DHBoy,
                                                 new Rect(0, 0, mTexture2DHBoy.width, mTexture2DHBoy.height), Vector2.one * 0.5f);
            }
            else if (userInfoModel.babyInfoVo.sex == 2)
            {
                ImageHead.sprite = Sprite.Create(mTexture2DHGirl,
                                                 new Rect(0, 0, mTexture2DHGirl.width, mTexture2DHGirl.height), Vector2.one * 0.5f);
            }
            TextName.text   = userInfoModel.babyInfoVo.name;
            mTexture2DAudio = mResLoader.LoadSync <Texture2D>("ic_share_audio");
            mTexture2DVideo = mResLoader.LoadSync <Texture2D>("ic_share_video");
            String subjectPicName = "ic_share_qiangguo";

            if (mData.AttendanceModel.subject == 0)
            {
                subjectPicName = "ic_share_qiangguo";
            }
            else if (mData.AttendanceModel.subject == 1)
            {
                subjectPicName = "ic_share_english";
            }
            else if (mData.AttendanceModel.subject == 2)
            {
                subjectPicName = "ic_share_chinese";
            }
            mTexture2DSubject   = mResLoader.LoadSync <Texture2D>(subjectPicName);
            ImageSubject.sprite = Sprite.Create(mTexture2DSubject,
                                                new Rect(0, 0, mTexture2DSubject.width, mTexture2DSubject.height), Vector2.one * 0.5f);
            if (mData.AttendanceModel.punchType == 0)
            {
                ImageDownloadUtils.Instance.SetAsyncImage(mData.AttendanceModel.punchPath, ImageContent);
            }
            else if (mData.AttendanceModel.punchType == 1)
            {
                ImageContent.sprite = Sprite.Create(mTexture2DAudio,
                                                    new Rect(0, 0, mTexture2DAudio.width, mTexture2DAudio.height), Vector2.one * 0.5f);
            }
            else if (mData.AttendanceModel.punchType == 2)
            {
                ImageContent.sprite = Sprite.Create(mTexture2DVideo,
                                                    new Rect(0, 0, mTexture2DVideo.width, mTexture2DVideo.height), Vector2.one * 0.5f);
            }
            TextContent.text = mData.AttendanceModel.punchText;
            TextCount.text   = mData.AttendanceModel.finishPunchNum.ToString();
            if (mData.AttendanceModel.score != 0)
            {
                CommonUtil.toast("打卡成功+" + mData.AttendanceModel.score + "积分");
            }

            BtnSaveAlbum.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                StartResquestForSharePoster(ShareAction.Save);
            });
            BtnShareWechat.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                StartResquestForSharePoster(ShareAction.Wechat);
            });
            BtnShareWechatMoments.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                StartResquestForSharePoster(ShareAction.WechatMoments);
            });

            SimpleEventSystem.GetEvent <ShareResult>().Subscribe(res =>
            {
                //1成功2失败3取消
                string status = res.Status;
                if ("1".Equals(status))
                {
                    if (mData.AttendanceModel.isShare == 0)
                    {
                        CommonUtil.toast("分享成功+" + mData.AttendanceModel.shareScore + "积分");
                        mData.AttendanceModel.isShare = 1;
                    }
                    StartResquestForAddRecord();
                }
                else if ("2".Equals(status))
                {
                }
                else if ("3".Equals(status))
                {
                }
            }).AddTo(this);
        }
Exemple #17
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as BookDayListPanelData ?? new BookDayListPanelData();
            PlayerPrefsUtil.SelectPlanId = mData.PlanId;
            string prefabName = "LionPrefab";
            string BGMusic    = "XXQG_BG_Music";

            if (PlayerPrefsUtil.ContentModel.planId == 100099)
            {
                prefabName = "TongtongPrefab";
                BGMusic    = "XXQG_BG_Music";
            }
            else if (PlayerPrefsUtil.ContentModel.subject == 2)
            {
                prefabName = "LionPrefab";
                BGMusic    = "CN_BG_Music";
            }
            else if (PlayerPrefsUtil.ContentModel.subject == 1)
            {
                prefabName = "DinoPrefab";
                BGMusic    = "EN_BG_Music";
            }
            AudioManager.SetMusicOn();
            AudioManager.PlayMusic(BGMusic);
            if (mData.Month != 0)
            {
                PlayerPrefsUtil.SaveBoxMonthIndex(mData.Month - 1);
            }
            // 3
            if (PlayerPrefsUtil.ContentModel.boxList.Count <= PlayerPrefsUtil.GetBoxMonthIndex())
            {
                PlayerPrefsUtil.SaveBoxMonthIndex(0);
            }
            var boxMonthIndex = PlayerPrefsUtil.GetBoxMonthIndex();

            Log.I("boxMonthIndex: " + boxMonthIndex);
            BoxModel = PlayerPrefsUtil.ContentModel.boxList[boxMonthIndex];
            Log.I("BoxModel.name: " + BoxModel.name);

            TvTitle.text = BoxModel.name;
            if (prefabName.IsNullOrEmpty())
            {
                CommonUtil.toast("prefabName为空");
            }
            mPlayer = mResLoader.LoadSync <GameObject>(prefabName)
                      .Instantiate()
                      .transform
                      .Identity()
                      .ApplySelfTo(self =>
            {
                self.GetComponent <MasterController>().SetData(BoxModel);
            })
                      .gameObject;
            BtnTitle.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                BookMonthObj.IsShow.Value = !BookMonthObj.IsShow.Value;
            });
            BookMonthObj.transform.localPosition = new Vector3(0, GetFixed(Screen.height));
            BtnBookMonthBack.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                BookMonthObj.IsShow.Value = !BookMonthObj.IsShow.Value;
            });
            BtnTarget.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <TargetDetailPanel>(new TargetDetailPanelData()
                {
                    BoxModel = BoxModel
                }, UITransitionType.CIRCLE, this);
            });
            BtnVideo.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <ListItemPanel>(new ListItemPanelData()
                {
                    FunTag = ItemType.VIDEO
                }, UITransitionType.CIRCLE, this);
            });
            BtnAudio.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <ListItemPanel>(new ListItemPanelData()
                {
                    FunTag = ItemType.AUDIO
                }, UITransitionType.CIRCLE, this);
            });
            BtnBook.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <ListItemPanel>(new ListItemPanelData()
                {
                    FunTag = ItemType.PICBOOK
                }, UITransitionType.CIRCLE, this);
            });
            SimpleEventSystem.GetEvent <CanvasAnimationFinish>().Subscribe(_ =>
            {
                UIMgr.OpenPanel <BookDayPanel>(new BookDayPanelData()
                {
                    BoxDayDetailModel = mPlayer.GetComponent <MasterController>().SelectDayDetailModel
                }, UITransitionType.CIRCLE, this);
            }).AddTo(this);
            BtnBookDayListBack.onClick.AddListener(() => { AudioManager.PlaySound("Button_Audio"); Back(); });
            Observable.EveryUpdate().Where(_ => Input.GetKeyDown(KeyCode.Escape))
            .Subscribe(_ =>
            {
                if (BookMonthObj.IsShow.Value)
                {
                    BookMonthObj.IsShow.Value = false;
                    return;
                }
                Back();
            }).AddTo(this);
            BookMonthObj.UpdateItemDate();
        }
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as ConnectDevicePanelData ?? new ConnectDevicePanelData();
            Meteors.transform.DOLocalMoveX(-2370, 5f).SetLoops(-1, LoopType.Restart);
            Meteors.transform.DOLocalMoveY(-470, 5f).SetLoops(-1, LoopType.Restart);

            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("ssid", mData.SSIDStr);
            param.Add("password", mData.SSIDPWD);
            param.Add("token", PlayerPrefsUtil.GetToken());
            param.Add("userId", PlayerPrefsUtil.GetUserId());
            if (Application.platform == RuntimePlatform.Android)
            {
                AndroidForUnity.CallAndroidForStartDeviceConnect(mData.SSIDStr, mData.SSIDPWD);
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                IOSClientUtil.StartBindDevice(param.ToJson());
            }

            StartCoroutine(CountDown());

            BtnBack.OnClickAsObservable().Subscribe(_ =>
            {
                UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                {
                    action     = TipAction.BindingBack,
                    message    = "返回后联网将不在继续,确认终止操作?",
                    strConfirm = "确定",
                    strCancel  = "继续等待",
                    strTitle   = "终止配网",
                });
            }).AddTo(this);

            BtnCheckWiFi.OnClickAsObservable().Subscribe(_ =>
            {
                UIMgr.OpenPanel <BindCheckWIFIPanel>(new BindCheckWIFIPanelData(), UITransitionType.NULL);
            }).AddTo(this);

            SimpleEventSystem.GetEvent <BindDeviceResult>().Subscribe(res =>
            {
                BindDeviceModel model = res.Model;

                if (Application.platform == RuntimePlatform.Android)
                {
                    if (model.status == 1)
                    {
                        StartResquestForBind(model.deviceId);
                    }
                    else
                    {
                        ConnectResult(false);
                    }
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    if (model.requestTag == 2 && model.deviceId.IsNotNullAndEmpty())
                    {
                        StartResquestForBind(model.deviceId);
                    }

                    if (model.requestTag == 1)
                    {
                        CommonUtil.toast("获取音频接口出错");
                    }
                }
            }).AddTo(this);

            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.BindDevice)
                {
                    ShowMainPanel();
                }
                else if (_.GetAction == TipAction.BindingBack)
                {
                    StopAllCoroutines();
                    if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        IOSClientUtil.StopBindDevice("");
                    }
                    else if (Application.platform == RuntimePlatform.Android)
                    {
                        AndroidForUnity.CallAndroidForStopDeviceConnect();
                    }
                    Back();
                }
            }).AddTo(this);
        }
Exemple #19
0
 protected override void OnInit(QFramework.IUIData uiData)
 {
     mData = uiData as AttendanceMainPanelData ?? new AttendanceMainPanelData();
     BtnBack.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         Back();
     });
     BtnPicture.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         UIMgr.OpenPanel <ChoosePhotoPanel>(new ChoosePhotoPanelData()
         {
             action = ChoosePhotoAction.AttendancePic,
         });
     });
     BtnAudio.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         if (Application.platform == RuntimePlatform.Android)
         {
             NativeGallery.RequestPermission((result, action) =>
             {
                 if (result == (int)NativeGallery.Permission.Granted)
                 {
                     UIMgr.OpenPanel <AttendanceAudioRecordPanel>(new AttendanceAudioRecordPanelData(), UITransitionType.CIRCLE);
                 }
             }, (int)NativeAction.Audio);
         }
         else
         {
             UIMgr.OpenPanel <AttendanceAudioRecordPanel>(new AttendanceAudioRecordPanelData(), UITransitionType.CIRCLE);
         }
     })
     ;
     BtnVideo.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         // UIMgr.OpenPanel<ChoosePhotoPanel>(new ChoosePhotoPanelData()
         // {
         //     action = ChoosePhotoAction.AttendanceVideo,
         //     showTip = true
         // });
         if (Application.platform == RuntimePlatform.IPhonePlayer)
         {
             IPhonePlayerMakeVideoOpenCamera();
         }
         else if (Application.platform == RuntimePlatform.Android)
         {
             NativeGallery.RequestPermission((result, action) =>
             {
                 if (result == (int)NativeGallery.Permission.Granted)
                 {
                     NativeGallery.GetVideoFromGalleryForAndroid((json) =>
                     {
                         if (json.IsNotNullAndEmpty())
                         {
                             NativeVideoModel model = SerializeHelper.FromJson <NativeVideoModel>(json);
                             if (model.IsNotNull())
                             {
                                 if (model.status == 1)
                                 {
                                     UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
                                     {
                                         BoxId         = mData.BoxId,
                                         BoxDay        = mData.BoxDay,
                                         Path          = model.videoPath,
                                         ThumbnailPath = model.imagePath,
                                         Action        = AttendanceAdd.Video,
                                     }, UITransitionType.CIRCLE);
                                     Close();
                                 }
                             }
                         }
                     }, "选择视频", "video/*", action);
                 }
             }, (int)NativeAction.Camera);
         }
     });
     SimpleEventSystem.GetEvent <RecordPath>().Subscribe(Path =>
     {
         UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
         {
             BoxId  = mData.BoxId,
             BoxDay = mData.BoxDay,
             Action = AttendanceAdd.Audio,
             Path   = Path.Path
         }, UITransitionType.CIRCLE);
         Close();
     }).AddTo(this);
     SimpleEventSystem.GetEvent <ChoosePhotoClick>()
     .Subscribe(_ =>
     {
         if (_.GetPhotoAction == ChoosePhotoAction.AttendancePic)
         {
             if (Application.platform == RuntimePlatform.IPhonePlayer)
             {
                 if (_.GetAction == NativeAction.Camera)
                 {
                     IPhonePlayerSelectPictureOpenCamera();
                 }
                 else if (_.GetAction == NativeAction.Album)
                 {
                     IPhonePlayerSelectPictureOpenAlbum();
                 }
                 else
                 {
                 }
             }
             else if (Application.platform == RuntimePlatform.Android)
             {
                 NativeGallery.RequestPermission((result, action) =>
                 {
                     if (result == (int)NativeGallery.Permission.Granted)
                     {
                         NativeGallery.GetImageFromGalleryForAndroid((path) =>
                         {
                             if (path.IsNotNullAndEmpty())
                             {
                                 UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
                                 {
                                     BoxId         = mData.BoxId,
                                     BoxDay        = mData.BoxDay,
                                     Path          = path,
                                     ThumbnailPath = path,
                                     Action        = AttendanceAdd.Pic
                                 }, UITransitionType.CIRCLE);
                                 Close();
                             }
                             Debug.Log("Image path: " + path);
                         }, "选择图片", "image/*", true, action);
                     }
                 }, (int)_.GetAction);
             }
         }
         // 视频不需要了
         else if (_.GetPhotoAction == ChoosePhotoAction.AttendanceVideo)
         {
             if (Application.platform == RuntimePlatform.IPhonePlayer)
             {
                 if (_.GetAction == NativeAction.Album)
                 {
                     IPhonePlayerSelectVideoOpenAlbum();
                 }
                 else if (_.GetAction == NativeAction.Camera)
                 {
                     IPhonePlayerMakeVideoOpenCamera();
                 }
             }
             else if (Application.platform == RuntimePlatform.Android)
             {
                 NativeGallery.RequestPermission((result, action) =>
                 {
                     if (result == (int)NativeGallery.Permission.Granted)
                     {
                         NativeGallery.GetVideoFromGalleryForAndroid((json) =>
                         {
                             if (json.IsNotNullAndEmpty())
                             {
                                 NativeVideoModel model = SerializeHelper.FromJson <NativeVideoModel>(json);
                                 if (model.IsNotNull())
                                 {
                                     if (model.status == 1)
                                     {
                                         UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
                                         {
                                             BoxId         = mData.BoxId,
                                             BoxDay        = mData.BoxDay,
                                             Path          = model.videoPath,
                                             ThumbnailPath = model.imagePath,
                                             Action        = AttendanceAdd.Video,
                                         }, UITransitionType.CIRCLE);
                                         Close();
                                     }
                                 }
                             }
                         }, "选择视频", "video/*", action);
                     }
                 }, (int)_.GetAction);
             }
         }
     }).AddTo(this);
 }
Exemple #20
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData        = uiData as BaByInfoPanelData ?? new BaByInfoPanelData();
            mData.IsEdit = mData.BabyInfoModel.IsNotNull();
            BtnBack.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });

            // please add init code here
            InputName.onValueChange.AddListener(Change);
            mTexture2DSel    = mResLoader.LoadSync <Texture2D>("btn_code_sel");
            mTexture2DNor    = mResLoader.LoadSync <Texture2D>("btn_code_nor");
            mTexture2DSexSel = mResLoader.LoadSync <Texture2D>("bg_sex_sel");
            mTexture2DSexNor = mResLoader.LoadSync <Texture2D>("bg_sex_nor");
            SimpleEventSystem.GetEvent <SelectPickDate>()
            .Subscribe(_ =>
            {
                Log.I(_.GetDate);
                mBirthday         = _.GetDate;
                mIsChooseBirthday = true;
                TextBirthday.text = _.GetDate;
                Color nowColor;
                ColorUtility.TryParseHtmlString("#3E3E3F", out nowColor);
                TextBirthday.color = nowColor;
            }).AddTo(this);

            SimpleEventSystem.GetEvent <BabyPhoto>()
            .Subscribe(_ =>
            {
                Log.I(_.GetPath);
                // mBabyHead = _.GetPath;
                // ImageDownloadUtils.Instance.SetAsyncImage("file://" + mBabyHead, ImgBabyHead, false);
            }).AddTo(this);

            SimpleEventSystem.GetEvent <ChoosePhotoClick>()
            .Subscribe(_ =>
            {
                Log.I("_.GetPhotoAction: " + _.GetPhotoAction + " _.GetAction: " + _.GetAction);
                if (_.GetPhotoAction == ChoosePhotoAction.Baby)
                {
                    PickImage(_.GetAction);
                }
            }).AddTo(this);

            OnClickListener();
            if (mData.IsEdit)
            {
                ImageDownloadUtils.Instance.SetAsyncImage(mData.BabyInfoModel.babyLogoUrl, ImgBabyHead);
                InputName.text    = mData.BabyInfoModel.name;
                mBirthday         = mData.BabyInfoModel.birthday;
                TextBirthday.text = mData.BabyInfoModel.birthday;
                Color nowColor;
                ColorUtility.TryParseHtmlString("#3E3E3F", out nowColor);
                TextBirthday.color = nowColor;
                if (mData.BabyInfoModel.sex == 1)
                {
                    BtnBoy.onClick.Invoke();
                }
                else
                {
                    BtnGirl.onClick.Invoke();
                }
                BtnBabyConfirm.enabled      = true;
                BtnBabyConfirm.image.sprite = Sprite.Create(mTexture2DNor,
                                                            new Rect(0, 0, mTexture2DNor.width, mTexture2DNor.height), Vector2.one * 0.5f);
            }
        }
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as BookDayPanelData ?? new BookDayPanelData();
            BtnBack.onClick.AddListener(() => { AudioManager.PlaySound("Button_Audio"); Back(); });
            ImageDownloadUtils.Instance.SetAsyncImage(mData.BoxDayDetailModel.thumbUrl, ImgDay);
            TvDayNum.text = "第" + mData.BoxDayDetailModel.day + "天";
            TvTitle.text  = mData.BoxDayDetailModel.topic;
            mData.BoxDayDetailModel.boxDayActionList.ForEach(DayActionModel =>
            {
                mResLoader.LoadSync <GameObject>("ItemTypeAction")
                .Instantiate()
                .transform
                .LocalIdentity()
                .Parent(Content)
                .LocalScale(1, 1, 1)
                .ApplySelfTo(game =>
                {
                    Button button         = game.Find("ItemType").GetComponent <Button>();
                    string actionIconName = GetActionIconName(DayActionModel.action);
                    var texture2D         = mResLoader.LoadSync <Texture2D>(actionIconName);
                    button.GetComponent <Image>().sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                    button.OnClickAsObservable().Subscribe(_ =>
                    {
                        OnClick(game, DayActionModel);
                    }).AddTo(this);

                    Text actionName = game.transform.Find("Image").Find("Text").GetComponent <Text>();
                    actionName.text = DayActionModel.name;
                })
                .Show();
            });
            BtnAttendance.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList.IsNotNull() &&
                    PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList
                    .Contains(mData.BoxDayDetailModel.day))
                {
                    UIMgr.OpenPanel <WorksWallPanel>(new WorksWallPanelData()
                    {
                        BoxId  = mData.BoxDayDetailModel.boxId,
                        BoxDay = mData.BoxDayDetailModel.day
                    }, UITransitionType.CIRCLE);
                }
                else
                {
                    //mData.BoxDayDetailModel
                    UIMgr.OpenPanel <AttendanceMainPanel>(new AttendanceMainPanelData()
                    {
                        BoxId  = mData.BoxDayDetailModel.boxId,
                        BoxDay = mData.BoxDayDetailModel.day
                    }, UITransitionType.CIRCLE);
                }
            });
            if (PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList != null && PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList.Contains(mData.BoxDayDetailModel.day)) // 已打卡
            {
                var texture2D = mResLoader.LoadSync <Texture2D>("btn_attendance_sel");
                BtnAttendance.image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
            }
            else
            {
                var texture2D = mResLoader.LoadSync <Texture2D>("btn_attendance_nor");
                BtnAttendance.image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
            }

            SimpleEventSystem.GetEvent <AttendanceSuccess>()
            .Subscribe(_ =>
            {
                if (PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList != null && PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList.Contains(mData.BoxDayDetailModel.day))     // 已打卡
                {
                    var texture2D = mResLoader.LoadSync <Texture2D>("btn_attendance_sel");
                    BtnAttendance.image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                }
                else
                {
                    var texture2D = mResLoader.LoadSync <Texture2D>("btn_attendance_nor");
                    BtnAttendance.image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                }
            }).AddTo(this);
        }
Exemple #22
0
 private void Awake()
 {
     BtnConfirm.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         if (Application.platform == RuntimePlatform.Android)
         {
             NativeGallery.GetSomethingFromNative((json, action1) =>
             {
                 if (json.IsNotNullAndEmpty())
                 {
                     AppInfo model = SerializeHelper.FromJson <AppInfo>(json);
                     StartResquestForAddFeedBack(model.version, model.build, "2");
                 }
                 else
                 {
                     StartResquestForAddFeedBack("未知", 0, "2");
                 }
             }, (int)NativeAction.VersionJson);
         }
         else if (Application.platform == RuntimePlatform.IPhonePlayer)
         {
             string version = Application.version;
             NativeGallery.GetSomethingFromIPhone(res =>
             {
                 StartResquestForAddFeedBack(version, res.ToInt(), "1");
             }, 4);
         }
         else
         {
             StartResquestForAddFeedBack("未知", 0, "0");
         }
     });
     BtnDel.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         if (mPhotoPath.IsNotNullAndEmpty())
         {
             UIMgr.OpenPanel <TipPanel>(new TipPanelData()
             {
                 action  = TipAction.FeedBackDel,
                 message = "确定要删除当前图片吗?"
             });
         }
     });
     SimpleEventSystem.GetEvent <TipConfirmClick>()
     .Subscribe(_ =>
     {
         if (_.GetAction == TipAction.FeedBackDel)
         {
             mPhotoPath      = "";
             ImgPhoto.sprite = Sprite.Create(texture2DAddPhoto, new Rect(0, 0, texture2DAddPhoto.width, texture2DAddPhoto.height), Vector2.one * 0.5f);
             BtnDel.gameObject.SetActive(false);
         }
     }).AddTo(this);
     BtnAddPhoto.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         ChoosePic(ChoosePhotoAction.FeedBack);
     });
     InputContent.onValueChange.AddListener(ChangeInput);
     SimpleEventSystem.GetEvent <ChoosePhotoClick>()
     .Subscribe(_ =>
     {
         Log.I("_.GetPhotoAction: " + _.GetPhotoAction + " _.GetAction: " + _.GetAction);
         if (_.GetPhotoAction == ChoosePhotoAction.FeedBack)
         {
             PickImage(_.GetAction);
         }
     }).AddTo(this);
     texture2DSel            = mResLoader.LoadSync <Texture2D>("btn_code_sel");
     texture2DNor            = mResLoader.LoadSync <Texture2D>("btn_code_nor");
     texture2DAddPhoto       = mResLoader.LoadSync <Texture2D>("btn_add_photo");
     BtnConfirm.image.sprite = Sprite.Create(texture2DSel, new Rect(0, 0, texture2DSel.width, texture2DSel.height), Vector2.one * 0.5f);
     BtnConfirm.enabled      = false;
 }
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData       = uiData as AddressEditPanelData ?? new AddressEditPanelData();
            mData.IsAdd = mData.AddressInfo.IsNull();
            BtnBack.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });
            if (mData.IsAdd)
            {
                BtnDelete.gameObject.SetActive(false);
            }

            if (!mData.IsAdd)
            {
                InpAddressDetail.text  = mData.AddressInfo.consigneeAddress;
                InpName.text           = mData.AddressInfo.consignee;
                InpMobile.text         = mData.AddressInfo.consigneeMobile;
                TextAddress.text       = mData.AddressInfo.provinceName + mData.AddressInfo.cityName + mData.AddressInfo.areaName;
                TextAddress.color      = Color.black;
                selectAddress          = new ProvinceModel();
                selectAddress.code     = mData.AddressInfo.provinceCode;
                selectAddress.name     = mData.AddressInfo.provinceName;
                selectAddress.cityCode = mData.AddressInfo.cityCode;
                selectAddress.cityName = mData.AddressInfo.cityName;
                selectAddress.areaCode = mData.AddressInfo.areaCode;
                selectAddress.areaName = mData.AddressInfo.areaName;
                if (mData.AddressInfo.isDefault == 1)
                {
                    Toggle.isOn = true;
                }
                else
                {
                    Toggle.isOn = false;
                }
            }
            BtnAddress.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <AddressPickerPanel>(new AddressPickerPanelData()
                {
                    selectAddress = selectAddress
                });
            });
            BtnDelete.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                {
                    action  = TipAction.AddressDel,
                    message = "确定要删除该地址吗?"
                });
            });
            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.AddressDel)
                {
                    StartResquestForDelBabyAddress();
                }
            }).AddTo(this);
            BtnCommit.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                StartResquestForAddOrEditAddress();
            });
            Toggle.onValueChanged.AddListener(ison =>
            {
                AudioManager.PlaySound("Button_Audio");
            });

            SimpleEventSystem.GetEvent <SelectAddressDate>()
            .Subscribe(_ =>
            {
                Log.I("_.GetDate: " + _.GetDate);
                if (_.IsNotNull() && _.GetDate.IsNotNull())
                {
                    this.selectAddress = _.GetDate;
                    TextAddress.text   = selectAddress.name + selectAddress.cityName + selectAddress.areaName;
                    TextAddress.color  = Color.black;
                }
            }).AddTo(this);
        }
Exemple #24
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as MedalSharePanelData ?? new MedalSharePanelData();

            TextDays.text      = String.Format("连续{0}日", mData.medalModel.medalDays.ToString());
            TextMedalName.text = String.Format("\"{0}勋章\"", mData.medalModel.medalName);
            TextName.text      = PlayerPrefsUtil.UserInfo.babyInfoVo.name;

            Texture2D mTexture2DHBoy  = mResLoader.LoadSync <Texture2D>("ic_head_boy");
            Texture2D mTexture2DHGirl = mResLoader.LoadSync <Texture2D>("ic_head_girl");

            if (PlayerPrefsUtil.UserInfo.babyInfoVo.babyLogoUrl.IsNotNullAndEmpty())
            {
                ImageDownloadUtils.Instance.SetAsyncImage(PlayerPrefsUtil.UserInfo.babyInfoVo.babyLogoUrl, ImageUserIcon);
            }
            else if (PlayerPrefsUtil.UserInfo.babyInfoVo.sex == 1)
            {
                ImageUserIcon.sprite = Sprite.Create(mTexture2DHBoy,
                                                     new Rect(0, 0, mTexture2DHBoy.width, mTexture2DHBoy.height), Vector2.one * 0.5f);
            }
            else if (PlayerPrefsUtil.UserInfo.babyInfoVo.sex == 2)
            {
                ImageUserIcon.sprite = Sprite.Create(mTexture2DHGirl,
                                                     new Rect(0, 0, mTexture2DHGirl.width, mTexture2DHGirl.height), Vector2.one * 0.5f);
            }
            TextStudyDayNum.text = mData.medalModel.medalDays.ToString();

            // please add init code here
            BtnBack.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            }).AddTo(this);
            if (mData.medalModel.isDraw != 1)
            {
                CommonUtil.toast("领取成功+" + mData.medalModel.medalScore + "积分");
            }

            BtnSaveAlbum.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("保存到相册-------");
                // Rect mRect = ImgContent.transform.GetComponent<RectTransform>().rect;
                // this.ScreenShot(mRect);
                StartResquestForSharePoster(ShareAction.Save);
            }).AddTo(this);

            BtnShareWeChatSession.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                StartResquestForSharePoster(ShareAction.Wechat);
                Debug.Log("分享到微信");
            }).AddTo(this);

            BtnShareWeChatTimeLine.OnClickAsObservable().Subscribe(_ =>
            { //WechatMoments
                AudioManager.PlaySound("Button_Audio");
                StartResquestForSharePoster(ShareAction.WechatMoments);
                Debug.Log("分享到朋友圈");
            }).AddTo(this);
            SimpleEventSystem.GetEvent <ShareResult>().Subscribe(res =>
            {
                //1成功2失败3取消
                string status = res.Status;
                if ("1".Equals(status))
                {
                    if (mData.medalModel.isShare == 0)
                    {
                        CommonUtil.toast("分享成功+" + mData.medalModel.medalShareScore + "积分");
                        mData.medalModel.isShare = 1;
                    }
                    StartResquestForAddRecord();
                }
                else if ("2".Equals(status))
                {
                }
                else if ("3".Equals(status))
                {
                }
            }).AddTo(this);
        }
Exemple #25
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as BindWIFIMessagePanelData ?? new BindWIFIMessagePanelData();

            if (Application.platform == RuntimePlatform.Android)
            {
                NativeGallery.RequestPermission((result, action) =>
                {
                    isSendMessage = true;
                    Log.I("RequestPermission: " + result);
                    if (result == (int)NativeGallery.Permission.Granted)
                    {
                        // InvokeRepeating("GetWifiInfo",1,1); 可以实时更新wifi,但无法修改wifi密码,暂时舍弃
                        NativeGallery.GetSomethingFromNative((json, action1) =>
                        {
                            if (json.IsNotNullAndEmpty())
                            {
                                isSSIDContains5G(json);
                                InputFieldSSID.text = json;
                                string pwd          = PlayerPrefsUtil.GetWiFiPWD(json);
                                if (pwd.IsNotNullAndEmpty())
                                {
                                    InputFieldPWD.text = pwd;
                                }
                                else
                                {
                                    InputFieldPWD.text = string.Empty;
                                }
                            }
                            Log.I("GetSomethingFromNative: " + json);
                        }, (int)NativeAction.Location);
                    }
                }, (int)NativeAction.Location);
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                if (NativeGallery.RequestIPhonePermission(2) == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetSomethingFromIPhone(result =>
                    {
                        if (result.IsNotNullAndEmpty())
                        {
                            InputFieldSSID.text = result;
                            isSSIDContains5G(result);
                            string pwd = PlayerPrefsUtil.GetWiFiPWD(result);
                            if (pwd.IsNotNullAndEmpty())
                            {
                                InputFieldPWD.text = pwd;
                            }
                            else
                            {
                                InputFieldPWD.text = String.Empty;
                            }
                        }
                    }, 1);
                }
            }

            var submit = Observable.Merge(
                InputFieldSSID.OnEndEditAsObservable().Where(_ => Input.GetKeyDown(KeyCode.Return)),
                BtnCommit.OnClickAsObservable().Select(_ => InputFieldSSID.text)
                );

            submit.Where(s => s != "")
            .Subscribe(s =>
            {
                AudioManager.PlaySound("Button_Audio");
                isSendMessage = false;
                if (saveWiFipwd)
                {
                    // 保存 WiFi ssid 和 pwd 到本地
                    PlayerPrefsUtil.SetWiFiSSIDPWD(InputFieldSSID.text, InputFieldPWD.text);
                }
                else
                {
                    PlayerPrefsUtil.SetWiFiSSIDPWD(InputFieldSSID.text, String.Empty);
                }

                Debug.Log("submit-确定 " + "ssid=" + s + "  pwd=" + InputFieldPWD.text);
                UIMgr.OpenPanel <BindDevicePanel>(new BindDevicePanelData()
                {
                    pwdStr  = InputFieldPWD.text,
                    ssidStr = InputFieldSSID.text
                }, UITransitionType.CIRCLE, this);
            }).AddTo(this);
            BtnClearPWD.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                InputFieldPWD.text = String.Empty;
            }).AddTo(this);
            BtnSSIDList.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
#if UNITY_ANDROID
                NativeGallery.RequestPermission((result, action) =>
                {
                    Log.I("RequestPermission: " + result);
                    if (result == (int)NativeGallery.Permission.Granted)
                    {
                        NativeGallery.OpenWifiSettings();
                    }
                }, (int)NativeAction.Location);
#elif UNITY_IOS
                NativeGallery.OpenSettings();
#else
#endif
            });
            InputFieldSSID.OnValueChangedAsObservable().Subscribe((s =>
            {
                var texture2D = mResLoader.LoadSync <Texture2D>("ic_bindDetermine");
                if (s.Length > 0)
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("ic_bindDetermine");
                }
                else
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("btn_code_sel");
                }
                ImgDetermine.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
            })).AddTo(this);

            BtnShow.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                var texture2D = mResLoader.LoadSync <Texture2D>("ic_savepwd");
                showWiFipwd   = !showWiFipwd;
                if (showWiFipwd)
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("btn_show_pwd");
                    InputFieldPWD.contentType = InputField.ContentType.EmailAddress;
                }
                else
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("btn_hide_pwd");
                    InputFieldPWD.contentType = InputField.ContentType.Password;
                }

                var image    = BtnShow.transform.Find("Image").GetComponent <Image>();
                image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                InputFieldPWD.MyUpdateLabel();
            }).AddTo(this);

            BtnConnectTips.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <BindCheckWIFIPanel>(new BindCheckWIFIPanelData(), UITransitionType.NULL);
            }).AddTo(this);

            BtnBack.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("WiFi 返回");
                Back();
            }).AddTo(this);

            BtnSavepwd.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("记住密码");
                saveWiFipwd   = !saveWiFipwd;
                var texture2D = mResLoader.LoadSync <Texture2D>("ic_savepwd");
                if (saveWiFipwd)
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("ic_savepwd");
                }
                else
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("ic_unsavepwd");
                }
                ImageSavePWD.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
            }).AddTo(this);


            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.Contains5GAlter)
                {
                    if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        NativeGallery.RequestPermission((result, action) =>
                        {
                            Log.I("RequestPermission: " + result);
                            if (result == (int)NativeGallery.Permission.Granted)
                            {
                                NativeGallery.OpenWifiSettings();
                            }
                        }, (int)NativeAction.Location);
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        NativeGallery.OpenSettings();
                    }
                }
            }).AddTo(this);

            // please add init code here
        }
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData             = uiData as AttendanceAddPanelData ?? new AttendanceAddPanelData();
            mPath             = mData.Path;
            mThumbnailPath    = mData.ThumbnailPath;
            texture2DAddPhoto = mResLoader.LoadSync <Texture2D>("attendance_main_add");
            BtnBack.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });
            BtnCancel.onClick.AddListener(() => {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });
            BtnPush.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                // if (InputContent.text.IsNullOrEmpty())
                // {
                //     CommonUtil.toast("请输入内容");
                //     Log.I("请输入内容");
                //     return;
                // }
                if (mPath.IsNullOrEmpty())
                {
                    if (mData.Action == AttendanceAdd.Pic)
                    {
                        CommonUtil.toast("请添加图片");
                        Log.I("请添加图片");
                    }
                    else if (mData.Action == AttendanceAdd.Audio)
                    {
                        CommonUtil.toast("请添加音频");
                        Log.I("请添加音频");
                    }
                    else if (mData.Action == AttendanceAdd.Video)
                    {
                        CommonUtil.toast("请添加视频");
                        Log.I("请添加视频");
                    }
                    return;
                }
                LoadingManager.GetInstance().CreatLoading();
                BtnPush.enabled = false;
                if (mData.Action == AttendanceAdd.Pic)
                {
                    string fileType = mPath.Substring(mPath.LastIndexOf("."));
                    Log.I("mPath: " + mPath + " fileType: " + fileType);
                    StartRequestForUpload("attendance" + fileType, mPath);
                }
                else if (mData.Action == AttendanceAdd.Audio)
                {
                    MicrophoneManager.GetInstance().StopPlay();
                    string fileType = mPath.Substring(mPath.LastIndexOf("."));
                    Log.I("mPath: " + mPath + " fileType: " + fileType);
                    StartRequestForUpload("attendance" + fileType, mPath);
                }
                else if (mData.Action == AttendanceAdd.Video)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        // CommonUtil.toast("视频压缩上传中,请稍等");
                        AndroidForUnity.CallAndroidForVideoCompress(mPath);
                    }
                    else
                    {
                        StartCoroutine(IPhonePlayerCompressFinished());
                    }
                }
            });
            BtnAdd.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (mData.Action == AttendanceAdd.Audio)
                {
                    UIMgr.OpenPanel <AttendanceAudioRecordPanel>(new AttendanceAudioRecordPanelData(), UITransitionType.CIRCLE);
                }
                else
                { //unityForPlayVideo
                    if (mPath.IsNullOrEmpty())
                    {
                        if (mData.Action == AttendanceAdd.Pic)
                        {
                            UIMgr.OpenPanel <ChoosePhotoPanel>(new ChoosePhotoPanelData()
                            {
                                action = ChoosePhotoAction.AttendancePic,
                            });
                        }
                        else if (mData.Action == AttendanceAdd.Video)
                        {
                            // UIMgr.OpenPanel<ChoosePhotoPanel>(new ChoosePhotoPanelData()
                            // {
                            //     action = ChoosePhotoAction.AttendanceVideo,
                            //     showTip = true
                            //
                            // });
                            if (Application.platform == RuntimePlatform.IPhonePlayer)
                            {
                                IPhonePlayerMakeVideoOpenCamera();
                            }
                            else if (Application.platform == RuntimePlatform.Android)
                            {
                                NativeGallery.RequestPermission((result, action) =>
                                {
                                    if (result == (int)NativeGallery.Permission.Granted)
                                    {
                                        NativeGallery.GetVideoFromGalleryForAndroid((json) =>
                                        {
                                            if (json.IsNotNullAndEmpty())
                                            {
                                                NativeVideoModel model = SerializeHelper.FromJson <NativeVideoModel>(json);
                                                if (model.IsNotNull())
                                                {
                                                    if (model.status == 1)
                                                    {
                                                        mPath          = model.videoPath;
                                                        mThumbnailPath = model.imagePath;
                                                        AudioContent.gameObject.SetActive(false);
                                                        if (model.imagePath.IsNotNullAndEmpty())
                                                        {
                                                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + model.imagePath, ImagePic);
                                                            BtnVideo.gameObject.SetActive(true);
                                                            BtnDel.gameObject.SetActive(true);
                                                        }
                                                    }
                                                    else if (model.status == 0)
                                                    {
                                                        mPath           = null;
                                                        mThumbnailPath  = null;
                                                        ImagePic.sprite = Sprite.Create(texture2DAddPhoto, new Rect(0, 0, texture2DAddPhoto.width, texture2DAddPhoto.height), Vector2.one * 0.5f);
                                                        BtnVideo.gameObject.SetActive(false);
                                                        BtnDel.gameObject.SetActive(false);
                                                    }
                                                }
                                            }
                                        }, "选择视频", "video/*", action);
                                    }
                                }, (int)NativeAction.Camera);
                            }
                        }
                    }
                    else
                    {
                        if (mData.Action == AttendanceAdd.Pic)
                        {
                            if (Application.platform == RuntimePlatform.Android)
                            {
                                AndroidForUnity.CallAndroidForShowPic(mPath);
                            }
                            else if (Application.platform == RuntimePlatform.IPhonePlayer)
                            {
                                UIMgr.OpenPanel <PhotoBrowserPanel>(new PhotoBrowserPanelData()
                                {
                                    ImageUrl = mPath,
                                }, UITransitionType.NULL);
                            }
                        }
                        else if (mData.Action == AttendanceAdd.Video)
                        {
                            if (Application.platform == RuntimePlatform.Android)
                            {
                                AndroidForUnity.CallAndroidForPlayVideo(mPath);
                            }
                            else if (Application.platform == RuntimePlatform.IPhonePlayer)
                            {
                                Dictionary <string, object> paramDic = new Dictionary <string, object>();
                                Dictionary <string, object> subParam = new Dictionary <string, object>();
                                subParam.Add("url", mPath);
                                paramDic.Add("target", AppConst.VIDEO_IOS);
                                paramDic.Add("method", IOSClientUtil.VideoMediaPlay);
                                paramDic.Add("params", subParam);
                                IOSClientUtil.CommonMethodCallIOSClient(paramDic.ToJson());
                            }
                        }
                    }
                }
            });
            BtnVideo.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (mData.Action == AttendanceAdd.Video)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        AndroidForUnity.CallAndroidForPlayVideo(mPath);
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        Dictionary <string, object> paramDic = new Dictionary <string, object>();
                        Dictionary <string, object> subParam = new Dictionary <string, object>();
                        subParam.Add("url", mPath);
                        paramDic.Add("target", AppConst.VIDEO_IOS);
                        paramDic.Add("method", IOSClientUtil.VideoMediaPlay);
                        paramDic.Add("params", subParam);
                        IOSClientUtil.CommonMethodCallIOSClient(paramDic.ToJson());
                    }
                }
            });
            if (mData.Action == AttendanceAdd.Audio)
            {
                UpdateTvTime("0");
                AddContent.gameObject.SetActive(mPath.IsNullOrEmpty());
                AudioContent.gameObject.SetActive(mPath.IsNotNullAndEmpty());
                TextAdd.text = "添加语音";
            }
            else
            {
                if (mData.Action == AttendanceAdd.Pic)
                {
                    TextAdd.text = "添加图片";
                    AudioContent.gameObject.SetActive(false);
                    if (mPath.IsNotNullAndEmpty())
                    {
                        ImageDownloadUtils.Instance.SetAsyncImage("file://" + mThumbnailPath, ImagePic);
                        BtnVideo.gameObject.SetActive(false);
                        BtnDel.gameObject.SetActive(true);
                    }
                }
                else
                {
                    TextAdd.text = "添加视频";
                    AudioContent.gameObject.SetActive(false);
                    if (mPath.IsNotNullAndEmpty())
                    {
                        ImageDownloadUtils.Instance.SetAsyncImage("file://" + mThumbnailPath, ImagePic);
                        BtnVideo.gameObject.SetActive(true);
                        BtnDel.gameObject.SetActive(true);
                    }
                }
            }
            BtnPlayAndPause.onClick.AddListener(() =>
            {
                if (mPath.IsNotNullAndEmpty())
                {
                    if (mPlayStatus == PlayStatus.NoPlaying || mPlayStatus == PlayStatus.Stop)
                    {
                        MicrophoneManager.GetInstance().PlayRecord();
                    }
                    else if (mPlayStatus == PlayStatus.Playing)
                    {
                        MicrophoneManager.GetInstance().PausePlay();
                    }
                    else if (mPlayStatus == PlayStatus.Pause)
                    {
                        MicrophoneManager.GetInstance().PlayRecord(MicrophoneManager.GetInstance().mPlayingTime.Value);
                    }
                }
            });
            BtnClose.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                mPath = null;
                MicrophoneManager.GetInstance().StopPlay();
                AddContent.gameObject.SetActive(mPath.IsNullOrEmpty());
                AudioContent.gameObject.SetActive(mPath.IsNotNullAndEmpty());
            });
            BtnDel.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                // 弹窗
                UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                {
                    action  = TipAction.DelAttendance,
                    message = "确定要删除当前内容吗?",
                });
            });
            InputContent.onValueChange.AddListener(EditChange);

            if (mData.Action == AttendanceAdd.Audio)
            {
                MicrophoneManager.GetInstance().mPlayStatus.Subscribe(status =>
                {
                    mPlayStatus = status;
                    if (mPlayStatus == PlayStatus.Playing)
                    {
                        // var soundOnTexture = mResLoader.LoadSync<Texture2D>("ic_audio_playing");
                        // ImgPlayAndPause.sprite = Sprite.Create(soundOnTexture, new Rect(0, 0, soundOnTexture.width, soundOnTexture.height), Vector2.one * 0.5f);
                        ImgPlayAndPause.gameObject.SetActive(false);
                        ImgPlaying.gameObject.SetActive(true);
                    }
                    else
                    {
                        // var soundOnTexture = mResLoader.LoadSync<Texture2D>("ic_audiio_pause");
                        // ImgPlayAndPause.sprite = Sprite.Create(soundOnTexture, new Rect(0, 0, soundOnTexture.width, soundOnTexture.height), Vector2.one * 0.5f);
                        ImgPlayAndPause.gameObject.SetActive(true);
                        ImgPlaying.gameObject.SetActive(false);
                    }

                    if (mPlayStatus == PlayStatus.Stop)
                    {
                        UpdateTvTime("0");
                    }
                }).AddTo(this);
            }
            SimpleEventSystem.GetEvent <RecordPath>().Subscribe(Path =>
            {
                mPath = Path.Path;
                UpdateTvTime("0");
                AddContent.gameObject.SetActive(mPath.IsNullOrEmpty());
                AudioContent.gameObject.SetActive(mPath.IsNotNullAndEmpty());
            }).AddTo(this);
            SimpleEventSystem.GetEvent <ChoosePhotoClick>()
            .Subscribe(_ =>
            {
                if (_.GetPhotoAction == ChoosePhotoAction.AttendancePic)
                {
                    if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        if (_.GetAction == NativeAction.Camera)
                        {
                            IPhonePlayerSelectPictureOpenCamera();
                        }
                        else if (_.GetAction == NativeAction.Album)
                        {
                            IPhonePlayerSelectPictureOpenAlbum();
                        }
                    }
                    else if (Application.platform == RuntimePlatform.Android)
                    {
                        NativeGallery.RequestPermission((result, action) =>
                        {
                            if (result == (int)NativeGallery.Permission.Granted)
                            {
                                NativeGallery.GetImageFromGalleryForAndroid((path) =>
                                {
                                    if (path.IsNotNullAndEmpty())
                                    {
                                        mPath          = path;
                                        mThumbnailPath = path;
                                        AudioContent.gameObject.SetActive(false);
                                        if (mPath.IsNotNullAndEmpty())
                                        {
                                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + mThumbnailPath, ImagePic);
                                            BtnVideo.gameObject.SetActive(false);
                                            BtnDel.gameObject.SetActive(true);
                                        }
                                    }
                                    Debug.Log("Image path: " + path);
                                }, "选择图片", "image/*", true, action);
                            }
                        }, (int)_.GetAction);
                    }
                }
                // 视频不需要了
                else if (_.GetPhotoAction == ChoosePhotoAction.AttendanceVideo)
                {
                    NativeGallery.RequestPermission((result, action) =>
                    {
                        if (result == (int)NativeGallery.Permission.Granted)
                        {
                            NativeGallery.GetVideoFromGalleryForAndroid((json) =>
                            {
                                if (json.IsNotNullAndEmpty())
                                {
                                    NativeVideoModel model = SerializeHelper.FromJson <NativeVideoModel>(json);
                                    if (model.IsNotNull())
                                    {
                                        if (model.status == 1)
                                        {
                                            mPath          = model.videoPath;
                                            mThumbnailPath = model.imagePath;
                                            AudioContent.gameObject.SetActive(false);
                                            if (model.imagePath.IsNotNullAndEmpty())
                                            {
                                                ImageDownloadUtils.Instance.SetAsyncImage("file://" + model.imagePath, ImagePic);
                                                BtnVideo.gameObject.SetActive(true);
                                                BtnDel.gameObject.SetActive(true);
                                            }
                                        }
                                        else if (model.status == 0)
                                        {
                                            mPath           = null;
                                            mThumbnailPath  = null;
                                            ImagePic.sprite = Sprite.Create(texture2DAddPhoto, new Rect(0, 0, texture2DAddPhoto.width, texture2DAddPhoto.height), Vector2.one * 0.5f);
                                            BtnVideo.gameObject.SetActive(false);
                                            BtnDel.gameObject.SetActive(false);
                                        }
                                    }
                                }
                            }, "选择视频", "video/*", action);
                        }
                    }, (int)_.GetAction);
                }
            }).AddTo(this);
            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.DelAttendance)
                {
                    mPath           = null;
                    mThumbnailPath  = null;
                    ImagePic.sprite = Sprite.Create(texture2DAddPhoto, new Rect(0, 0, texture2DAddPhoto.width, texture2DAddPhoto.height), Vector2.one * 0.5f);
                    BtnVideo.gameObject.SetActive(false);
                    BtnDel.gameObject.SetActive(false);
                }
            }).AddTo(this);
            SimpleEventSystem.GetEvent <VideoCompressResult>().Subscribe(res =>
            {
                VideoCompressModel model = res.Model;

                if (Application.platform == RuntimePlatform.Android)
                {
                    if (model.status == 1)
                    {
                        string fileType = model.path.Substring(model.path.LastIndexOf("."));
                        Log.I("mPath: " + model.path + " fileType: " + fileType);
                        StartRequestForUpload("attendance" + fileType, model.path);
                    }
                    else
                    {
                        CommonUtil.toast("视频压缩失败");
                    }
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                }
            }).AddTo(this);
        }
Exemple #27
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                AudioManager.SetMusicOn();
                AudioManager.PlayMusic("Main_BG_Music");
                AndroidForUnity.CallAndroidHideSplash();
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                Dictionary <string, object> param    = new Dictionary <string, object>();
                Dictionary <string, object> subParam = new Dictionary <string, object>();
                param.Add("method", IOSClientUtil.MainPanelOnInit);
                param.Add("params", subParam);
                IOSClientUtil.CommonMethodCallIOSClient(param.ToJson());

                if (App.IsFirstInitialize == 1)
                {
                    AudioManager.SetMusicOn();
                    AudioManager.PlayMusic("Main_BG_Music");
                }
            }
            else
            {
                AudioManager.SetMusicOn();
                AudioManager.PlayMusic("Main_BG_Music");
            }



            mTexture2DHBoy   = mResLoader.LoadSync <Texture2D>("ic_head_boy");
            mTexture2DHGirl  = mResLoader.LoadSync <Texture2D>("ic_head_girl");
            mMainAnimationGo = mResLoader.LoadSync <GameObject>("MainAnimation")
                               .Instantiate()
                               .transform
                               .LocalScale(1.4f, 1.4f, 1.4f)
                               .Position(-11.0f, -5.0f, 0)
                               .gameObject;
            mData = uiData as MainPanelData ?? new MainPanelData();
            BtnGift.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <GiftListPanel>(new GiftListPanelData(), UITransitionType.CLOUD, this);
            });
            BtnSetting.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <SettingPanel>(new SettingPanelData(), UITransitionType.CLOUD, this);
            });
            BtnListen.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                StartRequestForGetResourcePageUrl();
            });
            BtnMessage.onClick.AddListener(() => {
                // UIMgr.OpenPanel<AttendanceAddAudioPanel>();
            });
            BtnRobot.OnClickAsObservable().Subscribe((unit =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <DeviceStatusPanel>(new DeviceStatusPanelData(), UITransitionType.CLOUD, this);
            })).AddTo(this);
            BtnIntegral.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("每日任务");
                UIMgr.OpenPanel <DailyTaskPanel>(new DailyTaskPanelData(), UITransitionType.CLOUD, this);
            });
            BtnMedal.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("勋章");
                UIMgr.OpenPanel <DailyTaskPanel>(new DailyTaskPanelData()
                {
                    showMedal = 2,
                }, UITransitionType.CLOUD, this);
            });
            BtnScan.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (Application.platform == RuntimePlatform.Android)
                {
                    NativeGallery.RequestPermission((result, action) =>
                    {
                        if (result == (int)NativeGallery.Permission.Granted)
                        {
                            Dictionary <string, object> param    = new Dictionary <string, object>();
                            Dictionary <string, object> subParam = new Dictionary <string, object>();
                            param.Add("target", AppConst.SCAN);
                            param.Add("params", subParam);
                            AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CLOUD);
                        }
                    }, (int)NativeAction.Camera);
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    Dictionary <string, object> param    = new Dictionary <string, object>();
                    Dictionary <string, object> subParam = new Dictionary <string, object>();
                    param.Add("target", AppConst.SCAN_IOS);
                    param.Add("params", subParam);
                    IOSClientUtil.CallIOSClient(param.ToJson());
                }
            });
            BtnChineseShop.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (UserInfo.chPlanId != 0)
                {
                    StartRequestForGetPlanInfo(UserInfo.chPlanId, 0);
                }
                else
                {
                    UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                    {
                        action     = TipAction.PlanScan,
                        message    = "该计划未解锁\n需扫描盒子二维码进行解锁!",
                        strConfirm = "去扫描",
                        strTitle   = "解锁提示"
                    });
                    LoadingManager.GetInstance().DismissLoading();
                }
            });
            BtnEnglishShop.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (UserInfo.enPlanId != 0)
                {
                    StartRequestForGetPlanInfo(UserInfo.enPlanId, 0);
                }
                else
                {
                    UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                    {
                        action     = TipAction.PlanScan,
                        message    = "该计划未解锁\n需扫描盒子二维码进行解锁!",
                        strConfirm = "去扫描",
                        strTitle   = "解锁提示"
                    });
                    LoadingManager.GetInstance().DismissLoading();
                }
            });
            BtnLearningShop.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (UserInfo.qgPlanId != 0)
                {
                    StartRequestForGetPlanInfo(UserInfo.qgPlanId, 0);
                }
                else
                {
                    StartRequestForDrawPowerSpecialPlan();
                }
            });
            BtnPhotoWall.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <WorksWallPanel>(new WorksWallPanelData(), UITransitionType.CLOUD, this);
            });

            BtnAddRobot.onClick.AddListener(() =>
            {
                UIMgr.OpenPanel <BindConfirmBootPanel>(new BindConfirmBootPanelData()
                {
                }, UITransitionType.CLOUD, this);
            });
            SimpleEventSystem.GetEvent <ScanQRResult>()
            .Subscribe(_ =>
            {
                if (_.ScanResult.IsNotNullAndEmpty())
                {
                    StartRequestForScanQR(_.ScanResult);
                }
            }).AddTo(this);
            //扫码动画关闭监听
            SimpleEventSystem.GetEvent <CollectGiftBoxPanelClosed>()
            .Subscribe(_ =>
            {
                if (_.CollectGiftBoxType == CollectGiftBoxType.ChineseLearningPlan || _.CollectGiftBoxType == CollectGiftBoxType.EnglishLearningPlan)
                {
                    StartRequestForGetPlanInfo(ScanQrCodePlanId, ScanQrCodeMonth);
                }
            }).AddTo(this);
            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.PlanScan)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        NativeGallery.RequestPermission((result, action) =>
                        {
                            if (result == (int)NativeGallery.Permission.Granted)
                            {
                                Dictionary <string, object> param    = new Dictionary <string, object>();
                                Dictionary <string, object> subParam = new Dictionary <string, object>();
                                param.Add("target", AppConst.SCAN);
                                param.Add("params", subParam);
                                AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CLOUD);
                            }
                        }, (int)NativeAction.Camera);
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        Dictionary <string, object> param    = new Dictionary <string, object>();
                        Dictionary <string, object> subParam = new Dictionary <string, object>();
                        param.Add("target", AppConst.SCAN_IOS);
                        param.Add("params", subParam);
                        IOSClientUtil.CallIOSClient(param.ToJson());
                    }
                }
            }).AddTo(this);

            /**
             * 展示完引导页 的事件
             */
            SimpleEventSystem.GetEvent <MainPanelGuideDismiss>().Subscribe(_ =>
            {
                this.gameObject.SetActive(true);
            }).AddTo(this);

            SimpleEventSystem.GetEvent <LottieAnimationFinish>().Subscribe(_ =>
            {
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    if (App.IsFirstInitialize == 1)
                    {
                        AudioManager.SetMusicOn();
                        AudioManager.PlayMusic("Main_BG_Music");
                    }
                }
            }).AddTo(this);

            /**
             * 勋章领取成功
             */
            SimpleEventSystem.GetEvent <MedalDrawSuccess>()
            .Subscribe(_ =>
            {
                string medalCount = TvMedal.text;
                TvMedal.text      = (medalCount.ToInt() + 1).ToString();
                if (mMedalList.Count > 0)
                {
                    mMedalList.RemoveAt(0);
                }
                ShowMedalAnimationPanel();
            }).AddTo(this);
            setUserInfoData();
            StartResquestForGetUserInfo();
            RequestBabyMedalFindList();
            if (Application.platform == RuntimePlatform.Android)
            {
                NativeGallery.GetSomethingFromNative((json, action1) =>
                {
                    if (json.IsNotNullAndEmpty())
                    {
                        AppInfo model = SerializeHelper.FromJson <AppInfo>(json);
                        StartResquestForFindReleaseInfo("2", model.build);
                    }
                }, (int)NativeAction.VersionJson);
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                NativeGallery.GetSomethingFromIPhone(result =>
                {
                    Debug.Log("IOS - build = " + result);
                    StartResquestForFindReleaseInfo("1", result.ToInt());
                }, 4);
            }

            if (mData.ShopAction >= 1)
            {
                LoadingManager.GetInstance().CreatLoading();
                StartCoroutine(WaitMainPanelAnimationCompleted(mData.ShopAction));
            }
        }
Exemple #28
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as UserInfoPanelData ?? new UserInfoPanelData();
            // please add init code here
            BtnUserConfirm.enabled = false;
            mData.IsEdit           = mData.UserInfoModel.IsNotNull();
            BtnBack.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                Back();
            });
            // please add init code here

            mTexture2DSel    = mResLoader.LoadSync <Texture2D>("btn_code_sel");
            mTexture2DNor    = mResLoader.LoadSync <Texture2D>("btn_code_nor");
            mTexture2DSexSel = mResLoader.LoadSync <Texture2D>("bg_sex_sel");
            mTexture2DSexNor = mResLoader.LoadSync <Texture2D>("bg_sex_nor");

            SimpleEventSystem.GetEvent <UserPhoto>()
            .Subscribe(_ =>
            {
                Log.I(_.GetPath);
                // mUserHead = _.GetPath;
                // ImageDownloadUtils.Instance.SetAsyncImage("file://" + mUserHead, ImgUserHead, false);
            }).AddTo(this);

            SimpleEventSystem.GetEvent <ChoosePhotoClick>()
            .Subscribe(_ =>
            {
                Log.I("_.GetPhotoAction: " + _.GetPhotoAction + " _.GetAction: " + _.GetAction);
                if (_.GetPhotoAction == ChoosePhotoAction.User)
                {
                    PickImage(_.GetAction);
                }
            }).AddTo(this);
            OnClickListener();
            if (mData.IsEdit)
            {
                ImageDownloadUtils.Instance.SetAsyncImage(mData.UserInfoModel.logoUrl, ImgUserHead);
                string babyRelation = mData.UserInfoModel.babyRelation;
                if ("父亲".Equals(babyRelation))
                {
                    OnFatherClick();
                }
                else if ("母亲".Equals(babyRelation))
                {
                    OnMotherClick();
                }
                else if ("祖父".Equals(babyRelation))
                {
                    OnGrandFatherClick();
                }
                else if ("祖母".Equals(babyRelation))
                {
                    OnGrandMotherClick();
                }
                else if ("哥哥".Equals(babyRelation))
                {
                    OnBrotherClick();
                }
                else if ("姐姐".Equals(babyRelation))
                {
                    OnSisterClick();
                }
                BtnUserConfirm.enabled      = true;
                BtnUserConfirm.image.sprite = Sprite.Create(mTexture2DNor,
                                                            new Rect(0, 0, mTexture2DNor.width, mTexture2DNor.height), Vector2.one * 0.5f);
            }
        }