123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using LitJson;
- using rtc;
- using SC.XR.Unity;
- using ShadowStudio.UI;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using static ScenesManager;
- public class ActivityMgr : MonoBehaviour
- {
- public SCInputField sCInputField;
- public Text activityRemind;
- public Image AcvicityInputKuangImage;
- public Button querenBtn;
- public Button cancelBtn;
- private bool isLock;
- // Start is called before the first frame update
- void Start()
- {
- sCInputField.onValueChanged.AddListener(OnValueChanged);
- querenBtn.onClick.AddListener(ClickQueren);
- cancelBtn.onClick.AddListener(ClickCancel);
- }
- public void Init()
- {
- if (sCInputField.text != "")
- {
- sCInputField.text = "";
- }
- activityRemind.gameObject.SetActive(false);
- AcvicityInputKuangImage.color = Color.white;
- if (isLock)
- {
- isLock = false;
- }
- querenBtn.enabled = true;
- cancelBtn.enabled = true;
- }
- private void OnValueChanged(string content)
- {
- activityRemind.gameObject.SetActive(false);
- AcvicityInputKuangImage.color = Color.white;
- }
- public void ClickQueren()
- {
- if (sCInputField.text == "")
- {
- InputError(RtcStrConfig.activitynull);
- }
- else if(activityRemind.gameObject.activeSelf)
- {
- return;
- }
- else
- {
- if (sCInputField.text.Length != 8)
- {
- InputError(RtcStrConfig.activityError);
- }
- else
- {
- if (!isLock)
- {
- isLock = true;
- NetWorkHeaders.Activate(sCInputField.text, ActivitySucess, ActivityFail);
- }
- }
- }
- }
- public void InputError(string str)
- {
- activityRemind.gameObject.SetActive(true);
- AcvicityInputKuangImage.color = Color.red;
- activityRemind.text = str;
- }
- private void ActivityFail(string str)
- {
- isLock = false;
- JsonData data = null;
- string code = "";
- try
- {
- data = JsonMapper.ToObject(str);
- code = data["code"].ToString();
- }
- catch (Exception e)
- {
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, RtcStrConfig.serverError);
- return;
- }
- switch (code)
- {
- case "5001":
- InputError(RtcStrConfig.activityError);
- break;
- case "9002":
- InputError(RtcStrConfig.activityError);
- break;
- }
- }
- private void ActivitySucess(JsonData data)
- {
- if (data["code"].ToString() == "200")
- {
- isLock = false;
- querenBtn.enabled = false;
- cancelBtn.enabled = false;
- WSHandler.clientClosed();
- AcivtyGetUserInfo();
- }
- }
- public void ClickCancel()
- {
- this.gameObject.SetActive(false);
- }
- public void AcivtyGetUserInfo()
- {
- NetWorkHeaders.GetUserInfo((JsonData sData) => {
- UserInfo.phone = sData["data"]["phone"].ToString();
- UserInfo.userName = sData["data"]["nickName"].ToString();
- if (UserInfo.userName == "")
- {
- UserInfo.userName = UserInfo.phone;
- //UserInfo.userName = "YCKJ" + UserInfo.Account.Substring(UserInfo.Account.Length - 4);
- }
- UserInfo.activateType = int.Parse(sData["data"]["activateType"].ToString());
- UserInfo.indate = double.Parse(sData["data"]["indate"].ToString());
- CustomInfo.isSendAudio = bool.Parse(sData["data"]["settings"]["mic"].ToString());
- CustomInfo.isSendVideo = bool.Parse(sData["data"]["settings"]["camera"].ToString());
- CustomInfo.camIndex = int.Parse(sData["data"]["settings"]["resolution"].ToString());
- WSHandler.Office.OnInit -= Init;
- WSHandler.Office.OnInit += Init;
- WSHandler.init();
- }, (string failStr) => {
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, RtcStrConfig.serverFail);
- });
- }
- private void Init(JsonData data)
- {
- this.gameObject.SetActive(false);
- querenBtn.enabled = true;
- cancelBtn.enabled = true;
- switch (UserSystem.Instance.activityText.text)
- {
- case "激活":
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "账号激活成功");
- break;
- case "续费":
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "账号续费成功");
- break;
- }
- ScenesManager.Instance.showOffice(SceneType.UserSystem);
- WSHandler.Office.OnInit -= Init;
- }
- }
|