大侠
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

127 lines
4.9 KiB

//#region 文件引入
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText, Toggle } from "cc";
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
import { Global } from "../../Global";
import PlatformManager from "../../Platform/PlatformManager";
import FrameScrollView from "../../CComEx/FrameScrollView";
import rankitem_Proxy from "./rankitem_Proxy";
import { EPlatformType } from "../../Platform/T/EPlatformType";
//#endregion 文件引入
enum rankType{
World,
Friend,
}
const wxPl = window["wx"];
const {ccclass, property,menu} = _decorator;
@ccclass("RankUI_Proxy")
export default class RankUI_Proxy extends BaseUIForm{
//#region 节点自动生成
@property(Node)
n_woldrank: Node = null;
@property(Node)
n_myrank: Node = null;
@property(Label)
lab_rank: Label = null;
@property(Label)
lab_pass: Label = null;
@property(Button)
btn_auth: Button = null;
//#endregion 节点自动生成
@property(Node)
wxSubContextView: Node = null;
@property(FrameScrollView)
protected mScrollViewFrame: FrameScrollView;
@property(Node)
nFriend: Node = null;
private mRankType:rankType = rankType.World;
private isAuthorize:boolean = false;
private isWxPlatform:boolean = false;
onButtonClick(button:Button){
/**点击事件触发*/
switch (button) {
default:
ConsoleEx.Log(button);
break;
}
}
protected CloseUI(btn?: Node): void {
PlatformManager.PlatformInstance.hideUserInfoButton();
super.CloseUI(btn);
}
addEvent(): void {
this.mScrollViewFrame.m_ItemRendererFuntion = this.ItemRenderer.bind(this)
}
protected start(): void {
this.isAuthorize = false;
this.isWxPlatform = PlatformManager.PlatformInstance.platform == EPlatformType.WX;
CNodeUtils.setActive(this.btn_auth, false);
CNodeUtils.setActive(this.nFriend, this.isWxPlatform)
if(this.isWxPlatform){
const btnStyle = CNodeUtils.GetNodeInScreenRect(this.btn_auth);
PlatformManager.PlatformInstance.GetUserInfo({
success: () => {
this.isAuthorize = true;
CNodeUtils.setActive(this.btn_auth, false);
if (wxPl) {
// const passtime = this.mDataMgr.Pass.passed_times;
// const strpass = passtime < 1 ? this.mDataMgr.Scene.getRealLevel() + '关': `全通${passtime}次`;
Global.setInitCloudKeys({ "LevelNum": "0", "Power": "0" });
Global.setCloudValue("LevelNum", `${this.mDataMgr.Scene.getRealLevel()}`);
Global.setCloudValue("Power", `${this.mDataMgr.Role.fighting}`);
}
},
fail: () => {
CNodeUtils.setActive(this.btn_auth, true);
},
btnStyle: btnStyle
});
}
this.switchRank();
this.refreshMyInfo();
}
//#region 拥有的目标功法类型 列表
ItemRenderer(idx:number,tNode:Node){
const rank = this.mDataMgr.Rank.rankList[idx];
const ClassPoxy: rankitem_Proxy = tNode.getComponent(rankitem_Proxy);
ClassPoxy.setInfo(rank);
}
private reflashScrollView(){
this.mScrollViewFrame.m_ItemCount = this.mDataMgr.Rank.maxrankNum;
}
//#endregion
onToggle_ToggleGroup(tToggle:Toggle){
this.mRankType = +tToggle.node.name;
this.switchRank();
}
switchRank() {
switch (this.mRankType) {
case rankType.World:
CNodeUtils.setActive(this.n_woldrank, true);
CNodeUtils.setActive(this.wxSubContextView, false);
this.reflashScrollView();
break;
case rankType.Friend:
wxPl && wxPl.postMessage({ event: 'friend', check: "LevelNum" });
CNodeUtils.setActive(this.n_woldrank, false);
CNodeUtils.setActive(this.wxSubContextView, true);
break;
}
}
refreshMyInfo(){
const passtime = this.mDataMgr.Pass.passed_times;
const strpass = passtime < 1 ? this.mDataMgr.Scene.getRealLevel() + '关': `全通${passtime}次`;
CNodeUtils.switchText(this.lab_pass,strpass);
CNodeUtils.switchText(this.lab_rank,this.mDataMgr.Rank.myrank.toString());
}
}