为了实现一个完整的号码估价网站,前端部分(HTML、CSS、JavaScript)需要包含用户输入的手机号、微信号、车牌号、QQ号等信息后,随机显示出相应的估价、等级、评星、推荐、评价语录等数据。以下是一个实现思路和代码示例。
- HTML 结构
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>号码估价系统</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>号码估价系统</h1>
<div class="input-group">
<label for="inputNumber">请输入号码:</label>
<input type="text" id="inputNumber" placeholder="输入手机号、微信号、车牌号等">
<button onclick="generateEstimate()">获取估价</button>
</div>
<div id="result" class="result">
<h3>估价结果</h3>
<p id="value">价值: --</p >
<p id="level">等级: --</p >
<p id="stars">评星: --</p >
<p id="recommendation">推荐: --</p >
<p id="quote">评价语录: --</p >
</div>
</div>
<script src="script.js"></script>
</body>
</html>
2.CSS 样式
style.css
/* styles.css */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
color: #333;
margin: 0;
padding: 0;
}
.container {
width: 80%;
margin: 0 auto;
padding: 30px;
background-color: #fff;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
h1 {
text-align: center;
color: #4CAF50;
}
.input-group {
margin-bottom: 30px;
}
.input-group label {
display: block;
margin-bottom: 10px;
font-size: 16px;
}
.input-group input {
width: 80%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.input-group button {
padding: 10px 20px;
margin-left: 10px;
font-size: 16px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.input-group button:hover {
background-color: #45a049;
}
.result {
padding: 20px;
border-top: 1px solid #ccc;
display: none;
}
.result h3 {
text-align: center;
color: #333;
}
.result p {
font-size: 16px;
line-height: 1.6;
}
3.JavaScript逻辑
script.js
// script.js
function generateEstimate() {
// 获取用户输入的号码
const inputValue = document.getElementById('inputNumber').value.trim();
// 判断输入类型(手机号、微信号等)
const isPhoneNumber = /^1[3-9]\d{9}$/.test(inputValue);
const isQQ = /^[1-9][0-9]{4}$/.test(inputValue.slice(-4));
const isCarPlate = /^[A-Z0-9]{6}$/.test(inputValue);
const isDouyin = inputValue.length >= 3; // 假设抖音号长度大于3即可判断为有效
const isKuaishou = inputValue.length >= 3; // 快手号或名称也类似
// 随机生成估价数据
const randomValue = (min, max) => (Math.random() * (max - min) + min).toFixed(2);
const levels = ['基础', '中等', '优质', '稀缺', '超级稀缺'];
const stars = ['★', '★★', '★★★', '★★★★', '★★★★★'];
const recommendations = ['强烈推荐', '推荐', '一般推荐', '不推荐', '非常不推荐'];
const quotes = [
'这号码值一个亿!',
'值得拥有,性价比高!',
'还行,有些稀缺',
'普通号码,稍微差点',
'这号码,嗯…你想清楚吧'
];
// 根据输入类型生成随机数据
let value = '';
let level = '';
let star = '';
let recommendation = '';
let quote = '';
if (isPhoneNumber) {
value = randomValue(100, 10000);
level = levels[Math.floor(Math.random() * 5)];
star = stars[Math.floor(Math.random() * 5)];
recommendation = recommendations[Math.floor(Math.random() * 5)];
quote = quotes[Math.floor(Math.random() * 5)];
} else if (isQQ) {
value = randomValue(10, 5000);
level = levels[Math.floor(Math.random() * 5)];
star = stars[Math.floor(Math.random() * 5)];
recommendation = recommendations[Math.floor(Math.random() * 5)];
quote = quotes[Math.floor(Math.random() * 5)];
} else if (isCarPlate) {
value = randomValue(500, 10000);
level = levels[Math.floor(Math.random() * 5)];
star = stars[Math.floor(Math.random() * 5)];
recommendation = recommendations[Math.floor(Math.random() * 5)];
quote = quotes[Math.floor(Math.random() * 5)];
} else if (isDouyin || isKuaishou) {
value = randomValue(100, 100000);
level = levels[Math.floor(Math.random() * 5)];
star = stars[Math.floor(Math.random() * 5)];
recommendation = recommendations[Math.floor(Math.random() * 5)];
quote = quotes[Math.floor(Math.random() * 5)];
} else {
alert('请输入有效的号码或名称');
return;
}
// 更新结果显示
document.getElementById('value').textContent = `价值: ¥${value}`;
document.getElementById('level').textContent = `等级: ${level}`;
document.getElementById('stars').textContent = `评星: ${star}`;
document.getElementById('recommendation').textContent = `推荐: ${recommendation}`;
document.getElementById('quote').textContent = `评价语录: "${quote}"`;
// 显示结果
document.getElementById('result').style.display = 'block';
}
4.说明
1.前端部分:包括一个输入框,用于用户输入手机号、微信号、车牌号、QQ号等,点击按钮后,随机生成相关估价数据。显示结果包括“价值”、“等级”、“评星”、“推荐”和“评价语录”。
2.随机数据生成:为了模拟估价系统的核心功能,使用了随机数生成价值、等级、评星等内容。生成的值是随机的,具体的规则可以根据实际需求进一步改进。
3.输入验证:通过正则表达式判断用户输入的内容是否为合法的手机号、QQ号、车牌号等。如果输入不符合要求,系统会提示用户输入有效的数据。
5.功能扩展
1.用户反馈:可以加入用户对号码估价的反馈功能,让用户可以对某个号码的估价给出评价。
2.高级估算规则:可以根据号码的特殊性(如车牌的稀有性、手机号的尾号等)增加更精确的估值规则。
3.数据库存储:如果需要更为复杂的估价系统,可以将数据存储到后台数据库中,根据不同的用户输入来查询数据库的相关信息进行估价。
此系统的核心功能已通过前端实现,并且是一个简化版的估价工具,具体的估价逻辑和数据可以根据实际情况进一步优化。
暂无评论内容