diff --git a/index.html b/index.html
index a057676..64e52a0 100755
--- a/index.html
+++ b/index.html
@@ -173,7 +173,7 @@
.chat-header {
height: 50px;
padding: 1px 20px;
- padding-left: 22px;
+ padding-left: 56px;
background: #fff;
border-bottom: 1px solid #e3eaf2;
font-size: 16px;
@@ -181,7 +181,35 @@
color: #0057ff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
display: flex;
- justify-content: flex-start;
+ justify-content: space-between;
+ }
+
+ .chat-header .userinfo {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 5px;
+ color: #666;
+ font-weight: 400;
+ font-family: fangsong;
+
+ }
+
+ .chat-header .userinfo .logout {
+ color: #666;
+ font-weight: 400;
+ font-family: fangsong;
+ /* text-decoration: underline; */
+ cursor: pointer
+ }
+
+ .price {
+ text-decoration: none;
+ }
+
+ .price:hover,
+ .logout:hover {
+ color: #999 !important;
}
.chat-header .back {
@@ -472,6 +500,10 @@
display: none;
}
+ .userinfo-wrapper {
+ display: none;
+ }
+
/* 手机端适配 */
@media (max-width: 768px) {
@@ -484,7 +516,25 @@
}
.sidebar {
- display: none;
+ /* position: absolute;
+ top: 10px; */
+ /* display: none; */
+ width: 240px;
+ background: #ffffff;
+ border-right: 1px solid #e3eaf2;
+ display: flex;
+ flex-direction: column;
+ transition: all 0.3s ease;
+ box-shadow: 8px 0 60px rgba(0, 0, 0, 0.04);
+ z-index: 10;
+ position: absolute;
+ top: 10px;
+ height: 100%;
+ }
+
+ .sidebar.sidebar.collapsed>.toggle-btn {
+ position: fixed;
+ right: 10px !important;
}
.chat-container {
@@ -514,8 +564,83 @@
}
+ .userinfo-wrapper {
+ position: relative;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ /* 按钮样式 */
+ .userinfo-toggle {
+ padding: 10px 16px;
+ border-radius: 50px;
+ border: none;
+ background: #0057ff;
+ color: #fff;
+ font-weight: 500;
+ cursor: pointer;
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
+ transition: background 0.3s;
+ max-width: 70px;
+ overflow-x: hidden;
+ }
+
+ .userinfo-toggle:hover {
+ background: #0057ff;
+ }
+
+ /* 折叠面板 */
+ .userinfo-panel {
+ position: absolute;
+ top: 50px;
+ right: 0;
+ width: 100px;
+ background: #fff;
+ border-radius: 12px;
+ padding: 15px 20px;
+ box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ opacity: 0;
+ transform: translateY(-10px);
+ pointer-events: none;
+ transition: all 0.3s ease;
+ z-index: 1000;
+ }
+
+ /* 展开状态 */
+ .userinfo-panel.show {
+ opacity: 1;
+ transform: translateY(0);
+ pointer-events: auto;
+ }
+
+ /* 面板内部元素 */
+ .userinfo-panel span,
+ .userinfo-panel a {
+ padding: 8px 12px;
+ border-radius: 8px;
+ text-decoration: none;
+ color: #333;
+ background: #f1f1f1;
+ text-align: center;
+ transition: background 0.2s;
+ }
+
+ .userinfo-panel span:hover,
+ .userinfo-panel a:hover {
+ background: #e0e0e0;
+ }
+
+ .userinfo {
+ display: none !important;
+ }
+
}
+
.fourquestion {
display: flex;
flex-direction: row;
@@ -538,7 +663,8 @@
}
.fourquestion .question {
- width: 350px;
+ box-sizing: border-box;
+ width: 300px;
display: flex;
justify-content: center;
align-items: center;
@@ -649,11 +775,26 @@
display: flex;
justify-content: flex-start;
align-items: center;
- width: 100%;
">
新能源智能体(sataBotAgent)
+
@@ -762,6 +903,8 @@
// ✅ 先 URL 解码,再 Base64 解码,再 UTF-8 解码
const userId = decodeURIComponent(Number(escape(atob(encodedUserId))));
+ setCookie("userId", userId);
+ getUserName(userId);
// const userId = encodedUserId;
let sendParam = {
imageBase64: '',
@@ -769,7 +912,41 @@
sessionId: '',
userPrompt: ''
}
+ if (isMobile()) {
+ toggleSidebar();
+ }
const questions = document.querySelectorAll(".question");
+ // 获取到用户名称
+ function getUserName(userId) {
+ try {
+ fetch("http://1.95.137.212:30009/user", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify({
+ userId,
+
+ })
+ }).then(res => res.json()).then(data => {
+ if (data.code === 0) {
+ document.querySelectorAll('.username').forEach((e) => {
+ e.textContent = data.userName;
+ })
+
+ console.log("成功找到该用户:", data.userName, data.userId);
+
+ } else {
+ console.error("未找到该用户:",);
+ }
+ })
+
+
+
+ } catch (err) {
+ console.error("请求异常:", err);
+ }
+ }
questions.forEach(q => {
@@ -808,11 +985,20 @@
}
// getHistory();
+ function setCookie(name, value, days = 7) {
+ const d = new Date();
+ d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);
+ const expires = "expires=" + d.toUTCString();
+ document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}; path=/`;
+ }
function getCookie(name) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
if (match) return decodeURIComponent(match[2]);
return null;
}
+ function deleteCookie(name) {
+ document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
+ }
function handleBack() {
RPJavaFragmentInterface.navigateTo("StatusFragment");
@@ -825,6 +1011,10 @@
const random = Math.floor(Math.random() * 1e6).toString().padStart(6, "0");
return timestamp + random; // 一共 16 位
}
+ function logout() {
+ deleteCookie('userId');
+ window.location.href = 'http://ri.satabot.com/#/login?goRemote=1&clear=1';
+ }
function createSession(userId, sessionId) {
try {
@@ -840,6 +1030,7 @@
})
}).then(res => res.json()).then(data => {
if (data.code === 0) {
+ hasImage = false;
console.log("会话创建成功:", data.message);
} else {
console.error("创建失败:", data.error);
@@ -872,9 +1063,9 @@
}
- function toggleSidebar() {
- sidebar.classList.toggle("collapsed");
- }
+ // function toggleSidebar() {
+ // sidebar.classList.toggle("collapsed");
+ // }
function scrollToBottom() {
const chatMessages = document.getElementById("chatMessages");
setTimeout(() => {
@@ -882,6 +1073,24 @@
chatMessages.bottom = '0px';
}, 0);
}
+ const panel = document.querySelector('.userinfo-panel');
+ const toggleButton = document.querySelector('.userinfo-toggle');
+ function toggleUserInfo() {
+
+ panel.classList.toggle('show');
+ }
+
+ document.addEventListener('click', (e) => {
+ if (!toggleButton.contains(e.target) && !panel.contains(e.target)) {
+ panel.classList.remove('show');
+ }
+ });
+
+ // 阻止点击面板本身关闭
+ panel.addEventListener('click', (e) => {
+ e.stopPropagation();
+ });
+
function renderChatList(isNew) {
@@ -1260,13 +1469,12 @@
function isWeChat() {
return /MicroMessenger/i.test(navigator.userAgent);
}
- function getCookie(name) {
- console.log(document.cookie, 8777222)
- const value = `; ${document.cookie}`;
- const parts = value.split(`; ${name}=`);
- if (parts.length === 2) return parts.pop().split(';').shift();
- return null;
- }
+ // function getCookie(name) {
+ // const value = `; ${document.cookie}`;
+ // const parts = value.split(`; ${name}=`);
+ // if (parts.length === 2) return parts.pop().split(';').shift();
+ // return null;
+ // }
// gotoWeiXin();
function gotoWeiXin() {
console.log(isWeChat(), 8888, navigator.userAgent);
@@ -1291,8 +1499,14 @@
// }else{
// }
+ if (getCookie("userId")) {
+ getSessionList();
+ } else {
+ deleteCookie('userId');
+ window.location.href = 'http://ri.satabot.com/#/login?goRemote=1&clear=1';
+ }
+
- getSessionList();
function getSessionList() {
sendParam.userId = userId;
diff --git a/modal.html b/modal.html
new file mode 100644
index 0000000..e5a5d63
--- /dev/null
+++ b/modal.html
@@ -0,0 +1,433 @@
+
+
+
+
+
+
+
购买服务 - 价格表
+
+
+
+
+
+
+
购买服务
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
USAGE
+
+
+
+
+
+ 星点数
+
—
+
8,000 /月
+
30,000 /月
+
75,000 /月
+
+
+
+
+
+
常见问题
+
+
+
SataBot Agent是什么?
+
SataBot Agent 是一款由人工智能驱动的光伏场景AI应用程序。SataBot Agent AI 能力基于飒沓自研大模型的 AIGC 服务构建。
+
+
+
+
SataBot Agent 是免费的吗?
+
当您注册 SataBot Agent 时,将会免费获得 10 次问答。如果您希望长期使用,请考虑购买我们的服务。
+
+
+
+
什么是星点?
+
星点(Star Points)是 SataBot Agent 内部用于计量您所拥有的 AIGC 服务资源的货币单位。每月 Basic 套餐包含 8000 星点,Standard 套餐包含
+ 30000 星点,Pro 套餐包含 75000 星点,Premium 套餐包含 120000 星点。本月未消耗完星点会过期,下个月套餐生效时自动恢复。
+
+
+
+
星点消耗是如何计算的?
+
根据使用的 AIGC 服务,产生不同的星点消耗。当使用大语言模型问答时,将根据您的提问和模型的回答文本长度计算星点消耗。
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/node_modules/.bin/mkdirp b/node_modules/.bin/mkdirp
deleted file mode 100644
index 1ab9c81..0000000
--- a/node_modules/.bin/mkdirp
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@"
-else
- exec node "$basedir/../mkdirp/bin/cmd.js" "$@"
-fi
diff --git a/node_modules/.bin/mkdirp b/node_modules/.bin/mkdirp
new file mode 120000
index 0000000..017896c
--- /dev/null
+++ b/node_modules/.bin/mkdirp
@@ -0,0 +1 @@
+../mkdirp/bin/cmd.js
\ No newline at end of file
diff --git a/node_modules/.bin/openai b/node_modules/.bin/openai
deleted file mode 100644
index 1d3f518..0000000
--- a/node_modules/.bin/openai
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../openai/bin/cli" "$@"
-else
- exec node "$basedir/../openai/bin/cli" "$@"
-fi
diff --git a/node_modules/.bin/openai b/node_modules/.bin/openai
new file mode 120000
index 0000000..d3dcb0b
--- /dev/null
+++ b/node_modules/.bin/openai
@@ -0,0 +1 @@
+../openai/bin/cli
\ No newline at end of file
diff --git a/node_modules/mkdirp/bin/cmd.js b/node_modules/mkdirp/bin/cmd.js
old mode 100644
new mode 100755
diff --git a/node_modules/openai/bin/cli b/node_modules/openai/bin/cli
old mode 100644
new mode 100755
diff --git a/server2.js b/server2.js
index 7f74285..18b4f00 100755
--- a/server2.js
+++ b/server2.js
@@ -99,6 +99,31 @@ app.get("/test-db", async (req, res) => {
res.send("FAIL");
}
});
+app.post("/user", async (req, res) => {
+ try {
+ const { userId } = req.body; // 从请求体里拿到 user_id
+
+ if (!userId) {
+ return res.status(400).send("缺少 user_id");
+ }
+
+ // 查询 user_name
+ const [rows] = await pool.query(
+ "SELECT user_name FROM sys_user WHERE user_id = ?",
+ [userId]
+ );
+
+ if (rows.length === 0) {
+ return res.status(404).send("未找到该用户");
+ }
+
+ res.json({ code:0,userId, userName: rows[0].user_name });
+ } catch (err) {
+ console.error(err);
+ res.status(500).send("服务器错误");
+ }
+});
+
// 查询用户所有会话列表
app.get("/sessions", async (req, res) => {