1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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);
- });
- let timeStr = '';
- if (messageData.cdTime > 0) {
- timeStr = ' - ' + DWTool.calculateTime(messageData.cdTime / 1000);
- }
- this.titleLabel.string = messageData.desc + timeStr;
- },
- updateTime() {
- 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;
- }
- }
- },
- onDestroy() {
- console.log("释放一个信息流item");
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- // update (dt) {},
- });
|