Example #1
0
    public static IObservable <string> GetWithSign(string url, Dictionary <string, object> param, bool showToast = true)
    {
        if (token.IsNullOrEmpty())
        {
            token = PlayerPrefsUtil.GetToken();
        }

        if (!token.IsNullOrEmpty())
        {
            param.Add("token", token);
        }

        var methodParams = SignUtil.getMethodParamStr(param);
        var sign         = SignUtil.getSign(param);

        url = url + "?" + methodParams + "&sign=" + sign + "&appid=" + AppConst.APPID;
        return(ObservableWWW.Get(url).DoOnError(e =>
        {
            LoadingManager.GetInstance().DismissLoading();
            if (showToast)
            {
                if (e is HttpException)
                {
                }
                else if (e is WWWErrorException)
                {
                    ToastManager.GetInstance().CreatToast("网络连接失败,请检查网络连接");
                }
                else
                {
                    ToastManager.GetInstance().CreatToast(e.Message);
                }
            }
        }));
    }
Example #2
0
    private bool FillRoom(int aX, int aY, bool aStartingRoom = false)
    {
        bool generate = Random.Range(0f, 1f) >= myGenerationRoomPercentage ? true : false;

        if (!generate && !aStartingRoom)
        {
            myWorld[aY * myBiomeSideSize + aX].myRoomUsed = true;
            return(false);
        }

        myRoomsNumber++;
        LoadingManager.GetInstance().AddToSpawn();

        if (aX - 1 > 0 && myWorld[aY * myBiomeSideSize + aX - 1].myRoomUsed == false)
        {
            FillRoom(aX - 1, aY);
        }
        if (aX + 1 < myBiomeSideSize && myWorld[aY * myBiomeSideSize + aX + 1].myRoomUsed == false)
        {
            FillRoom(aX + 1, aY);
        }
        if (aY - 1 > 0 && myWorld[(aY - 1) * myBiomeSideSize + aX].myRoomUsed == false)
        {
            FillRoom(aX, aY - 1);
        }
        if (aY + 1 < myBiomeSideSize && myWorld[(aY + 1) * myBiomeSideSize + aX].myRoomUsed == false)
        {
            FillRoom(aX, aY + 1);
        }

        return(true);
    }
Example #3
0
    public static IObservable <string> PostWithSign(string url, Dictionary <string, object> param, bool showToast = true)
    {
        StringBuilder strParam  = new StringBuilder();
        var           formParam = new WWWForm();

        if (token.IsNullOrEmpty())
        {
            token = PlayerPrefsUtil.GetToken();
        }

        if (!token.IsNullOrEmpty())
        {
            param.Add("token", token);
        }

        if (param.Count > 0)
        {
            param.ForEach(pair =>
            {
                strParam.Append(pair.Key);
                strParam.Append(":");
                strParam.Append(pair.Value.ToString());
                strParam.Append("&");
                formParam.AddField(pair.Key, pair.Value.ToString());
            });
            string sign = SignUtil.getSign(param);
            formParam.AddField("sign", sign);
            formParam.AddField("appid", AppConst.APPID);
            strParam.Append("sign");
            strParam.Append(":");
            strParam.Append(sign);
            strParam.Append("&");
            strParam.Append("appid");
            strParam.Append(":");
            strParam.Append(AppConst.APPID);
        }
        Log.I("url==" + url);
        Log.I("formParam==" + strParam);
        return(ObservableWWW.Post(url, formParam).DoOnError(e =>
        {
            LoadingManager.GetInstance().DismissLoading();
            if (showToast)
            {
                if (e is HttpException)
                {
                    Log.E("e.Message: " + e.Message);
                }
                else if (e is WWWErrorException)
                {
                    ToastManager.GetInstance().CreatToast("网络连接失败,请检查网络连接");
                }
                else
                {
                    ToastManager.GetInstance().CreatToast(e.Message);
                }
            }
        }));
    }
 protected override void OnClose()
 {
     LoadingManager.GetInstance().DismissLoading();
     if (mResLoader.IsNotNull())
     {
         mResLoader.Recycle2Cache();
         mResLoader = null;
     }
     StopAllCoroutines();
 }
Example #5
0
 protected override void OnClose()
 {
     AudioManager.SetMusicOff();
     mMainAnimationGo.SetActive(false);
     GameObject.Destroy(mMainAnimationGo);
     mMainAnimationGo = null;
     mResLoader.Recycle2Cache();
     mResLoader      = null;
     mTexture2DHBoy  = null;
     mTexture2DHGirl = null;
     LoadingManager.GetInstance().DismissLoading();
     StopAllCoroutines();
 }
Example #6
0
    private IEnumerator InstantiateRooms()
    {
        if (WorldGeneration.GetInstance().DEBUG)
        {
            WorldGeneration.GetInstance().DEBUGCANVAS.ClearHighlightBiome();
        }

        for (int y = 0; y < myBiomeSideSize; ++y)
        {
            for (int x = 0; x < myBiomeSideSize; ++x)
            {
                if (myWorld[y * myBiomeSideSize + x].myRoomUsed == true)
                {
                    Room room = Instantiate(myRoomPrefab, myTransform);
                    room.transform.localPosition = new Vector3(x * myRoomSideSize * mySpriteSpace, y * myRoomSideSize * mySpriteSpace, 0);
                    room.myRoomData = myWorld[y * myBiomeSideSize + x];
                    myRooms.Add(room);
                    //room.ConstuctRoom(myRoomSideSize, this);

                    room.GetSeedAndGenerate(this);

                    if (myStartingRoomData.myX == x && myStartingRoomData.myY == y)
                    {
                        room.myStartingRoom = true;
                        myStartingRoom      = room;
                    }

                    room.transform.parent = myTransform;

                    LoadingManager.GetInstance().AddSpawned();

                    if (WorldGeneration.GetInstance().DEBUG)
                    {
                        WorldGeneration.GetInstance().DEBUGCANVAS.HighlightBiome(x, y);

                        yield return(new WaitForSeconds(WorldGeneration.GetInstance().STEPTIME));
                    }
                    else
                    {
                        yield return(null);
                    }
                }
            }
        }

        myGenerationDone = true;

        gameObject.SetActive(false);
    }
Example #7
0
    public static IObservable <T> GetWithSign <T>(string url, Dictionary <string, object> param, bool showToast = true)
    {
        if (token.IsNullOrEmpty())
        {
            token = PlayerPrefsUtil.GetToken();
        }

        if (!token.IsNullOrEmpty())
        {
            param.Add("token", token);
        }

        var methodParams = SignUtil.getMethodParamStr(param);
        var sign         = SignUtil.getSign(param);

        url = url + "?" + methodParams + "&sign=" + sign + "&appid=" + AppConst.APPID;
        return(ObservableWWW.Get(url).Select <string, T>(s =>
        {
            Log.I("url==" + url + "\n网络请求返回内容\n" + s);
            BaseEntity <T> deserializeObject = JsonConvert.DeserializeObject <BaseEntity <T> >(s);
            if (deserializeObject.status != 1)
            {
                CommonUtil.error(deserializeObject.errCode, deserializeObject.message, deserializeObject.status);
                throw new HttpException(deserializeObject.errCode, deserializeObject.message, deserializeObject.status);
            }

            return deserializeObject.data;
        }).DoOnError(e =>
        {
            LoadingManager.GetInstance().DismissLoading();
            if (showToast)
            {
                if (e is HttpException)
                {
                    CommonUtil.toast(((HttpException)e).ErrMessage);
                }
                else if (e is WWWErrorException)
                {
                    ToastManager.GetInstance().CreatToast("网络连接失败,请检查网络连接");
                }
                else
                {
                    ToastManager.GetInstance().CreatToast(e.Message);
                }
            }
        }));
    }
Example #8
0
    public void SwitchPauseState()
    {
        if (myPauseMenu == null)
        {
            myPauseMenu = LoadingManager.GetInstance().myPauseMenu;
        }
        myMenuOpen = !myMenuOpen;

        if (myMenuOpen)
        {
            myPauseMenu.SetActive(true);
        }
        else
        {
            myPauseMenu.SetActive(false);
        }
    }
        void StartRequestForPunch(string filePath)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("babyId", PlayerPrefsUtil.GetBabyId());
            paramDict.Add("relBoxId", mData.BoxId);
            paramDict.Add("boxDay", mData.BoxDay);
            if (mData.Action == AttendanceAdd.Audio)
            {
                paramDict.Add("duration", (int)(MicrophoneManager.GetInstance().GetClipLength() * 1000));
            }
            paramDict.Add("punchText", InputContent.text);
            paramDict.Add("punchType", (int)mData.Action);
            paramDict.Add("punchPath", filePath);
            HttpUtil.PostWithSign <AttendanceModel>(UrlConst.Punch, paramDict)
            .Subscribe(response =>
            {
                LoadingManager.GetInstance().DismissLoading();
                if (PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList.IsNull())
                {
                    PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList = new List <int>();
                }
                if (PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList
                    .Contains(mData.BoxDay))
                {
                    PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList.Remove(mData.BoxDay);
                }
                PlayerPrefsUtil.LockModels[PlayerPrefsUtil.GetBoxMonthIndex()].boxDayList.Add(mData.BoxDay);
                Log.I("发布:" + mData.Action);
                BtnPush.enabled = true;
                SimpleEventSystem.Publish(new AttendanceSuccess(true));
                UIMgr.OpenPanel <AttendanceSharePanel>(new AttendanceSharePanelData()
                {
                    AttendanceModel = response
                }, UITransitionType.CIRCLE);
                Close();
            }
                       , e =>
            {
                BtnPush.enabled = true;
                if (e is HttpException)
                {
                    HttpException http = e as HttpException;
                }
            }).AddTo(this);
        }
Example #10
0
    public static IObservable <string> PostWithSign(string url, Dictionary <string, object> param,
                                                    string fileName = null, string filePath = null, bool showToast = true)
    {
        var formParam = new WWWForm();

        if (token.IsNullOrEmpty())
        {
            token = PlayerPrefsUtil.GetToken();
        }

        if (!token.IsNullOrEmpty())
        {
            param.Add("token", token);
        }

        if (param.Count > 0)
        {
            param.ForEach(pair => { formParam.AddField(pair.Key, pair.Value.ToString()); });
            string sign = SignUtil.getSign(param);
            formParam.AddField("sign", sign);
            formParam.AddField("appid", AppConst.APPID);
        }

        return(ObservableWWW.Post(url, formParam).DoOnError(e =>
        {
            LoadingManager.GetInstance().DismissLoading();
            if (showToast)
            {
                if (e is HttpException)
                {
                }
                else if (e is WWWErrorException)
                {
                    ToastManager.GetInstance().CreatToast("网络连接失败,请检查网络连接");
                }
                else
                {
                    ToastManager.GetInstance().CreatToast(e.Message);
                }
            }
        }));
    }
Example #11
0
    public static IObservable <T> PostWithSign <T>(string url, Dictionary <string, object> param,
                                                   string fileName = null, string filePath = null, bool showToast = true)
    {
        StringBuilder strParam  = new StringBuilder();
        var           formParam = new WWWForm();

        if (token.IsNullOrEmpty())
        {
            token = PlayerPrefsUtil.GetToken();
        }

        if (!token.IsNullOrEmpty())
        {
            param.Add("token", token);
        }

        if (param.Count > 0)
        {
            param.ForEach(pair =>
            {
                strParam.Append(pair.Key);
                strParam.Append(":");
                strParam.Append(pair.Value.ToString());
                strParam.Append("&");
                formParam.AddField(pair.Key, pair.Value.ToString());
            });
            string sign = SignUtil.getSign(param);
            formParam.AddField("sign", sign);
            formParam.AddField("appid", AppConst.APPID);
            strParam.Append("sign");
            strParam.Append(":");
            strParam.Append(sign);
            strParam.Append("&");
            strParam.Append("appid");
            strParam.Append(":");
            strParam.Append(AppConst.APPID);
        }

        if (filePath.IsNotNullAndEmpty())
        {
            formParam.AddBinaryData("file", File.ReadAllBytes(filePath), fileName);
            strParam.Append("&");
            strParam.Append("file");
            strParam.Append(":");
            strParam.Append(File.ReadAllBytes(filePath));
        }

        return(ObservableWWW.Post(url, formParam).Select <string, T>(s =>
        {
            Log.I("url==" + url);
            Log.I("formParam==" + strParam);
            Log.I("返回信息是" + s);
            if (s.IsNullOrEmpty())
            {
                throw new HttpException("104", "网络连接失败", 104);
            }

            BaseEntity <T> deserializeObject = JsonConvert.DeserializeObject <BaseEntity <T> >(s);
            if (deserializeObject.status != 1)
            {
                CommonUtil.error(deserializeObject.errCode, deserializeObject.message, deserializeObject.status);
                throw new HttpException(deserializeObject.errCode, deserializeObject.message, deserializeObject.status);
            }

            return deserializeObject.data;
        }).DoOnError(e =>
        {
            LoadingManager.GetInstance().DismissLoading();
            if (showToast)
            {
                if (e is HttpException)
                {
                    CommonUtil.toast(((HttpException)e).ErrMessage);
                }
                else if (e is WWWErrorException)
                {
                    ToastManager.GetInstance().CreatToast("网络连接失败,请检查网络连接");
                }
                else
                {
                    ToastManager.GetInstance().CreatToast(e.Message);
                }
            }
        }));
    }
Example #12
0
        /**
         * 根据计划id,从服务器获取计划详情
         */
        private void StartRequestForGetPlanInfo(int planId, int month)
        {
            if (planId == 0)
            {
                Log.E("弹吐司" + "未获取计划");
                return;
            }
            LoadingManager.GetInstance().CreatLoading();
            Dictionary <string, object> babyStudyLockInfoParam = new Dictionary <string, object>();

            babyStudyLockInfoParam.Add("planId", planId);
            babyStudyLockInfoParam.Add("babyId", PlayerPrefsUtil.UserInfo.relBabyId);

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

            planInfoParam.Add("planId", planId);
            planInfoParam.Add("boxInfo", GetLocalPlanVersion(planId));// json

            Observable.WhenAll(HttpUtil.PostWithSign(UrlConst.BabyStudyLockInfo, babyStudyLockInfoParam, true),
                               HttpUtil.PostWithSign(UrlConst.PlanInfo, planInfoParam, true))
            .Subscribe(xs =>
            {
                LoadingManager.GetInstance().DismissLoading();
                if (xs.IsNull())
                {
                    Log.I("xs is null ");
                    CommonUtil.toast("数据异常");
                    return;
                }
                var babyStudyLockModelEntity = xs[0].FromJson <BaseEntity <List <BabyStudyLockModel> > >();
                var contentModelEntity       = xs[1].FromJson <BaseEntity <ContentModel> >();
                if (contentModelEntity.status == 1)
                {
                    PlayerPrefsUtil.ContentModel = contentModelEntity.data;
                }
                else
                {
                    CommonUtil.error(contentModelEntity.errCode, contentModelEntity.message, contentModelEntity.status);
                    return;
                }
                if (babyStudyLockModelEntity.status == 1)
                {
                    PlayerPrefsUtil.LockModels = babyStudyLockModelEntity.data;
                }
                else
                {
                    CommonUtil.error(contentModelEntity.errCode, contentModelEntity.message, contentModelEntity.status);
                    return;
                }
                if (contentModelEntity.data.IsNotNull())
                {
                    UIMgr.OpenPanel <BookDayListPanel>(new BookDayListPanelData()
                    {
                        PlanId = contentModelEntity.data.planId,
                        Month  = month
                    }, UITransitionType.CLOUD, this);
                }
            }, exception =>
            {
                Log.I(exception.ToString());
            }).AddTo(this);
        }
Example #13
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));
            }
        }
        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);
        }