请输入您的位置信息和搜索条件,我们将为您找到附近的便宜酒店。
查询结果:
<script>
const form = document.querySelector('form');const results = document.querySelector('.results');const hotelList = document.getElementById('hotel-list');form.addEventListener('submit', (e) => {e.preventDefault();const latitude = document.getElementById('latitude').value;const longitude = document.getElementById('longitude').value;const radius = document.getElementById('radius').value;const minPrice = document.getElementById('min-price').value;const maxPrice = document.getElementById('max-price').value;if (!latitude || !longitude) {alert('请输入纬度和经度!');return;}// 调用 API 查询附近的酒店fetch(`${latitude}&longitude=${longitude}&radius=${radius}&minPrice=${minPrice}&maxPrice=${maxPrice}`).then((response) => response.json()).then((data) => {results.style.display = 'block';// 清除之前的查询结果hotelList.innerHTML = '';// 遍历查询结果并显示酒店信息data.forEach((hotel) => {const hotelItem = document.createElement('div');hotelItem.classList.add('hotel-item');const hotelName = document.createElement('span');hotelName.classList.add('hotel-name');hotelName.textContent = hotel.name;const hotelPrice = document.createElement('span');hotelPrice.classList.add('hotel-price');hotelPrice.textContent = `¥${hotel.price}`;hotelItem.appendChild(hotelName);hotelItem.appendChild(hotelPrice);hotelList.appendChild(hotelItem);});}).catch((error) => {alert('查询失败!请稍后重试。');console.error(error);});});
script>
本文由:成都民宿于(2024-11-06)发表了关于
附近宾馆查询100米内最近的便宜酒店 (附近宾馆查询500米内50至60元)的文章
。如转载请注明出处:http://www.cdcy-mail.com
如果您对此感兴趣,可以通过以下联系方式与我们联系:
成都区销售
重庆区销售
云贵区销售
华南区销售
华北区销售
华东区销售
华为企业邮箱销售热线:400-0828-083