LoadingUI.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import BaseUI from "../../../MOKA/component/BaseUI";
  2. import GameController from "../../GameController";
  3. import LoadingNode from "./LoadingNode";
  4. const { ccclass, menu, property } = cc._decorator;
  5. @ccclass
  6. export default class LoadingUI extends BaseUI {
  7. ui: LoadingNode = null;
  8. protected static prefabUrl = "module/loading/loading";
  9. protected static className = "LoadingUI";
  10. @property(cc.EditBox)
  11. lbl_usename: cc.EditBox = null;
  12. @property(cc.EditBox)
  13. lbl_server: cc.EditBox = null;
  14. @property(cc.Button)
  15. btn_login: cc.Button = null;
  16. @property(cc.ToggleContainer)
  17. toogle: cc.ToggleContainer = null;
  18. onLoad() {
  19. this.ui = this.node.addComponent(LoadingNode);
  20. let mac = GameController.storageData.getStorage("testmac", 1);
  21. this.lbl_usename.string = mac == null ? "c9:65:e2:1c:b0:23" : mac;
  22. }
  23. disPlayloginBtn() {
  24. this.btn_login.node.active = true;
  25. }
  26. clickLogin() {
  27. GameController.http.mac = this.lbl_usename.string;
  28. GameController.http.serverUrl = this.lbl_server.string;
  29. GameController.storageData.setStorage("testmac", GameController.http.mac, 1);
  30. GameController.login();
  31. }
  32. clickServer(){
  33. if(this.toogle.toggleItems[0].isChecked){
  34. this.lbl_server.string = 'https://tafang-test.duiweize.com/';
  35. }
  36. else{
  37. this.lbl_server.string = 'http://172.16.15.167:9092/';
  38. GameController.commonData.appid = 'wxef592f91d2d15555';
  39. GameController.commonData.version = '1.0';
  40. }
  41. }
  42. start() {
  43. }
  44. setProgress(percent: number) {
  45. this.ui.node_chuan.getComponent(cc.Sprite).fillRange = percent;
  46. let x = this.ui.node_chuan.width * percent;
  47. this.ui.img_chuan.setPosition(x, this.ui.img_chuan.y);
  48. this.setLoadingStr("加载不耗流量 " + (percent * 100) + "%");
  49. }
  50. setLoadingStr(str) {
  51. this.ui.lbl_loading.getComponent(cc.Label).string = str;
  52. }
  53. setTips(str) {
  54. this.ui.lbl_tips.getComponent(cc.Label).string = str;
  55. }
  56. }