Login.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. mk.ui.openPanel("game/prefab/game");
  37. gData.gameData.dataFinish = false;
  38. }
  39. }
  40. else {
  41. gData.loginData.loadLocalRes();
  42. }
  43. }
  44. }