mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
更新登录
This commit is contained in:
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": {}
|
||||
}
|
Reference in New Issue
Block a user