Login.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { GameViewType } from "../main/ViewManage";
  2. import ViewObject from "../main/ViewObject";
  3. import { HttpStateType, ReveData } from "../util/CHttp";
  4. const {ccclass, property} = cc._decorator;
  5. @ccclass
  6. export default class Login extends ViewObject {
  7. @property(cc.EditBox)
  8. mUserName: cc.EditBox = null;
  9. @property(cc.EditBox)
  10. mPassWord: cc.EditBox = null;
  11. public onclickLogin(){
  12. let http = this.main.loginHttp;
  13. let msg = {
  14. 'userName':this.mUserName.string,
  15. 'passWord':this.mPassWord.string
  16. }
  17. this.main.startLoad();
  18. http.sendForm('/login',msg,(state,reve:ReveData)=>{
  19. this.main.stopLoad();
  20. if(state == HttpStateType.SUCCESS){
  21. if(reve.retCode == 0){
  22. this.main.userData = reve.data;
  23. this.openArea();
  24. }else{
  25. this.main.showTips(reve.message);
  26. }
  27. }else{
  28. this.main.showTips('网络异常');
  29. }
  30. })
  31. }
  32. /**
  33. * 打开选区界面
  34. */
  35. public openArea(){
  36. //载入测试的登陆界面
  37. this.main.viewManage.loadFunc(GameViewType.area,(viewObject:ViewObject)=>{
  38. viewObject.show(this);
  39. });
  40. }
  41. public onclickTest(){
  42. this.main.userData = {
  43. id:2,
  44. token:'edbeb6d9b01bfd41eff12efb7def330f',
  45. zone:null,
  46. };
  47. this.openArea();
  48. }
  49. }