源战役客户端
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.
 
 
 
 
 

170 lines
5.3 KiB

ChildChatNiceView = ChildChatNiceView or BaseClass(BaseView)
local ChildChatNiceView = ChildChatNiceView
function ChildChatNiceView:__init()
self.base_file = "child"
self.layout_file = "ChildChatNiceView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true
self.change_scene_close = true
self.append_to_ctl_queue = true --是否要添加进界面堆栈
self.hide_maincancas = true
self.blur_activity_bg = true
self.close_fog = true
self.model = ChildModel:GetInstance()
self.showNum = 0
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
if self.data.role_id then
self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16511, tonumber(self.data.role_id)) -- 获取点赞数
end
end
self.open_callback = function ( )
self:UpdateView()
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function ChildChatNiceView:Open(data,callBack)
self.data = data
self.callBack = callBack
BaseView.Open(self)
if self.data.role_id then
self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16511, tonumber(self.data.role_id)) -- 获取点赞数
end
end
function ChildChatNiceView:LoadSuccess()
local nodes = {
"closeBtn:obj","btn_nice:obj","text_num:tmp","bg:raw","rt_image_show","closeBtn2:obj",
"txt_name:tmp",
"name_con", "name_con/vip:obj:img",
"roleHead", "name_con/name:tmp",
"name_con/sex:img",
}
self:GetChildren(nodes)
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("child_chat_nice_bg_1009_622"),false)
local function bg_back_func( ... )
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
end
self:MoveUIToBack(self.bg_raw)
end
if self.background_wnd then
bg_back_func()
else
self.bg_back_func = bg_back_func
end
end
function ChildChatNiceView:AddEvent()
local function SUCCESS_CHILD_NICE_fun(vo)
-- self.text_num_tmp.text = self.showNum + 1
self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16511, tonumber(self.data.role_id)) -- 获取点赞数
end
self.success_child_nice_id = self.model:Bind(ChildConst.SUCCESS_CHILD_NICE, SUCCESS_CHILD_NICE_fun) --成功后返回
local function SUCCESS_CHECK_CHILD_NICE_fun(num)
self.showNum = num
self.text_num_tmp.text = num
end
self.success_check_child_nice_id = self.model:Bind(ChildConst.SUCCESS_CHECK_CHILD_NICE, SUCCESS_CHECK_CHILD_NICE_fun) --41404成功后返回
local on_click = function ( click_obj )
if self.closeBtn_obj == click_obj or self.closeBtn2_obj == click_obj then
self:Close()
elseif self.btn_nice_obj == click_obj then
self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16510,tonumber(self.data.role_id))
end
end
AddClickEvent(self.closeBtn_obj, on_click)
AddClickEvent(self.btn_nice_obj, on_click)
AddClickEvent(self.closeBtn2_obj, on_click)
end
function ChildChatNiceView:UpdateView()
self.text_num_tmp.text = self.showNum
self.txt_name_tmp.text = self.data.child_name
--local show_figure_id = self.model:GetFashionModelID( self.data.fashion_id, self.data.child_sex )()
local show_figure_id = self.model:GetChildClothByParam( tonumber(self.data.child_level), tonumber(self.data.child_sex), tonumber(self.data.fashion_id) )
local res_data = {
father_node = self,
transform = self.rt_image_show,
fashion_type = FuncOpenModel.TypeId.Child,
figure_id = show_figure_id,
ui_model_type = UIModelCommon.ModelType.BackModel,
can_rotate = true,
}
FuncOpenModel:getInstance():SetModelRes(res_data)
self:UpdatePlayerInfo( )
end
-- 更新玩家信息
function ChildChatNiceView:UpdatePlayerInfo( )
if not self.headItem then
self.headItem = HeadRoleItem.New(self.roleHead)
self.headItem:SetItemSize(50,50)
end
local board_id = nil
self.headItem:SetData({
id=tonumber(self.data.role_id),
career=self.data.career,
level= self.data.level,
sex=self.data.sex,
turn=self.data.turn,
picture_ver = nil,
picture = nil,
board = board_id,
is_big = false,
profile_photo_id = self.data.profile_photo_id,
use_bg = 3})
lua_resM:setImageSprite(self, self.sex_img, "common_asset", self.data.sex == 1 and "com_boy" or "com_girl", true)
-- lua_resM:setImageSprite(self, self.vip_img, "common_asset", "com_vip"..self.data.vip_flag)
if not self.vipItem then
self.vipItem = RoleVipItem.New(self.vip_img.transform)
end
self.vipItem:SetData(self.data.vip_flag,self.data.sup_vip_type)
if self.data.vip_flag == 0 and self.data.sup_vip_type == 0 then
self.vip_obj:SetActive(false)
else
self.vip_obj:SetActive(true)
end
self.name_tmp.text = HtmlColorTxt( " " .. self.data.name, "#a9c1e1")
SetSizeDelta(self.name, self.name_tmp.preferredWidth + 5, self.name_tmp.preferredHeight)
end
function ChildChatNiceView:SetCallBack(callBack)
self.callBack = callBack
end
function ChildChatNiceView:DestroySuccess( )
if self.success_child_nice_id then
self.model:UnBind(self.success_child_nice_id)
self.success_child_nice_id = nil
end
if self.success_check_child_nice_id then
self.model:UnBind(self.success_check_child_nice_id)
self.success_check_child_nice_id = nil
end
if self.vipItem then
self.vipItem:DeleteMe()
self.vipItem = nil
end
if self.headItem then
self.headItem:DeleteMe()
self.headItem = nil
end
end