Login.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import JsbSystem from "../../../mk/system/JsbSystem";
  2. import LoadingBar from "../../component/LoadingBar";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class Login extends cc.Component {
  6. @property(LoadingBar)
  7. private bar: LoadingBar = null;
  8. @property({ displayName: '加载文字', type: cc.Label })
  9. private lbl_progress: cc.Label = null;
  10. @property({ displayName: '服务协议', type: cc.Label })
  11. private lbl_server: cc.Label = null;
  12. @property({ displayName: '隐私协议', type: cc.Label })
  13. private lbl_privacy: cc.Label = null;
  14. onLoad() {
  15. this.setProgress(0);
  16. }
  17. start() {
  18. JsbSystem.getDeviceInfo();
  19. }
  20. private setProgress(current) {
  21. this.bar.setProgress(current);
  22. this.lbl_progress.string = "加载不消耗流量 " + current + "%";
  23. }
  24. private process: number = 0;
  25. update() {
  26. if (this.process < 100) {
  27. this.process += 2;
  28. this.setProgress(this.process);
  29. }
  30. if (gData.loginData.loadResCompelete) {
  31. if (gData.appData.getDeviceInfoCompelete) {
  32. gData.loginData.login();
  33. gData.appData.getDeviceInfoCompelete = false;
  34. }
  35. else if (gData.gameData.dataFinish) {//登录流程完毕
  36. if (!mk.storage.getStorage('notShowAgreementTip')) {//!mk.storage.getStorage('notShowAgreementTip')
  37. mk.ui.openPanel("module/agreementTip/agreementTip");
  38. } else {
  39. mk.ui.openPanel("game/prefab/game");
  40. }
  41. gData.gameData.dataFinish = false;
  42. }
  43. }
  44. else {
  45. gData.loginData.loadLocalRes();
  46. }
  47. }
  48. }