PlatformSetting = PlatformSetting or BaseClass() --用于初始化一些特殊设置的平台 function PlatformSetting:__init() if PlatformSetting.Instance ~= nil then error("attempt to create singleton(PlatformSetting) twice!") return end PlatformSetting.Instance = self self.cur_platform = nil end function PlatformSetting:getInstance() if PlatformSetting.Instance == nil then PlatformSetting.New() end return PlatformSetting.Instance end function PlatformSetting:Init(platform) self.cur_platform = platform --乐牛平台 if PlatformMgr:getInstance():IsLeniuPlatform() then local feedback_server = function(msg) self:FeedbackServer(msg) end GlobalEventSystem:Bind("LENIU_FEEDBACK_SERVER",feedback_server) end end function PlatformSetting:FeedbackServer(msg) --msg.type,msg.topictxt,msg.txt local role_info = RoleManager.Instance.mainRoleInfo local playerInfo = LoginController.Instance:GetPlatUserInfo() local uid = self.cur_platform:GetUserID() local server_role = self.cur_platform:ServerRole(0) local random = math.random(100,999) local now_order_num = server_role .. "-" .. uid .. "-" .. os.time() .. random local function encodeURI(s) s = string.gsub(s, "([^_%w%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end) return string.gsub(s, " ", "+") end local sent_param = { timestamp = TimeUtil:getServerTime(), --不要写机器时间 可能玩家时间对不上 unique_id = playerInfo.server_id .. "-" .. role_info.role_id, role_name = encodeURI(role_info.name), title = encodeURI(msg.topictxt), content = encodeURI(msg.txt), msg_type = msg.type, appid = "82d7a6e280727312", account_name = uid, game_zone = encodeURI(playerInfo.server_name), game_server = playerInfo.server_id, register_time = os.time(), login_time = os.time(), pay_total = 0, vip_level = role_info.vip_flag, ext = now_order_num, avatar = "", } local key_table = {} for key,_ in pairs(sent_param) do table.insert(key_table,key) end table.sort(key_table) local sign_value = "" for _,key in pairs(key_table) do sign_value = sign_value .. key .."=" .. sent_param[key] .. "&" end sign_value = string.sub(sign_value,1,#sign_value - 1) sign_value = sign_value .. "|7ca888b953f1ba402175529b4cbc9959" print("------sign_value--------",sign_value) sign_value = string.lower(Util.md5(sign_value)) sent_param["sign"] = sign_value local sent_back = function(ret,error_msg,data) local json_obj = JsonToTable(data) print("---------leniufeedback-------",ret,error_msg,data) if ret and json_obj then local errcode = json_obj["errcode"] local errmsg = json_obj["errmsg"] local data = json_obj["data"] local work_id = -1 if data then work_id = data["work_id"] end if tonumber(errcode) == 0 then GlobalEventSystem:Fire(WelfareModel.FEEDBACK_SUCCESS) Message.show("游戏客服已收到您的反馈,稍后会以邮件方式回复,请耐心等待。") else Message.show("网络异常,请稍后再试,错误码:" .. errcode .. " 错误信息:" .. errmsg ) end end end print("------sent_param---------",table2json(sent_param)) HttpUtil.HttpPostRequest("http://api.kf.leniu.com/message/send/v1/", sent_param, sent_back) end