1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- const DWTool = require("../utils/DWTool");
- cc.Class({
- extends: cc.Component,
- properties: {
- titleLabel: cc.Label,
- iconSprite: cc.Sprite,
- },
- // cdTime 剩余时间 是 [long] 查看
- // 5 desc 描述 是 [string] 查看
- // 6 name 名称 是 [string] 查看
- // 7 sId 业务ID 如果是商品就是商品ID 如果是技能就是技能id 是 [string] 查看
- // 8 type 类别 1商品 2技能
- init(messageData) {
- let iconPath = './textures/messageList/' + messageData.icon;
- this._messageData = messageData;
- DWTool.loadResSpriteFrame(iconPath)
- .then((spriteFrame) => {
- this.iconSprite.spriteFrame = spriteFrame;
- }).catch((err) => {
- console.log(err);
- });
-
- /// 如果cdTime为0那么就是一直存在的 并且是技能的话
- // this._isFix = 0;
- // if (messageData.type === 2) {
- // this._isFix = messageData.skillStatus === 0;
- // }
- if (this._messageData.type === 2 && this._messageData.skillStatus === 0) {
- this._messageData.desc = `${this._messageData.name}可使用`;
- this.titleLabel.string = this._messageData.desc;
- } else {
- let timeStr = '';
- if (messageData.cdTime > 0) {
- timeStr = ' -- ' + DWTool.calculateTime(messageData.cdTime / 1000);
- }
- this.titleLabel.string = messageData.desc + timeStr;
- }
- },
- updateTime() {
- /// 如果是技能 并且可以用的话 那么直接就不更新了
- if (this._messageData.type === 2 && this._messageData.skillStatus === 0) {
- this.titleLabel.string = this._messageData.desc;
- } else {
- if (this._messageData.cdTime > 0) {
- this._messageData.cdTime -= 1000;
- if (this._messageData.cdTime < 0) {
- this._messageData.cdTime = 0;
- }
- let timeStr = '';
- if (this._messageData.cdTime > 0) {
- timeStr = ' -- ' + DWTool.calculateTime(this._messageData.cdTime / 1000);
- }
- this.titleLabel.string = this._messageData.desc + timeStr;
- } else if (this._messageData.cdTime < 0) {
- this._messageData.cdTime += 1000;
- if (this._messageData.cdTime > 0) {
- this._messageData.cdTime = 0;
- }
- this.titleLabel.string = this._messageData.desc;
- }
- }
-
- },
- onDestroy() {
- console.log("释放一个信息流item");
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- // update (dt) {},
- });
|