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.
95 lines
3.2 KiB
95 lines
3.2 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 { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import User from "../../FrameWork/User/User";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import ZaoCanManager from "../Manager/ZaoCanManager";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ZaoCanDianYeWuitemNode extends cc.Component {
|
|
|
|
@property(cc.Label)
|
|
nameLabel: cc.Label = null;
|
|
|
|
@property(cc.Sprite)
|
|
headImg: cc.Sprite = null;
|
|
@property(cc.Label)
|
|
jiachengPercent: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
levelLabel: cc.Label = null;
|
|
|
|
@property(cc.ProgressBar)
|
|
levelProgress: cc.ProgressBar = null;
|
|
|
|
@property(cc.Label)
|
|
levelPercentLabel: cc.Label = null;
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
config = null
|
|
// onLoad () {}
|
|
|
|
start() {
|
|
}
|
|
|
|
setViewDate(config) {
|
|
this.config = config
|
|
this.refreshView()
|
|
}
|
|
refreshView() {
|
|
let lockType = ZaoCanManager.getIsLockById(this.config.id)
|
|
if (lockType == 0) {
|
|
//未解锁
|
|
this.node.getChildByName("未解锁").active = true
|
|
|
|
this.node.getChildByName("已解锁").active = false
|
|
this.node.getChildByName("等待解锁").active = false
|
|
this.node.getComponent(cc.Sprite).enabled = false
|
|
this.node.getChildByName("闪光框").active = false
|
|
} else if (lockType == 1) {
|
|
//待解锁
|
|
this.node.getChildByName("等待解锁").active = true
|
|
this.node.getComponent(cc.Sprite).enabled = true
|
|
this.node.getChildByName("闪光框").active = true
|
|
|
|
this.node.getChildByName("未解锁").active = false
|
|
this.node.getChildByName("已解锁").active = false
|
|
} else if (lockType == 2) {
|
|
//已解锁
|
|
this.node.getChildByName("已解锁").active = true
|
|
|
|
this.node.getChildByName("未解锁").active = false
|
|
this.node.getChildByName("等待解锁").active = false
|
|
this.node.getComponent(cc.Sprite).enabled = false
|
|
this.node.getChildByName("闪光框").active = false
|
|
}
|
|
let str = Common5.getNumberChangeHanzi(this.config.jiacheng * 100)
|
|
this.jiachengPercent.string = str + '%'
|
|
this.nameLabel.string = this.config.zaocan
|
|
|
|
let zaocan = this.config.zaocan
|
|
Common5.getSpriteFrameFromBundle("ZaoCanDian", 'res/icon/' + zaocan, this.headImg)
|
|
|
|
this.levelLabel.string = `店铺${this.config.needLevel}级解锁`
|
|
|
|
let level = User.getMyLevel()
|
|
this.levelProgress.progress = level / this.config.needLevel
|
|
this.levelPercentLabel.string = `${level}/${this.config.needLevel}`
|
|
}
|
|
|
|
onTouchUnLock() {
|
|
ZaoCanManager.setUnLock(this.config.id)
|
|
// this.refreshView()
|
|
EventMgr.emitEvent_custom(ryw_Event.refreshZaoCan)
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|
|
|