123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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技能
- // level 技能等级
- init(messageData) {
- if (messageData.type === 3) {
- messageData.icon = 900013;
- }
- 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 (messageData.type === 2 && messageData.skillStatus === 0) {
- this._messageData.infoDesc = `${messageData.name}可使用`;
- this.titleLabel.string = this._messageData.infoDesc;
- /// 不是好友助手
- } else if (messageData.type !== 3) {
- let timeStr = '';
- if (messageData.cdTime > 0) {
- timeStr = ' -- ' + DWTool.calculateTime(messageData.cdTime / 1000);
- }
- let infoDesc = this._messageData.infoDesc;
- //// 是技能 而且不是第二个技能 并且包含num 如果是本地构建的 那么是没有{num}的
- if (this._messageData.type === 2 && this._messageData.sId != 2 && infoDesc.indexOf('{num}') != -1) {
- let skillLevel = this._messageData.level;
- let skillId = this._messageData.sId;
- let skillLevelInfo = Global.BuildingManager.getSkillLevelInfo(skillId, skillLevel);
- /// 第一个技能
- if (skillId === 1) {
- let num = skillLevel > 11 ? (10 + skillLevel - 11) : 10;
- infoDesc = infoDesc.replace('{num}', num);
- /// 第三个技能
- } else {
- infoDesc = infoDesc.replace('${num}', skillLevelInfo.mt * 100);
- }
- this._messageData.infoDesc = infoDesc;
- }
-
- this.titleLabel.string = messageData.infoDesc + timeStr;
- /// 如果是好友助手
- } else if (messageData.type === 3) {
- let timeStr = '';
- if (messageData.cdTime > 0) {
- timeStr = ' -- ' + DWTool.calculateTime(messageData.cdTime / 1000);
- }
- this._messageData.infoDesc = '好友助力自动点击';
- this.titleLabel.string = this._messageData.infoDesc + timeStr;
- }
- },
- updateTime() {
- /// 如果是技能 并且可以用的话 那么直接就不更新了
- if (this._messageData.type === 2 && this._messageData.skillStatus === 0) {
- this.titleLabel.string = this._messageData.infoDesc;
- } 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.infoDesc + 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.infoDesc;
- }
- }
-
- },
- onDestroy() {
- console.log("释放一个信息流item");
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- // update (dt) {},
- });
|