local addonName, ZLAUTO = ...

local ZL = ZLAUTO.mainFrame
local autoBid = ZL.autoBid
local GameTooltipShow = ZL.GameTooltipShow
local GameTooltipShowAnchor = ZL.GameTooltipShowAnchor
local LoadItemDataByID = ZL.LoadItemDataByID
local InportToStatistics = ZL.InportToStatistics
local cGetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
local cGetItemIcon = C_Item and C_Item.GetItemIconByID or GetItemIcon
local DisableAddOn = C_AddOns and C_AddOns.DisableAddOn or DisableAddOn
local MyAddon = ZL.MyAddon

--定义静态弹出对话框
--重置当前拍卖记录
StaticPopupDialogs["ZL_RESETCURRENT"] = {
	text = "%s",
	button1 = "重置|cffffff00并保存|r",
	button2 = "重置|cffff0000不保存|r",
    button3 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        self.editBox:SetText(ZL_CURRENT.name or GetInstanceInfo())
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self)
        ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
        if ZL_CURRENT["auctionlist"] then
            for num, data in ipairs(ZL_CURRENT["auctionlist"]) do
                local f = ZL.AuctionFrame2.entries[num]
                if data.state == "auctioning" then
                    ZL_CURRENT.auctionlist[num].state = "waiting"
                    ZL_CURRENT.auctionlist[num].endTime = nil
                    ZL_CURRENT.auctionlist[num].isPaused = nil
                    ZL_CURRENT.auctionlist[num].bidderlist = {}
                    f:SetValues(num)
                end
                f:Hide()
            end
        end
        --将收入导入到Statistics
        InportToStatistics(ZL_CURRENT)
        local _, _, totalincome = ZL.GetAveWages()
        ZL_CURRENT.totalincome = totalincome
        if (not ZL_CURRENT.name) and (strlen(self.editBox:GetText()) == 0) then
            ZL_CURRENT.name = GetInstanceInfo()
        elseif strlen(self.editBox:GetText()) > 0 then
            ZL_CURRENT.name = self.editBox:GetText()
        end
        if not ZL_CURRENT.auctiondate then ZL_CURRENT.auctiondate = date("%Y-%m-%d %H:%M:%S", GetServerTime()) end
        local index
        local auctionGUID = (ZL_CURRENT.globalConfig and ZL_CURRENT.globalConfig.auctionGUID) and ZL_CURRENT.globalConfig.auctionGUID or ZL_CURRENT.auctionGUID
        if auctionGUID then
            for _index, _data in ipairs(ZL_HISTORY) do
                local _acutionGUID = (_data.globalConfig and _data.globalConfig.auctionGUID) and _data.globalConfig.auctionGUID or _data.auctionGUID
                if auctionGUID == _acutionGUID then
                    index = _index
                    break
                end
            end
        end
        if index then
            ZL_HISTORY[index] = ZL_CURRENT
        else
            table.insert(ZL_HISTORY, ZL_CURRENT)
        end
        ZL_PLAYERLIST = {}
        ZL_CURRENT = {}
        ZL.CreateAuctionInfo()
        ZL.AuctionFrame2:Update()
        ZL.AuctionRecordFrame.historyFrame:Update()
        ZL.AuctionRecordFrame.currentIncomeFrame:Update()
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
        if not ZL.PlayerIsML() and ZL.GetMLname() then
            MyAddon:TransmitAddonInfo2("AUTOAUC REQ", "auctioning", "WHISPER", ZL.GetMLname())
        end
        local chatType
        if IsInRaid(1) then
            chatType = "RAID"
        elseif IsInGroup(1) then
            chatType = "PARTY"
        elseif IsInGuild() then
            chatType = "GUILD"
        end
        if chatType then
            --获取团队版本号
            local data = {type="request", ver=ZL.addonVersion}
            MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, chatType, nil, "BULK")
        end
        ZL.TransmitAddonInfo_Pro()
        local link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "历史记录", "历史记录")
        ZL.Print("已重置当前记录，可到" .. link .. "中恢复", true)
	end,
	OnCancel = function(self)
        ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
        if ZL_CURRENT["auctionlist"] then
            for num, data in ipairs(ZL_CURRENT["auctionlist"]) do
                local f = ZL.AuctionFrame2.entries[num]
                if data.state == "auctioning" then
                    ZL_CURRENT.auctionlist[num].state = "waiting"
                    ZL_CURRENT.auctionlist[num].endTime = nil
                    ZL_CURRENT.auctionlist[num].isPaused = nil
                    ZL_CURRENT.auctionlist[num].bidderlist = {}
                    f:SetValues(num)
                end
                f:Hide()
            end
        end
        --将收入导入到Statistics
        InportToStatistics(ZL_CURRENT)
        ZL_PLAYERLIST = {}
        ZL_CURRENT = {}
        ZL.CreateAuctionInfo()
        ZL.AuctionFrame2:Update()
        ZL.AuctionRecordFrame.historyFrame:Update()
        ZL.AuctionRecordFrame.currentIncomeFrame:Update()
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
        if not ZL.PlayerIsML() and ZL.GetMLname() then
            MyAddon:TransmitAddonInfo2("AUTOAUC REQ", "auctioning", "WHISPER", ZL.GetMLname())
        end
        local chatType
        if IsInRaid(1) then
            chatType = "RAID"
        elseif IsInGroup(1) then
            chatType = "PARTY"
        elseif IsInGuild() then
            chatType = "GUILD"
        end
        if chatType then
            --获取团队版本号
            local data = {type="request", ver=ZL.addonVersion}
            MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, chatType, nil, "BULK")
        end
        ZL.TransmitAddonInfo_Pro()
        ZL.Print("拍卖记录已清空", true)
	end,
	OnAlt = function(self, data)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 1,  -- 避免与其他弹出窗口冲突
}

--流拍物品申请重拍确认
StaticPopupDialogs["ZL_RETAKE"] = {
	text = "%s",
	button1 = "重拍",
	button2 = "取消",
    hasEditBox = false,
    OnShow = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
		if ZL.retake and #ZL.retake > 0 then
            local retake = ZL.retake
            local function linshi()
                if #retake > 0 then
                    local AuctioningCount = ZL.GetAuctioningCount()
                    if (not ZL_CURRENT.globalConfig.allowMultipleAuctions) and AuctioningCount > 0 then
                        C_Timer.After(2, linshi)
                    else
                        local fdata = retake[1]
                        local _, _index = ZL.FetchDataFromItemId(fdata.itemlink, fdata.itemindex)
                        if _index then
                            local curAuctionList = ZL_CURRENT.auctionlist[_index]
                            --如果是流拍的物品重新拍卖，检测流拍物品是否在流拍包里，如果在移动到其他包里
                            if curAuctionList.state == "failed" and ZL.opt.liupaiToggle and curAuctionList["spawnUID"] and next(curAuctionList["spawnUID"], nil) then
                                local itemList = {}
                                for _, value in pairs(curAuctionList["spawnUID"]) do
                                    if value["itemGUID"] and next(value["itemGUID"], nil) then
                                        for key, _ in pairs(value["itemGUID"]) do
                                            local bagID, slotIndex = ZL.FindItemInBag(key)
                                            if bagID and (bagID == ZL.opt.liupaiBagId or bagID == ZL.opt.liupaiBagId2) then
                                                --从第一个背包开始查询空闲的格子，如果不是流拍背包，也不是自己拍到的背包，则放进去
                                                local targetBagID, targetslotIndex
                                                local currentInfo
                                                for _bagID = 0, NUM_BAG_SLOTS do
                                                    if _bagID ~= ZL.opt.liupaiBagId and _bagID ~= ZL.opt.liupaiBagId and _bagID ~= ZL.opt.selfBagId then
                                                        for _slotIndex = 1, C_Container.GetContainerNumSlots(_bagID) do
                                                            currentInfo = C_Container.GetContainerItemInfo(_bagID, _slotIndex)
                                                            if not currentInfo then
                                                                targetBagID = _bagID
                                                                targetslotIndex = _slotIndex
                                                                break
                                                            end
                                                        end
                                                    end
                                                end
                                                currentInfo = nil
                                                if targetBagID then
                                                    table.insert(itemList, {
                                                        bagID = bagID, slotIndex = slotIndex,
                                                        targetBagID = targetBagID, targetslotIndex = targetslotIndex,
                                                    })
                                                end
                                            end
                                        end
                                    end
                                end

                                if #itemList > 0 then
                                    local index = 1
                                    local function _linshi()
                                        if index <= #itemList then
                                            if not (InCombatLockdown() or UnitIsDeadOrGhost("player")) then
                                                C_Container.PickupContainerItem(itemList[index]["bagID"], itemList[index]["slotIndex"])
                                                C_Container.PickupContainerItem(itemList[index]["targetBagID"], itemList[index]["targetslotIndex"])
                                                index = index + 1
                                                C_Timer.After(1, _linshi)
                                            else
                                                C_Timer.After(0.2, _linshi)
                                            end
                                        end
                                    end
                                    _linshi()
                                end
                            end
                            curAuctionList.bidderlist = {}
                            table.insert(ZL_CURRENT.auctionlist[_index].bidderlist, {
                                bidder = ZL.GetClassColorName(fdata.sender),
                                bidamount = curAuctionList.startbidamount,
                                bidCount = 1,
                                time = GetTime()*1000,
                            })
                            local _data = {
                                type = "开始拍卖",
                                isRestart = "开始",
                                data2 = curAuctionList,
                                syncIndex = _index,
                                globalConfigData = ZL.globalConfigData(),
                            }
                            MyAddon:TransmitAddonInfo("AUTOAUC SYNC1", _data)
                            local Frame1 = ZL.AuctionFrame2.entries[_index]
                            Frame1.sync = true
                            Frame1.MLframe.functionFrame.CancelBtn:Disable()
                            C_Timer.After(10, function ()
                                Frame1.sync = nil
                                Frame1.MLframe.functionFrame.CancelBtn:Enable()
                            end)
                            tremove(ZL.retake, 1)
                            C_Timer.After(2, linshi)
                        end
                    end
                end
            end
            linshi()
        end
	end,
	OnCancel = function(self, data)
        SendChatMessage("因暂时不方便拍卖，请稍后重新提交重拍申请", "RAID")
        ZL.retake = {}
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 2,  -- 避免与其他弹出窗口冲突
}

--拾取绑定物品加入到打包拍卖确认提醒
StaticPopupDialogs["ZL_ISPACKAGE"] = {
	text = "%s",
	button1 = "打包拍卖",
	button2 = "取消",
    hasEditBox = false,
    OnShow = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
		ZL.AddToPackage(data)
	end,
	OnCancel = function(self)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 3,  -- 避免与其他弹出窗口冲突
}
--更改拍卖模式警告提醒
StaticPopupDialogs["ZL_CHANGEAUCTIONMODE"] = {
	text = "%s",
	button1 = "确定",
    button2 = "取消",
    OnShow = function(self)
		if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        if data.type == "匿名" then
            local fdata = {
                type = "开始投票",
                totalMembers = data.totalMembers,
            }
            MyAddon:TransmitAddonInfo("AUTOAUC VOTE", fdata)
        end
        ZL.AuctionFrame2.auctionModeDropdown:Disable()
	end,
	OnCancel = function(self)
        ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 4,
}

--切换为匿名拍卖模式投票
StaticPopupDialogs["ZL_CHANGEAUCTIONMODEVOTE"] = {
	text = "%s",
    timeout = 31,
	button1 = "同意",
	button2 = "反对",
    OnShow = function(self)
        self.text:SetFormattedText(self.data .. "正在进行|cffff0000【匿名】|r拍卖投票\n请选择(%d)", 30)
        self.ticker = C_Timer.NewTicker(1, function()
            if self.timeleft > 0 then
                self.text:SetFormattedText(self.data .. "正在进行|cffff0000【匿名】|r拍卖投票\n请选择(%d)", self.timeleft)
                if self.timeleft <= 0 then
                    self:Hide()
                end
            end
        end)
        if ZL.voteTimer then
            if not ZL.voteTimer:IsCancelled() then
                ZL.voteTimer:Cancel()
            end
            ZL.voteTimer = nil
        end
        ZL.voteTimer = C_Timer.NewTimer(32, function ()
            local pass = ZL.voteAgree*100/ZL.voteTotalMembers
            local msgStr = "|cff00ff00同意：|r" .. ZL.voteAgree .. " |cffff0000反对：|r" .. ZL.voteRefuse .. " |cff0070dd总人数：|r" .. ZL.voteTotalMembers
            ZL.Print(msgStr, true)
            if pass > 50 then
                if ZL.PlayerIsML() then
                    ZL.opt.auctionMode = ZL.AuctionFrame2.auctionModeDropdown:GetText()
                    ZL.TransmitAddonInfo_Pro()
                    ZL.AuctionFrame2.auctionModeDropdown:Enable()
                    SendChatMessage("通过！通过率：" .. format("%.2f%%", pass) .. "，大于50%，拍卖模式已切换为【匿名】拍卖！", "RAID")
                end
                msgStr = "|cff00ff00通过！|r通过率：" .. format("%.2f%%", pass) .. "，大于50%，拍卖模式已切换为【|cffff0000匿名|r】拍卖！"
                ZL.Print(msgStr, true)
            else
                msgStr = "|cffff0000失败！|r通过率：" .. format("%.2f%%", pass) .. "，没有大于50%，拍卖模式已切换为【团队】模式！"
                ZL.Print(msgStr, true)
                if ZL.PlayerIsML() then
                    ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
                    ZL.AuctionFrame2.auctionModeDropdown:Enable()
                end
            end
        end)
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        local fdata = {
            type = "同意",
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC VOTE", fdata)
	end,
    OnCancel = function(self, data)
        local fdata = {
            type = "反对",
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC VOTE", fdata)
    end,
    OnHide = function(self)
        if ( self.timeleft > 0 ) then
            self:Hide();
        end
        if self.ticker then
            self.ticker:Cancel()
            self.ticker = nil
        end
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 5,
}
--进入全新副本时提醒是否重置拍卖记录
StaticPopupDialogs["ZL_RESETCURRENTINFO"] = {
	text = "%s",
	button1 = "确定",
    button2 = "取消",
    OnShow = function(self)
		if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self)
        ZL.resetAuction()
	end,
    OnCancel = function (self, data)
        if data then
            if data.type == "更新日期" then
                ZL_CURRENT.auctiondate =  date("%Y-%m-%d %H:%M:%S", GetServerTime())
            elseif data.type == "更新副本" then
                ZL_CURRENT.instanceID = data.instanceID
                ZL_CURRENT.maxPlayers = data.maxPlayers
                ZL_CURRENT.name = data.name
            end
        end
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 6,  -- 避免与其他弹出窗口冲突
}
--手动添加收支记录
StaticPopupDialogs["ZL_ADDINCOME"] = {
    text = "【|cffffd100%s|r】请输入必填项目",
    button1 = "确定",
    button2 = "取消",
    OnShow = function(self, data)
		self.button1:Disable()
        -- self.text:SetJustifyH("LEFT")
        local xSize = 130 --self.editBox:GetWidth()
        local ySize = 30 --self.editBox:GetHeight()
        if not self.editBox2 then
			self.editBox2 = CreateFrame("EditBox", "StaticPopupDialogsEditBox2", self, "InputBoxTemplate")
			self.editBox2:SetSize(xSize, ySize)
			self.editBox2:SetPoint("TOP", self.text, "BOTTOM", 10, -10)
			self.editBox2:SetAutoFocus(false)
			self.editBox2:SetMaxLetters(150)
			self.editBox2.text = self.editBox2:CreateFontString(nil, "OVERLAY")
			self.editBox2.text:SetFontObject(GameFontWhite)
			self.editBox2.text:SetPoint("RIGHT", self.editBox2, "LEFT", -15, 0)
			self.editBox2.text:SetText("玩家名：")
            self.editBox2.text2 = self.editBox2:CreateFontString(nil, "OVERLAY")
			self.editBox2.text2:SetFontObject(GameFontWhite)
			self.editBox2.text2:SetPoint("LEFT", self.editBox2, "RIGHT", 5, 0)
		end
        if not self.editBox3 then
			self.editBox3 = CreateFrame("EditBox", "StaticPopupDialogsEditBox3", self, "InputBoxTemplate")
			self.editBox3:SetSize(xSize, ySize)
			self.editBox3:SetPoint("TOP", self.editBox2, "BOTTOM", 0, 8)
			self.editBox3:SetAutoFocus(false)
			self.editBox3:SetMaxLetters(9)
            self.editBox3:SetNumeric(true)
            self.editBox3:SetScript("OnEnter", function (self)
                GameTooltipShowAnchor(self, "ANCHOR_TOPRIGHT")
                GameTooltip:AddLine("输入大于0的数，最大9个字符！")
                GameTooltip:AddLine("支持鼠标滚轮快速设置", 1, 1, 1)
                GameTooltip:AddLine("右键：|cffffffff设置默认值和鼠标滚动幅度|r")
                GameTooltip:Show()
            end)
            self.editBox3:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
            self.editBox3:SetScript("OnMouseWheel", function (self, delta)
                if self:HasFocus() then
                    local number = self:GetNumber()
                    if delta > 0 then
                        number = number + ZL.opt.popupPriceDelta
                    else
                        number = number - ZL.opt.popupPriceDelta
                    end
                    if number < ZL.opt.popupPriceDelta then
                        number = ZL.opt.popupPriceDelta
                    end
                    self:SetNumber(number)
                end
            end)
            self.editBox3:SetScript("OnMouseDown", function (self, button)
                if button == "RightButton" then
                    local function tempfunc(self)
                        return {
                            {
                                text = "默认值",
                                hasArrow = 1,
                                menuTable = function ()
                                    local numList = {50, 100, 200, 400, 500, 1000, 2000, 4000, 5000, 10000}
                                    local menuList = {}
                                    for _, value in ipairs(numList) do
                                        tinsert(menuList, {
                                            text = value,
                                            checkable = 1,
                                            checked = value == ZL.opt.popupPrice and true or false,
                                            func = function ()
                                                ZL.opt.popupPrice = value
                                                ZL.GUI:CloseMenu()
                                            end
                                        })
                                    end
                                    return menuList
                                end,
                            },
                            {
                                text = "滚轮幅度",
                                hasArrow = 1,
                                menuTable = function ()
                                    local numList = {50, 100, 500, 1000, 5000, 10000}
                                    local menuList = {}
                                    for _, value in ipairs(numList) do
                                        tinsert(menuList, {
                                            text = value,
                                            checkable = 1,
                                            checked = value == ZL.opt.popupPriceDelta and true or false,
                                            func = function ()
                                                ZL.opt.popupPriceDelta = value
                                                ZL.GUI:CloseMenu()
                                            end
                                        })
                                    end
                                    return menuList
                                end,
                            },
                        }
                    end
                    ZL.GUI:ToggleMenu(self, tempfunc(self), 'TOPLEFT', self, 'BOTTOMRIGHT', 0, 0)
                end
            end)
			self.editBox3.text = self.editBox3:CreateFontString(nil, "OVERLAY")
			self.editBox3.text:SetFontObject(GameFontWhite)
			self.editBox3.text:SetPoint("RIGHT", self.editBox3, "LEFT", -15, 0)
			self.editBox3.text:SetText("单　价：")
            self.editBox3.text2 = self.editBox3:CreateFontString(nil, "OVERLAY")
			self.editBox3.text2:SetFontObject(GameFontWhite)
			self.editBox3.text2:SetPoint("LEFT", self.editBox3, "RIGHT", 5, 0)
			self.editBox3.text2:SetText("(必填)")
		end
        if not self.editBox4 then
			self.editBox4 = CreateFrame("EditBox", "StaticPopupDialogsEditBox4", self, "InputBoxTemplate")
			self.editBox4:SetSize(xSize, ySize)
			self.editBox4:SetPoint("TOP", self.editBox3, "BOTTOM", 0, 8)
			self.editBox4:SetAutoFocus(false)
			self.editBox4:SetMaxLetters(150)
            self.editBox4:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
            self.editBox4:SetScript("OnMouseUp", function (self)
                if (select(1, GetCursorInfo())) == "item" then
                    self:SetText(select(3, GetCursorInfo()))
                    ClearCursor()
                end
            end)
            -- self.editBox4:SetScript("OnEditFocusGained", function ()
            --     ZL.focusEditBox = self.editBox4
            -- end)
            -- self.editBox4:SetScript("OnEditFocusLost", function ()
            --     if ZL.focusEditBox == self.editBox4 then
            --         ZL.focusEditBox = nil
            --     end
            -- end)
			self.editBox4.text = self.editBox4:CreateFontString(nil, "OVERLAY")
			self.editBox4.text:SetFontObject(GameFontWhite)
			self.editBox4.text:SetPoint("RIGHT", self.editBox4, "LEFT", -15, 0)
			self.editBox4.text:SetText("名　称：")
            self.editBox4.text2 = self.editBox4:CreateFontString(nil, "OVERLAY")
			self.editBox4.text2:SetFontObject(GameFontWhite)
			self.editBox4.text2:SetPoint("LEFT", self.editBox4, "RIGHT", 5, 0)
			self.editBox4.text2:SetText("(必填)")
		end
        if not self.editBox7 then
			self.editBox7 = CreateFrame("EditBox", "StaticPopupDialogseditBox7", self, "InputBoxTemplate")
			self.editBox7:SetSize(xSize, ySize)
			self.editBox7:SetPoint("TOP", self.editBox4, "BOTTOM", 0, 8)
			self.editBox7:SetAutoFocus(false)
            self.editBox7:SetNumeric(true)
            self.editBox7:SetNumber(1)
            self.editBox7:SetScript("OnEnter", function (self)
                GameTooltip:ClearAllPoints()
                GameTooltip:ClearLines()
                GameTooltip:SetOwner(self, "ANCHOR_NONE")
                GameTooltip:AddLine("输入大于0的数，默认为1")
                GameTooltip:SetPoint("LEFT", self, "RIGHT")
                GameTooltip:Show()
            end)
            self.editBox7:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
			self.editBox7.text = self.editBox7:CreateFontString(nil, "OVERLAY")
			self.editBox7.text:SetFontObject(GameFontWhite)
			self.editBox7.text:SetPoint("RIGHT", self.editBox7, "LEFT", -15, 0)
			self.editBox7.text:SetText("数　量：")
            self.editBox7.text2 = self.editBox7:CreateFontString(nil, "OVERLAY")
			self.editBox7.text2:SetFontObject(GameFontWhite)
			self.editBox7.text2:SetPoint("LEFT", self.editBox7, "RIGHT", 5, 0)
			self.editBox7.text2:SetText("(必填)")
		end
        local function CreateMenu(self, level, menuList)
            local currentRoster = ZL.GetWagesGroupMembers()
            if not currentRoster then return end
            local info = UIDropDownMenu_CreateInfo()
            if (level or 1) == 1 then
                for i = 1, #currentRoster do
                    if #currentRoster[i] > 0 then
                        info.notCheckable = 1
                        info.text = "小队 " .. i
                        info.hasArrow = true
                        info.menuList = currentRoster[i]
                        UIDropDownMenu_AddButton(info, level)
                    end
                end
            else
                for _, name in ipairs(menuList) do
                    info.text = name
                    info.hasArrow = false
                    info.func = function()
                        self:GetParent().editBox2:SetText(name)
                        info.checked = true
                        CloseDropDownMenus()
                    end
                    UIDropDownMenu_AddButton(info, level)
                end
            end
        end
        if not self.dropDown then
            self.dropDown = CreateFrame("FRAME", "WPDemoDropDown", self, "UIDropDownMenuTemplate")
            self.dropDown:SetPoint("RIGHT", self.editBox2, "RIGHT", 17, -1)
            self.dropDown:SetScale(0.8)
            UIDropDownMenu_SetWidth(self.dropDown, 8)
            UIDropDownMenu_Initialize(self.dropDown, CreateMenu)
        end
        self.dropDown:Show()
        self.editBox2:SetScript("OnTextChanged", function (self)
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                if strlen(self:GetParent().editBox2:GetText()) > 0 and self:GetParent().editBox3:GetNumber() > 0 and
                    strlen(self:GetParent().editBox4:GetText()) > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            elseif data.type == "支出" then
                if self:GetParent().editBox3:GetNumber() > 0 and strlen(self:GetParent().editBox4:GetText()) > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            end
        end)
        self.editBox3:SetScript("OnTextChanged", function (self)
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                if strlen(self:GetParent().editBox2:GetText()) > 0 and self:GetParent().editBox3:GetNumber() > 0 and
                    strlen(self:GetParent().editBox4:GetText()) > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            elseif data.type == "支出" then
                if self:GetParent().editBox3:GetNumber() > 0 and strlen(self:GetParent().editBox4:GetText()) > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            end
        end)
        self.editBox4:SetScript("OnTextChanged", function (self)
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                if strlen(self:GetParent().editBox2:GetText()) > 0 and self:GetParent().editBox3:GetNumber() > 0 and
                    strlen(self:GetParent().editBox4:GetText()) > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            elseif data.type == "支出" then
                if self:GetParent().editBox3:GetNumber() > 0 and strlen(self:GetParent().editBox4:GetText()) > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            end
        end)
        self.editBox4:SetScript("OnEnter", function (self)
            GameTooltip:ClearAllPoints()
            GameTooltip:ClearLines()
            GameTooltip:SetOwner(self, "ANCHOR_NONE")
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                GameTooltip:AddLine("如：罚款，垃圾或其他收入")
            elseif data.type == "支出" then
                GameTooltip:AddLine("如：补贴，物资消耗支出等")
            end
            GameTooltip:AddLine("如需输入物品名，|cffffd100Shift+左键|r点击\n背包物品或拍卖图标", 1, 1, 1)
            GameTooltip:SetPoint("LEFT", self, "RIGHT")
            GameTooltip:Show()
        end)
        self.editBox2:SetText("")
		self.editBox3:SetText("")
        self.editBox4:SetText("")
        self.editBox7:SetNumber(1)
        self.editBox2:Show()
        self.editBox3:Show()
        self.editBox4:Show()
        self.editBox7:Show()
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
		self:SetHeight(90 + self.editBox2:GetHeight() + self.editBox3:GetHeight() + self.editBox4:GetHeight() + self.editBox7:GetHeight())
        do
            local editboxList = {"StaticPopupDialogsEditBox2", "StaticPopupDialogsEditBox3", "StaticPopupDialogsEditBox4", "StaticPopupDialogseditBox7"}
            local function OnTabPressed(self)
                EditBox_HandleTabbing(self, editboxList)
            end
            self.editBox2:SetScript("OnTabPressed", OnTabPressed)
            self.editBox3:SetScript("OnTabPressed", OnTabPressed)
            self.editBox4:SetScript("OnTabPressed", OnTabPressed)
            self.editBox7:SetScript("OnTabPressed", OnTabPressed)
        end
        if data.type == "收入" then
            self.editBox2.text2:SetText("(必填)")
            self.editBox7.text2:SetText("(必填)")
        elseif data.type == "支出" then
            self.editBox2.text2:SetText("(可选)")
            self.editBox7.text2:SetText("(可选)")
        elseif data.type == "指定人员" then
            local ddate = ZL_CURRENT.auctionlist[data.index]
            self.editBox2.text2:SetText("(必填)")
            self.editBox7.text2:SetText("(必填)")
            self.editBox3:SetNumber(ddate.startbidamount)
            self.editBox4:SetText(ddate.itemlink)
            self.editBox7:SetNumber(ddate.itemCount)
        elseif data.type == "罚款" then
            self.editBox2.text2:SetText("(必填)")
            self.editBox7.text2:SetText("(必填)")
            self.editBox2:SetText(ZL.GetClassColorName(data.name))
            self.editBox3:SetNumber(data.amount)
            self.editBox4:SetText("罚款")
        end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnUpdate = function(self)
		-- 确保高度保持不变
		self:SetHeight(85 + self.editBox2:GetHeight() + self.editBox3:GetHeight() + self.editBox4:GetHeight())
	end,
    OnAccept = function (self, data)
        local itemList
        local player = ZL.GetClassColorName(self.editBox2:GetText())
        local notes = self.editBox4:GetText()
        local amount = 0
        local itemCount = self.editBox7:GetNumber()
        if ((not itemCount) or itemCount <= 0) then
            itemCount = 1
        end
        if not ZL_CURRENT.IncomeList then ZL_CURRENT.IncomeList = {} end
        if data.type == "收入" or data.type == "支出" or data.type == "罚款" then
            if data.type == "收入" or data.type == "罚款" then
                amount = self.editBox3:GetNumber() * itemCount
            elseif data.type == "支出" then
                amount = -self.editBox3:GetNumber() * itemCount
            end
            table.insert(ZL_CURRENT.IncomeList, {
                player = player,
                amount = amount,
                notes = notes,
                itemCount = itemCount,
                itemList = itemList,
            })
            if ZL.PlayerIsML(player) and amount > 0 then
                --ML自己拍到的物品直接记录到已支付
                if not ZL_CURRENT.playerPayToML then ZL_CURRENT.playerPayToML = {} end
                local oldPayToML = ZL_CURRENT.playerPayToML[player] and ZL_CURRENT.playerPayToML[player] or 0
                ZL_CURRENT.playerPayToML[player] = oldPayToML + amount
                ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            end
            ZL.AuctionRecordFrame.currentIncomeFrame:Update()
            ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            local fdata = {
                type = "添加收支",
                data = ZL_CURRENT.IncomeList,
                globalConfigData = ZL.globalConfigData(),
            }
            MyAddon:TransmitAddonInfo("AUTOAUC SYNC11", fdata)
        elseif data.type == "指定人员" then
            local ddate = ZL_CURRENT.auctionlist[data.index]
            ddate.bidderlist = {}
            table.insert(ddate.bidderlist, {
                bidder = player,
                bidamount = self.editBox3:GetNumber(),
                bidCount = itemCount,
                time = GetTime()*1000,
            })
            ZL.startOrCanelAuction(data.index, true)
        end


    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 7,  -- 避免与其他弹出窗口冲突
}
--清除所有历史记录警告
StaticPopupDialogs["ZL_CLEARHISTORYWARNING"] = {
	text = "警告！警告！将清空所有历史拍卖记录，并且无法恢复！是否确定清空？",
	button1 = "确定",
    button2 = "取消",
    OnShow = function(self)
		if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        for _, f in ipairs(ZL.AuctionRecordFrame.historyFrame.entries) do
            f:Hide()
        end
        ZL_HISTORY = {}
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 8,  -- 避免与其他弹出窗口冲突
}
--删除历史拍卖记录警告
StaticPopupDialogs["ZL_DELETEHISTORYWARNING"] = {
	text = "删除后无法恢复，确认删除该拍卖记录？",
	button1 = "确定",
    button2 = "取消",
    OnShow = function(self)
		if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        table.remove(ZL_HISTORY, data)
        ZL.AuctionRecordFrame.historyFrame:Update()
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 9,  -- 避免与其他弹出窗口冲突
}
--删除拍卖警告
StaticPopupDialogs["ZL_DELETEAUCTIONWARNING"] = {
	text = "%s",
	button1 = "确定",
    button2 = "取消",
    OnShow = function(self)
		if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        local curAuctionList = ZL_CURRENT.auctionlist[data]
        --将需要删除的拍卖物品发送给其他成员
        local fdata = {
            type = "删除拍卖物品",
            itemindex = curAuctionList.itemindex,
            itemlink = curAuctionList.itemlink,
        }
        MyAddon:TransmitAddonInfo("AUTOAUC SYNC10", fdata)
        ZL.AuctionFrame2.entries[data].sync = true
        C_Timer.After(10, function ()
            ZL.AuctionFrame2.entries[data].sync = nil
        end)
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 10,  -- 避免与其他弹出窗口冲突
}
--自动出价
StaticPopupDialogs["ZL_AUTOBID"] = {
    text = "输入%s的最大心里价位:",
    timeout = 31,
	button1 = "开始自动出价",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
        self:SetHyperlinksEnabled(true)
        self:SetScript("OnHyperlinkEnter", function(self, link, _, button)
            local itemID = GetItemInfoInstant(link)
            if itemID then
                GameTooltip:SetOwner(button, "ANCHOR_RIGHT", 0, 0)
                GameTooltip:ClearLines()
                GameTooltip:SetHyperlink(link)
                GameTooltip:Show()
            end
        end)
        self:SetScript("OnHyperlinkLeave", function(self)
            GameTooltip:Hide()
        end)
        self.button1:Disable()
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.data.targetAmount then self.editBox:SetText(self.data.targetAmount) end
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
		data.f.maxAutoBid = self.editBox:GetNumber() or 0
        if data.f.maxAutoBid > 0 then
            data.f.bidFrame.bidEditBox:Disable()
            data.f.bidFrame.bidBtn:SetText("停止")
            data.f.bidFrame.lgnoreBtn:Disable()
            local itemCount = ZL_CURRENT.auctionlist[data.index].itemCount
            local bidCount = data.f.bidFrame.bidCounts:GetNumber()
            bidCount = bidCount > 0 and bidCount or 1
            bidCount = bidCount > itemCount and itemCount or bidCount
            autoBid(data.index, data.f.maxAutoBid, bidCount)
            if data.f.autoBid then
                if (not data.f.autoBid:IsCancelled()) then
                    data.f.autoBid:Cancel()
                end
                data.f.autoBid = nil
            end
            data.f.autoBid = C_Timer.NewTicker(2, function (self)
                autoBid(data.index, data.f.maxAutoBid, bidCount)
            end)
        end
        self.editBox:ClearFocus()
	end,
	OnCancel = function(self, data)
	end,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 11,  -- 避免与其他弹出窗口冲突
}

--代交欠款名单确认
StaticPopupDialogs["ZL_CONFIRMTRADERNAME"] = {
    text = "%s没有欠款记录，如果是代交欠款，请先选择代交人，然后点记录\n如果不是，请选择不记录:",
	button1 = "记录",
	button2 = "不记录",
    OnShow = function(self)
        self.button1:Disable()
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
        ZL.GroupMembersDropdown:SetDefaultText("")
        local menuTable = {}
        if IsInRaid(1) then
            local WagesGroupMembers = ZL.GetCurrentRoster()
            if WagesGroupMembers then
                for i, data in ipairs(WagesGroupMembers) do
                    if #data > 0 then
                        local memberList = {}
                        for _, playerName in ipairs(data) do
                            tinsert(memberList, {text=playerName, func = function ()
                                self.button1:Enable()
                            end})
                        end
                        tinsert(menuTable, {
                            text = i .. "队",
                            hasArrow = true,
                            disabled = true,
                            menuTable = memberList,
                        })
                    end
                end
            end
        end
        ZL.GroupMembersDropdown:SetMenuTable(menuTable)
        ZL.GroupMembersDropdown:ClearAllPoints()
        ZL.GroupMembersDropdown:SetPoint("BOTTOM", self, "BOTTOM", 0, 40)

    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnAccept = function(self, data)
        local playerName = ZL.GroupMembersDropdown:GetText()
        if playerName and playerName ~= "" then
            if not ZL_CURRENT.playerPayToML then ZL_CURRENT.playerPayToML = {} end
            ZL_CURRENT.playerPayToML[playerName] = (ZL_CURRENT.playerPayToML[playerName] or 0) + data.tradeMoneyOther
            ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            local msgStr = playerName .. "已由" .. data.tradePartner .. "代交欠款：|cffffffff" .. data.tradeMoneyOther .. "|rg"
            ZL.Print(msgStr, true)
        end
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 13,  -- 避免与其他弹出窗口冲突
}
--撤销指定玩家的出价
StaticPopupDialogs["ZL_REVOKEBID"] = {
    text = "选择你想撤销出价的玩家名字：",
    button1 = "确认",
    button2 = "取消",
    OnShow = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
        ZL.GroupMembersDropdown:SetDefaultText("")
        local _, index = ZL.FetchDataFromItemId(self.data.itemlink, self.data.itemindex)
        local bidderlist = ZL_CURRENT.auctionlist[index].bidderlist
        local menuTable = {}
        for _, bidderData in ipairs(bidderlist) do
            tinsert(menuTable, {text=bidderData.bidder})
        end
        ZL.GroupMembersDropdown:SetMenuTable(menuTable)
        ZL.GroupMembersDropdown:ClearAllPoints()
        ZL.GroupMembersDropdown:SetPoint("BOTTOM", self, "BOTTOM", 0, 40)
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnAccept = function(self, data)
        local playerName = ZL.GroupMembersDropdown:GetText()
        if playerName and #playerName > 0 then
            MyAddon:TransmitAddonInfo("AUTOAUC REVOKE", {itemlink=data.itemlink, itemindex=data.itemindex, playerName=playerName})
            ZL.AuctionFrame2.entries[data.index].MLframe.functionFrame.syncBtn:Disable()
        end
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 14,  -- 避免与其他弹出窗口冲突
}

--增加玩家收入金额
StaticPopupDialogs["ZL_ADDTOPLAYER"] = {
    text = "输入你想|cffffd100增加|r[|cffffd100%s|r]的收入金额：",
	button1 = "确定",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
		self.button1:Disable()
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
		local addamount = self.editBox:GetNumber() or 0
        if (not ZL_CURRENT.playerPayToML) then ZL_CURRENT.playerPayToML = {} end
        ZL_CURRENT.playerPayToML[data]= (ZL_CURRENT.playerPayToML[data] or 0 )+ addamount
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 15,  -- 避免与其他弹出窗口冲突
}
--扣除玩家收入金额
StaticPopupDialogs["ZL_REMFROMPLAYER"] = {
    text = "输入你想|cffffd100扣除|r[|cffffd100%s|r]的收入金额：",
	button1 = "确定",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
		self.button1:Disable()
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
		local addamount = self.editBox:GetNumber() or 0
        if (not ZL_CURRENT.playerPayToML) then ZL_CURRENT.playerPayToML = {} end
        ZL_CURRENT.playerPayToML[data] = (ZL_CURRENT.playerPayToML[data] or 0) - addamount
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 16,  -- 避免与其他弹出窗口冲突
}
--手动创建拍卖物品
StaticPopupDialogs["ZL_ADDAUCTIONITEM"] = {
    text = "请填写需要拍卖的物品ID和数量：",
    button1 = "确定",
    button2 = "取消",
    OnShow = function(self)
		self.button1:Disable()
        local xSize = 130 --self.editBox:GetWidth()
        local ySize = 30 --self.editBox:GetHeight()
         if not self.editBox5 then
			self.editBox5 = CreateFrame("EditBox", "StaticPopupDialogseditBox5", self, "InputBoxTemplate")
			self.editBox5:SetSize(xSize, ySize)
			self.editBox5:SetPoint("TOP", self.text, "BOTTOM", 10, -10)
			self.editBox5:SetAutoFocus(false)
            self.editBox5:SetNumeric(true)
            self.editBox5:SetScript("OnTextChanged", function (self)
                if self:GetParent().editBox5:GetNumber() > 0 and self:GetParent().editBox6:GetNumber() > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            end)
            self.editBox5:SetScript("OnMouseUp", function (self)
                if (select(1, GetCursorInfo())) == "item" then
                    self:SetText(select(2, GetCursorInfo()))
                    ClearCursor()
                end
            end)
            self.editBox5:SetScript("OnEnter", function (self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("提示")
                GameTooltip:AddLine("鼠标点击物品，移动到这里，\n释放鼠标后可以自动获取到物品ID", 1, 1, 1)
                GameTooltip:Show()
            end)
            self.editBox5:SetScript("OnLeave", function ()
                GameTooltip:Hide()
            end)
			self.editBox5.text = self.editBox5:CreateFontString(nil, "OVERLAY")
			self.editBox5.text:SetFontObject(GameFontWhite)
			self.editBox5.text:SetPoint("RIGHT", self.editBox5, "LEFT", -15, 0)
			self.editBox5.text:SetText("物品ID：")
            self.editBox5.text2 = self.editBox5:CreateFontString(nil, "OVERLAY")
			self.editBox5.text2:SetFontObject(GameFontWhite)
			self.editBox5.text2:SetPoint("LEFT", self.editBox5, "RIGHT", 5, 0)
            self.editBox5.text2:SetText("(必填)")
		end
        if not self.editBox6 then
			self.editBox6 = CreateFrame("EditBox", "StaticPopupDialogseditBox6", self, "InputBoxTemplate")
			self.editBox6:SetSize(xSize, ySize)
			self.editBox6:SetPoint("TOP", self.editBox5, "BOTTOM", 0, 5)
			self.editBox6:SetAutoFocus(false)
            self.editBox6:SetNumeric(true)
            self.editBox6:SetScript("OnTextChanged", function (self)
                if self:GetParent().editBox5:GetNumber() > 0 and self:GetParent().editBox6:GetNumber() > 0 then
                    self:GetParent().button1:Enable()
                else
                    self:GetParent().button1:Disable()
                end
            end)
            -- self.editBox6:SetScript("OnEnter", function (self)
            --     GameTooltipShow(self, "LEFT", "RIGHT")
            --     GameTooltip:AddLine("注意")
            --     GameTooltip:AddLine("如是拍卖打包的物品，数量填|cffffd1001|r", 1, 1, 1)
            --     GameTooltip:Show()
            -- end)
            -- self.editBox6:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
			self.editBox6.text = self.editBox6:CreateFontString(nil, "OVERLAY")
			self.editBox6.text:SetFontObject(GameFontWhite)
			self.editBox6.text:SetPoint("RIGHT", self.editBox6, "LEFT", -15, 0)
			self.editBox6.text:SetText("数　量：")
            self.editBox6.text2 = self.editBox6:CreateFontString(nil, "OVERLAY")
			self.editBox6.text2:SetFontObject(GameFontWhite)
			self.editBox6.text2:SetPoint("LEFT", self.editBox6, "RIGHT", 5, 0)
			self.editBox6.text2:SetText("(必填)")
		end
        self.editBox5:SetText("")
		self.editBox6:SetText("")
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.dropDown then self.dropDown:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        self.editBox5:Show()
        self.editBox6:Show()
        if self.data then
            self.editBox5:SetNumber(self.data.itemId)
        end
		self:SetHeight(85 + self.editBox5:GetHeight() + self.editBox6:GetHeight() + self.editBox5:GetHeight())
        do
            local editboxList = {"StaticPopupDialogseditBox5", "StaticPopupDialogseditBox6"}
            local function OnTabPressed(self)
                EditBox_HandleTabbing(self, editboxList)
            end
            self.editBox5:SetScript("OnTabPressed", OnTabPressed)
            self.editBox6:SetScript("OnTabPressed", OnTabPressed)
        end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnUpdate = function(self)
		-- 确保高度保持不变
		self:SetHeight(85 + self.editBox5:GetHeight() + self.editBox6:GetHeight() + self.editBox5:GetHeight())
	end,
    OnAccept = function (self, data)
        local itemId = self.editBox5:GetNumber()
        local itemCount = self.editBox6:GetNumber()
        local function func(itemlink)
            ZL.ManualCreateAuctionItem(itemlink, itemCount or 1, data and data.itemGuid)
        end
        LoadItemDataByID(itemId, func, self.editBox5)
     end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 17,  -- 避免与其他弹出窗口冲突
}

--首次提醒
StaticPopupDialogs["ZL_FIRSTNOTICE"] = {
    text = "|cff0000ff【AutoAuction】|r提醒：新增了鼠标提示功能开关：拍卖状态、历史成交价、历史成交趋势图，默认为展示状态，如需隐藏，可到设置里面修改",
	button1 = "修改",
    button2 = "取消",
    OnShow = function(self)
		if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL.OpenAceConfigDialog("金团拍卖助手", "tooltip")
	end,
    OnCancel = function(self)
        local msgStr = "后续可到设置——鼠标提示里取消展示"
        ZL.Print(msgStr, true)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 18,  -- 避免与其他弹出窗口冲突
}

--同步不同战网子账号之间数据弹窗确认
StaticPopupDialogs["ZL_SYNCROLES"] = {
	text = "%s",
	button1 = "同意",
	button2 = "拒绝",
    timeout = 0,
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
        self.timeout = nil
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL.SaveRoles(data)
        RolesOverView["syncKeyUnBind"][data.OwnRolesSyncKey] = nil --从新绑定的从这里面移除
        local _data = {
            type = "addnewAgree",
            playerName = ZL.GetClassColorName(UnitName("player")),
            rolesData = RolesOverView.owner,
            syncData = RolesOverView.sync,
            OwnRolesSyncKey = select(3, ZL.GetOwnRolesSyncKey()),
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(data.playerName), "BULK")
        local msgStr = "已成功与" .. data.playerName .. "绑定同步角色数据！"
        ZL.Print(msgStr, true)
	end,
	OnCancel = function(self, data)
        local _data = {
            type = "addnewRefuse",
            data = ZL.GetClassColorName(UnitName("player")),
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(data.playerName), "BULK")
	end,
    OnUpdate = function(self, elapsed)
        -- 每帧更新时触发
        if not self.timeout then self.timeout = self.data.timeout - GetTime() end
        self.timeout = self.timeout - elapsed
        if self.timeout <= 0 then
            self.timeout = 0
            self:Hide()  -- 倒计时结束后关闭对话框
        else
            self.text:SetText(self.data.playerName .. "请求与你共享角色数据，是否同意？倒数：" .. "|cff00ff00" .. ceil(self.timeout) .. "|r")
        end
    end,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 19,  -- 避免与其他弹出窗口冲突
}

--修改子账号名字
StaticPopupDialogs["ZL_MODIFYBNCHILD"] = {
	text = "%s",
	button1 = "修改",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if #self:GetText() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        self.button1:Disable()
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        local _, _, BNChild = strsplit(":", data)
        local BNChildNewName = self.editBox:GetText()
        BNChildNewName = BNChildNewName:gsub(":", "")
        RolesOverView["BNChildNewName"][BNChild] = self.editBox:GetText()
        if ZL.LgnoreRolesFrame:IsShown() then
            ZL.LgnoreRolesFrame:Update()
        end
        ZL.RolesOverViewFrame.battleTagDropdown:SetMenuTable(ZL.GetBattleTagDropdownList())
        ZL.RolesOverViewFrame.battleTagDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetMenuTable(ZL.GetBNChildDropdownList())
        ZL.RolesOverViewFrame.BNChildDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetValue("全部")
        ZL.RolesOverViewFrame.realmDropdown:SetMenuTable(ZL.GetRealmDropdownList())
        ZL.RolesOverViewFrame.realmDropdown:SetDefaultText(GetRealmName())
        ZL.RolesOverViewFrame:Update()
        ZL.LgnoreRolesFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 20,  -- 避免与其他弹出窗口冲突
}
--删除角色数据
StaticPopupDialogs["ZL_DELETEROLES"] = {
	text = "%s",
	button1 = "删除",
	button2 = "取消",
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        if not ZL.glb.rolesDel then ZL.glb.rolesDel = {} end
        ZL.glb.rolesDel[data] = true
        local playerName, realmName, BNChild, battleTag = strsplit(":", data)
        local parsePlayerName = ZL.ParseClassColorName(playerName)
        local factionGroup = select(2, UnitFactionGroup("player"))
        if RolesOverView["owner"][battleTag] and RolesOverView["owner"][battleTag][BNChild] and RolesOverView["owner"][battleTag][BNChild][realmName]
        and RolesOverView["owner"][battleTag][BNChild][realmName][factionGroup] then
            RolesOverView["owner"][battleTag][BNChild][realmName][factionGroup][parsePlayerName] = nil
        end
        if RolesOverView["sync"][battleTag] and RolesOverView["sync"][battleTag][BNChild] and RolesOverView["sync"][battleTag][BNChild][realmName]
        and RolesOverView["sync"][battleTag][BNChild][realmName][factionGroup] then
            RolesOverView["sync"][battleTag][BNChild][realmName][factionGroup][parsePlayerName] = nil
        end
        RolesOverView["syncKey"][realmName .. ":" .. factionGroup .. ":" .. parsePlayerName] = nil
        ZL.glb["rolesLgnore"][data] = nil
        ZL.RolesOverViewFrame:Update()
        ZL.LgnoreRolesFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 21,  -- 避免与其他弹出窗口冲突
}
--删除绑定子账号
StaticPopupDialogs["ZL_DELETEBNCHILD"] = {
	text = "%s",
	button1 = "解除绑定",
	button2 = "取消",
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        RolesOverView["syncKeyUnBind"][data] = nil
        local battleTag, BNChild = strsplit(":", data)
        if RolesOverView["sync"] and RolesOverView["sync"][battleTag] then
            RolesOverView["sync"][battleTag][BNChild] = nil
        end
        local accountPlayer = {}
        local myRealm, myFactiongroup = GetRealmName(), select(2, UnitFactionGroup("player"))
        for key, value in pairs(RolesOverView["syncKey"]) do
            if value == data then
                local realm, factiongroup, player = strsplit(":", key)
                if realm == myRealm and factiongroup == myFactiongroup then
                    tinsert(accountPlayer, player)
                end
                RolesOverView["syncKey"][key] = nil
            end
        end
        if ZL.glb["rolesLgnore"] then
            for key in pairs(ZL.glb["rolesLgnore"]) do
                local _, _, _BNChild, _battleTag = strsplit(":", key)
                if BNChild == _BNChild and battleTag == _battleTag then
                    ZL.glb["rolesLgnore"][key] = nil
                end
            end
        end
        if ZL.glb["rolesDel"] then
            for key in pairs(ZL.glb["rolesDel"]) do
                local _, _, _BNChild, _battleTag = strsplit(":", key)
                if BNChild == _BNChild and battleTag == _battleTag then
                    ZL.glb["rolesDel"][key] = nil
                end
            end
        end
        local msgStr = "已解除[|cffffff00" .. battleTag .. ":" .. (RolesOverView["BNChildNewName"][BNChild] or BNChild) .. "|r]绑定！"
        ZL.Print(msgStr, true)
        -- RolesOverView["BNChildNewName"][BNChild] = nil
        ZL.RolesOverViewFrame.battleTagDropdown:SetMenuTable(ZL.GetBattleTagDropdownList())
        ZL.RolesOverViewFrame.battleTagDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetMenuTable(ZL.GetBNChildDropdownList())
        ZL.RolesOverViewFrame.BNChildDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetValue("全部")
        ZL.RolesOverViewFrame.realmDropdown:SetMenuTable(ZL.GetRealmDropdownList())
        ZL.RolesOverViewFrame.realmDropdown:SetDefaultText(GetRealmName())
        ZL.RolesOverViewFrame:Update()
        ZL.LgnoreRolesFrame:Update()

        --发送解除消息
        if #accountPlayer > 0 then
            --先判断是否有在线好友
            local isOnline
            for _, player in ipairs(accountPlayer) do
                if ZL.IsOnline(player, nil, nil, true) then
                    --发送解绑信息
                    local _, _, ownSyncKey = ZL.GetOwnRolesSyncKey()
                    local _data = {
                        type = "unBind",
                        playerName = ZL.GetClassColorName(UnitName("player")),
                        rolesData = "已解绑",
                        accountSyncKey = ownSyncKey,
                    }
                    MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(player), "BULK")
                    isOnline = true
                    wipe(accountPlayer)
                    accountPlayer = nil
                    break
                end
            end
            --没有在线好友，则先全部添加, 最多添加2次
            if not isOnline then
                ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", ZL.AddFriendFilterFunc)
                for _, player in ipairs(accountPlayer) do
                    local info = C_FriendList.GetFriendInfo(player)
                    if (not info) and C_FriendList.GetNumFriends() < 100 then
                        C_FriendList.AddFriend(player)
                    end
                end
                --1秒后再添加一次
                C_Timer.After(1, function ()
                    for _, player in ipairs(accountPlayer) do
                        local info = C_FriendList.GetFriendInfo(player)
                        if (not info) and C_FriendList.GetNumFriends() < 100 then
                            C_FriendList.AddFriend(player)
                        end
                    end
                    --1秒后判断是否有在线好友
                    C_Timer.After(1, function ()
                        ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", ZL.AddFriendFilterFunc)
                        for _, player in ipairs(accountPlayer) do
                            if ZL.IsOnline(player, nil, nil, true) then
                                --发送解绑信息
                                local _, _, ownSyncKey = ZL.GetOwnRolesSyncKey()
                                local _data = {
                                    type = "unBind",
                                    playerName = ZL.GetClassColorName(UnitName("player")),
                                    rolesData = "已解绑",
                                    accountSyncKey = ownSyncKey,
                                }
                                MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(player), "BULK")
                                wipe(accountPlayer)
                                accountPlayer = nil
                                break
                            end
                        end
                    end)
                end)
            end
            
        end

	end,
	OnCancel = function(self, data)
	end,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 22,  -- 避免与其他弹出窗口冲突
}

--复制当前配置并切换为默认配置（全账号共享配置）
StaticPopupDialogs["ZL_CHANGEANDCOPYTODEFAULTPROFILE"] = {
	text = "%s",
	button1 = "复制当前配置并切换为默认配置",
	button2 = "直接切换为默认配置",
    button3 = "取消",
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        ZL.db:SetProfile("Default")
        ZL.db:CopyProfile(data)
        local msgStr = "已复制当前角色配置并切换到默认配置(全角色共享)，您也可以到设置里面重新更改。"
        ZL.Print(msgStr, true)
        ZL.db.global.copyToDefalutProfile = true
	end,
    OnCancel = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        ZL.db:SetProfile("Default")
        local msgStr = "已切换到默认配置(全角色共享)，您也可以到设置里面重新更改。"
        ZL.Print(msgStr, true)
    end,
	OnAlt = function()
        ZL.db.profile.askedAboutProfile = true
        local msgStr = "如需全角色共享配置，可到设置里面修改为默认配置。"
        ZL.Print(msgStr, true)
	end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 23,  -- 避免与其他弹出窗口冲突
}
--直接切换为默认配置（全账号共享配置）
StaticPopupDialogs["ZL_CHANGEDEFAULTPROFILE"] = {
	text = "%s",
	button1 = "切换为默认配置",
	button2 = "取消",
    OnShow = function(self)
		self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        ZL.db:SetProfile("Default")
        local msgStr = "已切换到默认配置(全角色共享)，您也可以到设置里面重新更改。"
        ZL.Print(msgStr, true)
	end,
    OnCancel = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        local msgStr = "如需全角色共享配置，可到设置里面修改为默认配置。"
        ZL.Print(msgStr, true)
    end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 24,  -- 避免与其他弹出窗口冲突
}

--导入关注物品字符串
StaticPopupDialogs["ZL_IMPORTCORCERNSTRING"] = {
	text = "%s",
	button1 = "导入",
	button2 = "取消",
    OnShow = function(self)
		self.button1:SetText(self.data.btnText)
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL.WaStringFrame:Hide()
        local selectCharKey = data.selectCharKey
        ZL.opt.concernList[selectCharKey] = data.data
        ZL.ConcernFrame:Update()
        if ZL.AuctionFrame2:IsShown() then
            ZL.AuctionFrame2:Update()
        end
        ZL.Print(selectCharKey .. "  关注物品数据导入成功", true)
	end,
    OnCancel = function(self, data)
    end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 25,  -- 避免与其他弹出窗口冲突
}

--设置快速出价幅度quickBidIncrement
StaticPopupDialogs["ZL_QUICKBIDINCREMENT"] = {
	text = "请输入快速出价弹窗加价幅度",
	button1 = "确认",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
		self.button1:Disable()
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL.opt.quickBidIncrement = self.editBox:GetNumber()
	end,
    OnCancel = function(self, data)
    end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 26,  -- 避免与其他弹出窗口冲突
}

--角色拥有物品数量大于1时出价确认
StaticPopupDialogs["ZL_CONFIRMBID"] = {
	text = "%s",
	button1 = "继续竞价",
	button2 = "取消",
    OnShow = function(self)
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        ZL_CURRENT.auctionlist[data.index].confirmBid = true
        if ZL_CURRENT.globalConfig.auctionMode == "团队" then
            if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                SendChatMessage(data.msgStr, "RAID")
            else
                SendChatMessage(data.itemlink .. data.msgStr, "RAID")
            end
        else
            MyAddon:TransmitAddonInfo2("AUTOAUC BID", data.itemlink .. data.msgStr)
        end
	end,
    OnCancel = function(self, data)
    end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 27,  -- 避免与其他弹出窗口冲突
}

--重载界面
StaticPopupDialogs["ZL_RELOADUI"] = {
    text = "%s",
	button1 = "|cffA335EE加载UI|r",
	button2 = "取消",
    OnShow = function(self)
        self.editBox:SetNumeric(false)
        self.editBox:SetAutoFocus(false)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
	OnAccept = function(self, data)
        DisableAddOn(addonName)
        ReloadUI()
	end,
	OnCancel = function(self, data)
        ZL.Print("你还未加载UI，可能会影响后续拍卖！输入/reload可重新加载UI", true)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
    preferredIndex = 28,  -- 避免与其他弹出窗口冲突
}
--校正包装备累计分配数量
StaticPopupDialogs["ZL_CORRECTBUYERTOTAL"] = {
    text = "请输入校正后的累计分配数量",
    button1 = "确定",
    button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
        self.editBox:SetNumeric(true)
        self.editBox:SetAutoFocus(true)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnAccept = function(self, index)
        local data = ZL.opt.buyerHistory[index]
        data.total = self.editBox:GetText()
        local item = Item:CreateFromItemID(data.itemId)
        if item:GetItemID() then
            item:ContinueOnItemLoad(function()
                local _, itemLink = cGetItemInfo(data.itemId)
                local buyerName = ZL.GetClassColorName(data.buyerName)
                ZL.Print(itemLink .. " - " .. buyerName .. " - 累计数量已调整为：" .. data.total)
            end)
        end
        self.editBox:ClearFocus()
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 29,
}

--设置ROLL计时
StaticPopupDialogs["ZL_ROLLCOUNTDOWN"] = {
    text = "请输入ROLL记录时长(秒)",
    button1 = "确定",
    button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button1:Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent().button1:Enable()
		else
			self:GetParent().button1:Disable()
		end
	end,
    OnShow = function(self)
        self.editBox:SetNumeric(true)
        self.editBox:SetAutoFocus(true)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnAccept = function(self)
        ZL.opt.rollCountDown =( self.editBox:GetNumber() and self.editBox:GetNumber() > 5) and self.editBox:GetNumber() or 5
        ZL.Print("ROLL时长已调整为：" .. ZL.opt.rollCountDown .. "秒", true)
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 30,
}
StaticPopupDialogs["ZL_IMPORTTASKPROFILESTRING1"] = {
    text = "%s",
    button1 = "覆盖导入",
    button2 = "新建导入",
    button3 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button2:Click() end,
    EditBoxOnTextChanged = function(self)
        if strlen(self:GetText()) > 0 then
            local isExist
            for _, profileKey in ipairs(ZL.opt.taskList["profileKeys"]) do
                if profileKey == self:GetText() then
                    isExist = true
                end
            end
            if not isExist then
                self:GetParent().button2:Enable()
            else
                self:GetParent().button2:Disable()
                ZL.Print("配置名已存在，请重新输入！", nil, nil, nil, nil, true)
            end
        else
            self:GetParent().button2:Disable()
        end
    end,
    OnShow = function(self)
		self.button2:Disable()
        self.editBox:SetAutoFocus(false)
        self.editBox:SetNumeric(true)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnAccept = function(self, data)
        local profileName
        for key in pairs(data) do
            profileName = key
            break
        end
        if profileName then
            local valueIndex
            for index, value in ipairs(ZL.opt.taskList["profileKeys"]) do
                if value == profileName then
                    valueIndex = index
                end
            end
            if valueIndex then
                ZL.opt.taskList.task[profileName] = data[profileName]
                ZL.TaskFrame.historyProfileDropdown:SetMenuTable(ZL.getTaskProfileDropdownList())
                ZL.TaskFrame.historyProfileDropdown:SetValue(valueIndex)
                ZL.Print("【|cffffffff" .. profileName .. "|r】配置已导入！")
            else
                ZL.Print("导入失败！")
            end
        else
            ZL.Print("导入失败！")
        end
    end,

    OnCancel = function(self, data)
        local profileName
        for key in pairs(data) do
            profileName = key
            break
        end
        if profileName then
            local _profileName = self.editBox:GetText()
            ZL.opt.taskList.task[_profileName] = data[profileName]
            tinsert(ZL.opt.taskList["profileKeys"], _profileName)
            ZL.TaskFrame.historyProfileDropdown:SetMenuTable(ZL.getTaskProfileDropdownList())
            ZL.TaskFrame.historyProfileDropdown:SetValue(#ZL.opt.taskList["profileKeys"])
            ZL.Print("【|cffffffff" .. profileName .. "|r】已导入新建配置【|cffffffff" .. _profileName .. "|r】中！")
        else
            ZL.Print("导入失败！")
        end
    end,

	OnAlt = function()

	end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 31,  -- 避免与其他弹出窗口冲突
}

StaticPopupDialogs["ZL_IMPORTTASKPROFILESTRING2"] = {
    text = "%s",
    button1 = "导入",
    button2 = "取消",
    hasEditBox = false,
    OnShow = function(self)
        self.editBox:SetNumeric(true)
        self.editBox:SetAutoFocus(true)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnHide = function(self)
        if self.editBox2 then self.editBox2:Hide() end
        if self.editBox3 then self.editBox3:Hide() end
        if self.editBox4 then self.editBox4:Hide() end
        if self.editBox5 then self.editBox5:Hide() end
        if self.editBox6 then self.editBox6:Hide() end
        if self.editBox7 then self.editBox7:Hide() end
        if self.dropDown then self.dropDown:Hide() end
    end,
    OnAccept = function(self, data)
        local profileName
        for key in pairs(data) do
            profileName = key
            break
        end
        if profileName then
            ZL.opt.taskList.task[profileName] = data[profileName]
            tinsert(ZL.opt.taskList["profileKeys"], profileName)
            ZL.TaskFrame.historyProfileDropdown:SetMenuTable(ZL.getTaskProfileDropdownList())
            ZL.TaskFrame.historyProfileDropdown:SetValue(#ZL.opt.taskList["profileKeys"])
            ZL.Print("【|cffffffff" .. profileName .. "|r】配置已导入！")
        else
            ZL.Print("导入失败！")
        end
    end,

    OnCancel = function(self)
    end,
    whileDead = true,
    hideOnEscape = true,
    preferredIndex = 32,  -- 避免与其他弹出窗口冲突
}