|
SplitView = SplitView or BaseClass(BaseView)
|
|
|
|
SplitView.TYPE =
|
|
{
|
|
SPLIT = 1, --拆分
|
|
BAT_USE = 2, --批量使用
|
|
BAT_DROP = 3, --批量丢弃
|
|
BAT_DECOMPOSE = 4, --批量分解
|
|
BAT_SEND_FLOWER = 5, --批量送礼
|
|
}
|
|
function SplitView:__init()
|
|
self.base_file = "bag"
|
|
self.layout_file = "BathandleView"
|
|
self.layer_name = "Top"
|
|
self.use_background = true
|
|
|
|
self.is_set_zdepth = true
|
|
self.type = SplitView.TYPE.SPLIT
|
|
|
|
self.blur_activity_bg = true
|
|
self.use_show_anim = true
|
|
self.use_hide_anim = true
|
|
|
|
self.load_callback = function ()
|
|
self:LocalSuccess()
|
|
end
|
|
self.open_callback = function ()
|
|
self:SetData()
|
|
end
|
|
self.destroy_callback = function ()
|
|
self:Remove()
|
|
end
|
|
|
|
end
|
|
|
|
function SplitView:Remove()
|
|
if self.icon_item then
|
|
self.icon_item:ReleaseObj()
|
|
self.icon_item = nil
|
|
end
|
|
|
|
if self.addNumComponent then
|
|
if self.change_count_id then
|
|
self.addNumComponent:UnBind(self.change_count_id)
|
|
self.change_count_id = nil
|
|
end
|
|
self.addNumComponent:DeleteMe()
|
|
self.addNumComponent = nil
|
|
end
|
|
end
|
|
|
|
function SplitView:LocalSuccess()
|
|
self.icon_item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self:GetChild("iconItem"))
|
|
self.icon_item:ChangeCountVisible(false)
|
|
|
|
self.bg_raw = self:GetChild("Window"):GetComponent("RawImage")
|
|
self.nameText = self:GetChild("nameText"):GetComponent("TextMeshProUGUI")
|
|
self.moneyIcon = self:GetChild("moneyIcon"):GetComponent("Image")
|
|
self.moneyText = self:GetChild("moneyText"):GetComponent("TextMeshProUGUI")
|
|
self.splitBtn = self:GetChild("splitBtn").gameObject
|
|
self.btnCancel = self:GetChild("btnCancel").gameObject
|
|
self.titleText = self:GetChild("Window/windowTitleCon/windowTitleText"):GetComponent("TextMeshProUGUI")
|
|
self.tipsText = self:GetChild("tipsText"):GetComponent("TextMeshProUGUI")
|
|
|
|
self.splitBtnText = self:GetChild("splitBtn/Text"):GetComponent("TextMeshProUGUI")
|
|
|
|
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("tips_comm_bg6"), false)
|
|
self.addNumComponent = NumberSliderComponent.New(self:GetChild("addNumCon"))
|
|
self.addNumComponent:SetComponentWidth(428)
|
|
self:InitEvent()
|
|
end
|
|
function SplitView:InitEvent()
|
|
local function onBtnClickHandler(target)
|
|
if target == self.splitBtn then
|
|
|
|
if self.type == SplitView.TYPE.SPLIT then
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15005,self.goods_vo.goods_id, self.goods_vo.type_id,self.addNumComponent:GetCurrCount())
|
|
elseif self.type == SplitView.TYPE.BAT_USE then
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15050,self.goods_vo.goods_id, self.goods_vo.type_id,self.addNumComponent:GetCurrCount())
|
|
elseif self.type == SplitView.TYPE.BAT_DROP then
|
|
local num = self.addNumComponent:GetCurrCount()
|
|
local function ok()
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15051, 0 , {[1] ={ goods_id = self.goods_vo.goods_id, type_id = self.goods_vo.type_id, num = num} })
|
|
end
|
|
local str = string.format("是否丢弃 <color=#ff2e65> %d个 %s</color> ?", num, self.goods_vo.goods_name)
|
|
Alert.show(str,Alert.Type.Two,ok)
|
|
elseif self.type == SplitView.TYPE.BAT_DECOMPOSE then
|
|
local decompose_goods_list = {}
|
|
decompose_goods_list[1] = {
|
|
goods_id = self.goods_vo.goods_id,
|
|
type_id = self.goods_vo.type_id,
|
|
goods_num = self.addNumComponent:GetCurrCount(),
|
|
}
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15019,decompose_goods_list)
|
|
elseif self.type == SplitView.TYPE.BAT_SEND_FLOWER then
|
|
if self.extra_param_list and self.extra_param_list.send_role_id then
|
|
SocialityModel:getInstance():Fire(SocialityModel.REQUEST_CCMD_EVENT, 22301, self.extra_param_list.send_role_id, self.goods_vo.type_id, self.addNumComponent:GetCurrCount(), 0)
|
|
end
|
|
end
|
|
self:Close()
|
|
elseif target == self.btnCancel then
|
|
self:Close()
|
|
end
|
|
end
|
|
AddClickEvent(self.splitBtn,onBtnClickHandler)
|
|
AddClickEvent(self.btnCancel,onBtnClickHandler)
|
|
|
|
local function onChangeCountHandler(count)
|
|
self:ChangeCount(count)
|
|
end
|
|
self.change_count_id = self.addNumComponent:Bind(ComponentEvent.AddNumberComponent.CHANGE_COUNT,onChangeCountHandler)
|
|
end
|
|
function SplitView:Open(goods_vo, type, extra_param_list)
|
|
self.goods_vo = goods_vo
|
|
self.type = type or SplitView.TYPE.SPLIT
|
|
self.extra_param_list = extra_param_list
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function SplitView:SetData()
|
|
if self.goods_vo then
|
|
self.icon_item:SetData(self.goods_vo.type_id, self.goods_vo.goods_num)
|
|
self.icon_item:SetItemSize(78, 78)
|
|
self.icon_item:SetLimitState(BagModel:getInstance():GetGoodsLimitState(self.goods_vo))
|
|
local min, max, step, cur = 0, self.goods_vo.goods_num-1, 1, 1
|
|
|
|
self.splitBtnText.text = "确定"
|
|
if self.type == SplitView.TYPE.SPLIT then
|
|
self.titleText.text = "物品拆分"
|
|
self.tipsText.text = "选择要拆分物品的数量"
|
|
elseif self.type == SplitView.TYPE.BAT_USE then
|
|
self.titleText.text = "批量使用"
|
|
self.tipsText.text = "选择要使用物品的数量"
|
|
min = 1
|
|
max = self.goods_vo.goods_num
|
|
cur = self.goods_vo.goods_num
|
|
elseif self.type == SplitView.TYPE.BAT_DROP then
|
|
self.titleText.text = "批量丢弃"
|
|
self.tipsText.text = "选择要丢弃物品的数量"
|
|
min = 1
|
|
max = self.goods_vo.goods_num
|
|
cur = self.goods_vo.goods_num
|
|
elseif self.type == SplitView.TYPE.BAT_DECOMPOSE then
|
|
self.titleText.text = "批量分解"
|
|
self.tipsText.text = "选择要分解物品的数量"
|
|
min = 1
|
|
max = self.goods_vo.goods_num
|
|
cur = self.goods_vo.goods_num
|
|
elseif self.type == SplitView.TYPE.BAT_SEND_FLOWER then
|
|
self.titleText.text = "批量赠送"
|
|
self.tipsText.text = "选择要赠送的物品数量"
|
|
min = 1
|
|
max = self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num or 1
|
|
-- cur = self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num or 1
|
|
if self.goods_vo.type_id == 102401 then
|
|
cur = self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num <= 5 and self.extra_param_list.gift_have_num or 5
|
|
else
|
|
cur = 1
|
|
end
|
|
self.splitBtnText.text = "赠送"
|
|
self.icon_item:SetData(self.goods_vo.type_id, self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num or 1)
|
|
self.icon_item:ChangeCountVisible(true,999)
|
|
end
|
|
self.addNumComponent:InitData(min, max, step, cur)
|
|
self:ChangeCount(1)
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id)
|
|
local name = Trim(self.goods_vo.goods_name)
|
|
if self.goods_vo.type == 11 and (self.goods_vo.subtype == 10 or self.goods_vo.subtype == 11) then
|
|
local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(self.goods_vo.type_id, RoleManager.Instance.mainRoleInfo.career, self.goods_vo.color)
|
|
name = _name
|
|
end
|
|
self.nameText.text = HtmlColorTxt(name, WordManager.GetGoodsColor(self.goods_vo.color))
|
|
end
|
|
end
|
|
|
|
function SplitView:ChangeCount(count)
|
|
|
|
end
|