123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>充电桩查询系统</title>
- <script type="text/javascript"
- src="https://webapi.amap.com/maps?v=2.0&key=f0eabeffc4e5f3d9f9836d21a3c4de1f"></script>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
- background-color: #f6f6f6;
- color: #333;
- }
- .container {
- max-width: 100%;
- margin: 0 auto;
- }
- .map-container {
- width: 100%;
- height: 50vh;
- background-color: #e5e5e5;
- position: relative;
- }
- .search-bar {
- position: absolute;
- top: 20px;
- left: 50%;
- transform: translateX(-50%);
- width: 90%;
- padding: 12px;
- background: white;
- border-radius: 8px;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
- display: flex;
- align-items: center;
- }
- .search-bar input {
- flex: 1;
- border: none;
- padding: 8px;
- font-size: 14px;
- outline: none;
- }
- .search-bar button {
- border: none;
- background: #4CAF50;
- color: white;
- padding: 8px 16px;
- border-radius: 4px;
- margin-left: 10px;
- cursor: pointer;
- }
- .station-list {
- padding: 16px;
- }
- .station-card {
- background: white;
- border-radius: 12px;
- padding: 16px;
- margin-bottom: 16px;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
- }
- .station-name {
- font-size: 16px;
- font-weight: bold;
- margin-bottom: 8px;
- color: #333;
- }
- .station-info {
- font-size: 14px;
- color: #666;
- margin-bottom: 4px;
- }
- .station-status {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 12px;
- }
- .status-tag {
- background: #e8f5e9;
- color: #4CAF50;
- padding: 4px 8px;
- border-radius: 4px;
- font-size: 12px;
- }
- .distance {
- color: #999;
- font-size: 12px;
- }
- .tab-bar {
- position: fixed;
- bottom: 0;
- width: 100%;
- background: white;
- display: flex;
- padding: 8px 0;
- border-top: 1px solid #eee;
- z-index: 1000;
- }
- .tab-item {
- flex: 1;
- text-align: center;
- color: #999;
- font-size: 12px;
- padding: 4px 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- transition: all 0.3s ease;
- cursor: pointer;
- }
- .tab-item svg {
- width: 24px;
- height: 24px;
- margin-bottom: 4px;
- fill: currentColor;
- transition: all 0.3s ease;
- }
- .tab-item.active {
- color: #4CAF50;
- transform: scale(1.1);
- }
- .custom-marker {
- background-color: white;
- padding: 8px 12px;
- border-radius: 4px;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
- min-width: 130px;
- }
- .marker-title {
- font-size: 14px;
- font-weight: bold;
- color: #333;
- margin-bottom: 4px;
- }
- .marker-info {
- font-size: 12px;
- color: #666;
- margin-bottom: 4px;
- }
- .marker-status {
- font-size: 12px;
- color: #4CAF50;
- background: #e8f5e9;
- padding: 2px 6px;
- border-radius: 3px;
- display: inline-block;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="map-container">
- <div class="search-bar">
- <input type="text" placeholder="搜索附近充电桩">
- <button>搜索</button>
- </div>
- <div id="container" style="width: 100%; height: 100%;"></div>
- </div>
- <div class="station-list">
- <div class="station-card">
- <div class="station-name">星星充电站 - 望京SOHO</div>
- <div class="station-info">北京市朝阳区望京SOHO T1</div>
- <div class="station-info">营业时间:24小时</div>
- <div class="station-status">
- <span class="status-tag">可用 10/12</span>
- <span class="distance">距离500m</span>
- </div>
- </div>
- <div class="station-card">
- <div class="station-name">特来电充电站 - 三里屯</div>
- <div class="station-info">北京市朝阳区三里屯太古里</div>
- <div class="station-info">营业时间:24小时</div>
- <div class="station-status">
- <span class="status-tag">可用 5/8</span>
- <span class="distance">距离1.2km</span>
- </div>
- </div>
- </div>
- <div class="tab-bar">
- <div class="tab-item active">
- <svg>
- <use xlink:href="./images/icons.svg#icon-home" />
- </svg>
- <span>首页</span>
- </div>
- <div class="tab-item">
- <svg>
- <use xlink:href="./images/icons.svg#icon-list" />
- </svg>
- <span>列表</span>
- </div>
- <div class="tab-item">
- <svg>
- <use xlink:href="./images/icons.svg#icon-favorite" />
- </svg>
- <span>收藏</span>
- </div>
- <div class="tab-item">
- <svg>
- <use xlink:href="./images/icons.svg#icon-person" />
- </svg>
- <span>我的</span>
- </div>
- </div>
- </div>
- <script>
- // 底部导航栏交互
- document.querySelectorAll('.tab-item').forEach(item => {
- item.addEventListener('click', function () {
- // 移除其他项的active类
- document.querySelectorAll('.tab-item').forEach(tab => {
- tab.classList.remove('active');
- });
- // 为当前点击项添加active类
- this.classList.add('active');
- });
- });
- // 初始化地图
- var map = new AMap.Map('container', {
- zoom: 13,
- center: [116.48621, 39.99875] // 望京SOHO坐标
- });
- // 添加定位控件
- AMap.plugin(['AMap.Geolocation'], function () {
- var geolocation = new AMap.Geolocation({
- enableHighAccuracy: true,
- timeout: 10000,
- buttonPosition: 'RB',
- buttonOffset: new AMap.Pixel(10, 20),
- zoomToAccuracy: true
- });
- map.addControl(geolocation);
- geolocation.getCurrentPosition();
- });
- // 定义充电桩图标样式
- var chargerIcon = new AMap.Icon({
- size: new AMap.Size(32, 32),
- image: './images/charging-station.svg',
- imageSize: new AMap.Size(32, 32)
- });
- // 添加充电站标记点
- var markers = [
- {
- position: [116.48621, 39.99875], // 望京SOHO坐标
- title: '星星充电站 - 望京SOHO',
- address: '北京市朝阳区望京SOHO T1',
- available: '10/12'
- },
- {
- position: [116.45398, 39.93428], // 三里屯坐标
- title: '特来电充电站 - 三里屯',
- address: '北京市朝阳区三里屯太古里',
- available: '5/8'
- }
- ];
- markers.forEach(function (marker) {
- var markerInstance = new AMap.Marker({
- map: map,
- position: marker.position,
- icon: chargerIcon,
- offset: new AMap.Pixel(-16, -32)
- });
- // 创建信息窗体
- var infoWindow = new AMap.InfoWindow({
- isCustom: true,
- content: `<div class="custom-marker">
- <div class="marker-title">${marker.title}</div>
- <div class="marker-info">${marker.address}</div>
- <div class="marker-status">可用: ${marker.available}</div>
- </div>`,
- offset: new AMap.Pixel(0, -30)
- });
- // 绑定点击事件
- markerInstance.on('click', function () {
- infoWindow.open(map, marker.position);
- });
- });
- // 搜索功能
- document.querySelector('.search-bar button').addEventListener('click', function () {
- var keyword = document.querySelector('.search-bar input').value;
- if (keyword) {
- AMap.plugin(['AMap.PlaceSearch'], function () {
- var placeSearch = new AMap.PlaceSearch({
- city: '北京',
- type: '充电站'
- });
- placeSearch.search(keyword, function (status, result) {
- if (status === 'complete' && result.info === 'OK') {
- var pois = result.poiList.pois;
- map.setCenter(pois[0].location);
- }
- });
- });
- }
- });
- </script>
- </body>
- </html>
|