PageSourceSearch

https://www.xwx.cn/home/js/public.js?time=1790310512

js xwx.cn collected 2026-09-25 04:28:40 UTC 11,758 bytes, 301 lines download raw bytes

1$(document).ready(function(){
2    // 页面滚动事件
3    $(window).scroll(function () {
4        var m_st = document.body.scrollTop || document.documentElement.scrollTop;
5        if(m_st > 70){
6            $('.topbtn').stop().fadeIn();
7        }else{
8            $('.topbtn').stop().fadeOut();
9        }
10    })
11    $(".topbtn").click(function() {
12        $("html,body").animate({"scrollTop":0}, 1000);
13    });
14
15    // 搜索
16    $("#input_btn").bind("click",function(){
17        var searchText = $(".input_txt").val();
18        if(searchText == ''){
19            $("#err").stop().fadeIn();
20            return false;
21        }
22        $("#err").stop().fadeOut();
23    })
24    $(".input_txt").bind("keyup",function(){
25        var searchText = $(this).val();
26        if(searchText == ''){
27            $("#err").stop().fadeIn();
28        }else{
29            $("#err").stop().fadeOut();
30        }
31
32        searchText = $(this).val();
33    
34    })
35
36    // 左边列表栏公共事件
37    var $menus =$("#menus li");
38    var $copyDelete = $("#copyDelete li span");
39    var $Delete = $("#copyDelete li i");
40    
41    $menus.each(function(i) {
42        $(this).click(function(){
43            $(this).addClass('cur').siblings().removeClass('cur');
44
45            //专辑左边和上边的文字切换
46            $copyDelete.text($menus.eq(i).text());
47            
48            $Delete.click(function(event) {
49                $copyDelete.text("全部");
50                $menus.eq(i).removeClass('cur');
51            });
52        })
53    });
54
55    //演艺经纪的悬浮微信二维码
56    var $iconCode = $(".small_icon");
57    $iconCode.each(function(i) {
58        $(this).mouseenter(function(){
59            $(this).children('.small_wechat_code').stop().fadeIn();
60        });
61        $(this).mouseleave(function(){
62            $(this).children('.small_wechat_code').stop().fadeOut();
63        });
64    });
65
66    // foot固定的二维码
67    var $qrCode = $("#qrCode li a");
68    $qrCode.mouseenter(function(event) {
69        $(this).siblings().stop().fadeIn();
70    });
71    $qrCode.mouseleave(function(event) {
72        $(this).siblings().stop().fadeOut();
73    });
74});
75// 通用幻灯片
76$(function(){
77    var paginationTop = null;
78    var paginationType = 'bullets';
79    var resizeTask = false;
80    var __DEFAULT_OPTIONS__ = {
81        zoom: true,
82        autoplay: true,
83        autoHeight: true,
84        mousewheel: false,
85        on: {
86            init: function (e) {
87                console.log('init', e);
88                if (this.slides.length <= 1) {
89                    $(this.wrapperEl).siblings('.swiper-button-prev, .swiper-button-next, .swiper-pagination').hide()
90                }
91            },
92            resize: function (e) {
93                console.log('resize', e);
94                if (paginationTop && $(window).width() <= 800) {
95                    var ptop = paginationTop || 0;
96                    if (typeof paginationTop !== 'number') {
97                        ptop = $(this.wrapperEl).find('.swiper-slide-active ' + paginationTop).height();
98                    }
99                    console.log('resize', ptop);
100                    $(this.wrapperEl).find('.swiper-pagination').css({top: ptop + 'px', bottom: 'auto'});
101                    $(this.wrapperEl).parent().siblings('.swiper-pagination').css({top: ptop + 'px', bottom: 'auto'});
102                }
103                if (!e && this.update) {
104                    this.emit('update', 'resize');
105                }
106            },
107            update (e) {
108                console.log('update', e)
109                if (this.slides.length <= this.params.slidesPerView) {
110                    $(this.wrapperEl).addClass('is-flexbox');
111                    $(this.wrapperEl).siblings('.swiper-indicator, .swiper-pagination, .swiper-button-prev, .swiper-button-next').hide();
112                    $(this.wrapperEl).parent().siblings('.swiper-indicator, .swiper-pagination, .swiper-button-prev, .swiper-button-next').hide();
113                } else {
114                    $(this.wrapperEl).removeClass('is-flexbox');
115                    $(this.wrapperEl).siblings('.swiper-indicator, .swiper-pagination, .swiper-button-prev, .swiper-button-next').show();
116                    $(this.wrapperEl).parent().siblings('.swiper-indicator, .swiper-pagination, .swiper-button-prev, .swiper-button-next').show();
117                }
118            }
119        }
120    }
121    var $swiperDoms = $('.common-swiper');
122    if ($swiperDoms.length) {
123        $swiperDoms.each((item, dom) => {
124            var options = $(dom).data('options') ? eval('(' + $(dom).data('options') + ')') : {};
125            paginationType = $(dom).data('pagination-type') || 'bullets';
126            paginationTop = $(dom).data('pagination-top') || 0;
127            new Swiper($(dom), $.extend(__DEFAULT_OPTIONS__, {
128                pagination: {
129                    el: $(dom).find('.swiper-pagination'),
130                    type: paginationType,
131                    // dynamicBullets: true,
132                    clickable: true,
133                },
134                navigation: {
135                    prevEl: $(dom).find('.swiper-button-prev'),
136                    nextEl: $(dom).find('.swiper-button-next'),
137                }
138            }, options));
139        });
140    }
141});
142
143 // Cookie 工具类
144    const CookieUtil = {
145        set(name, value, days = 1) {
146            let expires = "";
147            if (days) {
148                let date = new Date();
149                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
150                expires = "; expires=" + date.toUTCString();
151            }
152            document.cookie = name + "=" + (value || "") + expires + "; path=/";
153        },
154        get(name) {
155            let nameEQ = name + "=";
156            let ca = document.cookie.split(';');
157            for (let i = 0; i < ca.length; i++) {
158                let c = ca[i];
159                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
160                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
161            }
162            return null;
163        },
164        erase(name) {
165            document.cookie = name + '=; Max-Age=-99999999; path=/';
166        }
167    };
168    const tokenKey = 'token';
169    const userNameKey = 'userName';
170    /**
171     * 2. 初始化与 UI 渲染
172     */
173   
174    window.addEventListener('load', function() {
175        const token = CookieUtil.get(tokenKey);
176            const savedUsername = localStorage.getItem(userNameKey);
177            if (token && savedUsername) {
178                renderLoginState(true, savedUsername);
179            } else {
180                renderLoginState(false);
181            }
182    });
183    function renderLoginState(isLogin, username = "") {
184        const unloginBtn = document.getElementById('unloginBtn');
185        const userInfo = document.getElementById('userInfo');
186        const nameSpan = document.getElementById('displayUserName');
187
188        if (isLogin) {
189            if (unloginBtn) unloginBtn.style.display = 'none';
190            if (userInfo) userInfo.style.display = 'flex';
191            if (nameSpan) nameSpan.innerText = username;
192        } else {
193            if (unloginBtn) unloginBtn.style.display = 'block';
194            if (userInfo) userInfo.style.display = 'none';
195            if (nameSpan) nameSpan.innerText = '';
196        }
197    }
198
199    /**
200     * 3. 弹窗控制逻辑
201     */
202    function showLogin() {
203        const mask = document.getElementById('loginMask');
204        if (mask) {
205            mask.style.display = 'block';
206            toggleMode('login'); 
207            document.body.style.overflow = 'hidden'; 
208        }
209    }
210
211    function closeLogin() {
212        const mask = document.getElementById('loginMask');
213        if (mask) {
214            mask.style.display = 'none';
215            document.getElementById('username').value = '';
216            document.getElementById('password').value = '';
217            document.getElementById('confirmPassword').value = '';
218        }
219        document.body.style.overflow = 'auto';
220    }
221
222    window.onclick = function(event) {
223        const mask = document.getElementById('loginMask');
224        if (event.target == mask) closeLogin();
225    };
226
227    function toggleMode(mode) {
228        currentMode = mode;
229        const title = document.getElementById('modalTitle');
230        const btn = document.getElementById('submitBtn');
231        const switchBox = document.getElementById('switchBox');
232        const confirmInput = document.getElementById('confirmPassword');
233
234        if (mode === 'reg') {
235            title.innerText = '用户注册';
236            btn.innerText = '注册';
237            confirmInput.style.display = 'block';
238            switchBox.innerHTML = '已有账号?<a href="javascript:void(0);" onclick="toggleMode(\'login\')" style="display:inline;color:#ff3b3c;">去登录</a>';
239        } else {
240            title.innerText = '用户登录';
241            btn.innerText = '登录';
242            confirmInput.style.display = 'none';
243            switchBox.innerHTML = '没有账号?<a href="javascript:void(0);" onclick="toggleMode(\'reg\')" style="display:inline;color:#ff3b3c;">去注册</a>';
244        }
245    }
246
247    /**
248     * 4. 核心:提交逻辑(使用 Mock 接口)
249     */
250    async function handleSubmit() {
251        const userVal = document.getElementById('username').value.trim();
252        const passVal = document.getElementById('password').value.trim();
253        const confirmPassVal = document.getElementById('confirmPassword').value.trim();
254        const submitBtn = document.getElementById('submitBtn');
255
256        // 正则校验
257        const userReg = /^[\u4e00-\u9fa5a-zA-Z0-9]{1,20}$/;
258        const passReg = /^[a-zA-Z0-9]{6,12}$/;
259
260        if (!userReg.test(userVal)) return alert("用户名格式错误");
261        if (!passReg.test(passVal)) return alert("密码格式错误");
262        if (currentMode === 'reg' && passVal !== confirmPassVal) return alert("两次输入的密码不一致");
263
264        submitBtn.disabled = true;
265        submitBtn.innerText = currentMode === 'login' ? "登录中..." : "注册中...";
266
267        try {
268            // 调用 Mock 接口
269            const endpoint = currentMode === 'login' ? '/api/user/login' : '/api/user/register';
270            $.post(endpoint, {
271                userName: userVal,
272                password: passVal,
273                confirmPassword:confirmPassVal
274            }, function(response) {
275               if(response.status ===1) {                    
276                    // 请求成功回调
277                    CookieUtil.set(tokenKey, response.result.token, 7); 
278                    localStorage.setItem(userNameKey, response.result.userName); 
279                    renderLoginState(true, response.result.userName);
280                    closeLogin();
281                    alert(currentMode === 'login' ? '登录成功' : '注册成功');
282                    return;
283                }
284                alert(response.message || "操作失败");
285            }, 'json');
286            
287        } catch (error) {
288            alert("操作失败:" + error.message);
289        } finally {
290            submitBtn.disabled = false;
291            submitBtn.innerText = currentMode === 'login' ? "登录" : "注册";
292        }
293    }
294
295    function handleLogout() {
296        if (confirm("确定要退出当前账号吗?")) {
297            CookieUtil.erase(tokenKey);
298            localStorage.removeItem(userNameKey);
299            renderLoginState(false);
300        }
301    }

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.