protected override void OnInit(QFramework.IUIData uiData)
 {
     AudioManager.SetMusicOff();
     mData             = uiData as BookDetailPanelData ?? new BookDetailPanelData();
     TvAuth.text       = mData.DayActionModel.author.IsNullOrEmpty()?string.Empty:"作者:" + mData.DayActionModel.author;
     TvTitle.text      = mData.DayActionModel.title;
     TvName.text       = mData.DayActionModel.name;
     TvContentIns.text = mData.DayActionModel.contentIntroduction;
     TvPicBookIns.text = mData.DayActionModel.picBookIntroduction;
     ImageDownloadUtils.Instance.SetAsyncImage(mData.DayActionModel.thumbUrl, ImgThumb);
     BtnStart.onClick.AddListener(() => {
         AudioManager.PlaySound("Button_Audio");
         // 跳转原生传参
         var param    = new Dictionary <string, object>();
         var subParam = new Dictionary <string, object>();
         subParam.Add("picBookId", mData.DayActionModel.resourceId);
         if (Application.platform == RuntimePlatform.Android)
         {
             param.Add("target", AppConst.BOOK_ANDROID);
             param.Add("params", subParam);
             AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CIRCLE);
         }
         else
         {
             param.Add("target", AppConst.BOOK_IOS);
             param.Add("params", subParam);
             IOSClientUtil.CallIOSClient(param.ToJson());
         }
     });
     BtnBack.onClick.AddListener(() =>
     {
         AudioManager.PlaySound("Button_Audio");
         Back();
     });
 }
Example #2
0
        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());
                }
            });
        }
Example #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);
        }
Example #4
0
        private void ResquestDeviceStatus(int progress)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("deviceId", PlayerPrefsUtil.GetDeviceId());
            paramDict.Add("userId", PlayerPrefsUtil.GetUserId());
            HttpUtil.GetWithSign <DeviceModel>(UrlConst.GetDeviceStatus, paramDict)
            .Subscribe(response =>
            {
                if (progress != -1)
                {
                    if (response.deviceOnline)
                    {
                        if (Application.platform == RuntimePlatform.Android)
                        {
                            AndroidForUnity.CallAndroidForUpdateVol((progress).ToString("F0"));
                        }
                        else if (Application.platform == RuntimePlatform.IPhonePlayer)
                        {
                            Dictionary <string, object> param    = new Dictionary <string, object>();
                            Dictionary <string, object> subParam = new Dictionary <string, object>();
                            subParam.Add("valume", progress);
                            param.Add("method", IOSClientUtil.ExchangeDeviceVolume);
                            param.Add("params", subParam);
                            Debug.Log("params ========" + subParam);
                            IOSClientUtil.CommonMethodCallIOSClient(param.ToJson());
                        }
                    }
                    else
                    {
                        SliderDeviceVoice.Slider.value = 0;
                        TextProgress.text = string.Format("{0}%", 0);
                        CommonUtil.toast("dola未连接,请确认开机联网哦~");
                    }
                }
                if (response.deviceOnline)
                {
                    DeviceConnectStatus(true);
                }
                else
                {
                    DeviceConnectStatus(false);
                }
                UpdateDeviceBattery(response.deviceStatus.battery);
            }
                       , e =>
            {
                if (e is HttpException)
                {
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                }
            }).AddTo(this);
        }
        private void StartResquestForBind(String deviceId)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("deviceId", deviceId);
            paramDict.Add("userId", PlayerPrefsUtil.GetUserId());
            HttpUtil.PostWithSign <BindResultModel>(UrlConst.Bind, paramDict)
            .Subscribe(response =>
            {
                if (response.bindRelation == 1)
                {
                    UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                    {
                        action             = TipAction.BindDevice,
                        message            = "该账号已绑定其他设备,\n如需绑定当前设备,需解绑后重新绑定",
                        isHideCancelButton = true,
                        strConfirm         = "知道了"
                    });
                    StopAllCoroutines();
                }
                else
                {
                    ConnectResult(true);
                    StopAllCoroutines();
                }

                /**
                 * 停止播放音频
                 */
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    IOSClientUtil.StopBindDevice("");
                }
                else if (Application.platform == RuntimePlatform.Android)
                {
                    AndroidForUnity.CallAndroidForStopDeviceConnect();
                }
            }
                       , e =>
            {
                if (e is HttpException)
                {
                    ConnectResult(false);
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                }
            }).AddTo(this);
        }
Example #6
0
        /**
         * 获取随便听听地址
         */
        private void StartRequestForGetResourcePageUrl()
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("userId", PlayerPrefsUtil.GetUserId());
            if (Application.platform == RuntimePlatform.Android)
            {
                paramDict.Add("client", "android");
            }
            else
            {
                paramDict.Add("client", "ios");
            }
            HttpUtil.GetWithSign <string>(UrlConst.GetResourcePageUrl, paramDict)
            .Subscribe(response =>
            {
                if (Application.platform == RuntimePlatform.Android)
                {
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    param.Add("target", AppConst.WEBVIEW);
                    Dictionary <string, object> subParam = new Dictionary <string, object>();
                    subParam.Add("url", response);
                    subParam.Add("title", "随便听听");
                    param.Add("params", subParam);
                    AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CLOUD);
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    param.Add("target", AppConst.WKWEBVIEW_IOS);
                    Dictionary <string, object> subParam = new Dictionary <string, object>();
                    subParam.Add("webUrl", response);
                    subParam.Add("title", "随便听听");
                    param.Add("params", subParam);
                    IOSClientUtil.CallIOSClient(param.ToJson());
                }
            }
                       , e =>
            {
                if (e is HttpException)
                {
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                }
            }).AddTo(this);
        }
        private void RequestDeviceID(bool isLast)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("userId", PlayerPrefsUtil.GetUserId());
            HttpUtil.GetWithSign <string>(UrlConst.DeviceIdByUserId, paramDict)
            .Subscribe(response =>
            {
                if (response.IsNotNullAndEmpty())
                {
                    StartResquestForBind(response);
                }
                else
                {
                    if (isLast)
                    {
                        if (Application.platform == RuntimePlatform.Android)
                        {
                            AndroidForUnity.CallAndroidForStopDeviceConnect();
                        }

                        if (Application.platform == RuntimePlatform.IPhonePlayer)
                        {
                            IOSClientUtil.StopBindDevice("");
                        }
                        Log.I("配网超时 的失败");
                        ConnectResult(false);
                    }
                }
            }, e =>
            {
                if (e is HttpException)
                {
                    if (isLast)
                    {
                        ConnectResult(false);
                    }
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                    CommonUtil.toast(http.Message);
                }
            }).AddTo(this);
        }
Example #8
0
        private void OnVideoClick(DayActionModel dayActionModel)
        {
            AudioManager.PlaySound("Button_Audio");
            var param    = new Dictionary <string, object>();
            var subParam = new Dictionary <string, object>();

            subParam.Add("resourceId", dayActionModel.resourceId);
            if (Application.platform == RuntimePlatform.Android)
            {
                param.Add("target", AppConst.VIDEO_ANDROID);
                param.Add("params", subParam);
                AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CIRCLE);
            }
            else
            {
                param.Add("target", AppConst.VIDEO_IOS);
                param.Add("params", subParam);
                IOSClientUtil.CallIOSClient(param.ToJson());
            }
        }
Example #9
0
        private void StartRequestForScanQR(string scanQR)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("content", scanQR);
            paramDict.Add("babyId", PlayerPrefsUtil.GetBabyId());
            HttpUtil.GetWithSign <QRCodeModel>(UrlConst.ScanQR, paramDict)
            .Subscribe(response =>
            {
                int content = response.content;
                if (content == 1)
                {
                    StartResquestForGetUserInfo();
                    StartRequestForBabyStudyLockInfo();
                    ScanQrCodePlanId = response.planId;
                    ScanQrCodeMonth  = response.month;
                    UIMgr.OpenPanel <CollectGiftBoxPanel>(new CollectGiftBoxPanelData()
                    {
                        Type = response.subject == 1 ? CollectGiftBoxType.EnglishLearningPlan : CollectGiftBoxType.ChineseLearningPlan
                    });
                }
                else if (content == 3)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        Dictionary <string, object> param    = new Dictionary <string, object>();
                        Dictionary <string, object> subParam = new Dictionary <string, object>();
                        subParam.Add("resourceId", response.id);
                        subParam.Add("subject", response.subject);
                        param.Add("target", AppConst.AUDIO_ANDROID);
                        param.Add("params", subParam);
                        Debug.Log("params ========" + subParam);
                        AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CIRCLE);
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        Dictionary <string, object> param    = new Dictionary <string, object>();
                        Dictionary <string, object> subParam = new Dictionary <string, object>();
                        subParam.Add("resourceId", response.id);

                        subParam.Add("path", response.path);
                        subParam.Add("subject", response.subject);
                        subParam.Add("resourcePath", response.resourcePath);
                        subParam.Add("resourceTitle", response.resourceTitle);
                        subParam.Add("id", response.id);

                        param.Add("target", AppConst.AUDIO_IOS);
                        param.Add("method", IOSClientUtil.AudioPlay);
                        param.Add("params", subParam);
                        Debug.Log("params ========" + subParam);

                        IOSClientUtil.CommonMethodCallIOSClient(param.ToJson());
                    }
                }
            }
                       , e =>
            {
                if (e is HttpException)
                {
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                }
            }).AddTo(this);
        }
Example #10
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));
            }
        }
Example #11
0
 private void LoadNextScene(DayActionModel dayActionModel)
 {
     if (dayActionModel.action == 50) // 看视频
     {
         Dictionary <string, object> param    = new Dictionary <string, object>();
         Dictionary <string, object> subParam = new Dictionary <string, object>();
         subParam.Add("resourceId", dayActionModel.resourceId);
         if (Application.platform == RuntimePlatform.Android)
         {
             param.Add("target", AppConst.VIDEO_ANDROID);
             param.Add("params", subParam);
             AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CIRCLE);
         }
         else
         {
             param.Add("target", AppConst.VIDEO_IOS);
             param.Add("params", subParam);
             IOSClientUtil.CallIOSClient(param.ToJson());
         }
     }
     else if (dayActionModel.action == 60)
     {
         UIMgr.OpenPanel <BookDetailPanel>(new BookDetailPanelData()
         {
             DayActionModel = dayActionModel
         }, UITransitionType.CIRCLE, this);
     }
     else if (dayActionModel.action == 70)   //休息
     {
     }
     else if (dayActionModel.action == 0)   //亲子互动
     {
         UIMgr.OpenPanel <PlayGamePanel>(new PlayGamePanelData()
         {
             DayActionModel = dayActionModel
         }, UITransitionType.CIRCLE, this);
     }
     else if (dayActionModel.action == 80)
     {
         Dictionary <string, object> param    = new Dictionary <string, object>();
         Dictionary <string, object> subParam = new Dictionary <string, object>();
         subParam.Add("resourceId", dayActionModel.resourceId);
         if (Application.platform == RuntimePlatform.Android)
         {
             param.Add("target", AppConst.WORDCOVER_ANDROID);
             param.Add("params", subParam);
             AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CIRCLE);
         }
         else
         {
             param.Add("target", AppConst.WORDCOVER_IOS);
             param.Add("params", subParam);
             IOSClientUtil.CallIOSClient(param.ToJson());
         }
     }
     else
     {
         Dictionary <string, object> param    = new Dictionary <string, object>();
         Dictionary <string, object> subParam = new Dictionary <string, object>();
         subParam.Add("resourceId", dayActionModel.resourceId);
         subParam.Add("planId", PlayerPrefsUtil.ContentModel.planId);
         subParam.Add("boxId", mData.BoxDayDetailModel.boxId);
         subParam.Add("subject", PlayerPrefsUtil.ContentModel.subject);
         if (Application.platform == RuntimePlatform.Android)
         {
             param.Add("target", AppConst.AUDIO_ANDROID);
             param.Add("params", subParam);
             Debug.Log("params ========" + subParam);
             AndroidForUnity.CallAndroidStartActivityForAnim(param.ToJson(), AppConst.ANIM_CIRCLE);
         }
         else
         {
             param.Add("target", AppConst.AUDIO_IOS);
             param.Add("params", subParam);
             IOSClientUtil.CallIOSClient(param.ToJson());
         }
     }
 }
Example #12
0
    // Update is called once per frame
    public void SetData(WorksWall data)
    {
        float workWallItemHeight = 0;

        if (data.babyId == PlayerPrefsUtil.GetBabyId())
        {
            BtnShare.gameObject.SetActive(true);
        }
        else
        {
            BtnShare.gameObject.SetActive(false);
        }
        // 分享事件
        BtnShare.onClick.AddListener(() =>
        {
            AttendanceModel model = new AttendanceModel();
            model.boxDay          = data.boxDay;
            model.punchPath       = data.punchPathUrl;
            model.punchText       = data.punchText;
            model.punchType       = data.punchType;
            model.shareScore      = data.shareScore;
            model.finishPunchNum  = data.finishPunchNum;
            model.relBoxId        = data.relBoxId;
            model.id      = data.id;
            model.subject = data.subject;
            UIMgr.OpenPanel <AttendanceSharePanel>(new AttendanceSharePanelData()
            {
                AttendanceModel = model,
                isWall          = true
            }, UITransitionType.CIRCLE);
        });
        // 查看我的打卡 图片or 视频
        BtnImgPreview.onClick.AddListener(() =>
        {
            if (data.punchType == 0) //图文
            {
                if (Application.platform == RuntimePlatform.Android)
                {
                    AndroidForUnity.CallAndroidForShowPic(data.punchPathUrl);
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    UIMgr.OpenPanel <PhotoBrowserPanel>(new PhotoBrowserPanelData()
                    {
                        ImageUrl = data.punchPathUrl,
                    }, UITransitionType.NULL);
                }
            }
            else if (data.punchType == 2) //视频
            {
                if (Application.platform == RuntimePlatform.Android)
                {
                    AndroidForUnity.CallAndroidForPlayVideo(data.punchPathUrl);
                }
                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", data.punchPathUrl);
                    paramDic.Add("target", AppConst.VIDEO_IOS);
                    paramDic.Add("method", IOSClientUtil.VideoMediaPlay);
                    paramDic.Add("params", subParam);
                    IOSClientUtil.CommonMethodCallIOSClient(paramDic.ToJson());
                }
            }
        });
        TextShareContent.text = StringUtil.Emoji(data.punchText);
        TextAge.text          = data.age;
        TextName.text         = StringUtil.Emoji(data.name);
        TextTimeLine.text     = data.createTime;
        IsAudioPreviewPlaying.Subscribe(isPlaying =>
        {
            Texture2D soundOnTexture = mResLoader.LoadSync <Texture2D>(isPlaying ? "ic_works_wall_audio_pause" : "ic_works_wall_audio_start");
            ImgAudio.sprite          = Sprite.Create(soundOnTexture, new Rect(0, 0, soundOnTexture.width, soundOnTexture.height), Vector2.one * 0.5f);
        }).AddTo(this);
        IsAudioContenPlaying.Subscribe(isPlaying =>
        {
            Texture2D soundOnTexture = mResLoader.LoadSync <Texture2D>(isPlaying ? "ic_audio_playing" : "ic_audiio_pause");
            ImgPlayState.sprite      = Sprite.Create(soundOnTexture, new Rect(0, 0, soundOnTexture.width, soundOnTexture.height), Vector2.one * 0.5f);
        }).AddTo(this);
        AudioContenPlayingTime.Subscribe(time =>
        {
            if (time == 0)
            {
                TextTime.text = AudioContenTotleTime.Value + "\"";
            }
            else
            {
                TextTime.text = time + "\"" + "/" + AudioContenTotleTime.Value + "\"";
            }
        }).AddTo(this);

        // 用户头像,没有传头像 使用默认的
        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(data.logoRelativePathUrl, 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);
        }
        // 0-图文打卡 1-音频打卡 2-视频打卡
        if (data.punchType == 0)
        {
            ImgSharePreview.SetActive(true);
            ImgAudioPreview.SetActive(false);
            ImageDownloadUtils.Instance.SetAsyncImage(data.punchPathUrl, ImageThumIcon);
            ImagePunchType.gameObject.SetActive(false);
        }
        else if (data.punchType == 1)
        {
            ImgSharePreview.SetActive(false);
            ImgAudioPreview.SetActive(true);
            BtnAudioPreview.onClick.AddListener(() =>
            {
                if (AudioContentAudioSource.isPlaying)
                {
                    AudioContentAudioSource.Pause();
                }
                Log.I("data.punchPathUrl==" + data.punchPathUrl);
                if (AudioPreviewAudioSource.isPlaying)
                {
                    AudioPreviewAudioSource.Pause();
                }
                else
                {
                    StartCoroutine(SetAudioClip(data.punchPathUrl, AudioPreviewAudioSource));
                }
            });
            ImagePunchType.gameObject.SetActive(false);
        }
        else if (data.punchType == 2)
        {
            ImgSharePreview.SetActive(true);
            ImgAudioPreview.SetActive(false);
            ImageDownloadUtils.Instance.SetAsyncImage(data.thumbnailPath, ImageThumIcon);
            ImagePunchType.gameObject.SetActive(true);
        }

        if (data.comments.IsNotNull() && data.comments.Count > 0)
        {
            Line.SetActive(true);
            TextReply.gameObject.SetActive(true);
            TextReplyContent.gameObject.SetActive(data.comments[0].commentContent.IsNotNullAndEmpty());
            TextReplyContent.text = StringUtil.Emoji(data.comments[0].commentContent);
            if (data.comments[0].commentPathUrl.IsNotNullAndEmpty())
            {
                AudioContent.SetActive(true);
                TextTime.text = data.comments[0].duration / 1000 + "\"";
                BtnPlayState.onClick.AddListener(() =>
                {
                    if (AudioPreviewAudioSource.isPlaying)
                    {
                        AudioPreviewAudioSource.Pause();
                    }

                    if (AudioContentAudioSource.isPlaying)
                    {
                        AudioContentAudioSource.Pause();
                    }
                    else
                    {
                        StartCoroutine(SetAudioClip(data.comments[0].commentPathUrl, AudioContentAudioSource));
                    }
                });
            }
            else
            {
                AudioContent.SetActive(false);
            }
        }
        else
        {
            Line.SetActive(false);
            TextReply.gameObject.SetActive(false);
            TextReplyContent.gameObject.SetActive(false);
            AudioContent.SetActive(false);
        }
        LayoutRebuilder.ForceRebuildLayoutImmediate(MidPanelTransform);
        int height = (int)(Mathf.Abs(MidPanelTransform.rect.height) + 168);

        Debug.Log("MidPanelTransform 的高度 是 " + MidPanelTransform.rect.height);
        Debug.Log("TextShareContent 的高度 是 " + (TextShareContent.rectTransform.rect.height));
        workWallItemHeight += TextName.rectTransform.rect.height;         // 名称
        workWallItemHeight += 10;                                         // spacing
        workWallItemHeight += TextTimeLine.rectTransform.rect.height;     // 发布时间
        workWallItemHeight += 10;                                         // spacing
        workWallItemHeight += TextShareContent.rectTransform.rect.height; // 发布的内容
        workWallItemHeight += 10;                                         // spacing
        if (data.comments.Count > 0)
        {
            workWallItemHeight += TextReply.rectTransform.rect.height;        // 老师回复
            workWallItemHeight += 10;                                         // spacing
            workWallItemHeight += TextReplyContent.rectTransform.rect.height; // 点评的内容
            if (data.comments[0].commentPathUrl.IsNotNullAndEmpty())
            {
                workWallItemHeight += 44; // 回复音频高度
                workWallItemHeight += 10; // spacing
            }
        }
        workWallItemHeight += (34 + 60); // spacing

        if (workWallItemHeight < 312)
        {
            workWallItemHeight = 312;
        }

        transform.GetComponent <RectTransform>().sizeDelta = new Vector2(940, workWallItemHeight);
    }
Example #13
0
        private void StartResquestForSharePoster(ShareAction shareAction)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("babyId", PlayerPrefsUtil.GetBabyId());
            paramDict.Add("shareType", 2);
            paramDict.Add("medalGrade", mData.medalModel.medalGrade);
            HttpUtil.PostWithSign <string>(UrlConst.SharePoster, paramDict)
            .Subscribe(response =>
            {
                Log.I("图片地址: " + response);
                if (shareAction == ShareAction.Save)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        NativeGallery.RequestPermission((result, action) =>
                        {
                            if (result == (int)NativeGallery.Permission.Granted)
                            {
                                AndroidForUnity.CallAndroidForSavePicToAlbum(response);
                                CommonUtil.toast("保存成功");
                            }
                        }, (int)NativeAction.Album);
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        IOSClientUtil.SaveImageToAlubmCallIOSClient(response);
                    }
                }
                else if (shareAction == ShareAction.Wechat)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        ShareModel shareModel   = new ShareModel();
                        shareModel.imageUrl     = response;
                        shareModel.platformName = AppConst.SHARE_WECHAT;
                        shareModel.type         = AppConst.SHARE_IMAGE_TYPE;
                        shareModel.title        = AppConst.SHARE_TITLE;
                        if (mData.medalModel.isShare == 0)
                        {
                            shareModel.toastMessage = "分享成功+" + mData.medalModel.medalShareScore + "积分";
                        }
                        AndroidForUnity.CallAndroidForShare(SerializeHelper.ToJson(shareModel));
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        Dictionary <string, object> sharParmsDic = new Dictionary <string, object>();
                        sharParmsDic.Add("platformType", "WechatSession");
                        sharParmsDic.Add("shareType", "image");
                        sharParmsDic.Add("image", response);
                        if (mData.medalModel.isShare == 0)
                        {
                            string shareToastMessage = "分享成功+" + mData.medalModel.medalShareScore + "积分";
                            sharParmsDic.Add("shareToastMsg", shareToastMessage);
                        }
                        IOSClientUtil.ShareObjectCallIOSClient(SerializeHelper.ToJson(sharParmsDic));
                    }
                }
                else if (shareAction == ShareAction.WechatMoments)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        ShareModel shareModel   = new ShareModel();
                        shareModel.imageUrl     = response;
                        shareModel.platformName = AppConst.SHARE_WECHAT_MOMENTS;
                        shareModel.type         = AppConst.SHARE_IMAGE_TYPE;
                        shareModel.title        = AppConst.SHARE_TITLE;
                        if (mData.medalModel.isShare == 0)
                        {
                            shareModel.toastMessage = "分享成功+" + mData.medalModel.medalShareScore + "积分";
                        }
                        AndroidForUnity.CallAndroidForShare(SerializeHelper.ToJson(shareModel));
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        Dictionary <string, object> sharParmsDic = new Dictionary <string, object>();
                        sharParmsDic.Add("platformType", "WechatTimeLine");
                        sharParmsDic.Add("shareType", "image");
                        sharParmsDic.Add("image", response);

                        if (mData.medalModel.isShare == 0)
                        {
                            string shareToastMessage = "分享成功+" + mData.medalModel.medalShareScore + "积分";
                            sharParmsDic.Add("shareToastMsg", shareToastMessage);
                        }
                        IOSClientUtil.ShareObjectCallIOSClient(SerializeHelper.ToJson(sharParmsDic));
                    }
                }
            }
                       , e =>
            {
                if (e is HttpException)
                {
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                }
            }).AddTo(this);
        }
        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);
        }
Example #15
0
        private int action;      // 1注册,2登录,3登录忘记密码,4设置忘记密码


        protected override void OnInit(QFramework.IUIData uiData)
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                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());
            }
            BtnClearPwd.gameObject.SetActive(false);
            BtnClearPhone.gameObject.SetActive(false);
            StartAnimation();
            mData  = uiData as LoginPanelData ?? new LoginPanelData();
            action = mData.action;
            if (action == 4)
            {
                // 隐藏手机号输入 获取验证码
                PhonePanel.gameObject.SetActive(false);
                CodePanel.gameObject.SetActive(true);
                PwdPanel.gameObject.SetActive(false);
                BtnConfirm.gameObject.SetActive(false);
                BtnBack.gameObject.SetActive(true);
                mBusType = "2";
                StartResquestForSendSMS(mBusType);
            }
            else
            {
                PhonePanel.gameObject.SetActive(true);
                CodePanel.gameObject.SetActive(false);
                PwdPanel.gameObject.SetActive(false);
                BtnConfirm.gameObject.SetActive(true);
                BtnBack.gameObject.SetActive(false);
            }
            // please add init code here
            BtnBack.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                BackClick();
            });
            Observable.EveryUpdate().Where(_ => Input.GetKeyDown(KeyCode.Escape))
            .Subscribe(_ =>
            {
                if (PhonePanel.gameObject.active)
                {
                    Application.Quit();
                }
                else
                {
                    BackClick();
                }
            }).AddTo(this);
            BtnConfirm.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
                if (PhonePanel.gameObject.active)
                {
                    if (InputPhone.text.IsNullOrEmpty())
                    {
                        Log.I("请输入手机号");
                        CommonUtil.toast("请输入手机号");
                    }
                    else
                    {
                        StartRequestForCheckIsRegister();
                    }
                }
                else
                {
                    if (InputPwd.text.IsNullOrEmpty())
                    {
                        Log.I("请输入密码");
                        CommonUtil.toast("请输入密码");
                    }
                    else if (!StringUtil.checkPassword(InputPwd.text))
                    {
                        Log.I("密码必须由至少8位的字母+数字组成");
                        CommonUtil.toast("密码必须由至少8位的字母+数字组成");
                    }
                    else
                    {
                        if (action == 1)
                        {
                            StartResquestForDoRegister();
                        }
                        else if (action == 2)
                        {
                            StartResquestForDoLogin(InputPhone.text);
                        }
                        else if (action == 3)
                        {
                            StartResquestForModifyPasswd();
                        }
                        else if (action == 4)
                        {
                            StartResquestForDoUpdatePasswd();
                        }
                    }
                }
            });
            BtnCode.onClick.AddListener(() =>
            {
                Log.I("获取验证码 click");
                StartResquestForSendSMS(mBusType);
            });
            InputCode.onValueChange.AddListener(ChangeCode);
            InputPhone.onValueChange.AddListener(ChangePhone);
            InputPwd.onValueChange.AddListener(ChangePwd);
            BtnClearPhone.onClick.AddListener(() => { InputPhone.text = ""; });
            BtnClearPwd.onClick.AddListener(() => { InputPwd.text = ""; });
            BtnHideOrShow.onClick.AddListener(() =>
            {
                if (mIsHidePwd)
                {
                    var texture2D        = mResLoader.LoadSync <Texture2D>("btn_show_pwd");
                    ImgHideOrShow.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                    InputPwd.inputType   = InputField.InputType.Standard;
                    mIsHidePwd           = false;
                    InputPwd.MyUpdateLabel();
                    Log.I("显示" + InputPwd.text);
                }
                else
                {
                    var texture2D        = mResLoader.LoadSync <Texture2D>("btn_hide_pwd");
                    ImgHideOrShow.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                    InputPwd.inputType   = InputField.InputType.Password;
                    mIsHidePwd           = true;
                    InputPwd.MyUpdateLabel();
                    Log.I("隐藏" + InputPwd.text);
                }
            });
            BtnForget.onClick.AddListener(() =>
            {
                mBusType = "2";
                StartResquestForSendSMS(mBusType);
            });
            texture2DSel = mResLoader.LoadSync <Texture2D>("btn_code_sel");
            texture2DNor = mResLoader.LoadSync <Texture2D>("btn_code_nor");
        }
        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);
        }