PageSourceSearch

https://isp2dial.com/usr/plugins/activity/js/popup-lottery.js?v=fpgy57w

js isp2dial.com collected 2026-09-29 22:25:20 UTC 8,175 bytes, 219 lines download raw bytes

1// 春节活动弹窗 start
2;(function (doc, win) {
3    let popupOpen = false
4    let msgItems = []
5
6    const formatCountdown = seconds => {
7        const days = Math.floor(seconds / (24 * 3600))
8        const hours = Math.floor((seconds % (24 * 3600)) / 3600)
9        const minutes = Math.floor((seconds % 3600) / 60)
10        const secs = seconds % 60
11        return `${days}天${hours}小时${minutes}分${secs}秒`
12    }
13
14    // 创建轮播效果
15    const createScrollingEffect = () => {
16        const msgListDom = document.getElementById("msg-list")
17        if (!msgListDom || msgItems.length <= 1) return
18
19        // 如果只有一条消息,不需要轮播
20        if (msgItems.length === 1) {
21            msgListDom.innerHTML = `<div class="msg-list-item">${msgItems[0]}</div>`
22            msgListDom.classList.remove("scrolling")
23            return
24        }
25
26        // 复制一份消息以创建无缝轮播效果
27        const allItems = [...msgItems, ...msgItems]
28        const itemWidth = 100 / msgItems.length
29
30        msgListDom.innerHTML = allItems
31            .map((item, index) => `<div class="msg-list-item" style="width: ${itemWidth}%">${item}</div>`)
32            .join("&nbsp&nbsp&nbsp;")
33
34        // 设置总宽度
35        msgListDom.style.width = `${msgItems.length * 200}%`
36
37        // 添加轮播动画
38        msgListDom.classList.add("scrolling")
39
40        // 设置动画时长,根据消息数量调整速度
41        const animationDuration = msgItems.length * 3
42        msgListDom.style.animationDuration = `${animationDuration}s`
43    }
44
45    const renderMsgList = msgList => {
46        if (msgList.length > 0) {
47            const msgListWrap = document.querySelector(".msg-list-wrap")
48            if (msgListWrap) {
49                msgListWrap.classList.add("show")
50            }
51        }
52        setTimeout(() => {
53            const msgListDom = document.getElementById("msg-list")
54            const msgListContainer = document.querySelector(".msg-list-container")
55
56            if (msgList.length > 0 && msgListDom && msgListContainer) {
57                msgItems = msgList.map(item => `恭喜${item.nick_name}获得了${item.text}`)
58                createScrollingEffect()
59            }
60        }, 100)
61    }
62
63    const renderCountdown = (countdown, status) => {
64        const countDownDom = document.getElementById("count-down")
65        if (countDownDom) {
66            // if (status === 0) {
67            //     countDownDom.textContent = "活动未开始"
68            //     return
69            // }
70            if (status === 2) {
71                countDownDom.textContent = "活动已结束"
72                return
73            }
74            let remainingSeconds = countdown
75            countDownDom.textContent = formatCountdown(remainingSeconds)
76            const intervalId = setInterval(() => {
77                remainingSeconds--
78                if (remainingSeconds < 0) {
79                    clearInterval(intervalId)
80                    initPupupData()
81                    return
82                }
83                countDownDom.textContent = formatCountdown(remainingSeconds)
84            }, 1000)
85        }
86    }
87
88    const initPupupData = () => {
89        window.parent.$Http({ url: "/api/activity/limited_index", data: {} }).then(res => {
90            if (res?.status === 1) {
91                // 活动倒计时
92                const countdown = res?.data?.remain_seconds || 0
93                // 活动中奖消息列表
94                const msgList = res?.data?.record_list || []
95                // 活动状态
96                const status = res?.data?.status
97
98                renderCountdown(countdown, status)
99                if (msgList.length > 0) {
100                    renderMsgList(msgList, status)
101                }
102            }
103        })
104    }
105
106    function isFloatRecentlyClosed(localStorageKey) {
107        const lastClosedTimestamp = Number(localStorage.getItem(localStorageKey));
108        if (!lastClosedTimestamp || isNaN(lastClosedTimestamp)) return false;
109        const currentTimestamp = Date.now();
110        return (currentTimestamp - lastClosedTimestamp) < (24 * 60 * 60 * 1000);
111    }
112
113    function setFloatJustClosed(localStorageKey) {
114        localStorage.setItem(localStorageKey, Date.now());
115    }
116
117    const handleListenEvent = () => {
118        doc.addEventListener("click", function (event) {
119            const target = event.target.closest("a.popup-activity-annual-26")
120            if (target) {
121                event.preventDefault()
122                if (!$UserManager.isLogin()) {
123                    win.$WinOpen({
124                        event: "open",
125                        datas: {
126                            key: "LOGIN",
127                            url: `/ai/login/?redirect=${encodeURIComponent(win.location.pathname + win.location.search)}`
128                        }
129                    })
130                    return
131                }
132                win.$WinOpen({
133                    event: "open",
134                    datas: { key: "LOTTERY", url: "/my/activity/" }
135                })
136
137                // 增加活动入口点击埋点
138                win.$Http({ url: "/api/activity/click", data: {id: 4} })
139
140                $('#adFloat')?.hide()
141                popupOpen = true
142            }
143
144            const closeBtn = event.target.closest(".lottery-popup-btn")
145            if (closeBtn) {
146                window.parent.$WinClose({
147                    event: "allclose"
148                })
149                window.parent.$('#adFloat').show()
150                popupOpen = false
151            }
152        })
153    }
154
155    document.addEventListener("DOMContentLoaded", function () {
156        handleListenEvent()
157        const pupupDom = document.getElementById("lottery-popup-wrap")
158        if (pupupDom) {
159            initPupupData()
160        }
161
162        // 广告浮窗、ai浮窗和落地页入口根据本地存储显示或隐藏,默认CSS已全部隐藏
163        // 若未关闭,则显示入口。关闭后存储关闭时间,24小时后才再显示。
164
165        // 广告浮窗
166        const adFloatClosedKey = 'ADFLOAT_CLOSED';
167        const adFloatElement = document.querySelector('#adFloat');
168        const adFloatCloseButton = adFloatElement?.querySelector('.on-close-btn');
169        if (adFloatElement) {
170            if (!isFloatRecentlyClosed(adFloatClosedKey)) {
171                $(adFloatElement).show();
172            }
173            if (adFloatCloseButton) {
174                adFloatCloseButton.addEventListener('click', function (e) {
175                    e.stopPropagation();
176                    $(this).closest(".xqbj-component-adfloat").hide();
177                    setFloatJustClosed(adFloatClosedKey);
178                });
179            }
180        }
181
182        // ai科技入口浮窗
183        const aiFloatKey = 'AIFLOAT_CLOSED'
184        const aiFloatDom = document.querySelector('#aiFloat')
185        const aiFixedBtn = aiFloatDom?.querySelector('.on-close-btn')
186        if (aiFloatDom) {
187            if (!isFloatRecentlyClosed(aiFloatKey)) {
188                $(aiFloatDom).show()
189            }
190            if (aiFixedBtn) {
191                aiFixedBtn.addEventListener('click', function (e) {
192                    e.stopPropagation()
193                    $(this).closest(".xqbj-component-aifloat").hide()
194                    setFloatJustClosed(aiFloatKey)
195                })
196            }
197        }
198
199        // 落地页入口浮窗
200        const launchAppFloatKey = 'LAUNCHAPP_CLOSED'
201        const launchappFloatDom = document.querySelector('.launchapp-btn-container')
202        const launchappFixedBtn = launchappFloatDom?.querySelector('.launchapp-close-btn')
203        if (launchappFloatDom) {
204            if (!isFloatRecentlyClosed(launchAppFloatKey)) {
205                $(launchappFloatDom).show()
206            }
207            if (launchappFixedBtn) {
208                launchappFixedBtn.addEventListener('click', function (e) {
209                    e.stopPropagation()
210                    $(this).closest(".launchapp-btn-container").hide()
211                    setFloatJustClosed(launchAppFloatKey)
212                })
213            }
214        }
215
216
217    })
218})(document, window)
219// 春节活动弹窗 end

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.