mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
更新登录
This commit is contained in:
@@ -4,6 +4,8 @@ import { Toggle } from 'cc';
|
||||
import { JNSyncAction } from '../../../../extensions/ngame/assets/ngame/sync/JNSyncAction';
|
||||
import { director } from 'cc';
|
||||
import { WorldCanvas } from '../../WorldCanvas';
|
||||
import { StorageData, StorageEnum } from '../../consts/GData';
|
||||
import { GUI } from '../UIConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HomeView')
|
||||
@@ -39,10 +41,17 @@ export class HomeView extends JNGLayerBase {
|
||||
//前往PVP
|
||||
onClickGoPVP(){
|
||||
director.getScene().getComponentInChildren(WorldCanvas).index = 0;
|
||||
app.layer.Open(GUI.Tips,{text:"切换成功 请点击重置"});
|
||||
}
|
||||
//前往无尽
|
||||
onClickGoOnHook(){
|
||||
director.getScene().getComponentInChildren(WorldCanvas).index = 1;
|
||||
app.layer.Open(GUI.Tips,{text:"切换成功 请点击重置"});
|
||||
}
|
||||
//清除Token
|
||||
onClickToken(){
|
||||
StorageData.delect(StorageEnum.Token);
|
||||
app.layer.Open(GUI.Tips,{text:"清除成功"});
|
||||
}
|
||||
|
||||
}
|
||||
|
9
JisolGameCocos/assets/script/ui/System.meta
Normal file
9
JisolGameCocos/assets/script/ui/System.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "beb0794b-9e15-4b22-8b23-48017459df89",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
58
JisolGameCocos/assets/script/ui/System/LoginView.ts
Normal file
58
JisolGameCocos/assets/script/ui/System/LoginView.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
import { API } from '../../consts/API';
|
||||
import { EditBox } from 'cc';
|
||||
import { app } from '../../App';
|
||||
import { GUI } from '../UIConfig';
|
||||
import { StorageData, StorageEnum } from '../../consts/GData';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('LoginView')
|
||||
export class LoginView extends JNLayerBase {
|
||||
|
||||
resolve:(token:string) => void;
|
||||
|
||||
@property(EditBox)
|
||||
account:EditBox;
|
||||
@property(EditBox)
|
||||
password:EditBox;
|
||||
|
||||
onJNLoad(resolve?: (token:string) => void): void {
|
||||
super.onJNLoad();
|
||||
this.resolve = resolve;
|
||||
}
|
||||
|
||||
|
||||
//点击登录
|
||||
async onClickLogin(){
|
||||
//校验
|
||||
if(!(this.account.string.length) || !(this.password.string.length)){
|
||||
app.layer.Open(GUI.Tips,{text:"请输入账号密码"});
|
||||
return;
|
||||
}
|
||||
|
||||
//登录账号
|
||||
let info = await API.UserLogin(this.account.string,this.password.string);
|
||||
if(info){
|
||||
app.layer.Open(GUI.Tips,{text:"登录成功"});
|
||||
//保存Token
|
||||
StorageData.set(StorageEnum.Token,info.token);
|
||||
this.resolve(info.token);
|
||||
this.onJNClose();
|
||||
}
|
||||
}
|
||||
|
||||
//点击注册账号
|
||||
async onClickRegister(){
|
||||
//注册账号
|
||||
let info = await API.UserRegister();
|
||||
//显示提示
|
||||
app.layer.Open(GUI.Tips,{text:"注册成功"});
|
||||
//显示账号和密码
|
||||
this.account.string = `${info.userId}`;
|
||||
this.password.string = info.userPass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
9
JisolGameCocos/assets/script/ui/System/LoginView.ts.meta
Normal file
9
JisolGameCocos/assets/script/ui/System/LoginView.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d36bcaa8-bb30-419b-be25-ed9f10aef387",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
9
JisolGameCocos/assets/script/ui/System/Tips.meta
Normal file
9
JisolGameCocos/assets/script/ui/System/Tips.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "072aa010-a6b8-4ff4-b104-5bc19b5ac2fb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
35
JisolGameCocos/assets/script/ui/System/Tips/TipsView.ts
Normal file
35
JisolGameCocos/assets/script/ui/System/Tips/TipsView.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
import { app } from '../../../App';
|
||||
import { Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export interface TipsArgs{
|
||||
text?:string; //内容
|
||||
time?:number; //显示时间
|
||||
}
|
||||
|
||||
@ccclass('TipsView')
|
||||
export class TipsView extends JNLayerBase {
|
||||
|
||||
@property(Label)
|
||||
text:Label;
|
||||
|
||||
onJNLoad(data: TipsArgs = {}): void {
|
||||
if(!data) data = {};
|
||||
|
||||
data.text = data.text || "这是一个提示";
|
||||
data.time = data.time || 3;
|
||||
|
||||
//显示弹窗内容
|
||||
this.text.string = data.text;
|
||||
|
||||
this.scheduleOnce(() => {
|
||||
this.onJNClose();
|
||||
},data.time)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "76584604-effd-4af6-b3ef-7246a8c37260",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -3,15 +3,39 @@ import { JNLayerAnim, JNLayerInfo } from "../../../extensions/ngame/assets/ngame
|
||||
|
||||
export enum GLayer{
|
||||
View = "View",
|
||||
Popup = "Popup",
|
||||
Tips = "Tips",
|
||||
}
|
||||
|
||||
export enum GUI{
|
||||
Loading = "Loading",
|
||||
Home = "Home",
|
||||
/** 系统UI */
|
||||
Login = "Login", //登录页面
|
||||
Loading = "Loading", //加载页面
|
||||
Tips = "Tips", //提示
|
||||
|
||||
Home = "Home", //主页面
|
||||
}
|
||||
|
||||
export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
[GUI.Loading]:{
|
||||
|
||||
//系统UI
|
||||
const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
[GUI.Tips]:{
|
||||
layer:GLayer.Tips,
|
||||
uri: "prefab/ui/System/Tips/TipsView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
},
|
||||
[GUI.Login]:{
|
||||
layer:GLayer.Popup,
|
||||
uri: "prefab/ui/System/LoginView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
},
|
||||
[GUI.Loading]:{
|
||||
layer:GLayer.View,
|
||||
uri: "prefab/ui/Loading/LoadingView",
|
||||
anims:{
|
||||
@@ -19,7 +43,10 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
||||
},
|
||||
},
|
||||
[GUI.Home]:{
|
||||
}
|
||||
|
||||
export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
[GUI.Home]:{
|
||||
layer:GLayer.View,
|
||||
uri: "prefab/ui/Home/HomeView",
|
||||
anims:{
|
||||
@@ -29,5 +56,6 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
||||
},
|
||||
},
|
||||
...UISystemConfig
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user