script/mvcar/js/result.js

24 lines
945 B
JavaScript

document.addEventListener('DOMContentLoaded', function() {
const phoneNumberElement = document.getElementById('phoneNumber');
const plateNumberElement = document.getElementById('plateNumber');
const carBrandElement = document.getElementById('carBrand');
const callButton = document.getElementById('callButton');
// 从 sessionStorage 获取车辆信息
const carInfoJson = sessionStorage.getItem('carInfo');
if (carInfoJson) {
const carInfo = JSON.parse(carInfoJson);
// 显示车辆信息
phoneNumberElement.textContent = carInfo.phone;
plateNumberElement.textContent = carInfo.plate;
carBrandElement.textContent = carInfo.brand;
// 设置拨号链接
callButton.href = 'tel:' + carInfo.phone.replace(/-/g, '');
} else {
// 如果没有车辆信息,返回搜索页面
window.location.href = 'index.html';
}
});