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.
89 lines
2.9 KiB
89 lines
2.9 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import User from "../../FrameWork/User/User";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class PaiHangBangItem extends cc.Component {
|
|
@property(cc.Label)
|
|
mingciLab: cc.Label = null;
|
|
@property(cc.Label)
|
|
nameLab: cc.Label = null;
|
|
@property(cc.Label)
|
|
levelLab: cc.Label = null;
|
|
@property(cc.Label)
|
|
chenghaoLab: cc.Label = null;
|
|
|
|
@property(cc.Sprite)
|
|
diban: cc.Sprite = null;
|
|
|
|
@property(cc.Sprite)
|
|
mingciTag: cc.Sprite = null;
|
|
|
|
@property(cc.Sprite)
|
|
headIcon: cc.Sprite = null;
|
|
|
|
|
|
@property([cc.SpriteFrame])
|
|
dikuangs: cc.SpriteFrame[] = [];
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
configDate = null
|
|
|
|
setViewDate(config, idx) {
|
|
this.configDate = config
|
|
|
|
let mingci = config.rank
|
|
this.mingciLab.string = mingci + ''
|
|
this.levelLab.string = this.configDate.score
|
|
this.chenghaoLab.string = JSON.parse(this.configDate.remark).chenghao
|
|
this.nameLab.string = this.configDate.nickname ? this.truncateString(this.configDate.nickname, 3) + '' : this.configDate.nickname
|
|
|
|
// Common5.addUrlSprite_custom("paihangbang/"+this.configDate.id,this.headIcon)
|
|
// Common5.addUrlSprite_custom(this.configDate.pic, this.headIcon)
|
|
|
|
if (config.rank == 1) {
|
|
this.mingciTag.node.active = true
|
|
// Common5.addUrlSprite_custom("paihangbang/第一名",this.mingciTag)
|
|
// Common5.addUrlSprite_custom("paihangbang/第一名bg1",this.diban)
|
|
this.diban.spriteFrame = this.dikuangs[0]
|
|
} else if (config.rank == 2) {
|
|
this.mingciTag.node.active = true
|
|
// Common5.addUrlSprite_custom("paihangbang/第二名",this.mingciTag)
|
|
// Common5.addUrlSprite_custom("paihangbang/第二名bg2",this.diban)
|
|
this.diban.spriteFrame = this.dikuangs[1]
|
|
} else if (config.rank == 3) {
|
|
this.mingciTag.node.active = true
|
|
// Common5.addUrlSprite_custom("paihangbang/第三名",this.mingciTag)
|
|
// Common5.addUrlSprite_custom("paihangbang/第三名bg",this.diban)
|
|
this.diban.spriteFrame = this.dikuangs[2]
|
|
} else {
|
|
// Common5.addUrlSprite_custom("paihangbang/普通2",this.diban)
|
|
this.mingciTag.node.active = false
|
|
this.diban.spriteFrame = this.dikuangs[3]
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
truncateString(str: string, maxLength: number): string {
|
|
return str.length > maxLength ? str.slice(0, maxLength) + '' : str;
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|
|
|