2025-06-04 05:02:57 +08:00

226 lines
7.8 KiB
Plaintext

autoImport("ShopDressingView")
HairDressingView = class("HairDressingView",ShopDressingView)
HairDressingView.ViewType = UIViewType.NormalLayer
autoImport("HairCutPage")
autoImport("HairDyePage")
local shoptype = ShopDressingProxy.Instance:GetShopType()
local shopID = ShopDressingProxy.Instance:GetShopId()
function HairDressingView:FindObjs()
HairDressingView.super.FindObjs(self)
self.pageDragScrollView = self:FindGO("page"):GetComponent(UIDragScrollView)
self.cutPage = self:FindGO("cutPage")
self.cutScrollView = self.cutPage:GetComponent(UIScrollView)
self.dyePage = self:FindGO("dyePage")
self.dyeScrollView = self.dyePage:GetComponent(UIScrollView)
self.hairCutLabel = self:FindGO("HairCutLabel"):GetComponent(UILabel)
self.hairDyeLabel = self:FindGO("HairDyeLabel"):GetComponent(UILabel)
self.headgearToggle = self:FindGO("headgearToggle"):GetComponent(UIToggle)
self.HideHeadgearLabel = self:FindGO("HideHeadgearLabel"):GetComponent(UILabel)
self.hairCutToggle = self:FindGO("hairCutToggle")
self.hairDyeToggle = self:FindGO("hairDyeToggle")
self:Hide(self.dyePage);
end
function HairDressingView:InitUIView()
self.super.InitUIView(self)
self.HairCutPage = self:AddSubView("HairCutPage" ,HairCutPage);
self.HairDyePage = self:AddSubView("HairDyePage" ,HairDyePage);
self.hairCutLabel.text = ZhString.HairDressingView_HairCutPageTitle;
self.hairDyeLabel.text = ZhString.HairDressingView_HairDyePageTitle;
self.HideHeadgearLabel.text = ZhString.HairDressingView_HideHeadgear;
self.pageType = 1;
end
function HairDressingView:AddEvts()
self.super.AddEvts(self)
self:AddClickEvent(self.headgearToggle.gameObject,function (g)
self:ClickHeadGearToggle()
end)
self:AddTabChangeEvent(self.hairCutToggle,self.cutPage,PanelConfig.HairCutPage)
self:AddTabChangeEvent(self.hairDyeToggle,self.dyePage,PanelConfig.HairDyePage)
end
local args = {}
function HairDressingView:TabChangeHandler(key)
HairDressingView.super.TabChangeHandler(self, key);
if(self.pageType==key)then return end
self.pageType = key;
if(key==1) then
self.pageDragScrollView.scrollView=self.cutScrollView;
self.cutScrollView:ResetPosition();
self.chargeTitle.text = ZhString.HairdressingView_cost;
if(self.HairDyePage.chooseCtl)then
self.HairDyePage.chooseCtl:UnChoose();
self.HairDyePage.chooseCtl=nil;
end
self.HairCutPage:InitPageView()
elseif(key==2) then
self.pageDragScrollView.scrollView=self.dyeScrollView
self.dyeScrollView:ResetPosition();
self.chargeTitle.text = ZhString.HairDressingView_consume;
if(self.HairCutPage.chooseCtl)then
self.HairCutPage.chooseCtl:UnChoose();
self.HairCutPage.chooseCtl=nil;
end
self.HairCutPage:Hide(self.HairCutPage.desc);
self.HairCutPage:Hide(self.HairCutPage.menuDes);
self.HairDyePage:InitPageView()
end
ShopDressingProxy.Instance.chooseData={};
args[1]=nil
args[2]=nil
args[3]=nil
ShopDressingProxy.Instance:SetQueryData(args);
self:DisableState();
self:RefreshModel();
end
function HairDressingView:ClickHeadGearToggle()
self:RefreshModel();
end
function HairDressingView:ClickReplaceBtn()
local queryData = ShopDressingProxy.Instance:GetQueryData()
local hasTicket = false
shoptype = ShopDressingProxy.Instance:GetShopType()
shopID = ShopDressingProxy.Instance:GetShopId()
if(queryData.type==ShopDressingProxy.DressingType.HAIR) then
if(not queryData.id) then return end
local choosedata = ShopDressingProxy.Instance.chooseData;
if(nil == choosedata)then
return
end
-- 是否是同一髮型
if(ShopDressingProxy.Instance:bSameItem(ShopDressingProxy.DressingType.HAIR))then
MsgManager.FloatMsgTableParam(nil,ZhString.HairDressingView_bSameHair)
return;
end
local tempcsv = ShopProxy.Instance:GetShopItemDataByTypeId(shoptype,shopID,choosedata.id)
if(tempcsv:CheckCanRemove())then
MsgManager.FloatMsgTableParam(nil,ZhString.HappyShop_overtime)
return
end
local tempId = tempcsv.goodsID;
local hairID = ShopDressingProxy.Instance:GetHairStyleIDByItemID(tempId);
if(not hairID or not ShopDressingProxy.Instance:bActived(hairID,ShopDressingProxy.DressingType.HAIR))then
local lockmsg = tempcsv:GetQuestLockDes()
if(lockmsg)then
MsgManager.FloatMsgTableParam(nil,lockmsg)
end
return
end
-- 是否有體驗券
local preCost = tempcsv.PreCost
hasTicket=self:_bHasTicket(preCost)
-- 錢夠不夠
if(not hasTicket)then
local moneyID = choosedata.ItemID;
local itemNum = choosedata.ItemCount*choosedata.Discount*0.01;
local curMoney=ShopDressingProxy.Instance:GetCurMoneyByID(moneyID);
if(curMoney<itemNum)then
MsgManager.FloatMsgTableParam(nil,ZhString.HappyShop_silverNotEnough)
return;
end
end
elseif(queryData.type==ShopDressingProxy.DressingType.HAIRCOLOR) then
if(nil == ShopDressingProxy.Instance.chooseData) then return end
if(not queryData.id) then return end
-- 是否是同一顏色
if(ShopDressingProxy.Instance:bSameItem(ShopDressingProxy.DressingType.HAIRCOLOR))then
MsgManager.FloatMsgTableParam(nil,ZhString.HairDressingView_bSameColor)
return;
end
-- 是否有體驗券
local tempcsv = ShopProxy.Instance:GetShopItemDataByTypeId(shoptype,shopID,queryData.id)
if(tempcsv:CheckCanRemove())then
MsgManager.FloatMsgTableParam(nil,ZhString.HappyShop_overtime)
return
end
local preCost = tempcsv.PreCost
hasTicket=self:_bHasTicket(preCost)
-- 染料夠不夠
if(not hasTicket)then
local dyeID = tempcsv.hairColorID;
local result = ShopDressingProxy.Instance:bDyeMaterialEnough(dyeID);
if(not result)then
MsgManager.FloatMsgTableParam(nil,ZhString.HairDressingView_dyeNotEnough)
return;
end
end
end
ShopDressingProxy.Instance:CallReplaceDressing(queryData.id,queryData.count);
end
function HairDressingView:_bHasTicket(id)
if(id)then
local ticketNum = BagProxy.Instance:GetAllItemNumByStaticID(id)
return ticketNum>0
else
return false
end
end
function HairDressingView:RefreshSelectedROB(type,precost,constID,costCount,hairID)
self:Show(self.chargeNum)
self:RefreshMoney();
local hasTicket=false
if(type==1) then
self.chargeNum.text = costCount;
self.chargeTitle.text = ZhString.HairdressingView_cost;
local curCount = ShopDressingProxy.Instance:GetCurMoneyByID(constID);
if(curCount>=costCount)then
self.chargeNum.color = ColorUtil.ButtonLabelBlue;
else
ColorUtil.RedLabel(self.chargeWidget)
end
hasTicket=self:_bHasTicket(precost)
local flag = (curCount >= costCount) and ShopDressingProxy.Instance:bActived(hairID,ShopDressingProxy.DressingType.HAIR)
self:SetReplaceBtnState(hasTicket and true or flag)
local itemStaticData = Table_Item[constID]
if(itemStaticData and itemStaticData.Icon) then
IconManager:SetItemIcon(itemStaticData.Icon,self.itemIcon)
end
elseif (type==2) then
local itemData = Table_Item[constID];
local iconName = itemData.NameZh or ""
self.chargeNum.text = iconName .." x "..costCount
local bEnough = false;
local bagItem = BagProxy.Instance:GetItemByStaticID(constID);
if(bagItem and bagItem.num>=costCount) then
bEnough=true;
self.chargeNum.color = ColorUtil.ButtonLabelBlue;
else
bEnough=false;
ColorUtil.RedLabel(self.chargeWidget)
end
hasTicket=self:_bHasTicket(precost)
self:SetReplaceBtnState(hasTicket and true or bEnough)
self.chargeTitle.text = ZhString.HairDressingView_consume;
IconManager:SetItemIcon(itemData.Icon,self.itemIcon)
end
self:Show(self.itemIcon)
end
function HairDressingView:RecvUseDressing(note)
local id=note.body.id;
local usetype=note.body.type;
if(ShopDressingProxy.DressingType.HAIR == usetype) then
ShopDressingProxy.Instance.originalHair = id;
elseif(ShopDressingProxy.DressingType.HAIRCOLOR == usetype) then
ShopDressingProxy.Instance.originalHairColor = id;
elseif(ShopDressingProxy.DressingType.ClothColor == usetype)then
ShopDressingProxy.Instance.originalBodyColor = id;
end
self:RefreshModel()
end
function HairDressingView:OnEnter()
self.super.OnEnter(self)
self:CameraRotateToMe()
end