PageSourceSearch

https://www.fhyx.com/public/js/application/fhyx_top.js?r=1790303984

js fhyx.com collected 2026-09-25 02:40:11 UTC 24,834 bytes, 628 lines download raw bytes

1//生成二维码
2var host = location.origin;
3var app_qrcode = new QRCode("fhyxHeaderDownApp", {
4    text: host + "/zt/app/m/?appdown=Homepopup",
5    width: 80,
6    height: 80
7});
8
9//根据屏幕分辨率改变文本内容
10var mediaQuery = window.matchMedia("(max-width: 1610px)");
11checkResolution(mediaQuery);
12
13mediaQuery.addListener(function (mq) {
14    checkResolution(mq);
15});
16
17function checkResolution(mq) {
18    if (mq.matches) {
19        $(".fhyxHeaderLeftDownCon span").html("客户端");
20    } else {
21        $(".fhyxHeaderLeftDownCon span").html("下载客户端");
22    }
23}
24
25//用户信息
26$.getJSON("/header/onload_new.html", function (reback) {
27    if (reback.status == 1) {
28        $(".fhyxHeaderRightLogin").html('<div class="fhyxHeaderRightLoginCon">\n' +
29            '                <a class="userImgCon" href="/ucenter/" fhyx_shushuTj td-name="顶部个人中心">\n' +
30            '                    <img class="userimg" src="' + (reback.userinfo.img ? reback.userinfo.img : '//static.fhyx.com/images/application/pc/hk/user_img.png') + '">\n' +
31            '                    ' + (reback.userinfo.imgFrame != '' ? '<em class="userFrame" style="background: url(' + reback.userinfo.imgFrame + ');background-size: 100% 100%;"></em>' : "") + '\n' +
32            '                </a>\n' +
33            '                <div class="fhyxHeaderRightLoginConAlert">\n' +
34            '                    <a class="username">' + reback.userinfo.uname + '</a>\n' +
35            '                    <div class="smrz">\n' +
36            '                        <div class="smrzIcon"></div>\n' +
37            '                        <a class="smrzBtn fhyx_shushuTj" href="/ucenter/verified.html" target="_blank" td-name="顶部实名认证"></a>\n' +
38            '                    </div>\n' +
39            '                    <div class="balanceCon">\n' +
40            '                        <a class="balanceConLi creditsCon fhyx_shushuTj" href="https://www.fhyx.com/credit/detailed.html" target="_blank" td-name="顶部P币明细">\n' +
41            '                            <span class="balance">0</span>\n' +
42            '                            <span class="title">P币</span>\n' +
43            '                        </a>\n' +
44            '                        <a class="balanceConLi allowanceCon fhyx_shushuTj" href="/ucenter/allowance.html" target="_blank" td-name="顶部津贴明细">\n' +
45            '                            <span class="balance">0</span>\n' +
46            '                            <span class="title">津贴</span>\n' +
47            '                        </a>\n' +
48            '                        <a class="balanceConLi couponCon fhyx_shushuTj" href="/ucenter/coupon.html" target="_blank" td-name="顶部优惠券">\n' +
49            '                            <span class="balance">0</span>\n' +
50            '                            <span class="title">优惠券</span>\n' +
51            '                        </a>\n' +
52            '                    </div>\n' +
53            '                    <a class="fhyxHeaderVip qy" href="/vip/">\n' +
54            '                        <em class="bg"></em>\n' +
55            '                        <em class="icon"></em>\n' +
56            '                        <span class="title">青羽会员</span>\n' +
57            '                        <span class="more">查看详情 ></span>\n' +
58            '                        <div class="endtime">累计消费<span>1</span>元即可解锁</div>\n' +
59            '                    </a>\n' +
60            '                    <div class="bindsteam">\n' +
61            '                        <em class="icon"></em>\n' +
62            '                        <span class="title">未绑定</span>\n' +
63            '                        <a class="bindsteamBtn fhyx_shushuTj" td-name="顶部绑定Steam"></a>\n' +
64            '                    </div>\n' +
65            '                    <a class="userInfoLi userinfo fhyx_shushuTj" href="/ucenter/" target="_blank" td-name="顶部个人中心">\n' +
66            '                        <em class="icon"></em>\n' +
67            '                        <span class="title">个人中心</span>\n' +
68            '                        <em class="rightIcon"></em>\n' +
69            '                    </a>\n' +
70            '                    <a class="userInfoLi userproclaim fhyx_shushuTj" href="https://www.fhyx.com/credit/medal.html" target="_blank" td-name="顶部我的勋章墙">\n' +
71            '                        <em class="icon"></em>\n' +
72            '                        <span class="title">我的勋章墙</span>\n' +
73            '                        <em class="rightIcon"></em>\n' +
74            '                    </a>\n' +
75            '                    <div class="fg"></div>\n' +
76            '                    <a class="userInfoLi userlogout fhyx_shushuTj" href="/account/logout.html" td-name="顶部退出登录">\n' +
77            '                        <em class="icon"></em>\n' +
78            '                        <span class="title">退出登录</span>\n' +
79            '                    </a>\n' +
80            '                </div>\n' +
81            '            </div>');
82
83        $(".fhyxHeaderRightCredits").show();
84        fhyx_ta.login(reback.userinfo.uid);
85    } else {
86        $(".fhyxHeaderRightLogin").html('<a href="javascript:void(0);" id="login_btn" class="fhyx_shushuTj">登录</a>');
87    }
88});
89
90var userTopData = [];
91$(".fhyxHeaderRightLogin").hover(
92    function () {
93        if ($(".fhyxHeaderRightLoginCon").length > 0) {
94            if (userTopData == '') {
95                var Authtoken = encodeURIComponent(getCookie('_token'));
96                $.ajax({
97                    type: "POST",
98                    async: false,
99                    url: "https://"+global_domain['webapi_domain']+"/sync/getUserdata",
100                    headers: {
101                        "Authtoken": Authtoken,
102                    },
103                    dataType: "json",
104                    success: function (json) {
105                        if (json.status == 1) {
106                            userTopData = json.data;
107                        }
108                    }
109                });
110            }
111            if (userTopData.isvalid == 1) {
112                $(".fhyxHeaderRightLogin .smrzIcon").addClass("checked");
113                $(".fhyxHeaderRightLogin .smrzBtn").remove();
114            }
115            $(".fhyxHeaderRightLogin .creditsCon .balance").html(userTopData.credit);
116            $(".fhyxHeaderRightLogin .allowanceCon .balance").html(userTopData.allowance / 100);
117            $(".fhyxHeaderRightLogin .couponCon .balance").html(userTopData.coupon);
118            if (userTopData.vipdata.grade > 0) {
119                var vipLevel = "";
120                var vipName = "";
121                if (userTopData.vipdata.grade == 1) {
122                    vipLevel = "qy";
123                    vipName = "青羽会员";
124                }
125                if (userTopData.vipdata.grade == 2) {
126                    vipLevel = "yy";
127                    vipName = "银翼会员";
128                }
129                if (userTopData.vipdata.grade == 3) {
130                    vipLevel = "jy";
131                    vipName = "金翎会员";
132                }
133                if (userTopData.vipdata.grade == 4) {
134                    vipLevel = "fh";
135                    vipName = "凤凰会员";
136                }
137
138                var expiretime = "有效期至" + userTopData.vipdata.expiretime;
139                $(".fhyxHeaderVip").addClass(vipLevel);
140                $(".fhyxHeaderVip .title").html(vipName);
141                $(".fhyxHeaderVip .endtime").html(expiretime);
142            }
143            if (userTopData.steamuser != '') {
144                $(".fhyxHeaderRightLogin .bindsteam .title").addClass("checked");
145                $(".fhyxHeaderRightLogin .bindsteam .title").html(userTopData.steamuser);
146                $(".fhyxHeaderRightLogin .bindsteam .bindsteamBtn").addClass("checked");
147                $(".fhyxHeaderRightLogin .bindsteam .bindsteamBtn").removeAttr("href");
148                $(".fhyxHeaderRightLogin .bindsteam .bindsteamBtn").removeAttr("target");
149            } else {
150                $(".fhyxHeaderRightLogin .bindsteam .title").removeClass("checked");
151                $(".fhyxHeaderRightLogin .bindsteam .bindsteamBtn").attr({"href": "/ucenter/bind.html", "target": "_blank"});
152            }
153        }
154    },
155    function () {
156    }
157);
158
159//登录
160$("body").on("click", "#login_btn", function () {
161    var sc_login_ret = if_login_container(1, 1);
162    if (sc_login_ret == 1) {
163        return;
164    }
165});
166
167//登录
168$("body").on("click", ".isLoginFhyx", function () {
169    var sc_login_ret = if_login_container(1, 1);
170    if (sc_login_ret == 1) {
171        return;
172    }
173
174    if ($(this).attr('data-newopen') == 1) {
175        window.open($(this).attr("data-url"));
176    } else {
177        location.href = $(this).attr("data-url");
178    }
179});
180
181var indexPathname = location.pathname;
182if (indexPathname == '/' || indexPathname == '/index.html') {
183    $(".fhyxindex").addClass("checked");
184}
185//语言
186$(function () {
187    var ft = getCookie("ft");
188    if (!ft) {
189        ft = 0;
190    }
191    StranBody(document.body, ft);
192    $(".fhyxHeaderRightLanguageConLi").removeClass("checked");
193    if (ft == 0) {
194        $(".fhyxHeaderRightLanguageTxt").text("简中");
195        $(".fhyxHeaderRightLanguageConLi").eq(0).addClass("checked");
196        setCookie("ft", 0, 7, '.fhyx.com');
197    } else {
198        $(".fhyxHeaderRightLanguageTxt").text("繁中");
199        $(".fhyxHeaderRightLanguageConLi").eq(1).addClass("checked");
200        setCookie("ft", 1, 7, '.fhyx.com');
201    }
202});
203
204//语言切换
205$(".fhyxHeaderRightLanguageConLi").on("click", function () {
206    $(".fhyxHeaderRightLanguageConLi").removeClass("checked");
207    $(this).addClass("checked");
208    if ($(this).attr("data-id") == 1) {
209        StranBody(document.body, 1);
210        setCookie("ft", 1, 7, '.fhyx.com');
211        $(".fhyxHeaderRightLanguageTxt").text("繁中");
212        event.stopPropagation();
213    } else {
214        StranBody(document.body, 0);
215        setCookie("ft", 0, 7, '.fhyx.com');
216        $(".fhyxHeaderRightLanguageTxt").text("简中");
217        event.stopPropagation();
218    }
219});
220
221
222//搜索
223(function () {
224    var searchInput = document.getElementById('searchInput');
225    var searchDropdown = document.getElementById('searchDropdown');
226    var searchTimeout;
227    var searchCache = {}; // 搜索结果缓存
228    var searchIndex = {}; // 搜索索引
229
230    // 兼容性处理
231    var isIE8 = !document.addEventListener;
232
233    // 数据源
234    var products = search_data;
235
236    // 初始化搜索索引
237    function initSearchIndex() {
238        for (var i = 0; i < products.length; i++) {
239            var item = products[i];
240            // 分词处理
241            var text = (item.name).toLowerCase();
242            var words = text.replace(/[^\w\s\u4e00-\u9fa5]/g, '').split(/\s+/);
243
244            // 中文分词
245            var cnWords = [];
246            for (var j = 0; j < text.length; j++) {
247                var char = text.charAt(j);
248                if (/[\u4e00-\u9fa5]/.test(char)) {
249                    cnWords.push(char);
250                }
251            }
252
253            // 合并分词结果
254            words = words.concat(cnWords);
255
256            // 建立索引
257            for (var k = 0; k < words.length; k++) {
258                var word = words[k];
259                if (!searchIndex[word]) {
260                    searchIndex[word] = {};
261                }
262                searchIndex[word][item.id] = true;
263            }
264        }
265    }
266
267    // 初始化索引
268    initSearchIndex();
269
270    // 绑定输入事件
271    function bindEvents() {
272        if (isIE8) {
273            searchInput.attachEvent('onpropertychange', handleInput);
274            document.attachEvent('onclick', handleDocumentClick);
275            searchDropdown.attachEvent('onclick', handleItemClick);
276        } else {
277            searchInput.addEventListener('input', handleInput);
278            document.addEventListener('click', handleDocumentClick);
279            searchDropdown.addEventListener('click', handleItemClick);
280        }
281    }
282
283    function handleInput() {
284        var keyword = searchInput.value.replace(/^\s+|\s+$/g, ''); // trim polyfill
285
286        if (searchTimeout) {
287            clearTimeout(searchTimeout);
288        }
289
290        if (keyword) {
291            // 检查缓存
292            if (searchCache[keyword]) {
293                showResults(searchCache[keyword]);
294                return;
295            }
296
297            searchTimeout = setTimeout(function () {
298                var results = searchProducts(keyword);
299                // 缓存结果
300                searchCache[keyword] = results;
301                showResults(results);
302            }, 300);
303        } else {
304            hideDropdown();
305        }
306    }
307
308    function handleDocumentClick(e) {
309        e = e || window.event;
310        var target = e.target || e.srcElement;
311
312        if (!contains(searchInput, target) && !contains(searchDropdown, target)) {
313            hideDropdown();
314        }
315    }
316
317    // DOM contains polyfill
318    function contains(parent, child) {
319        if (parent.contains) {
320            return parent.contains(child);
321        }
322
323        while (child && child !== parent) {
324            child = child.parentNode;
325        }
326        return child === parent;
327    }
328
329    // 优化的搜索函数
330    function searchProducts(keyword) {
331
332        return containsSearch(keyword);
333        
334        keyword = keyword.toLowerCase();
335
336        // 分词
337        var text = keyword.replace(/[^\w\s\u4e00-\u9fa5]/g, '');
338        var words = text.split(/\s+/);
339        var cnWords = [];
340
341        // 中文分词
342        for (var i = 0; i < text.length; i++) {
343            var char = text.charAt(i);
344            if (/[\u4e00-\u9fa5]/.test(char)) {
345                cnWords.push(char);
346            }
347        }
348
349        words = words.concat(cnWords);
350
351        // 短关键词使用包含搜索
352        if (words.length === 1 && words[0].length < 2) {
353            return containsSearch(keyword);
354        }
355
356        // 使用索引搜索
357        var matchedIds = {};
358        var isFirst = true;
359
360        for (var j = 0; j < words.length; j++) {
361            var word = words[j];
362            var ids = {};
363
364            // 查找索引
365            for (var key in searchIndex) {
366                if (key.indexOf(word) !== -1) {
367                    for (var id in searchIndex[key]) {
368                        ids[id] = true;
369                    }
370                }
371            }
372
373            // 取交集
374            if (isFirst) {
375                matchedIds = ids;
376                isFirst = false;
377            } else {
378                var newIds = {};
379                for (var id in matchedIds) {
380                    if (ids[id]) {
381                        newIds[id] = true;
382                    }
383                }
384                matchedIds = newIds;
385            }
386        }
387
388        // 转换回商品数据
389        var results = [];
390        for (var id in matchedIds) {
391            for (var k = 0; k < products.length; k++) {
392                if (products[k].id.toString() === id) {
393                    results.push(products[k]);
394                    break;
395                }
396            }
397        }
398
399        return results.slice(0, 10);
400    }
401
402    // 包含搜索
403    function containsSearch(keyword) {
404        var priceMap = {};
405
406        var results = [];
407        for (var i = 0; i < products.length; i++) {
408            var item = products[i];
409            var title = item.name.toLowerCase();
410            keyword=keyword.toLowerCase();
411            if (title.indexOf(keyword) !== -1) {
412                const { products_id, price } = item;
413                if (!priceMap[products_id] || priceMap[products_id].price != price) {
414                    priceMap[products_id] = {
415                        price: price,
416                    };
417                    results.push(item);
418                }
419            }
420        }
421        return results.slice(0, 10);
422    }
423
424    // 显示搜索结果
425    function showResults(results) {
426        if (!results || !results.length) {
427            searchDropdown.innerHTML = '<div class="search-item">没有找到相关商品</div>';
428            return;
429        }
430
431        // 分离商品和系列,优化去重逻辑
432        var productResults = [];
433        var seriesResults = [];
434        var seriesMap = {}; // 用于去重系列
435
436        for (var i = 0; i < results.length; i++) {
437            var item = results[i];
438            // 商品部分
439            productResults.push(item);
440
441            // 系列部分(去重并保存第一个匹配的商品信息)
442            var seriesKey = item.series.toLowerCase(); // 转小写以确保大小写不敏感
443            if (seriesKey.length > 0) {
444                if (!seriesMap[seriesKey]) {
445                    seriesMap[seriesKey] = {
446                        series: item.series,
447                        id: item.id,
448                        productCount: item.seriesnum,    // 记录该系列下的产品数量
449                        firstProduct: item  // 保存该系列的第一个商品信息
450                    };
451                }
452            }
453
454        }
455
456        // 转换系列Map为数组
457        for (var key in seriesMap) {
458            seriesResults.push(seriesMap[key]);
459        }
460
461        var html = '';
462
463        // 商品部分
464        if (productResults.length) {
465            html += '<div class="search-section">';
466            for (var j = 0; j < productResults.length; j++) {
467                if (j < 5) {
468                    var product = productResults[j];
469                    //var title = highlightText(product.name, searchInput.value);
470                    var status = '';
471                    if (product.label == '最新') status = '<span class="new">最新</span>';
472                    if (product.label == '预售') status = '<span class="ys">预售</span>';
473                    if (product.label == '史低') status = '<span class="lowest">史低</span>';
474                    if (product.label == '新史低') status = '<span class="newlowest">新史低</span>';
475                    if (product.label == '超史低') status = '<span class="overlowest">超史低</span>';
476
477                    var price = product.price.split(".");
478
479                    html += [
480                        '<div class="search-item fhyx_searchitemTj" td-name="搜索产品" data-id="' + product.products_id + '" data-type="product">',
481                        '<div class="search-item-img">',
482                        status,
483                        '<img src="https://img.fhyx.com' + product.w_img + '" alt="' + product.name + '">',
484                        '</div>',
485                        '<div class="search-item-info">',
486                        '<div class="search-item-title">' + product.name + '</div>',
487                        '<div class="search-item-price">',
488                        '<span class="current-price">' + (product.price == 0 ? '未公布' : '¥<em>' + price[0] + '</em>.' + price[1]) + (product.commoditynum > 1 ? ' 起' : '') + '</span>',
489                        '<span class="original-price">' + ((product.price != product.old_price && product.old_price > 0 && product.price>0) ? 'Â¥' + product.old_price : '') + '</span>',
490                        '</div>',
491                        '<span class="search-item-plat hk_' + product.plat + '_l"></span>',
492                        '</div>',
493                        '</div>'
494                    ].join('');
495                }
496            }
497            html += '</div>';
498            if (productResults.length > 5) {
499                html += '<a class="search-more fhyx_searchitemTj" href="/list/search?keyword=' + searchInput.value + '">查看全部搜索结果></a>';
500            }
501        }
502
503        // 系列部分
504        if (seriesResults.length) {
505            html += '<div class="search-section">';
506            for (var k = 0; k < seriesResults.length; k++) {
507                if (k < 3) {
508                    var series = seriesResults[k];
509                    //var seriesName = highlightText(series.series, searchInput.value);
510
511                    html += [
512                        '<div class="search-item series fhyx_searchitemTj" td-name="搜索系列" data-id="' + series.id + '" data-type="series" data-series="' + series.series + '">',
513                        '<div class="search-item-series-info">',
514                        '<div class="search-item-series">「' + series.series + '系列」</div>',
515                        '<div class="search-item-count">
515' + series.productCount + '款游戏</div>',
516                        '</div>',
517                        '</div>'
518                    ].join('');
519                }
520            }
521            html += '</div>';
522        }
523
524        searchDropdown.innerHTML = html;
525
526        fhyx_ta.trackLink({class: ["fhyx_searchitemTj"]}, "click");//商品跳转
527        showDropdown();
528    }
529
530    // 高亮匹配文字
531    function highlightText(text, keyword) {
532        if (!keyword) return text;
533        keyword = keyword.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'); // 转义正则特殊字符
534        var pattern = new RegExp('(' + keyword + ')', 'gi');
535        return text.replace(pattern, '<span class="highlight">$1</span>');
536    }
537
538    function showDropdown() {
539        addClass(searchDropdown, 'active');
540    }
541
542    function hideDropdown() {
543        removeClass(searchDropdown, 'active');
544    }
545
546    // IE8 class操作兼容
547    function addClass(el, className) {
548        if (el.classList) {
549            el.classList.add(className);
550        } else {
551            var classes = el.className.split(' ');
552            if (classes.indexOf(className) === -1) {
553                classes.push(className);
554                el.className = classes.join(' ');
555            }
556        }
557    }
558
559    function removeClass(el, className) {
560        if (el.classList) {
561            el.classList.remove(className);
562        } else {
563            var classes = el.className.split(' ');
564            var index = classes.indexOf(className);
565            if (index !== -1) {
566                classes.splice(index, 1);
567                el.className = classes.join(' ');
568            }
569        }
570    }
571
572    // 添加商品项点击处理函数
573    function handleItemClick(e) {
574        e = e || window.event;
575        var target = e.target || e.srcElement;
576
577        // 查找最近的商品项元素
578        var item = target;
579        while (item && !item.getAttribute('data-id') && item !== searchDropdown) {
580            item = item.parentNode;
581        }
582
583        if (item && item.getAttribute('data-id')) {
584            var id = item.getAttribute('data-id');
585            var type = item.getAttribute('data-type'); // 获取类型
586            //console.log('选中项:', type, id);
587
588            // 根据类型处理不同的跳转逻辑
589            if (type === 'product') {
590                // 处理商品点击
591                //console.log('跳转到产品详情页');
592                window.open("/item/" + item.getAttribute('data-id') + ".html");
593            } else if (type === 'series') {
594                // 处理系列点击
595                //console.log('跳转到系列页面');
596                window.open("/list/series?keyword=" + item.getAttribute('data-series') + "&type=series");
597            }
598
599            hideDropdown();
600            searchInput.value = '';
601        }
602    }
603
604    // 初始化
605    bindEvents();
606})();
607
608$("#searchInput").bind('keydown', function (e) {
609    var key = e.which;
610    if (key == 13) {
611        e.preventDefault();
612        var value = $(this).val();
613        if (value == "") {
614            value = $(this).attr("data-value");
615        }
616        window.location.href = "/list/search?keyword="+encodeURIComponent(value);
617    }
618});
619
620$("#search_sub").on('click', function (e) {
621    var value = $("#searchInput").val();
622    if (value == "") {
623        value = $("#searchInput").attr("data-value");
624    }
625    window.location.href = "/list/search?keyword="+encodeURIComponent(value);
626});
627
628fhyx_ta.quick('autoTrack', {name: 'fhyx_show_view',})

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.