|
|
- --[[
- 小天使小恶魔续费界面
- ]]
- SpecialEquipExpiredView = SpecialEquipExpiredView or BaseClass(BaseView)
-
- function SpecialEquipExpiredView:__init()
- self.base_file = "itemUse"
- self.layout_file = "SpecialEquipExpiredView"
- self.layer_name = "Top"
- self.is_set_zdepth = true
- self.destroy_imm = true
- self.change_scene_close = true
- self.use_background = true
- self.hide_maincancas = false
-
- self.model = ItemUseModel:getInstance()
- self.mainVo = RoleManager.Instance.mainRoleInfo
-
- --self.use_local_view = true
- self.gril_anima = "sheep"
- self:AddPreLoadList(self.gril_anima,{self.gril_anima})
- self.load_callback = function ()
- self:LoadSuccess()
- self:InitEvent()
- end
- self.open_callback = function ()
- self:UpdateView()
- if self.type_id and self.type_id == 1011000005 then
- --小恶魔体验版
- self.goBtn:SetActive(false)
- --self.renewBtn:SetActive(false)
- self.renewBtn:SetActive(true)
- else
- self.goBtn:SetActive(false)
- self.renewBtn:SetActive(true)
- end
- end
- self.close_callback = function ()
- if self.type == 2 then
- TreasureModel:getInstance():Fire(TreasureModel.OPEN_EXP_HINT_VIEW,"exp_hunt")
- end
- end
- self.destroy_callback = function ()
- self:Clear()
- end
- end
-
- function SpecialEquipExpiredView:Open(goods_id,type)
- self.type = type or 1
-
- self.goods_id = goods_id
- BaseView.Open(self)
- end
-
- function SpecialEquipExpiredView:Clear( )
- if self.awardItem then
- self.awardItem:DeleteMe()
- self.awardItem = nil
- end
-
- if self.anima then
- destroy(self.anima)
- self.anima = nil
- end
- end
-
- function SpecialEquipExpiredView:LoadSuccess( )
- self.itemCon
- = GetChildTransforms(self.transform,
- {
- "itemCon"
-
- })
-
- self.cost,
- self.renewBtn_text,
- self.renewBtn_dia_text,
- self.dia_cost,
- self.name
- = GetChildTexts(self.transform,
- {
- "renewBtn/cost",
- "renewBtn/Label2",
- "renewBtn1/Label2",
- "renewBtn1/cost",
- "name"
- })
-
-
- self.Image,
- self.flag,
- self.title,
- self.bg
- = GetChildImages(self.transform,
- {
- "renewBtn/Image",
- "Image",
- "title",
- "Window"
- })
-
- self.renewBtn,
- self.renewBtn_dia,
- self.goBtn
- = GetChildGameObjects(self.transform,
- {
- "renewBtn",
- "renewBtn1",
- "goBtn"
- })
-
-
- lua_resM:setOutsideImageSprite(self,self.bg,GameResPath.GetTreasureImage("mjsui_bg"),false)
-
-
-
- self.awardItem = AwardItem.New(self.itemCon)
- self.awardItem:SetItemSize(80, 80)
- self.awardItem.transform.anchoredPosition = Vector2.zero
- --if tonumber(AppConst.EnglineVer) >= 78 then
- local load_back = function(objs)
- if objs and objs[0] then
- self.anima = newObject(objs[0])
- self.anima.transform:SetParent(self.transform)
- SetLocalScale(self.anima.transform, 0.29)
- self.anima.transform.localEulerAngles = Vector3(0, 0, 0)
- SetLocalPosition(self.anima.transform, -321, -281, 0)
- end
- end
- --end
- lua_resM:loadPrefab(self,self.gril_anima,self.gril_anima, load_back, ASSETS_LEVEL.HIGHT)
- end
-
- function SpecialEquipExpiredView:InitEvent( )
- local function onBtnClickHandler(target)
- if target == self.renewBtn then
- if self.goods_id and self.price then
- local role = RoleManager.Instance.mainRoleInfo
- if RoleManager.Instance.mainRoleInfo:GetRealJin() < self.price then
- local function ok_callback()
- GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW, 1)
- self:Close()
- end
- Alert.show("您的彩钻不足,是否充值?", Alert.Type.Two, ok_callback, nil,"确定", "取消")
- else
- if self.type == 2 then
- ShopModel:getInstance():Fire(ShopModel.BUY_GOODS,20004,1)
- else
- GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15006,self.goods_id,1)
-
- end
- BaseDungeonModel:getInstance():Fire(BaseDungeonModel.SHOW_UES_EXP_EVIL_BTN,false)
-
- self:Close()
- end
- end
-
- elseif target == self.goBtn then
- if self.type_id and self.type_id == 1011000005 then
- GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, 3, 1011000001)
- else
- GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, 3, self.type_id)
- end
- self:Close()
- elseif target == self.renewBtn_dia then
- if self.goods_id and self.dia_price then
- local role = RoleManager.Instance.mainRoleInfo
- if role.jinLock < self.dia_price then
- local function ok_callback()
- GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW, 1)
- self:Close()
- end
- Alert.show("您的红钻不足,是否充值?", Alert.Type.Two, ok_callback, nil,"确定", "取消")
- else
-
- if self.type == 2 then
- ShopModel:getInstance():Fire(ShopModel.BUY_GOODS,20004,1)
- else
- GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15006,self.goods_id,2)
- end
- BaseDungeonModel:getInstance():Fire(BaseDungeonModel.SHOW_UES_EXP_EVIL_BTN,false)
- self:Close()
- end
- end
- end
- end
- AddClickEvent(self.renewBtn,onBtnClickHandler)
- AddClickEvent(self.goBtn,onBtnClickHandler)
- AddClickEvent(self.renewBtn_dia,onBtnClickHandler)
- end
-
- function SpecialEquipExpiredView:UpdateView( )
- if self.type == 1 then
-
- --可能在背包也可能在身上
- --local goodsVo = GoodsModel:getInstance():GetBagGoodsInfoById(self.goods_id)
- local goodsVo = EquipModel:getInstance():GetEquipById(self.goods_id)
- if not goodsVo then
- goodsVo = GoodsModel:getInstance():GetBagGoodsInfoById(self.goods_id)
- end
- --PrintTable(goodsVo)
- if not goodsVo then return end
- if goodsVo.type_id == 1011000003 or goodsVo.type_id == 1011000004 then
- local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goodsVo.type_id)
- self.renewBtn_dia:SetActive(false)
- self.renewBtn.transform.localPosition = Vector2(55,-186)
- self.type_id = goodsVo.type_id
- self.awardItem:SetData(basic.type_id, 1)
- self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
- self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
- self.price = Config.Goodsrenew[self.type_id.."@1"].price
- else
-
- local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goodsVo.type_id)
- self.type_id = goodsVo.type_id
- self.awardItem:SetData(basic.type_id, 1)
- self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
- self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
- self.price = Config.Goodsrenew[self.type_id.."@1"].price
- self.dia_cost.text = Config.Goodsrenew[self.type_id.."@2"].price
- self.dia_price = Config.Goodsrenew[self.type_id.."@2"].price
- end
- else
- if goodsVo.type_id == 1011000003 or goodsVo.type_id == 1011000004 then
- local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goodsVo.type_id)
- self.renewBtn_dia:SetActive(false)
- self.renewBtn.transform.localPosition = Vector2(55,-186)
- self.type_id = goodsVo.type_id
- self.awardItem:SetData(basic.type_id, 1)
- self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
- self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
- self.price = Config.Goodsrenew[self.type_id.."@1"].price
- self.renewBtn_text.text = "购买"
- else
- local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_id)
- self.type_id = self.goods_id
- self.awardItem:SetData(basic.type_id, 1)
- self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
- self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
- self.price = Config.Goodsrenew[self.type_id.."@1"].price
- self.dia_cost.text = Config.Goodsrenew[self.type_id.."@2"].price
- self.dia_price = Config.Goodsrenew[self.type_id.."@2"].price
- self.renewBtn_text.text = "购买"
- self.renewBtn_dia_text.text = "购买"
- end
- end
-
- local res,title_res
- if (self.type_id == 1011000001 or self.type_id == 1011000005) then
- res = "icon_bygz_1"
- title_res = "icon_jyjc"
- elseif self.type_id == 1011000003 then
- res = "icon_bygz_2"
- title_res = "icon_jyjc_2"
- elseif self.type_id == 1011000002 then
- res = "icon_byts"
- title_res = "icon_jyjc_1"
- else
- res = "icon_bygz_3"
- title_res = "icon_jyjc_3"
- end
-
- if not res then return end
- lua_resM:setImageSprite(self,self.flag,"treasureHunt_asset",res)
- lua_resM:setImageSprite(self,self.title,"treasureHunt_asset",title_res)
-
-
- end
|