“SearchResultstest”的版本間的差異
來自Youbianku
第1行: | 第1行: | ||
? | <html> | ? | <html> |
? | + | <style> | |
? | + | div.pc_right td { | |
? | + | ? padding:10px 10px; | |
? | + | } | |
? | + | .pc_right li { | |
? | + | ? color: #555; | |
? | + | ? font-size: 15px; | |
? | + | ? line-height: 18px; | |
? | + | ? margin-top: 8px; | |
? | + | ? word-wrap: break-word; | |
? | + | } | |
? | + | .paging { | |
? | + | ? float:right; | |
? | + | } | |
? | + | .paging li { | |
? | + | ? display: inline-block; | |
? | + | ? padding-left:20px; | |
? | + | } | |
? | + | .paging li a { | |
? | + | ? cursor: pointer; | |
? | + | } | |
? | + | .noresult { | |
? | + | ? font-weight: bold; | |
? | + | ? text-align: center; | |
? | + | } | |
? | + | .noresult p { | |
? | + | ? margin-top: 6px; | |
? | + | } | |
? | + | a.disabled { | |
? | + | ? pointer-events: none; | |
? | + | ? filter: alpha(opacity=50); /*IE濾鏡,透明度50%*/ | |
? | + | ? -moz-opacity: 0.5; /*Firefox私有,透明度50%*/ | |
? | + | ? opacity: 0.5; /*其他,透明度50%*/ | |
? | + | ? cursor: not-allowed; | |
? | + | } | |
? | + | </style> | |
? | + | <div class="pc_right"> | |
? | + | ? <div class="noresult unified-content "> | |
? | ?? </div> | ? | ?? </div> |
? | + | </div> | |
? | + | <script type='text/javascript'> | |
? | + | function getQueryVariable(variable) { | |
? | + | ? var query = window.location.search.substring(1); | |
? | + | ? var pos = query.indexOf('loc'); | |
? | + | ? var str = query[pos-1]; | |
? | + | ? var vars = query.split(str); | |
? | + | ? for (var i=0; i<vars.length; i++) { | |
? | + | ? ? var pair = vars[i].split("="); | |
? | + | ? ? if(pair[0] == variable){return pair[1];} | |
? | + | ? } | |
? | + | ? return ''; | |
? | + | } | |
? | ? | ||
? | + | var pageSize = 12; | |
? | + | var currentPage = 0; | |
? | + | var pages = 1; | |
? | + | var allData = []; | |
? | ? | ||
? | + | function paging(currentPage, arr) { | |
? | + | ? var html = ''; | |
? | + | ? var skipNum = currentPage * pageSize; | |
? | + | ? var results = (skipNum + pageSize >= arr.length)?arr.slice(skipNum, arr.length): arr.slice(skipNum, skipNum + pageSize); | |
? | + | ? var len = results.length; | |
? | + | ? if (results[0].street!= '') { | |
? | + | ? ? html += '<tr><th>地址</th><th>郵編</th></tr>'; | |
? | + | ? ? for (var i=0; i<len; i++) { | |
? | + | ? ? ? html += '<tr><td>'+results[i].address+'</td><td><a href="/'+results[i].postcode+'">'+results[i].postcode+'</a></tr>'; | |
? | ? | ||
? | ? | ||
? | ?? ? } | ? | ?? ? } |
? | ? | + | ? } else { |
? | ?? ? // | + | ?? ? html += '<tr><th>地址</th><th>郵編</th></tr>'; |
? | ?? ? | + | ?? ? for (var i=0; i<len; i++) { |
? | ?? ? ? | + | ?? ? ? html += '<tr><td>'+results[i].address+'</td><td><a href="/'+results[i].postcode+'">'+results[i].postcode+'</a></td></tr>'; |
? | ? | ||
? | ? | ||
? | ? | ||
? | ?? ? } | ? | ?? ? } |
? | + | ? } | |
? | + | ? $(".zipcode-datas").html(html); | |
? | + | } | |
? | ? | ||
? | + | function previous() { | |
? | + | ? currentPage -= 1; | |
? | + | ? paging(currentPage, allData); | |
? | + | ? if (currentPage == 0) { | |
? | + | ? ? $(".paging li a:first").addClass("disabled"); | |
? | + | ? } | |
? | + | ? $(".paging li a:last").removeClass("disabled"); | |
? | + | } | |
? | ? | ||
? | + | function next() { | |
? | + | ? currentPage += 1; | |
? | + | ? paging(currentPage, allData); | |
? | ? | + | ? if (currentPage == pages-1) { |
? | + | ? ? $(".paging li a:last").addClass("disabled"); | |
? | + | ? } | |
? | + | ? $(".paging li a:first").removeClass("disabled"); | |
? | + | } | |
? | ? | ||
? | ? | ||
? | ? | ? | |
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ? | |
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | + | function focusOnResults() { | |
? | ? | + | ?? document.querySelector('.pc_right').scrollIntoView({ behavior: 'smooth' }); |
? | ? | ||
? | ?? | ? | |
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | } | ? | } |
? | ? | ||
? | + | </script> | |
? | + | <script> | |
? | + | function add() { | |
? | + | ? // 定義三個廣告代碼 特別需要注意的是百度聯(lián)盟的廣告不能用反屏蔽代碼,要不然無法正常解析 2021-09-16 | |
? | + | ? var pc_ad = '<div class="unified-content ad-pc"><div class="_guq2pst47gb"></div><script type="text/javascript">(window.slotbydup = window.slotbydup || []).push({id: "u6626265",container: "_guq2pst47gb",async: true});<\/script></div>'; | |
? | + | ? var mobile_ad = '<div class="unified-content ad-mobile"><div class="_c5d19wrylrj"></div><script type="text/javascript">(window.slotbydup = window.slotbydup || []).push({id: "u6626285",container: "_c5d19wrylrj",async: true});<\/script><script type="text/javascript" src="//cpro.baidustatic.com/cpro/ui/cm.js" async="async" defer="defer" ><\/script></div>'; | |
? | + | ? loc = getQueryVariable('loc'); | |
? | + | ? address = getQueryVariable('address'); | |
? | + | ? city = getQueryVariable('city'); | |
? | + | ? if (loc!= '' || address!= '' || city!= '') { | |
? | + | ? ? var d = new Date(); | |
? | + | ? ? var str = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+ d.getDate(); | |
? | + | ? ? var key = window.btoa(str+'youbiankuyoubianku'); | |
? | + | ? ? $.ajax({ | |
? | + | ? ? ? url: "http://www.foodsell.com.cn/api/youbianku_zhannei_search.php", | |
? | + | ? ? ? type: "POST", | |
? | ?? ? ? ? ? ? ? | + | ? ? ? data: { address: decodeURI(address), loc: decodeURI(loc), city: decodeURI(city), key: key }, |
? | + | ? ? ? success: (obj) => { | |
? | + | ? ? ? ? var obj = JSON.parse(obj); | |
? | + | ? ? ? ? if (obj.msg) { | |
? | + | ? ? ? ? ? var message = '<img src="/skins/Green/resources/images/noresult.svg" alt="無結(jié)果" width="180px" height="auto"><p>很抱歉!該查詢暫無結(jié)果!'; | |
? | + | ? ? ? ? ? if (obj.msg === '1') { | |
? | + | ? ? ? ? ? ? message += '如果您需要查詢英文地址的郵編,推薦訪問:<a href="http://www.foodsell.com.cn/%E5%9B%BD%E9%99%85%E9%82%AE%E7%BC%96">國際郵編查詢</a>'; | |
? | + | ? ? ? ? ? } else { | |
? | + | ? ? ? ? ? ? message += '請重新輸入地址進行查詢!'; | |
? | + | ? ? ? ? ? } | |
? | + | ? ? ? ? ? message += '</p>'; | |
? | + | ? ? ? ? ? $(".noresult").html(message); | |
? | + | ? ? ? ? ? focusOnResults(); | |
? | + | ? ? ? ? ? return false; | |
? | + | ? ? ? ? } | |
? | + | ? ? ? ? if (obj.results.length == 0) { | |
? | + | ? ? ? ? ? $(".noresult").html('<img src="/skins/Green/resources/images/noresult.svg" alt="無結(jié)果" width="180px" height="auto"><p>很抱歉!該查詢暫無結(jié)果!</P>'); | |
? | + | ? ? ? ? ? focusOnResults(); | |
? | + | ? ? ? ? ? return false; | |
? | + | ? ? ? ? } | |
? | + | ? ? ? ? if (obj.num == 1) { | |
? | + | ? ? ? ? ? var itemFront = '<ul class="serach-head unified-content"><div class="tabel_response"><table class="zipcode-datas"><tbody>'; | |
? | + | ? ? ? ? ? if (address!= '') { | |
? | + | ? ? ? ? ? ? if (loc == '') { | |
? | + | ?? ? ? ? ? ? ? itemFront += '<tr><th>搜索詞</th><td>'+decodeURI(address)+'</td></tr>'; | |
? | ?? ? ? ? ? ? } | ? | ?? ? ? ? ? ? } |
? | ?? ? ? ? ? ? if (obj.results.length === | + | ? ? ? ? ? } |
? | + | ? ? ? ? ? itemFront += '<tr><th>地址</th><td>'+obj.results[0].address+'</td></tr><tr><th>郵編</th><td><a href="'+'/'+obj.results[0].postcode+'" >'+obj.results[0].postcode+'</a></td></tr>'; | |
? | ?? ? ? ? ? ? ? | + | ? ? ? ? ? var more = '<div class="content-msg unified-content"><h2 class="view-title common-color">'+decodeURI(address)+'更多查詢推薦</h2><p class="top-space"><a href="/如何快速查詢某個地址所屬街道辦事處??Subject='+decodeURI(address)+'">??立即查詢'+decodeURI(address)+'所屬街道辦事處</a></p><p class="top-space"><a href="/如何快速查詢某個地址所屬派出所?Subject='+decodeURI(address)+'">??立即查詢'+decodeURI(address)+'附近的派出所</p></div></a>'; |
? | + | ? ? ? ? ? var more2 = '<div class="unified-content"><h2 class="view-title common-color"><span id="提出查詢要求"></span><span class="mw-headline" id=".E6.8F.90.E5.87.BA.E6.9F.A5.E8.AF.A2.E8.A6.81.E6.B1.82">提出查詢要求</span></h2><div class="content-msg"><p class="top-space"><a target="_blank" rel="noreferrer noopener" class="external text" href="/Special:Form/%E6%9F%A5%E8%AF%A2%E8%A6%81%E6%B1%82?Subject='+decodeURI(address)+'">提出查詢“'+decodeURI(address)+'”的要求</a></p><p class="top-space">點擊以上鏈接,可提出自己的查詢要求,管理員和網(wǎng)友會及時進行<a href="/%E7%95%99%E8%A8%80%E5%9B%9E%E5%A4%8D" title="留言回復(fù)">留言回復(fù)</a>。</p></div></div>'; | |
? | + | ? ? ? ? ? var itemEnd = '</tbody></table class="top-space"></div></ul>'+mobile_ad+'<div style="width:100%;">'+more+more2; | |
? | + | ? ? ? ? ? if (obj.results[0].street!= '') { | |
? | + | ?? ? ? ? ? ? $(".pc_right").html(itemFront+itemEnd); | |
? | + | ? ? ? ? ? } else { | |
? | + | ? ? ? ? ? ? $(".pc_right").html(itemFront+itemEnd); | |
? | + | ? ? ? ? ? } | |
? | + | ? ? ? ? ? focusOnResults(); | |
? | + | ? ? ? ? } else if (obj.num > 1) { | |
? | + | ? ? ? ? ? pages = parseInt(obj.results.length / pageSize) + 1; | |
? | + | ? ? ? ? ? var html = '<div class="unified-content"><ul style="margin-bottom:20px;">'; | |
? | + | ? ? ? ? ? if (address!= '') { | |
? | + | ? ? ? ? ? ? if (loc == '') { | |
? | + | ?? ? ? ? ? ? ? html += '<li><b>搜索詞:</b><span itemprop="name">'+decodeURI(address)+'</span></li>'; | |
? | ?? ? ? ? ? ? } | ? | ?? ? ? ? ? ? } |
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ? | ||
? | ?? ? ? ? ? } | ? | ?? ? ? ? ? } |
? | + | ? ? ? ? ? html += '</ul><div class="view-content-scroll"><table class="zipcode-datas top-space bottom-space"></table></div>'; | |
? | ?? ? ? } | + | ? ? ? ? ? if (pages > 1) { |
? | ?? ? ? ? | + | ? ? ? ? ? ? html += '<ul class="paging"><li><a href="javascript:void(0);" onclick="previous();">上一頁</a></li><li><a href="javascript:void(0);" onclick="next();">下一頁</a></li></ul><div style="clear:both;"></div>'; |
? | ?? ? ? } | + | ? ? ? ? ? } |
? | ?? ? } | + | ? ? ? ? ? var more2 = '</div>'+mobile_ad+'<div class="unified-content"><h2 class="view-title common-color"><span id="提出查詢要求"></span><span class="mw-headline">? 提出查詢要求</span></h2><div class="content-msg"><p class="top-space"><a target="_blank" rel="noreferrer noopener" class="external text" href="/Special:Form/%E6%9F%A5%E8%AF%A2%E8%A6%81%E6%B1%82?Subject='+decodeURI(address)+'">提出查詢“'+decodeURI(address)+'”的要求</a></p><p class="top-space">點擊以上鏈接,可提出自己的查詢要求,管理員和網(wǎng)友會及時進行<a href="/%E7%95%99%E8%A8%80%E5%9B%9E%E5%A4%8D" title="留言回復(fù)">留言回復(fù)</a>。</p></div></div>'; |
? | ? | + | ? ? ? ? ? html += more2; |
? | ?? ? window.onload = add; | + | ? ? ? ? ? $(".pc_right").html(html); |
? | + | ? ? ? ? ? paging(0, obj.results); | |
? | + | ? ? ? ? ? allData = obj.results; | |
? | + | ? ? ? ? ? $(".paging li a:first").addClass("disabled"); | |
? | + | ? ? ? ? ? focusOnResults(); | |
? | + | ? ? ? ? } | |
? | + | ?? ? ? }, | |
? | + | ? ? ? error: (error) => { | |
? | + | ?? ? ? ? $(".noresult").html('<img src="/skins/Green/resources/images/noresult.svg" alt="無結(jié)果" width="180px" height="auto"><p>抱歉,未查詢到結(jié)果!請嘗試使用更標(biāo)準(zhǔn)的地址進行查詢。比如:在查詢詞的前面加上城市或者區(qū)縣。</P>'); | |
? | + | ? ? ? ? focusOnResults(); | |
? | + | ?? ? ? }, | |
? | + | ? ? ? complete: () => {} | |
? | + | ?? ? }); | |
? | + | ? } else { | |
? | + | ?? ? $(".noresult").html('<img src="/skins/Green/resources/images/noresult.svg" alt="無結(jié)果" width="180px" height="auto"><p>抱歉,沒有查詢條件!</P>'); | |
? | + | ? ? focusOnResults(); | |
? | + | ? } | |
? | + | } | |
? | + | window.onload = add; | |
? | + | </script> | |
? | </html> | ? | </html> |
? | + | {{DISPLAYTITLE:搜索結(jié)果}} |
2025年2月17日 (一) 15:53的版本