| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- ------------------------------------
- -- 常用Html函数封装
- -- font
- -- fontAFlag
- -- fontAFlagU
- -- fontItem 道具信息转字符串
- -- fontJYTeamLink 精英战队邀请链接
- ------------------------------------
- Json = Json or require("common.Json")
- local Util = require("common.Util")
- local Lang = require("common.Lang")
- local Config = require("Config")
- local Msg = require("core.Msg")
- --local Grid = require("bag.Grid")
- --local ItemDefine = require("bag.ItemDefine")
- TYPE_SHOW_ITEM = 1 -- 展示道具
- TYPE_JOIN_JYTEAM = 2 -- 加入精英战队
- TYPE_OPEN_PANEL = 3 -- 打开面板
- TYPE_FISH_QIANG = 4 -- 抢鱼
- colorTable = {
- "#ffffff", --白色
- "#1bff2b", --绿色
- "#1f9eff", --蓝色
- "#ff29f7", --紫色
- "#fffe0d", --黄色
- "#ff9d1d", --橙色
- "#ff1a1a", --红色
- }
- mapColorTable = {
- "#1f9eff", --水
- "#f40f0b", --火
- "#1bff2b", --草
- "#ff9d1d", --光
- "#ff29f7" --暗
- }
- function fontAFlagU(data, content)
- return "<a href=\'" .. data .."\'>" .. content .. "</a>"
- end
- function font(content, color)
- if type(color) == "number" then
- color = colorTable[color]
- else
- color = color or colorTable[1]
- end
- return "<font color='" .. color .. "'>" .. content .. "</font>"
- end
- function fontItem(grid, index, human)
- if not grid or grid.id == 0 then
- return ""
- end
- local msgRet = Msg.gc.GC_BAG_CHANGE
- Grid.makeItem(msgRet.itemData, grid)
- local itemConfig = ItemDefine.getConfig(grid.id)
- local itemColor = itemConfig.Color
- local data = TYPE_SHOW_ITEM .."|".. Json.Encode(msgRet.itemData)
- local itemName = "【" .. itemConfig.Name .. "】"
- local content = font(itemName, itemColor)
- return fontAFlagU(data, content)
- end
- function fontJYTeamLink(content, jyid)
- local data = TYPE_JOIN_JYTEAM .. "|" .. jyid .. "|" .. Config.SVR_INDEX
- return font(fontAFlagU(data, content), "#1bff2b")
- end
- function fontFishQiangLink(content, uuid)
- local data = TYPE_FISH_QIANG .. "|" .. uuid
- return font(fontAFlagU(data, content), "#1bff2b")
- end
- function fontOpenPanel(content, panelID)
- local data = TYPE_OPEN_PANEL .. "|" .. panelID
- return fontAFlagU(data, content)
- end
- function getFormatTime(sec)
- if sec < 60 then
- return Util.format(Lang.COMMON_STR_TIME1, sec)
- end
- local min = math.floor(sec / 60)
- sec = sec % 60
- if min < 60 then
- return Util.format(Lang.COMMON_STR_TIME2, min, sec)
- end
- local hour = math.floor(min / 60)
- min = min % 60
- return Util.format(Lang.COMMON_STR_TIME3, hour, min, sec)
- end
- -- 传入一个时间戳 返回xx年x月x日 例如:2019年1月29日
- function getDataStr(ts)
- local d = os.date("*t",ts)
- return Util.format(Lang.COMMON_STR_TIME_YMD, d.year, d.month, d.day)
- end
- function getDataStrMD(ts)
- local d = os.date("*t",ts)
- return Util.format(Lang.COMMON_STR_TIME_MD, d.month, d.day)
- end
|