-- 主界面 local ClubPlayerMatchAdjustHongHua = class("ClubPlayerMatchAdjustHongHua", cc.UIView) local ClubDefine = require("luaScript.Protocol.Club.ClubDefine") function ClubPlayerMatchAdjustHongHua:ctor(clubId,uidList,callBack,player) ClubPlayerMatchAdjustHongHua.super.ctor(self); local ui = loadUI("res/ui/ui_club/ui_club_player_match_adjust_honghua_single.ui"); self.ui = ui; self:addChild(ui); self.numbers = {}; self.clubId = clubId self.clubInfo = app.club_php.clubList[clubId] self.operatorId = app.user.loginInfo.uid self.uidList = uidList self.player = player self.callBack = callBack end function ClubPlayerMatchAdjustHongHua:onEnter() ClubPlayerMatchAdjustHongHua.super.onEnter(self) for i = 1,10 do self.ui.Items["Button_"..i-1]:registerClick(function() self:onClickNumber(i-1) end) end -- 重输 self.ui.Items.Button_reset:registerClick(handler(self , self.onClickReturn)) -- 回删 self.ui.Items.Button_del:registerClick(handler(self , self.onClickBack)) --sub self.ui.Items.Button_sub:registerClick(handler(self , self.onClickSub)) --sum self.ui.Items.Button_sum:registerClick(handler(self , self.onClickSum)) --point self.ui.Items.Button_point:registerClick(handler(self , self.onClickPoint)) self.ui.Items.Button_Sure:registerClick(handler(self , self.onClickConfirm)) -- 关闭 self.ui.Items.Button_guanbi:registerClick(handler(self , self.onClickClose)) self.score = score or 0 self.ui.Items.Text:setText("") self:restNumbers() end function ClubPlayerMatchAdjustHongHua:restNumbers() --[[local str = string.toTableByString(tostring(self.score),",") for k,v in ipairs(str) do table.insert(self.numbers,v) end--]] self.numbers = {}; self:updateNumbers() end -- 关闭 function ClubPlayerMatchAdjustHongHua:onClickClose() playBtnCloseEffect() self:removeFromParent() end -- 重输 function ClubPlayerMatchAdjustHongHua:onClickReturn() playBtnEffect() self:restNumbers() end -- 回删 function ClubPlayerMatchAdjustHongHua:onClickBack() playBtnEffect() local num = #self.numbers if num <= 0 then return; end table.remove(self.numbers, num) self:updateNumbers() end function ClubPlayerMatchAdjustHongHua:onClickSub() playBtnEffect() table.insert(self.numbers, "-") self:updateNumbers() end function ClubPlayerMatchAdjustHongHua:onClickSum() playBtnEffect() table.insert(self.numbers, "+") self:updateNumbers() end function ClubPlayerMatchAdjustHongHua:onClickPoint() playBtnEffect() table.insert(self.numbers, ".") self:updateNumbers() end -- 数字 function ClubPlayerMatchAdjustHongHua:onClickNumber(number) playBtnEffect() local num = 0 for k,v in ipairs(self.numbers) do local data = tonumber(v) if data then num = num + 1 end end if num >= 5 then showTooltip("最多不超过10000!") return end table.insert(self.numbers, number) self:updateNumbers() end function ClubPlayerMatchAdjustHongHua:calutPointNum(str) local list = string.split(str,".") if list and list[2] then if string.len(list[2]) > 2 then return true end end return false end function ClubPlayerMatchAdjustHongHua:onClickConfirm() self.ui.Items.Button_Sure:setTouchEnabled(false) self.ui.Items.Button_Sure:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function () self.ui.Items.Button_Sure:setTouchEnabled(true) end))) local honghua = tonumber(self.ui.Items.Text:getText()) logD("ClubPlayerMatchAdjustHongHua onClickConfirm final:",honghua) if self:calutPointNum(honghua) then showTooltip("小数点后最多保留两位") return end if honghua then if #self.uidList <= 0 then showTooltip("请选择玩家!") return; end local uidList = "" for k,v in ipairs(self.uidList) do uidList = uidList..tostring(v).."," end local function callback() showTooltip("调整成功!") if self.callBack then self.callBack() end if not tolua.isnull(self) then self:removeFromParent() end end if #self.uidList == 1 and self.player then local idx = honghua >= 0 and 1 or 2 local itr = idx == 1 and "增加" or "减少" local name = getShortName(self.player.name) local content = "是否将玩家【"..tostring(name).."】的红花数"..itr..tostring(math.abs(honghua)).."?" local function okCallBack() app.club_php:requestSetRedFlower(self.clubId,self.operatorId,uidList,honghua,callback,ClubDefine.PlayListType.MATCH_MEMBER) end local view = import("luaScript.Views.Club.ClubPlayerAddHuaHongTip"):new(idx,content,self.player,okCallBack) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view); else app.club_php:requestSetRedFlower(self.clubId,self.operatorId,uidList,honghua,callback,ClubDefine.PlayListType.MATCH_MEMBER) end else showTooltip("输入不合法!请重新输入!") self:restNumbers() end end function ClubPlayerMatchAdjustHongHua:updateNumbers() local str = "" if #self.numbers > 0 then for k,v in ipairs(self.numbers) do str = str..v end end self.ui.Items.Text:setText(str) end return ClubPlayerMatchAdjustHongHua;