PageSourceSearch

https://www.fhyx.hk/public/js/application/fhyx_top.js?r=1790304744

js fhyx.hk collected 2026-09-25 02:52:39 UTC 26,196 bytes, 662 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 fhyx_shushuTj" href="/ucenter/" 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="https://www.fhyx.com/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="' + (ishk == 1 ? '' : '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                setCookie("isbindsteam", 1, 7, '.fhyx.hk');
150            } else {
151                $(".fhyxHeaderRightLogin .bindsteam .title").removeClass("checked");
152                $(".fhyxHeaderRightLogin .bindsteam .bindsteamBtn").attr({"href": "/ucenter/bind.html", "target": "_blank"});
153                setCookie("isbindsteam", 0, 7, '.fhyx.hk');
154            }
155        }
156    },
157    function () {
158    }
159);
160
161//登录
162$("body").on("click", "#login_btn", function () {
163    var sc_login_ret = if_login_container(1, 1);
164    if (sc_login_ret == 1) {
165        return;
166    }
167});
168
169//登录
170$("body").on("click", ".isLoginFhyx", function () {
171    var sc_login_ret = if_login_container(1, 1);
172    if (sc_login_ret == 1) {
173        return;
174    }
175
176    if ($(this).attr('data-newopen') == 1) {
177        window.open($(this).attr("data-url"));
178    } else {
179        location.href = $(this).attr("data-url");
180    }
181});
182
183var indexPathname = location.pathname;
184if (indexPathname == '/' || indexPathname == '/index.html') {
185    $(".fhyxindex").addClass("checked");
186}
187//语言
188$(function () {
189    if (ishk == 0) {
190        var ft = getCookie("ft");
191        if (!ft) {
192            ft = 0;
193        }
194    } else {
195        ft = 1;
196    }
197
198    StranBody(document.body, ft);
199    $(".fhyxHeaderRightLanguageConLi").removeClass("checked");
200    if (ft == 0) {
201        $(".fhyxHeaderRightLanguageTxt").text("简中");
202        $(".fhyxHeaderRightLanguageConLi").eq(0).addClass("checked");
203        setCookie("ft", 0, 7, '.fhyx.hk');
204    } else {
205        $(".fhyxHeaderRightLanguageTxt").text("繁中");
206        $(".fhyxHeaderRightLanguageConLi").eq(1).addClass("checked");
207        setCookie("ft", 1, 7, '.fhyx.hk');
208    }
209});
210
211//语言切换
212$(".fhyxHeaderRightLanguageConLi").on("click", function () {
213    $(".fhyxHeaderRightLanguageConLi").removeClass("checked");
214    $(this).addClass("checked");
215    if ($(this).attr("data-id") == 1) {
216        StranBody(document.body, 1);
217        setCookie("ft", 1, 7, '.fhyx.hk');
218        $(".fhyxHeaderRightLanguageTxt").text("繁中");
219        event.stopPropagation();
220    } else {
221        StranBody(document.body, 0);
222        setCookie("ft", 0, 7, '.fhyx.hk');
223        $(".fhyxHeaderRightLanguageTxt").text("简中");
224        event.stopPropagation();
225    }
226});
227
228var isbindsteam = getCookie('isbindsteam');
229if (ishk == 1 && isbindsteam == 0) {
230    $(".fhyxHeaderRightBindsteam").show();
231}
232
233$("body").on("click", ".fhyxHeaderRightBindsteam", function () {
234    var sc_login_ret = if_login_container(1,1);
235    if (sc_login_ret == 1) {
236        return;
237    }
238
239    var url = location.href;
240    get_global_loginsteam(url);
241});
242
243var commodityHkpriceData = '';
244if(ishk == 1) {
245    $.ajax({
246        type: "GET",
247        url: "/public/data/commodityHkpriceData.json",
248        dataType: "json",
249        async: false,
250        success: function (json) {
251            commodityHkpriceData = json;
252        }
253    });
254}
255
256//搜索
257(function () {
258    var searchInput = document.getElementById('searchInput');
259    var searchDropdown = document.getElementById('searchDropdown');
260    var searchTimeout;
261    var searchCache = {}; // 搜索结果缓存
262    var searchIndex = {}; // 搜索索引
263
264    // 兼容性处理
265    var isIE8 = !document.addEventListener;
266
267    // 数据源
268    var products = search_data;
269
270    // 初始化搜索索引
271    function initSearchIndex() {
272        for (var i = 0; i < products.length; i++) {
273            var item = products[i];
274            // 分词处理
275            var text = (item.name).toLowerCase();
276            var words = text.replace(/[^\w\s\u4e00-\u9fa5]/g, '').split(/\s+/);
277
278            // 中文分词
279            var cnWords = [];
280            for (var j = 0; j < text.length; j++) {
281                var char = text.charAt(j);
282                if (/[\u4e00-\u9fa5]/.test(char)) {
283                    cnWords.push(char);
284                }
285            }
286
287            // 合并分词结果
288            words = words.concat(cnWords);
289
290            // 建立索引
291            for (var k = 0; k < words.length; k++) {
292                var word = words[k];
293                if (!searchIndex[word]) {
294                    searchIndex[word] = {};
295                }
296                searchIndex[word][item.id] = true;
297            }
298        }
299    }
300
301    // 初始化索引
302    initSearchIndex();
303
304    // 绑定输入事件
305    function bindEvents() {
306        if (isIE8) {
307            searchInput.attachEvent('onpropertychange', handleInput);
308            document.attachEvent('onclick', handleDocumentClick);
309            searchDropdown.attachEvent('onclick', handleItemClick);
310        } else {
311            searchInput.addEventListener('input', handleInput);
312            document.addEventListener('click', handleDocumentClick);
313            searchDropdown.addEventListener('click', handleItemClick);
314        }
315    }
316
317    function handleInput() {
318        var keyword = searchInput.value.replace(/^\s+|\s+$/g, ''); // trim polyfill
319
320        if (searchTimeout) {
321            clearTimeout(searchTimeout);
322        }
323
324        if (keyword) {
325            // 检查缓存
326            if (searchCache[keyword]) {
327                showResults(searchCache[keyword]);
328                return;
329            }
330
331            searchTimeout = setTimeout(function () {
332                var results = searchProducts(keyword);
333                // 缓存结果
334                searchCache[keyword] = results;
335                showResults(results);
336            }, 300);
337        } else {
338            hideDropdown();
339        }
340    }
341
342    function handleDocumentClick(e) {
343        e = e || window.event;
344        var target = e.target || e.srcElement;
345
346        if (!contains(searchInput, target) && !contains(searchDropdown, target)) {
347            hideDropdown();
348        }
349    }
350
351    // DOM contains polyfill
352    function contains(parent, child) {
353        if (parent.contains) {
354            return parent.contains(child);
355        }
356
357        while (child && child !== parent) {
358            child = child.parentNode;
359        }
360        return child === parent;
361    }
362
363    // 优化的搜索函数
364    function searchProducts(keyword) {
365
366        return containsSearch(keyword);
367
368        keyword = keyword.toLowerCase();
369
370        // 分词
371        var text = keyword.replace(/[^\w\s\u4e00-\u9fa5]/g, '');
372        var words = text.split(/\s+/);
373        var cnWords = [];
374
375        // 中文分词
376        for (var i = 0; i < text.length; i++) {
377            var char = text.charAt(i);
378            if (/[\u4e00-\u9fa5]/.test(char)) {
379                cnWords.push(char);
380            }
381        }
382
383        words = words.concat(cnWords);
384
385        // 短关键词使用包含搜索
386        if (words.length === 1 && words[0].length < 2) {
387            return containsSearch(keyword);
388        }
389
390        // 使用索引搜索
391        var matchedIds = {};
392        var isFirst = true;
393
394        for (var j = 0; j < words.length; j++) {
395            var word = words[j];
396            var ids = {};
397
398            // 查找索引
399            for (var key in searchIndex) {
400                if (key.indexOf(word) !== -1) {
401                    for (var id in searchIndex[key]) {
402                        ids[id] = true;
403                    }
404                }
405            }
406
407            // 取交集
408            if (isFirst) {
409                matchedIds = ids;
410                isFirst = false;
411            } else {
412                var newIds = {};
413                for (var id in matchedIds) {
414                    if (ids[id]) {
415                        newIds[id] = true;
416                    }
417                }
418                matchedIds = newIds;
419            }
420        }
421
422        // 转换回商品数据
423        var results = [];
424        for (var id in matchedIds) {
425            for (var k = 0; k < products.length; k++) {
426                if (products[k].id.toString() === id) {
427                    results.push(products[k]);
428                    break;
429                }
430            }
431        }
432
433        return results.slice(0, 10);
434    }
435
436    // 包含搜索
437    function containsSearch(keyword) {
438        var priceMap = {};
439
440        var results = [];
441        for (var i = 0; i < products.length; i++) {
442            var item = products[i];
443            var title = item.name.toLowerCase();
444            keyword=keyword.toLowerCase();
445            if (title.indexOf(keyword) !== -1) {
446                const { products_id, price } = item;
447                if (!priceMap[products_id] || priceMap[products_id].price != price) {
448                    priceMap[products_id] = {
449                        price: price,
450                    };
451                    results.push(item);
452                }
453            }
454        }
455        return results.slice(0, 10);
456    }
457
458    // 显示搜索结果
459    function showResults(results) {
460        if (!results || !results.length) {
461            searchDropdown.innerHTML = '<div class="search-item">没有找到相关商品</div>';
462            return;
463        }
464
465        // 分离商品和系列,优化去重逻辑
466        var productResults = [];
467        var seriesResults = [];
468        var seriesMap = {}; // 用于去重系列
469
470        for (var i = 0; i < results.length; i++) {
471            var item = results[i];
472            // 商品部分
473            productResults.push(item);
474
475            // 系列部分(去重并保存第一个匹配的商品信息)
476            var seriesKey = item.series.toLowerCase(); // 转小写以确保大小写不敏感
477            if (seriesKey.length > 0) {
478                if (!seriesMap[seriesKey]) {
479                    seriesMap[seriesKey] = {
480                        series: item.series,
481                        id: item.id,
482                        productCount: item.seriesnum,    // 记录该系列下的产品数量
483                        firstProduct: item  // 保存该系列的第一个商品信息
484                    };
485                }
486            }
487
488        }
489
490        // 转换系列Map为数组
491        for (var key in seriesMap) {
492            seriesResults.push(seriesMap[key]);
493        }
494
495        var html = '';
496
497        // 商品部分
498        if (productResults.length) {
499            html += '<div class="search-section">';
500            for (var j = 0; j < productResults.length; j++) {
501                if (j < 5) {
502                    var product = productResults[j];
503                    //var title = highlightText(product.name, searchInput.value);
504                    var status = '';
505                    if (product.label == '最新') status = '<span class="new">最新</span>';
506                    if (product.label == '预售') status = '<span class="ys">预售</span>';
507                    if (product.label == '史低') status = '<span class="lowest">史低</span>';
508                    if (product.label == '新史低') status = '<span class="newlowest">新史低</span>';
509                    if (product.label == '超史低') status = '<span class="overlowest">超史低</span>';
510
511                    var price = product.price.split(".");
512
513                    html += [
514                        '<div class="search-item fhyx_searchitemTj" td-name="搜索产品" data-id="' + product.products_id + '" data-type="product">',
515                        '<div class="search-item-img">',
516                        status,
517                        '<img src="https://img.fhyx.com' + product.w_img + '" alt="' + product.name + '">',
518                        '</div>',
519                        '<div class="search-item-info">',
520                        '<div class="search-item-title">' + product.name + '</div>',
521                        '<div class="search-item-price">',
522                        '<span class="current-price">' + (ishk == 1 && commodityHkpriceData[product.id] != undefined ? (commodityHkpriceData[product.id].hkPrice == 0 ? '未公布' : 'HK$<em>' + commodityHkpriceData[product.id].hkPrice + '</em>') : (product.price == 0 ? '未公布' : '¥<em>' + price[0] + '</em>.' + price[1])) + (product.commoditynum > 1 ? ' 起' : '') +'</span>',
523                        '<span class="original-price">' + (ishk == 1 && commodityHkpriceData[product.id] != undefined ? (commodityHkpriceData[product.id].hkprice != commodityHkpriceData[product.id].hkoldprice && commodityHkpriceData[product.id].hkoldprice > 0 ? 'HK$' + commodityHkpriceData[product.id].hkoldprice : '') : ((product.price != product.old_price && product.old_price > 0 && product.price>0) ? 'Â¥' + product.old_price : '')) + '</span>',
524                        '</div>',
525                        '<span class="search-item-plat hk_' + product.plat + '_l"></span>',
526                        '</div>',
527                        '</div>'
528                    ].join('');
529                }
530            }
531            html += '</div>';
532            if (productResults.length > 5) {
533                html += '<a class="search-more fhyx_searchitemTj" href="/list/search?keyword=' + searchInput.value + '">查看全部搜索结果></a>';
534            }
535        }
536
537        // 系列部分
538        if (seriesResults.length) {
539            html += '<div class="search-section">';
540            for (var k = 0; k < seriesResults.length; k++) {
541                if (k < 3) {
542                    var series = seriesResults[k];
543                    //var seriesName = highlightText(series.series, searchInput.value);
544
545                    html += [
546                        '<div class="search-item series fhyx_searchitemTj" td-name="搜索系列" data-id="' + series.id + '" data-type="series" data-series="' + series.series + '">',
547                        '<div class="search-item-series-info">',
548                        '<div class="search-item-series">「' + series.series + '系列」</div>',
549                        '<div class="search-item-count">
549' + series.productCount + '款游戏</div>',
550                        '</div>',
551                        '</div>'
552                    ].join('');
553                }
554            }
555            html += '</div>';
556        }
557
558        searchDropdown.innerHTML = html;
559
560        fhyx_ta.trackLink({class: ["fhyx_searchitemTj"]}, "click");//商品跳转
561        showDropdown();
562    }
563
564    // 高亮匹配文字
565    function highlightText(text, keyword) {
566        if (!keyword) return text;
567        keyword = keyword.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'); // 转义正则特殊字符
568        var pattern = new RegExp('(' + keyword + ')', 'gi');
569        return text.replace(pattern, '<span class="highlight">$1</span>');
570    }
571
572    function showDropdown() {
573        addClass(searchDropdown, 'active');
574    }
575
576    function hideDropdown() {
577        removeClass(searchDropdown, 'active');
578    }
579
580    // IE8 class操作兼容
581    function addClass(el, className) {
582        if (el.classList) {
583            el.classList.add(className);
584        } else {
585            var classes = el.className.split(' ');
586            if (classes.indexOf(className) === -1) {
587                classes.push(className);
588                el.className = classes.join(' ');
589            }
590        }
591    }
592
593    function removeClass(el, className) {
594        if (el.classList) {
595            el.classList.remove(className);
596        } else {
597            var classes = el.className.split(' ');
598            var index = classes.indexOf(className);
599            if (index !== -1) {
600                classes.splice(index, 1);
601                el.className = classes.join(' ');
602            }
603        }
604    }
605
606    // 添加商品项点击处理函数
607    function handleItemClick(e) {
608        e = e || window.event;
609        var target = e.target || e.srcElement;
610
611        // 查找最近的商品项元素
612        var item = target;
613        while (item && !item.getAttribute('data-id') && item !== searchDropdown) {
614            item = item.parentNode;
615        }
616
617        if (item && item.getAttribute('data-id')) {
618            var id = item.getAttribute('data-id');
619            var type = item.getAttribute('data-type'); // 获取类型
620            //console.log('选中项:', type, id);
621
622            // 根据类型处理不同的跳转逻辑
623            if (type === 'product') {
624                // 处理商品点击
625                //console.log('跳转到产品详情页');
626                window.open("/item/" + item.getAttribute('data-id') + ".html");
627            } else if (type === 'series') {
628                // 处理系列点击
629                //console.log('跳转到系列页面');
630                window.open("/list/series?keyword=" + item.getAttribute('data-series') + "&type=series");
631            }
632
633            hideDropdown();
634            searchInput.value = '';
635        }
636    }
637
638    // 初始化
639    bindEvents();
640})();
641
642$("#searchInput").bind('keydown', function (e) {
643    var key = e.which;
644    if (key == 13) {
645        e.preventDefault();
646        var value = $(this).val();
647        if (value == "") {
648            value = $(this).attr("data-value");
649        }
650        window.location.href = "/list/search?keyword=" + encodeURIComponent(value);
651    }
652});
653
654$("#search_sub").on('click', function (e) {
655    var value = $("#searchInput").val();
656    if (value == "") {
657        value = $("#searchInput").attr("data-value");
658    }
659    window.location.href = "/list/search?keyword=" + encodeURIComponent(value);
660});
661
662fhyx_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.