源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

264 lines
10 KiB

SupremeVipDiamondExchangeView = SupremeVipDiamondExchangeView or BaseClass(BaseItem)
local SupremeVipDiamondExchangeView = SupremeVipDiamondExchangeView
function SupremeVipDiamondExchangeView:__init()
self.base_file = "supremeVip"
self.layout_file = "SupremeVipDiamondExchangeView"
self.model = SupremeVipModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self:Load()
end
function SupremeVipDiamondExchangeView:Load_callback()
self.nodes = {
"oneBtn:obj:img", "active_btn:obj", "des2Img:img:obj",
"tenBtn:obj:img",
"des1Img:img", --使用绑定的红钻……
"rightConBg:img", --底栏bg
"awardCon1", "awardCon2",
"moneyTxt2:tmp", "moneyTxt1:tmp", "desc:tmp:obj",
"leftTimes:tmp",
"exchangeBg:img",
"moneyIcon1",
"oneBtn/oneRed:obj",
}
self:GetChildren(self.nodes)
self.oneText = self:GetChild("oneBtn/Text"):GetComponent("TextMeshProUGUI")
self.tenText = self:GetChild("tenBtn/Text"):GetComponent("TextMeshProUGUI")
-- lua_resM:setOutsideImageSprite(self,self.des2Img_img,GameResPath.GetSupremeVipIcon("supremeVip_des_3_pointfilter"),false,nil)
lua_resM:setOutsideImageSprite(self,self.des1Img_img,GameResPath.GetSupremeVipIcon("supremeVip_des_8_pointfilter"),false,nil)
lua_resM:setOutsideImageSprite(self,self.rightConBg_img,GameResPath.GetSupremeVipIcon("supremeVip_right_bg_long"),false,nil)
lua_resM:setOutsideImageSprite(self,self.exchangeBg_img,GameResPath.GetSupremeVipIcon("supremeVip_right_exchange_bg"),false,nil)
self.desc_tmp.text = SupremeVipConst.ViewDesc[SupremeVipConst.RED_DOT_TYPE.DiamondExchange] or ""
self.award_item_1 = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.awardCon1)
self.award_item_1:SetItemSize(78, 78)
self.award_item_1:SetIsAct(true)
self.award_item_1:SetData(100001)
self.award_item_2 = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.awardCon2)
self.award_item_2:SetItemSize(78, 78)
self.award_item_2:SetIsAct(true)
-- self.award_item_2:SetData(100000)
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
end
function SupremeVipDiamondExchangeView:DoExchange(times)
self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45103,2,0,times)
-- local jinLock_ratio,jin_ratio = self.model:GetDiamondExchangeRatio()--彩钻红钻兑换比例数
-- local cost_price = jinLock_ratio*times
-- local function ok_callback( ... )
-- self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45103,2,0,times)
-- end
-- local function toggle_function( flag )
-- self.model._diamond_exchange_no_double_check = flag
-- end
-- local function use_function( toggle_tip_data,call_fun_sum )
-- if not self.model._diamond_exchange_no_double_check and cost_price ~= 0 then
-- GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
-- else
-- call_fun_sum()
-- end
-- end
-- local buy_tip_data = {
-- gold_type = 2,--货币类型
-- cost_price = cost_price,--消耗金额
-- ok_callback = ok_callback,--成功
-- toggle_function = toggle_function,--多选
-- togglePriceStr = string.format("<#fdffc2>%s</color> 进行兑换",cost_price),--提示语
-- use_function = use_function,--最终调用
-- diamond_nonuse = true,
-- }
-- CustomActivityModel:getInstance():BuyTips(buy_tip_data)
end
function SupremeVipDiamondExchangeView:AddEvents( )
local on_click = function ( click_obj )
if self.oneBtn_obj == click_obj then -- 单次
local is_simple_svip = self.model:IsMomentSupremeVip()
if not is_simple_svip then
if self.rest_counts >= 1 then
self:DoExchange(1)
else
Message.show("兑换次数不足","fault")
end
else--一阶贵族要给一次体验机会
if self.rest_counts >= 1 then
self:DoExchange(1)
else
Alert.show("成为<#04bd27>二阶贵族</color>,享<#ff6519>点金手</color>特权,红钻免费兑换彩钻", Alert.Type.Two, function()
self.model:Fire(SupremeVipConst.OPEN_SUPREME_VIP_BUY_VIEW)
end, nil, "前往升级", "取消")
end
end
elseif self.tenBtn_obj == click_obj then -- 十次
local have_supreme_vip_right = self.model:HaveSupremeVipRight(2)
if have_supreme_vip_right then
if self.rest_counts >= 10 then
self:DoExchange(10)
else
Message.show("兑换次数不足","fault")
end
else
-- Message.show("成为二阶贵族后可激活新特权","fault")
Alert.show("成为<#04bd27>二阶贵族</color>,享<#ff6519>点金手</color>特权,红钻免费兑换彩钻", Alert.Type.Two, function()
self.model:Fire(SupremeVipConst.OPEN_SUPREME_VIP_BUY_VIEW)
end, nil, "前往升级", "取消")
end
elseif self.active_btn_obj == click_obj then -- 激活永久特权
self.model:Fire(SupremeVipConst.OPEN_SUPREME_VIP_BUY_VIEW)
end
end
AddClickEvent(self.oneBtn_obj, on_click)
AddClickEvent(self.tenBtn_obj, on_click)
AddClickEvent(self.active_btn_obj, on_click,1)
local function onChangeJinLockHandler()
if not self.is_loaded or self._use_delete_method then return end
self:UpdateDiamondNum()
end
self.change_lockJin_id = self.mainVo:BindOne("jinLock",onChangeJinLockHandler)
--刷新兑换剩余次数
local function update_exchange_rest_counts()
if not self.is_loaded or self._use_delete_method then return end
self:UpdateExchangeRestCounts()
end
self:BindEvent(self.model, SupremeVipConst.REFRESH_EXCHANGE_REST_COUNTS,update_exchange_rest_counts)
--刷新红点
local function on_update_red(tab_id)
if not self.is_loaded or self._use_delete_method then return end
if tab_id == SupremeVipConst.RED_DOT_TYPE.DiamondExchange then
self:UpdateRedDot()
end
end
self:BindEvent(self.model, SupremeVipConst.ANS_UPDATE_RED_DOT,on_update_red)
end
function SupremeVipDiamondExchangeView:UpdateRedDot( )
local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
if sup_vip_type == 1 then--体验贵族 一次兑换有体验次数时给红点
local rest_counts_red = self.model:GetDiamondExchangeRed()
if rest_counts_red then
self.oneRed_obj:SetActive(true)
else
self.oneRed_obj:SetActive(false)
end
else
self.oneRed_obj:SetActive(false)
end
end
function SupremeVipDiamondExchangeView:UpdateView( )
self:UpdateExchangeRestCounts()
self:UpdateDiamondNum()
self:UpdateRedDot()
end
--刷新剩余兑换次数以及相应的按钮样式
function SupremeVipDiamondExchangeView:UpdateExchangeRestCounts( )
-- do return end
self.rest_counts = self.model:GetExchangeRestCount(SupremeVipConst.ExchangeType.Diamond)
-- self.leftTimes_tmp.text = self.rest_counts.."次"
local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
-- SetImageGray(self.oneBtn_img,self.rest_counts<1 or sup_vip_type < 2)
-- SetImageGray(self.tenBtn_img,self.rest_counts<10 or sup_vip_type < 2)
-- SetTMPSharedMaterial(self.takeBtn_txt, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
-- SetTMPSharedMaterial(self.takeBtn_txt, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
if sup_vip_type == 1 then--一阶贵族按钮常亮,引导玩家去点
SetImageGray(self.oneBtn_img, false)
SetImageGray(self.tenBtn_img, false)
SetTMPSharedMaterial(self.oneText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
SetTMPSharedMaterial(self.tenText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
elseif sup_vip_type == 2 then
if self.rest_counts < 1 then
SetImageGray(self.oneBtn_img, true)
SetImageGray(self.tenBtn_img, true)
SetTMPSharedMaterial(self.oneText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
SetTMPSharedMaterial(self.tenText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
elseif self.rest_counts >= 1 and self.rest_counts < 10 then
SetImageGray(self.oneBtn_img, false)
SetImageGray(self.tenBtn_img, true)
SetTMPSharedMaterial(self.oneText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
SetTMPSharedMaterial(self.tenText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
else
SetImageGray(self.oneBtn_img, false)
SetImageGray(self.tenBtn_img, false)
SetTMPSharedMaterial(self.oneText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
SetTMPSharedMaterial(self.tenText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
end
else
SetImageGray(self.oneBtn_img, true)
SetImageGray(self.tenBtn_img, true)
SetTMPSharedMaterial(self.oneText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
SetTMPSharedMaterial(self.tenText, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
end
if sup_vip_type == 2 then
local num_color = self.rest_counts == 0 and ColorUtil.RED_DARK or ColorUtil.GREEN_TIPS
self.leftTimes_tmp.text = string.format("今日剩余:<%s>%s</color>", num_color, self.rest_counts)
else
self.leftTimes_tmp.text = ""
end
end
--刷新货币数量显示
function SupremeVipDiamondExchangeView:UpdateDiamondNum( )
local jinLock_num = WordManager:ConvertNum(self.mainVo.jinLock)--红钻数量
local jinLock_ratio,jin_ratio = self.model:GetDiamondExchangeRatio()--彩钻红钻兑换比例数
local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
if sup_vip_type == 2 then
self.moneyTxt1_tmp.text = jinLock_num.."/"..jinLock_ratio
else
self.moneyTxt1_tmp.text = jinLock_ratio
end
SetAnchoredPositionX(self.moneyIcon1,-49-self.moneyTxt1_tmp.preferredWidth/2-18)
self.moneyTxt2_tmp.text = jin_ratio
-- self.award_item_2:SetData(100000,jin_ratio)
self.award_item_2:SetData(100000)
end
function SupremeVipDiamondExchangeView:SetData( data )
self.data = data
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function SupremeVipDiamondExchangeView:__delete( )
if self.award_item_1 then
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.award_item_1)
self.award_item_1 = nil
end
if self.award_item_2 then
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.award_item_2)
self.award_item_2 = nil
end
if self.change_lockJin_id then
self.mainVo:UnBind(self.change_lockJin_id)
self.change_lockJin_id = nil
end
end