|
@@ -0,0 +1,261 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="zh-CN">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
|
+ <title>AI 客服 - 饰品商城</title>
|
|
|
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
|
|
|
+ <style>
|
|
|
+ /* 基础样式(继承自之前的代码) */
|
|
|
+ * {
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ box-sizing: border-box;
|
|
|
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
|
+ }
|
|
|
+ body {
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ color: #333;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 聊天窗口样式 */
|
|
|
+ .chat-container {
|
|
|
+ /*max-width: 600px; 移除最大宽度限制 */
|
|
|
+ /*margin: 20px auto; 移除外边距 */
|
|
|
+ background-color: #fff;
|
|
|
+ border-radius: 0px; /* 将圆角设置为0,可以完全贴合屏幕 */
|
|
|
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
|
+ overflow: hidden; /* 防止内容超出 */
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ height: 100vh; /* 占据整个屏幕高度 */
|
|
|
+ width: 100vw; /* 占据整个屏幕宽度 */
|
|
|
+ position: fixed; /* 添加固定定位 */
|
|
|
+ top: 0; /* 顶部对齐 */
|
|
|
+ left: 0; /* 左侧对齐 */
|
|
|
+ z-index: 1000; /* 确保在其他内容之上 */
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-header {
|
|
|
+ background-color: #1890ff;
|
|
|
+ color: white;
|
|
|
+ padding: 15px;
|
|
|
+ text-align: center;
|
|
|
+ font-weight: bold;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+ position: relative; /*为了让返回按钮可以相对于header定位*/
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-messages {
|
|
|
+ flex-grow: 1;
|
|
|
+ padding: 15px;
|
|
|
+ overflow-y: auto; /* 允许滚动 */
|
|
|
+ }
|
|
|
+
|
|
|
+ .message {
|
|
|
+ margin-bottom: 10px;
|
|
|
+ padding: 8px 12px;
|
|
|
+ border-radius: 15px;
|
|
|
+ max-width: 70%; /* 限制消息宽度 */
|
|
|
+ word-wrap: break-word; /* 自动换行 */
|
|
|
+ }
|
|
|
+
|
|
|
+ .user-message {
|
|
|
+ background-color: #e6f7ff;
|
|
|
+ text-align: right;
|
|
|
+ margin-left: auto; /* 靠右对齐 */
|
|
|
+ }
|
|
|
+
|
|
|
+ .ai-message {
|
|
|
+ background-color: #f0f0f0;
|
|
|
+ text-align: left;
|
|
|
+ margin-right: auto; /* 靠左对齐 */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 聊天输入区 */
|
|
|
+ .chat-input {
|
|
|
+ padding: 10px;
|
|
|
+ border-top: 1px solid #eee;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-field {
|
|
|
+ flex-grow: 1;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ border-radius: 20px;
|
|
|
+ padding: 8px 15px;
|
|
|
+ font-size: 14px;
|
|
|
+ outline: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .send-button {
|
|
|
+ background-color: #1890ff;
|
|
|
+ color: white;
|
|
|
+ border: none;
|
|
|
+ border-radius: 20px;
|
|
|
+ padding: 8px 15px;
|
|
|
+ margin-left: 10px;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .send-button:hover {
|
|
|
+ background-color: #0d79d9;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* AI建议/快捷回复 */
|
|
|
+ .ai-suggestions {
|
|
|
+ padding: 10px;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .suggestion-button {
|
|
|
+ background-color: #fff;
|
|
|
+ border: 1px solid #1890ff;
|
|
|
+ color: #1890ff;
|
|
|
+ border-radius: 20px;
|
|
|
+ padding: 5px 10px;
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .suggestion-button:hover {
|
|
|
+ background-color: #e6f7ff;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 功能按钮 */
|
|
|
+ .function-buttons {
|
|
|
+ padding: 10px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-around;
|
|
|
+ border-top: 1px solid #eee;
|
|
|
+ }
|
|
|
+
|
|
|
+ .function-button {
|
|
|
+ background-color: #fff;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ color: #333;
|
|
|
+ border-radius: 8px;
|
|
|
+ padding: 8px 12px;
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .function-button:hover {
|
|
|
+ background-color: #f0f0f0;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div class="chat-container">
|
|
|
+ <div class="chat-header">
|
|
|
+ <button onclick="goBack()" style="background: none; border: none; color: white; font-size: 16px; cursor: pointer; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);">
|
|
|
+ <i class="bi bi-arrow-left"></i> 返回
|
|
|
+ </button>
|
|
|
+ AI 客服
|
|
|
+ </div>
|
|
|
+ <div class="chat-messages" id="chatMessages">
|
|
|
+ <!-- 消息示例 -->
|
|
|
+ <div class="ai-message message">您好!有什么可以帮您?</div>
|
|
|
+ <div class="user-message message">我想问一下 AWP | 二西莫夫 的价格。</div>
|
|
|
+ <div class="ai-message message">AWP | 二西莫夫 的当前市场价格大约在 ¥XXX - ¥YYY 之间,具体价格取决于磨损程度和印花。</div>
|
|
|
+ </div>
|
|
|
+ <div class="ai-suggestions">
|
|
|
+ <button class="suggestion-button">如何绑定 Steam 账号?</button>
|
|
|
+ <button class="suggestion-button">忘记密码怎么办?</button>
|
|
|
+ <button class="suggestion-button">如何进行身份验证?</button>
|
|
|
+ </div>
|
|
|
+ <div class="chat-input">
|
|
|
+ <input type="text" class="input-field" id="messageInput" placeholder="请输入您的问题...">
|
|
|
+ <button class="send-button" onclick="sendMessage()">发送</button>
|
|
|
+ </div>
|
|
|
+ <div class="function-buttons">
|
|
|
+ <button class="function-button">砍价</button>
|
|
|
+ <button class="function-button">推荐商品</button>
|
|
|
+ <button class="function-button">查询订单</button>
|
|
|
+ <button class="function-button">交易帮助</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ function goBack() {
|
|
|
+ // 这里你可以定义返回的逻辑。例如:
|
|
|
+ // 1. 返回到上一页历史记录:
|
|
|
+ window.location.href = "WOde.html";
|
|
|
+
|
|
|
+ // 2. 或者,返回到指定的 URL:
|
|
|
+ // window.location.href = "https://你的商城首页地址";
|
|
|
+
|
|
|
+ // 3. 或者,隐藏 chat-container (如果聊天窗口是动态创建的)
|
|
|
+ // document.querySelector('.chat-container').style.display = 'none';
|
|
|
+ }
|
|
|
+
|
|
|
+ function sendMessage() {
|
|
|
+ const messageInput = document.getElementById('messageInput');
|
|
|
+ const message = messageInput.value;
|
|
|
+ if (message.trim() === '') return;
|
|
|
+
|
|
|
+ // 添加用户消息到聊天窗口
|
|
|
+ const chatMessages = document.getElementById('chatMessages');
|
|
|
+ const userMessageElement = document.createElement('div');
|
|
|
+ userMessageElement.classList.add('user-message', 'message');
|
|
|
+ userMessageElement.textContent = message;
|
|
|
+ chatMessages.appendChild(userMessageElement);
|
|
|
+
|
|
|
+ // 模拟 AI 回复(实际应调用 AI 接口)
|
|
|
+ setTimeout(() => {
|
|
|
+ const aiResponse = getAIResponse(message); // 调用 AI 函数
|
|
|
+ const aiMessageElement = document.createElement('div');
|
|
|
+ aiMessageElement.classList.add('ai-message', 'message');
|
|
|
+ aiMessageElement.textContent = aiResponse;
|
|
|
+ chatMessages.appendChild(aiMessageElement);
|
|
|
+
|
|
|
+ // 滚动到底部
|
|
|
+ chatMessages.scrollTop = chatMessages.scrollHeight;
|
|
|
+ }, 500);
|
|
|
+
|
|
|
+ // 清空输入框
|
|
|
+ messageInput.value = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 模拟 AI 回复函数 (需要替换为真正的 AI 逻辑)
|
|
|
+ function getAIResponse(message) {
|
|
|
+ message = message.toLowerCase();
|
|
|
+
|
|
|
+ if (message.includes('awp | 二西莫夫')) {
|
|
|
+ return 'AWP | 二西莫夫 的当前市场价格大约在 ¥XXX - ¥YYY 之间,具体价格取决于磨损程度和印花。';
|
|
|
+ } else if (message.includes('忘记密码')) {
|
|
|
+ return '请访问“忘记密码”页面,按照提示重置您的密码。';
|
|
|
+ } else if (message.includes('如何绑定')) {
|
|
|
+ return '请访问“个人资料”页面,然后点击“绑定 Steam 账号”按钮。';
|
|
|
+ }
|
|
|
+ else if (message.includes('身份验证')) {
|
|
|
+ return '请访问“个人资料”页面,根据平台要求进行身份验证。';
|
|
|
+ }else if (message.includes('蝴蝶刀')) {
|
|
|
+ return '蝴蝶刀目前价格较高,大约在¥XXX - ¥YYY 之间。';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return '这个问题我还在学习中,请稍后再试。';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 快捷回复功能
|
|
|
+ const suggestionButtons = document.querySelectorAll('.suggestion-button');
|
|
|
+ suggestionButtons.forEach(button => {
|
|
|
+ button.addEventListener('click', function() {
|
|
|
+ document.getElementById('messageInput').value = this.textContent;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 自动滚动到底部
|
|
|
+ document.addEventListener('DOMContentLoaded', function() {
|
|
|
+ const chatMessages = document.getElementById('chatMessages');
|
|
|
+ chatMessages.scrollTop = chatMessages.scrollHeight;
|
|
|
+ });
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|