Compare commits

...

23 Commits

Author SHA1 Message Date
jeremygan2021
da24458e5d new 2026-03-27 14:00:56 +08:00
jeremygan2021
84b243dc52 new 2026-03-27 13:27:47 +08:00
jeremygan2021
df261106da 1 2026-03-26 22:24:00 +08:00
jeremygan2021
3ab71269d7 fenzhuo 2026-03-26 20:27:59 +08:00
jeremygan2021
1b5faf00cc 自定义字段 2026-03-26 20:15:10 +08:00
jeremygan2021
cc46eb03cd actino 2026-03-20 16:28:04 +08:00
jeremygan2021
b902f70f7e actino 2026-03-20 16:26:09 +08:00
jeremygan2021
ccced584dc actino 2026-03-20 16:21:33 +08:00
jeremygan2021
7caff4d72d new 2026-03-20 16:18:58 +08:00
jeremygan2021
3bdb055b83 t 2026-03-20 15:55:02 +08:00
jeremygan2021
a770fbfd2a t 2026-03-20 15:47:12 +08:00
jeremygan2021
5396504c67 new
Some checks failed
Docker 构建与部署 / deploy (push) Has been cancelled
Docker 构建与部署 / build (push) Has been cancelled
2026-03-20 15:38:55 +08:00
jeremygan2021
97e743d031 new
Some checks failed
Docker 构建与部署 / build (push) Has been cancelled
Docker 构建与部署 / deploy (push) Has been cancelled
2026-03-20 15:38:02 +08:00
jeremygan2021
c6bfc59faa new
Some checks failed
Docker 构建与部署 / deploy (push) Has been cancelled
Docker 构建与部署 / build (push) Has been cancelled
2026-03-20 15:13:14 +08:00
jeremygan2021
730007f121 完成页面签到一致性以及手机验证 2026-01-28 23:44:15 +08:00
jeremygan2021
da2f7b34ea 完成页面签到一致性以及手机验证 2026-01-28 23:43:12 +08:00
jeremygan2021
4597d6fe35 支付功能 2026-01-28 22:54:03 +08:00
jeremygan2021
4c7f8126e8 数据库和支付页面 2026-01-28 20:46:41 +08:00
jeremygan2021
b97c9f548d 优化泡泡手机端 2026-01-21 22:00:33 +08:00
jeremygan2021
5dad2533df 完善大屏泡泡效果 2026-01-21 21:43:56 +08:00
jeremygan2021
e94bc11083 大屏 2026-01-21 20:50:22 +08:00
jeremygan2021
b5b9d6e731 数据库更新 2026-01-21 18:06:06 +08:00
jeremygan2021
2b70af6652 完成admin 2026-01-21 17:58:31 +08:00
29 changed files with 5946 additions and 256 deletions

View File

@@ -0,0 +1,69 @@
name: 部署到服务器
on:
push:
branches: [main, master]
workflow_dispatch:
env:
TARGET_DIR: /home/quant/data/dev/checkin
jobs:
deploy:
runs-on: ubuntu
steps:
- name: 安装 sshpass
run: |
sudo apt-get update
sudo apt-get install -y sshpass
- name: 在服务器上部署
env:
SERVER_HOST: ${{ secrets.SERVER_HOST }}
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
SERVER_PORT: ${{ secrets.SERVER_PORT }}
TARGET_DIR: ${{ env.TARGET_DIR }}
run: |
sshpass -p "$SERVER_PASSWORD" ssh -p "$SERVER_PORT" -o StrictHostKeyChecking=no "${SERVER_USER}@${SERVER_HOST}" << 'EOF'
set -e
run_sudo() {
echo "$SERVER_PASSWORD" | sudo -S -p '' "$@"
}
echo "===== 切换到目标目录: $TARGET_DIR ====="
cd $TARGET_DIR || {
echo "错误:目录 $TARGET_DIR 不存在!"
exit 1
}
echo -e "\n===== 停止并清理 Docker ====="
run_sudo docker compose down || true
echo -e "\n===== 拉取 Git 代码 ====="
if ! git pull; then
echo "警告Git pull 失败,尝试强制同步远程代码..."
git fetch --all
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git reset --hard origin/$CURRENT_BRANCH
git pull
fi
echo -e "\n===== 配置环境变量 ====="
cat > backend/.env <<'ENVEOF'
ALIYUN_ACCESS_KEY_ID=${{ secrets.ALIYUN_ACCESS_KEY_ID }}
ALIYUN_ACCESS_KEY_SECRET=${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
ALIYUN_OSS_ENDPOINT=https://oss-cn-shanghai.aliyuncs.com
ALIYUN_OSS_BUCKET_NAME=tangledup-ai-staging
ALIYUN_OSS_INTERNAL_ENDPOINT=https://oss-cn-shanghai-internal.aliyuncs.com
ALIYUN_TINGWU_APP_KEY=${{ secrets.ALIYUN_TINGWU_APP_KEY }}
DASHSCOPE_API_KEY=${{ secrets.DASHSCOPE_API_KEY }}
ENVEOF
echo -e "\n===== 启动 Docker 容器 ====="
run_sudo docker compose up -d --build
echo -e "\n===== 操作完成!====="
EOF

View File

@@ -0,0 +1,52 @@
I have analyzed the current project structure and designed a "Check-in Large Screen" (签到大屏) solution that integrates seamlessly with your existing system.
### **Plan Overview**
I will implement a **"Galaxy Spotlight"** style large screen:
1. **Background (Danmaku/Floating Tags)**:
* `Business Scope` and short `Vision` keywords will float elegantly in the background like stars or drifting clouds.
* Uses the project's blue/cyan tech theme.
2. **Foreground (Spotlight Card)**:
* A central, animated card that cycles through checked-in guests.
* Displays: **Company Name** (Prominent), **Guest Name/Position**, and **Vision 2026**.
* Updates every 8-10 seconds to ensure everyone gets exposure.
### **Implementation Steps**
#### 1. Backend (`main.py`)
* Add a new route `/wall` to serve the large screen page.
* Add an API `/api/wall/data` to fetch approved check-in data (filtering out empty entries).
#### 2. Frontend (`templates/wall.html`)
* Create a new responsive HTML template.
* **Visuals**: Reusing the `radial-gradient` background and neon aesthetics from `index.html`.
* **Animation**:
* JS-based floating animation for background tags.
* CSS transitions for the central spotlight card.
#### 3. Admin Integration (`templates/admin.html`)
* Add a button "Open Large Screen" (打开签到大屏) in the Admin Dashboard for easy access.
### **Technical Details**
* **Tech Stack**: Native JS/CSS (no extra heavy libraries needed), integrated into the existing FastAPI app.
* **Data Source**: Reads directly from `checkin_info` table.
* **Compatibility**: Optimized for 1080p/4K displays (MacOS standard).

View File

@@ -0,0 +1,34 @@
I have analyzed the current project structure and designed a "Check-in Large Screen" (签到大屏) solution that integrates seamlessly with your existing system.
### **Plan Overview**
I will implement a **"Galaxy Spotlight"** style large screen:
1. **Background (Danmaku/Floating Tags)**:
- `Business Scope` and short `Vision` keywords will float elegantly in the background like stars or drifting clouds.
- Uses the project's blue/cyan tech theme.
2. **Foreground (Spotlight Card)**:
- A central, animated card that cycles through checked-in guests.
- Displays: **Company Name** (Prominent), **Guest Name/Position**, and **Vision 2026**.
- Updates every 8-10 seconds to ensure everyone gets exposure.
### **Implementation Steps**
#### 1. Backend (`main.py`)
- Add a new route `/wall` to serve the large screen page.
- Add an API `/api/wall/data` to fetch approved check-in data (filtering out empty entries).
#### 2. Frontend (`templates/wall.html`)
- Create a new responsive HTML template.
- **Visuals**: Reusing the `radial-gradient` background and neon aesthetics from `index.html`.
- **Animation**:
- JS-based floating animation for background tags.
- CSS transitions for the central spotlight card.
#### 3. Admin Integration (`templates/admin.html`)
- Add a button "Open Large Screen" (打开签到大屏) in the Admin Dashboard for easy access.
### **Technical Details**
- **Tech Stack**: Native JS/CSS (no extra heavy libraries needed), integrated into the existing FastAPI app.
- **Data Source**: Reads directly from `checkin_info` table.
- **Compatibility**: Optimized for 1080p/4K displays (MacOS standard).

View File

@@ -0,0 +1,37 @@
I will optimize the registration and payment flow with the specific requirement to record the actual payment amount.
### 1. Backend Updates (`main.py`)
- **Database Schema**: Add `out_trade_no` column to `gsdh_data` to link users with payment orders.
- **Pre-payment Validation**:
- Update `create_payment` (H5) and `create_native_payment`.
- Check if phone exists in `gsdh_data`.
- **Logic**:
- If `fee` has a valid amount (not empty, '0', or 'PENDING'), reject as "Already Registered".
- If `fee` is empty/PENDING, allow payment.
- Upsert user with `fee` = 'PENDING' and `payment_channel` = '..._pending'.
- **Payment Status Sync**:
- Update `check_payment_status`:
- When WeChat returns `SUCCESS`:
- **Update `fee`** to the actual configured payment amount (e.g., "0.01").
- Update `payment_channel` to the final channel (removing '_pending').
- Update `out_trade_no` logic to ensure we find the correct user.
### 2. Frontend Optimization (`templates/ticket.html`)
- **Dynamic Form Fields**:
- Replace hardcoded inputs with a loop that renders fields based on `config.field_config` (managed in Admin).
- Respect "Show", "Required", and "Label" settings.
- **QR Code Modal**:
- Add explicit text: "请使用微信扫一扫完成支付" (Please use WeChat Scan to pay).
- Optimize layout.
- **Payment Logic**:
- Handle "Already Registered" error.
- Redirect to Success Page on completion.
### 3. New Success Page
- Create `templates/success.html` to show a "Registration Successful" message.
- Add route in `main.py`.
### 4. Admin Interface
- Verify `templates/admin.html` field configuration works with the new `ticket.html` dynamic rendering.
This ensures that successful payments overwrite the 'PENDING' status with the actual amount paid.

1
.vercel/project.json Normal file
View File

@@ -0,0 +1 @@
{"projectName":"trae_upload_7ilw"}

7
.vercelignore Normal file
View File

@@ -0,0 +1,7 @@
node_modules
build
dist
.git
.trae
.log
.figma

Binary file not shown.

Binary file not shown.

View File

@@ -1,18 +1,49 @@
{
"event_title": "123",
"event_sub_title": "123",
"event_time": "123",
"event_location": "123",
"event_content": "123",
"event_title": "面对面行业联合分享",
"event_sub_title": "3月特别期",
"event_time": "2026.3.27 19:30-22:00",
"event_location": "百里春秋文化空间二楼小剧场",
"event_content": "当增长不再靠规模,企业还能怎么活",
"primary_color": "#00f2ff",
"secondary_color": "#0066ff",
"bg_color": "#050814",
"header_image": "/static/image.jpg",
"header_image": "/static/image1.jpg",
"enable_qrcode": false,
"qrcode_image": "/admin",
"enable_ticket_validation": false,
"enable_sms_verification": false,
"enable_payment": false,
"payment_amount": 0.01,
"wechat_pay_config": {
"appid": "wxdf2ca73e6c0929f0",
"mchid": "1723685511",
"api_v3_key": "XishanquBanzhanweixinzhifumiyao3",
"serial_no": "49E299FC2F01841ECD6658D8B037C5338BD170BA",
"private_key_path": "static/cert/apiclient_key.pem",
"notify_url": "https://event.quant-speed.com/ticket/finish/"
},
"enable_seating": false,
"seat_unit_name": "桌",
"total_tables": 14,
"max_per_table": 10,
"field_config": {
"ticket_field_config": {
"name": {
"label": "姓名",
"show": true,
"required": true
},
"phone": {
"label": "手机号码",
"show": true,
"required": true
},
"industry_company": {
"label": "单位名称",
"show": true,
"required": true
}
},
"checkin_field_config": {
"name": {
"label": "姓名",
"show": true,
@@ -37,16 +68,25 @@
"label": "公司主要经营 / 业务",
"show": true,
"required": true
},
"vision_2026": {
"label": "2026年业务愿景",
"show": false,
"required": false
}
},
"db_host": "6.6.6.86",
"wall_config": {
"bg_opacity": 0.3,
"show_title": true,
"learn_more_url": "",
"show_qrcode": true,
"show_seating": true,
"show_fields": {
"name": false,
"phone": false,
"company_name": false,
"position": true,
"business_scope": true
}
},
"db_host": "6.6.6.66",
"db_port": "5432",
"db_user": "gsdh",
"db_password": "123gsdh",
"db_name": "gsdh"
"db_user": "AI_event",
"db_password": "123AI_event",
"db_name": "AI_event"
}

61
diagnose_db.py Normal file
View File

@@ -0,0 +1,61 @@
import psycopg2
import json
import os
from psycopg2.extras import RealDictCursor
def load_config():
if os.path.exists("config.json"):
with open("config.json", "r", encoding="utf-8") as f:
return json.load(f)
return {}
def diagnose():
config = load_config()
print(f"Config Loaded: Host={config.get('db_host')}, DB={config.get('db_name')}, User={config.get('db_user')}")
try:
conn = psycopg2.connect(
host=config.get("db_host", "localhost"),
port=config.get("db_port", "5432"),
user=config.get("db_user", "gsdh"),
password=config.get("db_password", "123gsdh"),
database=config.get("db_name", "gsdh"),
connect_timeout=5
)
cur = conn.cursor()
# 1. List Tables
print("\n=== Tables in 'public' schema ===")
cur.execute("""
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
""")
tables = cur.fetchall()
for t in tables:
print(f"- {t[0]}")
# 2. Detail Columns for our tables
target_tables = ['gsdh_data', 'checkin_info']
for table in target_tables:
print(f"\n=== Columns for table '{table}' ===")
cur.execute("""
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = %s
""", (table,))
columns = cur.fetchall()
if not columns:
print("(Table not found)")
else:
for col in columns:
print(f" - {col[0]}: {col[1]}")
conn.close()
except Exception as e:
print(f"\nConnection Failed: {e}")
if __name__ == "__main__":
diagnose()

View File

@@ -13,10 +13,10 @@
# =============================================================================
# 配置非局域网变量 - 公网上传方法
SERVER_HOST="121.43.104.161" # 服务器IP地址
SERVER_USER="ubuntu" # 服务器用户名
SERVER_PASSWORD="qweasdzxc1" # 服务器密码
SERVER_PORT="6222"
# SERVER_HOST="121.43.104.161" # 服务器IP地址
# SERVER_USER="ubuntu" # 服务器用户名
# SERVER_PASSWORD="qweasdzxc1" # 服务器密码
# SERVER_PORT="6222"
# 配置局域网变量 - 公司局域网上传方法
# SERVER_HOST="6.6.6.86" # 服务器IP地址
@@ -25,6 +25,12 @@ SERVER_PORT="6222"
# SERVER_PORT="22" # SSH端口默认22
SERVER_HOST="6.6.6.66" # 服务器IP地址
SERVER_USER="quant" # 服务器用户名
SERVER_PASSWORD="123quant-speed" # 服务器密码
SERVER_PORT="22"
IMAGE_NAME="checkin_sys" # Docker镜像名称
IMAGE_TAG="latest" # Docker镜像标签
CONTAINER_NAME="checkin_sys-container" # 容器名称
@@ -163,27 +169,32 @@ deploy_on_server() {
sshpass -p "$SERVER_PASSWORD" ssh -p "$SERVER_PORT" -o StrictHostKeyChecking=no "${SERVER_USER}@${SERVER_HOST}" << EOF
set -e
# 定义 sudo 包装函数以处理密码输入
run_sudo() {
echo "$SERVER_PASSWORD" | sudo -S -p '' "\$@"
}
echo "[INFO] 开始服务器端部署..."
# 检查并停止现有容器
if sudo docker ps -a --format 'table {{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
if run_sudo docker ps -a --format 'table {{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo "[INFO] 发现现有容器 ${CONTAINER_NAME},正在停止并删除..."
sudo docker stop ${CONTAINER_NAME} || true
sudo docker rm ${CONTAINER_NAME} || true
run_sudo docker stop ${CONTAINER_NAME} || true
run_sudo docker rm ${CONTAINER_NAME} || true
fi
# 检查并删除现有镜像
if sudo docker images --format 'table {{.Repository}}:{{.Tag}}' | grep -q "^${IMAGE_NAME}:${IMAGE_TAG}$"; then
if run_sudo docker images --format 'table {{.Repository}}:{{.Tag}}' | grep -q "^${IMAGE_NAME}:${IMAGE_TAG}$"; then
echo "[INFO] 发现现有镜像 ${IMAGE_NAME}:${IMAGE_TAG},正在删除..."
sudo docker rmi ${IMAGE_NAME}:${IMAGE_TAG} || true
run_sudo docker rmi ${IMAGE_NAME}:${IMAGE_TAG} || true
fi
# 加载新镜像
echo "[INFO] 加载新镜像..."
sudo docker load -i /tmp/${TAR_FILE}
run_sudo docker load -i /tmp/${TAR_FILE}
# 验证镜像是否加载成功
if sudo docker images | grep -q "${IMAGE_NAME}"; then
if run_sudo docker images | grep -q "${IMAGE_NAME}"; then
echo "[SUCCESS] 镜像加载成功"
else
echo "[ERROR] 镜像加载失败"
@@ -194,21 +205,21 @@ deploy_on_server() {
echo "[INFO] 启动新容器..."
# 使用 host 网络模式,让容器直接使用宿主机网络栈,从而可以通过 localhost:5432 访问宿主机数据库
# 同时覆盖环境变量,强制使用本地数据库配置
sudo docker run -d --network host --name ${CONTAINER_NAME} \
run_sudo docker run -d --network host --name ${CONTAINER_NAME} \
--env-file /tmp/.env \
-e DB_HOST=localhost \
-e DB_PORT=5432 \
${IMAGE_NAME}:${IMAGE_TAG}
# 验证容器是否启动成功
if sudo docker ps | grep -q "${CONTAINER_NAME}"; then
if run_sudo docker ps | grep -q "${CONTAINER_NAME}"; then
echo "[SUCCESS] 容器启动成功"
echo "[INFO] 容器状态:"
sudo docker ps | grep "${CONTAINER_NAME}"
run_sudo docker ps | grep "${CONTAINER_NAME}"
else
echo "[ERROR] 容器启动失败"
echo "[INFO] 查看容器日志:"
sudo docker logs ${CONTAINER_NAME}
run_sudo docker logs ${CONTAINER_NAME}
exit 1
fi

1367
main.py

File diff suppressed because it is too large Load Diff

View File

@@ -5,3 +5,5 @@ pydantic
jinja2
python-multipart
python-dotenv
requests
cryptography

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

View File

@@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIEITCCAwmgAwIBAgIUSeKZ/C8BhB7NZljYsDfFM4vRcLowDQYJKoZIhvcNAQEL
BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
Q0EwHhcNMjYwMTI4MTQxNTE4WhcNMzEwMTI3MTQxNTE4WjB7MRMwEQYDVQQDDAox
NzIzNjg1NTExMRswGQYDVQQKDBLlvq7kv6HllYbmiLfns7vnu58xJzAlBgNVBAsM
HuS6keWNl+mHj+i/ueenkeaKgOaciemZkOWFrOWPuDELMAkGA1UEBhMCQ04xETAP
BgNVBAcMCFNoZW5aaGVuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
xxKpTgk0MAbX/cU2zXn9T6uCWToRJzNXiGf45RIcP9mD7wlXdr3p2HQ6Vv3zhDKE
goj980THhoaqX3mWXs9jxMNtdXPsjrFXk0I0e0O7BqFl/5pVicoDv3GZ/LASdqwC
rLFWZRmmkB45ehb5qoFBTFBmE3SS5qm8v2UbrrRMuu07vM1AHmtw36YyAlGRKaMj
fQVr5l0u9769j2F8Rd8/HlyiyjUZjhpRiGuv/n1eEWoL6ZIFGA/BCPgvU+Q+Xm3q
6aZd8odO5p2c1knlV/dJfRv2vC9Q8fXLalr3UQF0bM0vFCKn2sWLRYFo9Z+Nep51
/S9eUZn+7yhpxoImKBGycQIDAQABo4G5MIG2MAkGA1UdEwQCMAAwCwYDVR0PBAQD
AgP4MIGbBgNVHR8EgZMwgZAwgY2ggYqggYeGgYRodHRwOi8vZXZjYS5pdHJ1cy5j
b20uY24vcHVibGljL2l0cnVzY3JsP0NBPTFCRDQyMjBFNTBEQkMwNEIwNkFEMzk3
NTQ5ODQ2QzAxQzNFOEVCRDImc2c9SEFDQzQ3MUI2NTQyMkUxMkIyN0E5RDMzQTg3
QUQxQ0RGNTkyNkUxNDAzNzEwDQYJKoZIhvcNAQELBQADggEBAEqNn5h/g+PNkbwM
2sIl8aSgtB1tOgBAQH0sI2zqJbP/nEkeqAS1PL7Eo8EwbVrxXQV7rv75+iF8g3ry
DiCGGgooO4F/Ohh3X1BwiSKokzl8sZV6rB/ojHKkfwA0GE9xualqo2sikGpNQyUt
BeDp9OC8puBd7LR8KK8fJ7+3e3xcnH+cWZ6IZCRXgVtlofvM3OuzHQs0Bq31B4fp
yhuX1Dig/gldeKt2S624tUfOaVVdFROikYFKx8vxcsWmKMZnK8M5UBiJJIE/txvK
TT+vRUXdjZ737j4GQ86T6vedn5S88rFFiBv7LsQTIa69CRdD2dGajoTexgh1m+l9
LsHf65A=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDHEqlOCTQwBtf9
xTbNef1Pq4JZOhEnM1eIZ/jlEhw/2YPvCVd2venYdDpW/fOEMoSCiP3zRMeGhqpf
eZZez2PEw211c+yOsVeTQjR7Q7sGoWX/mlWJygO/cZn8sBJ2rAKssVZlGaaQHjl6
FvmqgUFMUGYTdJLmqby/ZRuutEy67Tu8zUAea3DfpjICUZEpoyN9BWvmXS73vr2P
YXxF3z8eXKLKNRmOGlGIa6/+fV4RagvpkgUYD8EI+C9T5D5eberppl3yh07mnZzW
SeVX90l9G/a8L1Dx9ctqWvdRAXRszS8UIqfaxYtFgWj1n416nnX9L15Rmf7vKGnG
giYoEbJxAgMBAAECggEAf6NzcllsYK7Cpi9gp/ZjeEWbWeJlRSEiKo+fgiBOhJHO
ieEPd07lNKexED3beRN66sczLFsZIyQM8RJgW4HVkj9LW1dsgUEryXtVcwNGU0YA
xBYMakBgjssj1GSAMh6vyFIb9s6vgRAgAivhAHXHjEqwaCECX2rNXlpRmX55BBAd
nMudGbbnb/jE9EUVOEvovrYqfCCxloHejCEY2/XwmU2GpGkDQIklOv2gnsvAWvDu
V+jx8OlMDeyoAZ65yIdRzgrX20JmxqyXZPOfbleNmR3F03sgpuv5cZSZVgLU8Hd+
CPVDGOV66kupFmsMi5R2rvrExhTp4I0V6s5s+wwNAQKBgQDu7G8BQcUB4NXsKemf
D89e5di0BKK5+MvMDGYTRmEMJJ9Ag1iCD11/4eg6iEei1h6TRTxmvDWm3e20KnrK
8Ug3oJQf8kYYUGgmIDhvWegfbAw1RNoZ9+I7UYofUzFk4pAdJMMqolc0kXIoOPX7
uym/FiDgIqstjNRr+kbLtU8/qQKBgQDVTRU/cE3R0eZMDZ3EvbqD00BzPmK3h3Hs
9358oh3v0Xf69p2TH58gVpbJPbHydeUvbmjPc6QeRFT9pVA7dFqXi3lJ4WOu9vu+
l2Sn0NX+g7khDzig8lj27RWxmAVc5H//VqeSxi8Z87JWGKGn1bkttN8MGvCSn8UA
W3LLfRw5iQKBgQCAmI1etdGdozBA/oYZ8N6Ci1/J9LzJMBow53OBaF4PtR5qEMfw
qOiATk06Q+Oax3iJd7h860xNViH82Ohilt9x4WIYl8QWjiCgdLMra86+Kt+fREHH
vF3t44NePN7XGALNTN4m8l3Rk39IGvB631Am43gqaz6LM8OZoom8VwgikQKBgEFT
4nYTh0ID72zLns5q7X0CbnLdYI6lRRc2ld7GKDUTCpQqhAhTXwEgg/4OjzmbMh5c
ymz/FfzPINiukOwkrrpLVVJzXXxw2Jl+9K0RIPlajpC5gLaKgwTdiA9kaAATW8Bw
YdJqMHLaWHxV/uzQYG7HPqkOdy/xDv0VBQudvc9BAoGBANIzo192Da7c7BrtDetc
C+/sc8B4Y/1mkTDc/LS3b53VfGA+otsCAKZF53ezK8xQrtWONFKF9dWkk/fPERsV
qgfg3WQIiaobDpLbjgbIOkcP/PX2H0HqhrRofDBt6QiTANBuh6FK4KOPnklXuYPp
8Sj4YnidN9RxTxPdIQuoQKaV
-----END PRIVATE KEY-----

View File

Before

Width:  |  Height:  |  Size: 229 KiB

After

Width:  |  Height:  |  Size: 229 KiB

1
static/js/qrcode.min.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
static/qrcode.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@@ -253,6 +253,9 @@
</div>
<div class="container">
<div style="margin-bottom: 10px;">
<a href="/admin" style="color: var(--text-muted); text-decoration: none;">← 返回管理后台</a>
</div>
<header>
<img src="{{ config.header_image }}" alt="{{ config.event_title }}" class="header-img" onerror="this.style.display='none'">
<h1>添加新嘉宾</h1>
@@ -291,34 +294,69 @@
<div id="submit-success" class="success-msg hidden"></div>
</div>
<div style="text-align: center; margin-top: 20px;">
<div style="text-align: center; margin-top: 20px; display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;">
<a href="/" style="color: var(--text-muted); text-decoration: none; border-bottom: 1px dashed var(--text-muted);">返回签到首页</a>
<a href="/admin" style="color: var(--text-muted); text-decoration: none; border-bottom: 1px dashed var(--text-muted);">← 返回管理后台</a>
</div>
</div>
<script>
// Use secret from backend
const ACCESS_SECRET = "{{ secret }}";
document.addEventListener('DOMContentLoaded', checkAuthStatus);
// Password Check Logic
function checkSecret() {
const input = document.getElementById('secret-input');
const error = document.getElementById('secret-error');
const overlay = document.getElementById('password-overlay');
if (input.value === ACCESS_SECRET) {
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
}, 500);
} else {
error.classList.remove('hidden');
input.value = '';
input.focus();
async function checkAuthStatus() {
try {
const res = await fetch('/api/admin/check-auth');
const data = await res.json();
if (data.authenticated) {
hideOverlay();
} else {
showOverlay();
}
} catch (e) {
showOverlay();
}
}
function showOverlay() {
document.getElementById('password-overlay').style.display = 'flex';
}
function hideOverlay() {
const overlay = document.getElementById('password-overlay');
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
}, 500);
}
async function checkSecret() {
const input = document.getElementById('secret-input');
const error = document.getElementById('secret-error');
const password = input.value;
try {
const res = await fetch('/api/admin/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({password: password})
});
const data = await res.json();
if (data.success) {
error.classList.add('hidden');
hideOverlay();
} else {
error.classList.remove('hidden');
input.value = '';
input.focus();
}
} catch (e) {
error.textContent = '网络错误';
error.classList.remove('hidden');
}
}
// Allow pressing Enter to submit password
document.getElementById('secret-input').addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
checkSecret();

File diff suppressed because it is too large Load Diff

870
templates/data_base.html Normal file
View File

@@ -0,0 +1,870 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据库管理 - 云南AI共生大会</title>
<style>
:root {
--primary-color: #00f2ff;
--secondary-color: #0066ff;
--bg-color: #050814;
--card-bg: rgba(12, 24, 50, 0.5);
--text-color: #ffffff;
--text-muted: #b0c4de;
--accent-glow: rgba(0, 242, 255, 0.6);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
background-image:
radial-gradient(circle at 50% 0%, #1a3a75 0%, #050814 60%),
radial-gradient(circle at 85% 30%, rgba(0, 242, 255, 0.1) 0%, transparent 40%),
radial-gradient(circle at 15% 70%, rgba(0, 102, 255, 0.15) 0%, transparent 40%);
background-attachment: fixed;
min-height: 100vh;
display: flex;
flex-direction: column;
padding: 20px;
}
.container {
width: 100%;
max-width: 1400px;
margin: 0 auto;
position: relative;
z-index: 1;
}
h1 {
font-size: 1.8rem;
margin-bottom: 20px;
text-align: center;
background: linear-gradient(180deg, #ffffff 0%, #d0eaff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 900;
text-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}
.nav-bar {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.nav-bar a {
text-decoration: none;
color: var(--text-muted);
padding: 8px 16px;
border-radius: 6px;
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(0, 242, 255, 0.2);
transition: all 0.3s;
}
.nav-bar a:hover, .nav-bar a.active {
background: rgba(0, 242, 255, 0.1);
border-color: var(--primary-color);
color: var(--primary-color);
}
.card {
background: var(--card-bg);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(0, 242, 255, 0.2);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}
.table-list {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-bottom: 20px;
}
.table-btn {
padding: 10px 20px;
background: rgba(0, 0, 0, 0.4);
border: 1px solid rgba(0, 242, 255, 0.3);
border-radius: 8px;
color: white;
cursor: pointer;
transition: all 0.3s;
}
.table-btn:hover, .table-btn.active {
background: linear-gradient(90deg, #0051ff 0%, #00f2ff 100%);
border-color: var(--primary-color);
}
.toolbar {
display: flex;
gap: 10px;
margin-bottom: 15px;
flex-wrap: wrap;
align-items: center;
}
.toolbar input[type="text"] {
padding: 8px 12px;
background: rgba(0, 0, 0, 0.4);
border: 1px solid rgba(0, 242, 255, 0.3);
border-radius: 6px;
color: white;
outline: none;
}
.toolbar input[type="text"]:focus {
border-color: var(--primary-color);
}
button {
background: linear-gradient(90deg, #0051ff 0%, #00f2ff 100%);
color: white;
padding: 8px 16px;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.3s;
box-shadow: 0 2px 10px rgba(0, 242, 255, 0.3);
}
button:hover {
transform: translateY(-1px);
box-shadow: 0 4px 15px rgba(0, 242, 255, 0.5);
}
button.btn-success {
background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
box-shadow: 0 2px 10px rgba(32, 201, 151, 0.35);
}
button.btn-danger {
background: linear-gradient(90deg, #cc0000 0%, #ff4d4d 100%);
box-shadow: 0 2px 10px rgba(255, 0, 0, 0.3);
}
button.btn-warning {
background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%);
box-shadow: 0 2px 10px rgba(255, 193, 7, 0.35);
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.table-container {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th, td {
padding: 10px 12px;
text-align: left;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
th {
background: rgba(0, 0, 0, 0.3);
color: var(--primary-color);
font-weight: 600;
white-space: nowrap;
position: sticky;
top: 0;
}
tr:hover {
background: rgba(0, 242, 255, 0.05);
}
td {
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.action-btns {
display: flex;
gap: 5px;
}
.action-btns button {
padding: 4px 8px;
font-size: 0.8rem;
}
.pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 15px;
}
.pagination button {
padding: 6px 12px;
}
.pagination span {
color: var(--text-muted);
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
z-index: 1000;
justify-content: center;
align-items: center;
}
.modal.show {
display: flex;
}
.modal-content {
background: var(--card-bg);
border-radius: 16px;
padding: 25px;
width: 90%;
max-width: 600px;
max-height: 90vh;
overflow-y: auto;
border: 1px solid rgba(0, 242, 255, 0.3);
backdrop-filter: blur(20px);
}
.modal h2 {
margin-bottom: 20px;
color: var(--primary-color);
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
color: var(--text-muted);
font-size: 0.9rem;
}
.form-group input, .form-group textarea, .form-group select {
width: 100%;
padding: 10px;
background: rgba(0, 0, 0, 0.4);
border: 1px solid rgba(0, 242, 255, 0.3);
border-radius: 6px;
color: white;
font-size: 0.95rem;
}
.form-group textarea {
min-height: 80px;
resize: vertical;
}
.form-group input:focus, .form-group textarea:focus {
outline: none;
border-color: var(--primary-color);
}
.modal-btns {
display: flex;
gap: 10px;
justify-content: flex-end;
margin-top: 20px;
}
#message {
position: fixed;
top: 20px;
right: 20px;
padding: 15px 25px;
border-radius: 8px;
color: white;
font-weight: bold;
display: none;
z-index: 1001;
backdrop-filter: blur(10px);
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.success {
background: rgba(40, 167, 69, 0.9);
border: 1px solid #28a745;
}
.error {
background: rgba(220, 53, 69, 0.9);
border: 1px solid #dc3545;
}
.table-info {
display: flex;
gap: 20px;
margin-bottom: 15px;
color: var(--text-muted);
font-size: 0.9rem;
}
.loading {
text-align: center;
padding: 40px;
color: var(--text-muted);
}
.empty-state {
text-align: center;
padding: 60px;
color: var(--text-muted);
}
.checkbox-cell {
width: 40px;
text-align: center;
}
.checkbox-cell input {
width: 18px;
height: 18px;
accent-color: var(--primary-color);
}
</style>
</head>
<body>
<!-- Password Overlay -->
<div id="password-overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--bg-color); z-index: 9999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(10px);">
<div class="card" style="text-align: center; width: 90%; max-width: 400px;">
<h2 style="margin-bottom: 20px; color: var(--primary-color);">请输入访问密钥</h2>
<div class="form-group">
<input type="password" id="secret-input" placeholder="输入密钥" style="text-align: center;">
</div>
<button onclick="checkSecret()">确认</button>
<p id="secret-error" style="color: #ff6b6b; margin-top: 15px; display: none;">密钥错误</p>
</div>
</div>
<div class="container">
<h1>数据库管理</h1>
<div class="nav-bar">
<a href="/admin">← 返回管理后台</a>
</div>
<div class="card">
<h2 style="margin-bottom: 15px; color: var(--primary-color);">选择数据表</h2>
<div class="table-list" id="tableList">
<div class="loading">加载中...</div>
</div>
</div>
<div class="card" id="dataCard" style="display: none;">
<h2 style="margin-bottom: 15px; color: var(--primary-color);" id="tableTitle">数据表</h2>
<div class="table-info" id="tableInfo"></div>
<div class="toolbar">
<input type="text" id="searchInput" placeholder="搜索..." onkeyup="handleSearch()">
<button onclick="loadData()">🔄 刷新</button>
<button class="btn-success" onclick="showInsertModal()"> 新增</button>
<button class="btn-danger" id="deleteSelectedBtn" onclick="deleteSelected()" disabled>🗑️ 删除选中</button>
</div>
<div class="table-container" id="tableContainer">
<div class="loading">请先选择数据表</div>
</div>
<div class="pagination" id="pagination"></div>
</div>
</div>
<div class="modal" id="editModal">
<div class="modal-content">
<h2 id="modalTitle">编辑数据</h2>
<form id="editForm">
<div id="formFields"></div>
<div class="modal-btns">
<button type="button" onclick="closeModal()">取消</button>
<button type="submit" class="btn-success" id="submitBtn">保存</button>
</div>
</form>
</div>
</div>
<div id="message"></div>
<script>
document.addEventListener('DOMContentLoaded', checkAuthStatus);
async function checkAuthStatus() {
try {
const res = await fetch('/api/admin/check-auth');
const data = await res.json();
if (data.authenticated) {
hideOverlay();
} else {
showOverlay();
}
} catch (e) {
showOverlay();
}
}
function showOverlay() {
document.getElementById('password-overlay').style.display = 'flex';
}
function hideOverlay() {
const overlay = document.getElementById('password-overlay');
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
}, 500);
}
async function checkSecret() {
const input = document.getElementById('secret-input');
const error = document.getElementById('secret-error');
const password = input.value;
try {
const res = await fetch('/api/admin/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({password: password})
});
const data = await res.json();
if (data.success) {
error.style.display = 'none';
hideOverlay();
} else {
error.style.display = 'block';
input.value = '';
input.focus();
}
} catch (e) {
error.textContent = '网络错误';
error.style.display = 'block';
}
}
document.getElementById('secret-input').addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
checkSecret();
}
});
let currentTable = '';
let currentPage = 1;
let pageSize = 50;
let totalRows = 0;
let tableColumns = [];
let tableData = [];
let primaryKey = '';
let editingId = null;
// 加载表列表
async function loadTables() {
try {
const res = await fetch('/api/db/tables');
const data = await res.json();
if (data.success) {
const tableList = document.getElementById('tableList');
tableList.innerHTML = '';
data.tables.forEach(table => {
const btn = document.createElement('button');
btn.className = 'table-btn';
btn.textContent = table;
btn.onclick = () => selectTable(table);
if (currentTable === table) btn.classList.add('active');
tableList.appendChild(btn);
});
}
} catch (e) {
showMessage('加载表列表失败', 'error');
}
}
// 选择表
async function selectTable(table) {
currentTable = table;
currentPage = 1;
document.getElementById('dataCard').style.display = 'block';
document.getElementById('tableTitle').textContent = table + ' - 数据管理';
document.querySelectorAll('.table-btn').forEach(btn => {
btn.classList.remove('active');
if (btn.textContent === table) btn.classList.add('active');
});
await loadData();
}
// 加载数据
async function loadData() {
if (!currentTable) return;
try {
const res = await fetch(`/api/db/table/${currentTable}?page=${currentPage}&page_size=${pageSize}`);
const data = await res.json();
if (data.success) {
tableColumns = data.columns;
tableData = data.rows;
totalRows = data.total;
primaryKey = data.primary_key || '';
renderTable();
renderPagination();
} else {
showMessage(data.message || '加载数据失败', 'error');
}
} catch (e) {
showMessage('网络错误', 'error');
}
}
// 渲染表格
function renderTable() {
const container = document.getElementById('tableContainer');
if (tableData.length === 0) {
container.innerHTML = '<div class="empty-state">暂无数据</div>';
return;
}
let html = '<table><thead><tr>';
// 复选框列
html += '<th class="checkbox-cell"><input type="checkbox" onchange="toggleAllCheckboxes(this)"></th>';
// 数据列
tableColumns.forEach(col => {
html += `<th>${col}</th>`;
});
// 操作列
html += '<th>操作</th></tr></thead><tbody>';
tableData.forEach(row => {
const id = primaryKey ? row[primaryKey] : JSON.stringify(row);
html += `<tr data-id="${id}">`;
html += `<td class="checkbox-cell"><input type="checkbox" class="row-checkbox" data-id="${id}"></td>`;
tableColumns.forEach(col => {
let value = row[col];
if (value === null || value === undefined) value = '';
value = String(value);
if (value.length > 50) {
value = value.substring(0, 50) + '...';
}
html += `<td title="${row[col] || ''}">${escapeHtml(value)}</td>`;
});
html += `<td class="action-btns">
<button class="btn-warning" onclick="showEditModal('${escapeId(id)}')">编辑</button>
<button class="btn-danger" onclick="deleteRow('${escapeId(id)}')">删除</button>
</td></tr>`;
});
html += '</tbody></table>';
container.innerHTML = html;
}
// 转义ID用于HTML属性
function escapeId(id) {
return String(id).replace(/'/g, "\\'").replace(/"/g, '&quot;');
}
// HTML转义
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// 渲染分页
function renderPagination() {
const totalPages = Math.ceil(totalRows / pageSize);
const pagination = document.getElementById('pagination');
if (totalPages <= 1) {
pagination.innerHTML = '';
return;
}
let html = `
<button ${currentPage === 1 ? 'disabled' : ''} onclick="goToPage(1)">首页</button>
<button ${currentPage === 1 ? 'disabled' : ''} onclick="goToPage(${currentPage - 1})">上一页</button>
<span>第 ${currentPage} / ${totalPages} 页 (共 ${totalRows} 条)</span>
<button ${currentPage === totalPages ? 'disabled' : ''} onclick="goToPage(${currentPage + 1})">下一页</button>
<button ${currentPage === totalPages ? 'disabled' : ''} onclick="goToPage(${totalPages})">末页</button>
`;
pagination.innerHTML = html;
}
// 跳转到指定页
function goToPage(page) {
currentPage = page;
loadData();
}
// 搜索
let searchTimeout;
function handleSearch() {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
const keyword = document.getElementById('searchInput').value;
filterData(keyword);
}, 300);
}
// 过滤数据(前端过滤)
function filterData(keyword) {
if (!keyword) {
renderTable();
return;
}
keyword = keyword.toLowerCase();
const filtered = tableData.filter(row => {
return tableColumns.some(col => {
const val = String(row[col] || '').toLowerCase();
return val.includes(keyword);
});
});
// 临时显示过滤结果
const originalData = tableData;
tableData = filtered;
renderTable();
tableData = originalData;
}
// 全选/取消全选
function toggleAllCheckboxes(source) {
const checkboxes = document.querySelectorAll('.row-checkbox');
checkboxes.forEach(cb => cb.checked = source.checked);
updateDeleteButton();
}
// 更新删除按钮状态
function updateDeleteButton() {
const checked = document.querySelectorAll('.row-checkbox:checked');
document.getElementById('deleteSelectedBtn').disabled = checked.length === 0;
}
// 监听复选框变化
document.addEventListener('change', (e) => {
if (e.target.classList.contains('row-checkbox')) {
updateDeleteButton();
}
});
// 显示新增弹窗
async function showInsertModal() {
editingId = null;
document.getElementById('modalTitle').textContent = '新增数据 - ' + currentTable;
await renderFormFields();
document.getElementById('editModal').classList.add('show');
}
// 显示编辑弹窗
async function showEditModal(id) {
editingId = id;
document.getElementById('modalTitle').textContent = '编辑数据 - ' + currentTable;
// 查找当前行数据
const row = tableData.find(r => {
const pk = primaryKey;
return pk ? String(r[pk]) === id : JSON.stringify(r) === id;
});
await renderFormFields(row);
document.getElementById('editModal').classList.add('show');
}
// 渲染表单字段
async function renderFormFields(data = {}) {
const formFields = document.getElementById('formFields');
// 获取表结构
try {
const res = await fetch(`/api/db/table/${currentTable}/columns`);
const result = await res.json();
if (!result.success) {
showMessage('获取表结构失败', 'error');
return;
}
let html = '';
result.columns.forEach(col => {
const isPrimary = col.column_name === primaryKey;
if (isPrimary && !data[primaryKey]) {
return; // 新增时跳过自增主键
}
let value = data[col.column_name] || '';
html += `<div class="form-group">
<label>${col.column_name}${col.is_nullable === 'YES' ? '' : ' *'}</label>
<input type="text"
name="${col.column_name}"
value="${escapeHtml(String(value))}"
${isPrimary ? 'readonly' : ''}
data-type="${col.data_type}">
</div>`;
});
formFields.innerHTML = html;
} catch (e) {
showMessage('网络错误', 'error');
}
}
// 关闭弹窗
function closeModal() {
document.getElementById('editModal').classList.remove('show');
editingId = null;
}
// 提交表单
document.getElementById('editForm').onsubmit = async (e) => {
e.preventDefault();
const formData = {};
const inputs = document.querySelectorAll('#editForm input');
inputs.forEach(input => {
formData[input.name] = input.value;
});
const url = editingId
? `/api/db/table/${currentTable}/update`
: `/api/db/table/${currentTable}/insert`;
const method = editingId ? 'PUT' : 'POST';
try {
const res = await fetch(url, {
method: method,
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: editingId,
data: formData
})
});
const result = await res.json();
if (result.success) {
showMessage(editingId ? '更新成功' : '添加成功', 'success');
closeModal();
loadData();
} else {
showMessage(result.message || '操作失败', 'error');
}
} catch (e) {
showMessage('网络错误', 'error');
}
};
// 删除单行
async function deleteRow(id) {
if (!confirm('确定要删除这条记录吗?')) return;
try {
const res = await fetch(`/api/db/table/${currentTable}/delete`, {
method: 'DELETE',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ ids: [id] })
});
const result = await res.json();
if (result.success) {
showMessage('删除成功', 'success');
loadData();
} else {
showMessage(result.message || '删除失败', 'error');
}
} catch (e) {
showMessage('网络错误', 'error');
}
}
// 删除选中
async function deleteSelected() {
const checkboxes = document.querySelectorAll('.row-checkbox:checked');
const ids = Array.from(checkboxes).map(cb => cb.dataset.id);
if (ids.length === 0) return;
if (!confirm(`确定要删除选中的 ${ids.length} 条记录吗?`)) return;
try {
const res = await fetch(`/api/db/table/${currentTable}/delete`, {
method: 'DELETE',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ ids: ids })
});
const result = await res.json();
if (result.success) {
showMessage('删除成功', 'success');
loadData();
} else {
showMessage(result.message || '删除失败', 'error');
}
} catch (e) {
showMessage('网络错误', 'error');
}
}
// 显示消息
function showMessage(text, type) {
const msg = document.getElementById('message');
msg.textContent = text;
msg.className = type;
msg.style.display = 'block';
setTimeout(() => msg.style.display = 'none', 3000);
}
// 初始化
loadTables();
</script>
</body>
</html>

View File

@@ -273,7 +273,22 @@
</style>
</head>
<body>
<!-- Password Overlay -->
<div id="password-overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--bg-color); z-index: 9999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(10px);">
<div class="card" style="text-align: center; width: 90%; max-width: 400px;">
<h2 style="margin-bottom: 20px;">请输入访问密钥</h2>
<div class="input-group">
<input type="password" id="secret-input" placeholder="输入密钥" style="text-align: center;">
</div>
<button onclick="checkSecret()">确认</button>
<p id="secret-error" class="error-msg hidden">密钥错误</p>
</div>
</div>
<div class="container">
<div style="margin-bottom: 10px;">
<a href="/admin" style="color: var(--text-muted); text-decoration: none;">← 返回管理后台</a>
</div>
<header>
<img src="{{ config.header_image }}" alt="{{ config.event_title }}" class="header-img" onerror="this.style.display='none'">
<div style="text-align: center; margin-bottom: 10px; color: var(--primary-color); font-size: 0.8rem; letter-spacing: 2px; font-weight: 600; opacity: 0.9;">
@@ -380,10 +395,75 @@
<button onclick="window.location.href='/'" style="margin-top: 30px;">返回首页</button>
<button onclick="resetFlow()" style="margin-top: 15px; background: transparent; border: 1px solid rgba(255,255,255,0.2);">继续修改</button>
<a href="/admin">
<button style="margin-top: 15px; background: transparent; border: 1px solid rgba(255,255,255,0.2);">← 返回管理后台</button>
</a>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', checkAuthStatus);
async function checkAuthStatus() {
try {
const res = await fetch('/api/admin/check-auth');
const data = await res.json();
if (data.authenticated) {
hideOverlay();
} else {
showOverlay();
}
} catch (e) {
showOverlay();
}
}
function showOverlay() {
document.getElementById('password-overlay').style.display = 'flex';
}
function hideOverlay() {
const overlay = document.getElementById('password-overlay');
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
}, 500);
}
async function checkSecret() {
const input = document.getElementById('secret-input');
const error = document.getElementById('secret-error');
const password = input.value;
try {
const res = await fetch('/api/admin/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({password: password})
});
const data = await res.json();
if (data.success) {
error.classList.add('hidden');
hideOverlay();
} else {
error.classList.remove('hidden');
input.value = '';
input.focus();
}
} catch (e) {
error.textContent = '网络错误';
error.classList.remove('hidden');
}
}
document.getElementById('secret-input').addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
checkSecret();
}
});
async function searchUser() {
const query = document.getElementById('search-input').value.trim();
const btn = document.getElementById('search-btn');

View File

@@ -463,6 +463,45 @@
100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}
/* 入群二维码样式 */
.qrcode-section {
margin-top: 25px;
padding: 20px;
background: rgba(255, 255, 255, 0.05);
border-radius: 12px;
border: 1px solid rgba(0, 242, 255, 0.3);
text-align: center;
}
.qrcode-title {
color: var(--primary-color);
font-size: 0.9rem;
margin-bottom: 15px;
font-weight: 600;
}
.qrcode-image {
max-width: 180px;
width: 100%;
border-radius: 8px;
border: 1px solid rgba(0, 242, 255, 0.4);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.qrcode-image:hover {
transform: scale(1.02);
box-shadow: 0 6px 20px rgba(0, 242, 255, 0.3);
}
.qrcode-hint {
color: var(--text-muted);
font-size: 0.75rem;
margin-top: 10px;
opacity: 0.8;
}
</style>
</head>
<body>
@@ -487,9 +526,20 @@
<label>请输入手机号码或姓名</label>
<input type="text" id="search-input" placeholder="例如13800000000 或 张三">
</div>
<button onclick="searchUser()" id="search-btn">查询</button>
<button onclick="searchUser()" id="search-btn">签到</button>
<div id="search-error" class="error-msg hidden"></div>
<div id="user-list" class="hidden" style="margin-top: 15px;"></div>
{% if config.enable_payment %}
<div style="margin-top: 25px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); text-align: center;">
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 15px;">尚未购票?</p>
<a href="/ticket" style="text-decoration: none;">
<button style="background: transparent; border: 1px solid var(--primary-color); color: var(--primary-color);">
购票报名 (¥{{ config.payment_amount }})
</button>
</a>
</div>
{% endif %}
</div>
<!-- Step 2: Fill Info -->
@@ -513,35 +563,16 @@
<input type="text" id="form-phone" required>
</div>
{% set fc = config.field_config or {} %}
{% if fc.company_name and fc.company_name.show %}
<div class="input-group">
<label>{{ fc.company_name.label }}</label>
<input type="text" id="form-company" placeholder="点此输入" {{ 'required' if fc.company_name.required else '' }}>
<div class="input-group hidden" id="sms-verification-group">
<label>验证码</label>
<div style="display: flex; gap: 10px;">
<input type="text" id="form-verification-code" placeholder="输入验证码" style="flex: 1;">
<button type="button" id="send-checkin-code-btn" onclick="sendCheckinSms()" style="width: auto; padding: 14px; background: var(--secondary-color); margin-bottom: 0; border: none; border-radius: 8px; color: white; cursor: pointer; font-weight: bold;">发送验证码</button>
</div>
</div>
{% endif %}
{% if fc.position and fc.position.show %}
<div class="input-group">
<label>{{ fc.position.label }}</label>
<input type="text" id="form-position" placeholder="点此输入" {{ 'required' if fc.position.required else '' }}>
</div>
{% endif %}
{% if fc.business_scope and fc.business_scope.show %}
<div class="input-group">
<label>{{ fc.business_scope.label }}</label>
<textarea id="form-business" rows="2" placeholder="点此输入" {{ 'required' if fc.business_scope.required else '' }}></textarea>
</div>
{% endif %}
{% if fc.vision_2026 and fc.vision_2026.show %}
<div class="input-group">
<label>{{ fc.vision_2026.label }}</label>
<textarea id="form-vision" rows="3" placeholder="点此输入 (为了业务更好对接,最好表述清晰)" {{ 'required' if fc.vision_2026.required else '' }}></textarea>
</div>
{% endif %}
<!-- 动态签到字段容器 - 根据 checkin_field_config 自动生成 -->
<div id="dynamic-checkin-fields"></div>
<input type="hidden" id="form-location" value="">
@@ -567,8 +598,14 @@
</div>
</div>
<div id="qrcode-container-success" class="qrcode-section hidden">
<p class="qrcode-title">📱 扫码加入社群</p>
<img id="qrcode-img-success" class="qrcode-image" src="" alt="入群二维码" oncontextmenu="handleQrcodeLongPress(event)">
<p class="qrcode-hint">长按二维码保存到相册</p>
</div>
<p style="margin-top: 20px;">请入座等待会议开始</p>
<button onclick="resetFlow()" style="margin-top: 30px; background: transparent; border: 1px solid rgba(255,255,255,0.2);">返回首页</button>
<button id="success-btn" onclick="window.location.href='/wall'" style="margin-top: 30px; background: transparent; border: 1px solid rgba(255,255,255,0.2);">前往活动</button>
</div>
<!-- Step 4: Already Signed -->
@@ -592,8 +629,14 @@
</div>
</div>
<div id="qrcode-container-signed" class="qrcode-section hidden">
<p class="qrcode-title">📱 扫码加入社群</p>
<img id="qrcode-img-signed" class="qrcode-image" src="" alt="入群二维码" oncontextmenu="handleQrcodeLongPress(event)">
<p class="qrcode-hint">长按二维码保存到相册</p>
</div>
<p style="margin-top: 20px;">请入座等待会议开始</p>
<button onclick="resetFlow()" style="margin-top: 30px; background: transparent; border: 1px solid rgba(255,255,255,0.2);">返回首页</button>
<button id="signed-btn" onclick="window.location.href='/wall'" style="margin-top: 30px; background: transparent; border: 1px solid rgba(255,255,255,0.2);">前往活动</button>
</div>
</div>
@@ -635,6 +678,175 @@
// Inject Config
const CONFIG = {{ config | tojson }};
let isCheckinCodeVerified = false;
/**
* 获取座位单位名称
*/
function getSeatUnitName() {
return CONFIG.seat_unit_name || '桌';
}
/**
* 格式化座位号显示(替换"桌"为单位名称)
* @param {string} seatText 原始座位文字
* @returns {string} 格式化后的座位文字
*/
function formatSeatDisplay(seatText) {
if (!seatText) return '';
const unit = getSeatUnitName();
if (unit === '桌') return seatText;
return seatText.replace(/桌/g, unit);
}
async function refreshConfig() {
try {
const res = await fetch('/api/admin/config');
if (res.ok) {
const newConfig = await res.json();
// Update global CONFIG object
Object.assign(CONFIG, newConfig);
applyConfigUI();
}
} catch (e) {
console.error("Failed to refresh config", e);
}
}
/**
* 动态渲染签到表单字段
* 根据 checkin_field_config 配置生成字段 HTML
*/
function renderDynamicCheckinFields() {
const container = document.getElementById('dynamic-checkin-fields');
if (!container) return;
const fc = CONFIG.checkin_field_config || {};
container.innerHTML = '';
// 定义字段显示顺序
const fieldOrder = ['company_name', 'position', 'business_scope', 'vision_2026'];
// 按顺序添加字段
fieldOrder.forEach(key => {
const field = fc[key];
if (!field) return;
const div = document.createElement('div');
div.className = 'input-group' + (field.show ? '' : ' hidden');
div.id = 'group-' + key;
const isTextarea = (key === 'business_scope' || key === 'vision_2026');
let placeholder = '点此输入';
if (key === 'business_scope') placeholder = '点此输入';
if (key === 'vision_2026') placeholder = '点此输入 (为了业务更好对接,最好表述清晰)';
if (isTextarea) {
const rows = key === 'vision_2026' ? 3 : 2;
div.innerHTML = `
<label id="label-${key}">${field.label || key}</label>
<textarea id="form-${key}" rows="${rows}" placeholder="${placeholder}"></textarea>
`;
} else {
div.innerHTML = `
<label id="label-${key}">${field.label || key}</label>
<input type="text" id="form-${key}" placeholder="${placeholder}">
`;
}
container.appendChild(div);
});
}
function applyConfigUI() {
const smsGroup = document.getElementById('sms-verification-group');
if (smsGroup) {
if (CONFIG.enable_sms_verification) {
smsGroup.classList.remove('hidden');
} else {
smsGroup.classList.add('hidden');
}
}
// 动态渲染字段
renderDynamicCheckinFields();
}
function updateCheckinButtonState() {
const btn = document.getElementById('submit-btn');
const codeInput = document.getElementById('form-verification-code');
const smsGroup = document.getElementById('sms-verification-group');
// Check if loading (by checking loader class or text content)
if (btn.innerHTML.includes('loader')) return;
// Check if SMS verification is enabled (group is visible)
if (smsGroup && !smsGroup.classList.contains('hidden')) {
if (isCheckinCodeVerified && codeInput && codeInput.value.trim().length === 4) {
btn.disabled = false;
} else {
btn.disabled = true;
}
} else {
btn.disabled = false;
}
}
async function verifyCheckinCode() {
const codeInput = document.getElementById('form-verification-code');
const phoneInput = document.getElementById('form-phone');
const errorDiv = document.getElementById('submit-error');
if (!codeInput) return;
const code = codeInput.value.trim();
const phone = phoneInput ? phoneInput.value.trim() : '';
if (code.length === 4 && phone) {
try {
const res = await fetch('/api/verify-sms-code', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({phone: phone, code: code})
});
const data = await res.json();
if (data.success) {
isCheckinCodeVerified = true;
errorDiv.classList.add('hidden');
} else {
isCheckinCodeVerified = false;
errorDiv.textContent = "验证码错误";
errorDiv.classList.remove('hidden');
}
} catch(e) {
isCheckinCodeVerified = false;
}
} else {
isCheckinCodeVerified = false;
if (code.length < 4) errorDiv.classList.add('hidden');
}
updateCheckinButtonState();
}
window.addEventListener('DOMContentLoaded', () => {
applyConfigUI();
const codeInput = document.getElementById('form-verification-code');
const phoneInput = document.getElementById('form-phone');
if (codeInput) {
codeInput.addEventListener('input', verifyCheckinCode);
// Initial check
updateCheckinButtonState();
}
if (phoneInput) {
phoneInput.addEventListener('input', () => {
isCheckinCodeVerified = false;
updateCheckinButtonState();
});
}
});
async function searchUser() {
const query = document.getElementById('search-input').value.trim();
const btn = document.getElementById('search-btn');
@@ -661,6 +873,7 @@
if (response.ok) {
if (data.allow_create) {
await refreshConfig();
const u = data.user || {};
const tempId = 'TEMP_' + Date.now();
currentUser = { new_id: tempId };
@@ -675,6 +888,8 @@
document.getElementById('step-search').classList.add('hidden');
document.getElementById('step-form').classList.remove('hidden');
applyConfigUI();
updateCheckinButtonState();
return;
}
@@ -698,7 +913,7 @@
document.getElementById('signed-phone').textContent = data.user.phone;
if (CONFIG.enable_seating !== false) {
document.getElementById('signed-seat-display').textContent = data.seat || "自由";
document.getElementById('signed-seat-display').textContent = formatSeatDisplay(data.seat) || ("自由" + getSeatUnitName());
document.getElementById('signed-seat-display').style.display = 'block';
document.getElementById('signed-seat-label').textContent = "您的座位是";
document.getElementById('signed-seat-label').style.display = 'block';
@@ -714,8 +929,12 @@
document.getElementById('signed-seat-label').textContent = "签到成功,请自由入座";
document.getElementById('signed-tablemates-container').classList.add('hidden');
}
// 显示二维码(如果配置开启)
updateQrcodeDisplay();
} else {
// Single user found
await refreshConfig();
selectUser(data.user);
}
} else {
@@ -732,11 +951,15 @@
}
}
function selectUser(user) {
async function selectUser(user) {
// Check if fee is 0 (unpaid)
if (user.fee == 0) {
// Ensure fee is treated as number. If fee is missing or 0, block checkin.
// CONFIG.payment_amount is usually 0.01 or 26.
const fee = parseFloat(user.fee || 0);
if (fee <= 0) {
const errorDiv = document.getElementById('search-error');
errorDiv.textContent = "⚠️ 无法签到请先前往签到处付费26元";
const amount = CONFIG.payment_amount || 26;
errorDiv.textContent = `⚠️ 无法签到:请先前往签到处付费${amount}`;
errorDiv.classList.remove('hidden');
errorDiv.classList.add('important-warning');
errorDiv.scrollIntoView({ behavior: 'smooth', block: 'center' });
@@ -747,18 +970,35 @@
// Populate form
document.getElementById('gsdh-id').value = user.new_id;
document.getElementById('form-name').value = user.name;
document.getElementById('form-phone').value = user.phone;
document.getElementById('form-company').value = user.industry_company || ''; // Pre-fill if we have something roughly mapping
const setVal = (id, val) => {
const el = document.getElementById(id);
if (el) el.value = val || '';
};
setVal('form-name', user.name);
setVal('form-phone', user.phone);
// 动态字段填充
const fc = CONFIG.checkin_field_config || {};
Object.keys(fc).forEach(key => {
if (key === 'name' || key === 'phone') return;
// 特殊映射company_name 字段填充 industry_company 的值
const fieldKey = (key === 'company_name') ? 'industry_company' : key;
setVal('form-' + key, user[fieldKey] || '');
});
// Display preview
document.getElementById('display-name').textContent = user.name;
document.getElementById('display-phone').textContent = user.phone;
document.getElementById('display-company').textContent = user.industry_company || '暂无单位信息';
if (document.getElementById('display-name')) document.getElementById('display-name').textContent = user.name;
if (document.getElementById('display-phone')) document.getElementById('display-phone').textContent = user.phone;
if (document.getElementById('display-company')) document.getElementById('display-company').textContent = user.industry_company || '暂无单位信息';
// Ensure UI reflects current config (e.g. SMS button)
applyConfigUI();
// Switch steps
document.getElementById('step-search').classList.add('hidden');
document.getElementById('step-form').classList.remove('hidden');
updateCheckinButtonState();
}
async function submitCheckin(e) {
@@ -776,17 +1016,22 @@
return el ? el.value : '';
};
// 构建 payload
const payload = {
gsdh_id: getVal('gsdh-id'),
name: getVal('form-name'),
phone: getVal('form-phone'),
company_name: getVal('form-company'),
position: getVal('form-position'),
business_scope: getVal('form-business'),
vision_2026: getVal('form-vision'),
verification_code: getVal('form-verification-code'),
location: getVal('form-location')
};
// 动态收集签到字段数据
const fc = CONFIG.checkin_field_config || {};
Object.keys(fc).forEach(key => {
if (key === 'name' || key === 'phone') return;
payload[key] = getVal('form-' + key);
});
try {
const response = await fetch('/api/checkin', {
method: 'POST',
@@ -799,9 +1044,10 @@
const data = await response.json();
if (response.ok) {
document.getElementById('success-btn').textContent = payload.name + '/点击进入活动大厅';
if (CONFIG.enable_seating !== false) {
// Show assigned seat
document.getElementById('seat-display').textContent = data.seat || "自由";
document.getElementById('seat-display').textContent = formatSeatDisplay(data.seat) || ("自由" + getSeatUnitName());
document.getElementById('seat-display').style.display = 'block';
document.getElementById('success-seat-label').textContent = "您的座位已分配";
document.getElementById('success-seat-label').style.display = 'block';
@@ -818,6 +1064,9 @@
document.getElementById('tablemates-container').classList.add('hidden');
}
// 显示二维码(如果配置开启)
updateQrcodeDisplay();
document.getElementById('step-form').classList.add('hidden');
document.getElementById('step-success').classList.remove('hidden');
} else {
@@ -828,8 +1077,8 @@
errorDiv.textContent = "网络错误,请稍后重试";
errorDiv.classList.remove('hidden');
} finally {
btn.disabled = false;
btn.textContent = '确认签到';
updateCheckinButtonState();
}
}
@@ -891,6 +1140,105 @@
document.getElementById('user-list').innerHTML = '';
document.getElementById('checkin-form').reset();
currentUser = null;
updateCheckinButtonState();
}
/**
* 根据配置控制二维码显示
*/
function updateQrcodeDisplay() {
const enableQrcode = CONFIG.enable_qrcode === true;
const qrcodeImage = CONFIG.qrcode_image;
if (enableQrcode && qrcodeImage) {
// 签到成功页面的二维码
const successContainer = document.getElementById('qrcode-container-success');
const successImg = document.getElementById('qrcode-img-success');
if (successContainer) {
successImg.src = qrcodeImage;
successContainer.classList.remove('hidden');
}
// 已签到页面的二维码
const signedContainer = document.getElementById('qrcode-container-signed');
const signedImg = document.getElementById('qrcode-img-signed');
if (signedContainer) {
signedImg.src = qrcodeImage;
signedContainer.classList.remove('hidden');
}
} else {
document.getElementById('qrcode-container-success')?.classList.add('hidden');
document.getElementById('qrcode-container-signed')?.classList.add('hidden');
}
}
/**
* 处理二维码长按保存(在 PC 端右键保存)
*/
function handleQrcodeLongPress(event) {
event.preventDefault();
const img = event.target;
if (img.src) {
const link = document.createElement('a');
link.href = img.src;
link.download = '入群二维码';
link.click();
}
}
async function sendCheckinSms() {
const phone = document.getElementById('form-phone').value.trim();
const errorDiv = document.getElementById('submit-error');
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) {
errorDiv.textContent = '请输入有效的手机号码';
errorDiv.classList.remove('hidden');
return;
} else {
errorDiv.classList.add('hidden');
}
const btn = document.getElementById('send-checkin-code-btn');
if (!btn) return;
btn.disabled = true;
let count = 60;
const originalText = "发送验证码";
// Show loading state
btn.innerHTML = '<span class="loader" style="width: 14px; height: 14px; border-width: 2px; margin-right: 5px;"></span> 发送中...';
try {
const res = await fetch('/api/send-sms', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({phone: phone})
});
const data = await res.json();
if (data.success) {
btn.innerText = `${count}s`;
const timer = setInterval(() => {
count--;
btn.innerText = `${count}s`;
if (count <= 0) {
clearInterval(timer);
btn.disabled = false;
btn.innerText = originalText;
}
}, 1000);
} else {
errorDiv.textContent = data.message || '发送失败';
errorDiv.classList.remove('hidden');
btn.disabled = false;
btn.innerText = originalText;
}
} catch (e) {
errorDiv.textContent = '网络错误';
errorDiv.classList.remove('hidden');
btn.disabled = false;
btn.innerText = originalText;
}
}
</script>
</body>

104
templates/success.html Normal file
View File

@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>报名成功 - {{ config.event_title }}</title>
<style>
:root {
--primary-color: {{ config.primary_color }};
--secondary-color: {{ config.secondary_color }};
--bg-color: {{ config.bg_color }};
--card-bg: rgba(12, 24, 50, 0.7);
--text-color: #ffffff;
}
body {
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
background-image:
radial-gradient(circle at 50% 0%, #1a3a75 0%, #050814 60%),
radial-gradient(circle at 85% 30%, rgba(0, 242, 255, 0.1) 0%, transparent 40%),
radial-gradient(circle at 15% 70%, rgba(0, 102, 255, 0.15) 0%, transparent 40%);
background-attachment: fixed;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
margin: 0;
}
.card {
background: var(--card-bg);
border-radius: 20px;
padding: 40px;
text-align: center;
max-width: 500px;
width: 100%;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(0, 242, 255, 0.3);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.icon-success {
width: 80px;
height: 80px;
border-radius: 50%;
background: #28a745;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
margin: 0 auto 20px;
box-shadow: 0 0 20px rgba(40, 167, 69, 0.4);
}
h1 {
font-size: 1.8rem;
margin-bottom: 15px;
color: #fff;
}
p {
color: #ccc;
line-height: 1.6;
margin-bottom: 30px;
}
.btn {
display: inline-block;
padding: 12px 30px;
background: linear-gradient(90deg, #0051ff 0%, #00f2ff 100%);
color: white;
text-decoration: none;
border-radius: 25px;
font-weight: bold;
transition: all 0.3s;
box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 25px rgba(0, 242, 255, 0.5);
}
</style>
</head>
<body>
<div class="card">
<div class="icon-success"></div>
<h1>报名成功</h1>
<p>您已成功支付并完成报名!<br>请届时凭手机号或二维码入场。</p>
<a href="/" class="btn">返回首页</a>
</div>
</body>
</html>

638
templates/ticket.html Normal file
View File

@@ -0,0 +1,638 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>购票报名 - {{ config.event_title }}</title>
<script src="/static/js/qrcode.min.js"></script>
<style>
:root {
--primary-color: {{ config.primary_color }};
--secondary-color: {{ config.secondary_color }};
--bg-color: {{ config.bg_color }};
--card-bg: rgba(12, 24, 50, 0.7);
--text-color: #ffffff;
--input-bg: rgba(0, 0, 0, 0.4);
--border-color: rgba(0, 242, 255, 0.3);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
background-image:
radial-gradient(circle at 50% 0%, #1a3a75 0%, #050814 60%),
radial-gradient(circle at 85% 30%, rgba(0, 242, 255, 0.1) 0%, transparent 40%),
radial-gradient(circle at 15% 70%, rgba(0, 102, 255, 0.15) 0%, transparent 40%);
background-attachment: fixed;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
}
.container {
width: 100%;
max-width: 600px;
margin-top: 40px;
margin-bottom: 60px;
animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
header {
text-align: center;
margin-bottom: 40px;
}
h1 {
font-size: 2rem;
margin-bottom: 10px;
background: linear-gradient(180deg, #ffffff 0%, #d0eaff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 900;
text-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}
.subtitle {
font-size: 1rem;
color: var(--primary-color);
letter-spacing: 2px;
opacity: 0.9;
}
.card {
background: var(--card-bg);
border-radius: 20px;
padding: 30px;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid var(--border-color);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.form-group {
margin-bottom: 25px;
}
label {
display: block;
margin-bottom: 10px;
color: var(--primary-color);
font-size: 0.95rem;
font-weight: bold;
}
input[type="text"], input[type="tel"] {
width: 100%;
padding: 15px;
background: var(--input-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
color: white;
font-size: 1.1rem;
outline: none;
transition: all 0.3s;
}
input:focus {
border-color: var(--primary-color);
box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
background: rgba(0, 0, 0, 0.6);
}
.submit-btn {
width: 100%;
padding: 18px;
background: linear-gradient(90deg, #0051ff 0%, #00f2ff 100%);
color: white;
border: none;
border-radius: 12px;
font-size: 1.2rem;
font-weight: bold;
cursor: pointer;
transition: all 0.3s;
box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
margin-top: 20px;
position: relative;
overflow: hidden;
}
.submit-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 25px rgba(0, 242, 255, 0.5);
}
.submit-btn:disabled {
background: #444;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.price-tag {
text-align: center;
margin-bottom: 20px;
font-size: 1.2rem;
color: #fff;
}
.price-amount {
font-size: 2rem;
color: #ffaa00;
font-weight: bold;
margin: 0 5px;
}
#message {
margin-top: 20px;
padding: 15px;
border-radius: 12px;
text-align: center;
display: none;
font-weight: bold;
}
.success {
background: rgba(40, 167, 69, 0.2);
border: 1px solid #28a745;
color: #28a745;
}
.error {
background: rgba(220, 53, 69, 0.2);
border: 1px solid #dc3545;
color: #ff6b6b;
}
.loading {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255,255,255,.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s ease-in-out infinite;
margin-right: 10px;
vertical-align: middle;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Modal Styles */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: none;
justify-content: center;
align-items: center;
z-index: 1000;
backdrop-filter: blur(5px);
}
.modal-content {
background: #fff;
padding: 30px;
border-radius: 15px;
text-align: center;
max-width: 90%;
width: 400px;
position: relative;
box-shadow: 0 0 30px rgba(0, 242, 255, 0.2);
}
.modal-close {
position: absolute;
top: 10px;
right: 15px;
font-size: 24px;
cursor: pointer;
color: #333;
}
#qrcode {
margin: 20px auto;
display: flex;
justify-content: center;
}
.modal-title {
color: #333;
margin-bottom: 10px;
font-size: 1.2rem;
font-weight: bold;
}
.modal-tip {
color: #666;
font-size: 0.9rem;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>{{ config.event_title }}</h1>
<div class="subtitle">在线报名通道</div>
</header>
<div class="card">
<div class="price-tag">
报名费用 <span class="price-amount">¥{{ config.payment_amount }}</span>
</div>
<form id="paymentForm" onsubmit="handlePayment(event)">
<!-- 动态渲染报名字段 -->
<div id="registration_fields">
<!-- Fields will be rendered dynamically by JavaScript -->
</div>
<button type="submit" class="submit-btn" id="submitBtn">
立即支付报名
</button>
</form>
<div id="message"></div>
</div>
</div>
<!-- QR Code Modal -->
<div id="qrModal" class="modal-overlay">
<div class="modal-content">
<span class="modal-close" onclick="closeModal()">&times;</span>
<div class="modal-title">微信扫码支付</div>
<div style="margin: 15px 0; color: #28a745; font-weight: bold; font-size: 1.1rem;">
<span style="display:inline-block; margin-right:5px; vertical-align:middle;">📱</span>
请使用微信“扫一扫”
</div>
<div id="qrcode"></div>
<div id="payment-status" style="color: #666; font-size: 14px; margin-top: 15px;">等待支付...</div>
</div>
</div>
<script>
// 字段配置(从后端传入)
var ticketFieldConfig = {{ config.ticket_field_config | tojson | safe }};
var enableSmsVerification = {{ 'true' if config.enable_sms_verification else 'false' }};
// 字段渲染顺序(锁定字段优先)
var lockedFields = ['name', 'phone'];
// 页面加载完成后渲染字段
window.addEventListener('DOMContentLoaded', function() {
renderRegistrationFields();
});
function renderRegistrationFields() {
var container = document.getElementById('registration_fields');
if (!container) return;
container.innerHTML = '';
// 定义字段渲染顺序
var orderedKeys = Object.keys(ticketFieldConfig).sort(function(a, b) {
// 锁定字段优先
var aLocked = lockedFields.indexOf(a) !== -1;
var bLocked = lockedFields.indexOf(b) !== -1;
if (aLocked && !bLocked) return -1;
if (!aLocked && bLocked) return 1;
return 0;
});
// 按顺序渲染字段
orderedKeys.forEach(function(key) {
var field = ticketFieldConfig[key];
if (!field || !field.show) return;
var div = document.createElement('div');
div.className = 'form-group';
// 创建标签
var label = document.createElement('label');
label.textContent = field.label + (field.required ? ' *' : '');
// 创建输入框
var inputHtml = '';
if (key === 'phone') {
// 手机号特殊处理
inputHtml = '<input type="tel" id="' + key + '"' + (field.required ? ' required' : '') + ' placeholder="请输入' + field.label + '" pattern="[0-9]{11}">';
if (enableSmsVerification) {
inputHtml += '<div style="display: flex; gap: 10px; margin-top: 10px;">' +
'<input type="text" id="verification_code" placeholder="请先发送验证码" style="flex: 1;" disabled>' +
'<button type="button" id="send-code-btn" onclick="sendSmsCode()" style="width: auto; padding: 10px; font-size: 0.9rem; background: var(--secondary-color); margin-top: 0; border: none; border-radius: 8px; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; min-width: 100px;">发送验证码</button>' +
'</div>';
}
} else {
inputHtml = '<input type="text" id="' + key + '"' + (field.required ? ' required' : '') + ' placeholder="请输入' + field.label + '">';
}
div.appendChild(label);
div.insertAdjacentHTML('beforeend', inputHtml);
container.appendChild(div);
});
// 初始化按钮状态
updateSubmitButtonState();
}
var pollTimer = null;
var isCodeVerified = false;
function updateSubmitButtonState() {
const btn = document.getElementById('submitBtn');
const codeInput = document.getElementById('verification_code');
// Only update if not in loading state (checking innerHTML for loading spinner)
if (btn.innerHTML.includes('loading')) return;
if (codeInput) {
if (isCodeVerified && codeInput.value.trim().length === 4) {
btn.disabled = false;
} else {
btn.disabled = true;
}
} else {
btn.disabled = false;
}
}
async function verifyCode() {
const codeInput = document.getElementById('verification_code');
const phoneInput = document.getElementById('phone');
if (!codeInput) return;
const code = codeInput.value.trim();
const phone = phoneInput ? phoneInput.value.trim() : '';
if (code.length === 4 && phone) {
try {
const res = await fetch('/api/verify-sms-code', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({phone: phone, code: code})
});
const data = await res.json();
if (data.success) {
isCodeVerified = true;
showMessage('验证码正确', 'success');
} else {
isCodeVerified = false;
showMessage('验证码错误', 'error');
}
} catch(e) {
isCodeVerified = false;
}
} else {
isCodeVerified = false;
}
updateSubmitButtonState();
}
function closeModal() {
document.getElementById('qrModal').style.display = 'none';
if (pollTimer) clearInterval(pollTimer);
document.getElementById('qrcode').innerHTML = '';
// Reset button state
const btn = document.getElementById('submitBtn');
btn.innerHTML = '立即支付报名';
updateSubmitButtonState();
}
// Initialize button state on load
window.addEventListener('DOMContentLoaded', () => {
const codeInput = document.getElementById('verification_code');
const phoneInput = document.getElementById('phone');
if (codeInput) {
updateSubmitButtonState();
codeInput.addEventListener('input', verifyCode);
}
if (phoneInput) {
phoneInput.addEventListener('input', () => {
isCodeVerified = false;
updateSubmitButtonState();
});
}
});
async function handlePayment(e) {
e.preventDefault();
var btn = document.getElementById('submitBtn');
var msg = document.getElementById('message');
var originalText = "立即支付报名";
// Validate - 收集所有动态字段
var getVal = function(id) {
var el = document.getElementById(id);
return el ? el.value.trim() : '';
};
// 验证必填字段
var hasError = false;
Object.keys(ticketFieldConfig).forEach(function(key) {
var field = ticketFieldConfig[key];
if (field && field.required) {
var value = getVal(key);
if (!value) {
hasError = true;
}
}
});
if (hasError) {
showMessage('请填写所有必填项', 'error');
return;
}
// Loading State
btn.disabled = true;
btn.innerHTML = '<span class="loading"></span> 处理中...';
msg.style.display = 'none';
// 收集所有字段数据
var data = {
name: getVal('name'),
phone: getVal('phone'),
verification_code: getVal('verification_code')
};
// 添加所有动态字段
Object.keys(ticketFieldConfig).forEach(function(key) {
if (key !== 'name' && key !== 'phone') {
data[key] = getVal(key);
}
});
// Check Screen Width
var isWideScreen = window.innerWidth > 768;
var apiEndpoint = isWideScreen ? '/api/payment/native' : '/api/payment/h5';
try {
const res = await fetch(apiEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await res.json();
if (result.success) {
if (isWideScreen && result.code_url) {
// Show Native Pay QR Code
document.getElementById('qrModal').style.display = 'flex';
document.getElementById('qrcode').innerHTML = ''; // Clear previous
new QRCode(document.getElementById("qrcode"), {
text: result.code_url,
width: 200,
height: 200
});
// Start Polling
startPolling(result.out_trade_no);
} else if (result.h5_url) {
// H5 Redirect
showMessage('正在跳转支付...', 'success');
window.location.href = result.h5_url;
} else {
throw new Error('未获取到支付链接');
}
} else {
showMessage(result.message || '支付请求失败', 'error');
btn.innerHTML = originalText;
updateSubmitButtonState();
}
} catch (err) {
console.error(err);
showMessage(err.message || '网络请求错误,请重试', 'error');
btn.innerHTML = originalText;
updateSubmitButtonState();
}
}
function startPolling(out_trade_no) {
const statusDiv = document.getElementById('payment-status');
let attempts = 0;
const maxAttempts = 600; // 30 mins max
if (pollTimer) clearInterval(pollTimer);
pollTimer = setInterval(async () => {
attempts++;
if (attempts > maxAttempts) {
clearInterval(pollTimer);
statusDiv.textContent = '支付超时,请刷新重试';
return;
}
try {
const res = await fetch(`/api/payment/check/${out_trade_no}`);
const data = await res.json();
if (data.success && data.trade_state === 'SUCCESS') {
clearInterval(pollTimer);
statusDiv.textContent = '支付成功!正在跳转...';
statusDiv.style.color = '#28a745';
setTimeout(() => {
window.location.href = '/success';
}, 1000);
}
} catch (e) {
console.error("Polling error", e);
}
}, 3000);
}
function showMessage(text, type) {
const msg = document.getElementById('message');
msg.textContent = text;
msg.className = type;
msg.style.display = 'block';
}
async function sendSmsCode() {
const phone = document.getElementById('phone').value.trim();
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) {
showMessage('请输入有效的手机号码', 'error');
return;
}
const btn = document.getElementById('send-code-btn');
const codeInput = document.getElementById('verification_code');
if (!btn) return;
btn.disabled = true;
const originalText = "发送验证码";
// 添加loading效果
btn.innerHTML = '<span class="loading" style="width: 14px; height: 14px; border-width: 2px; margin-right: 6px;"></span>发送中';
let count = 60;
try {
const res = await fetch('/api/send-sms', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({phone: phone})
});
const data = await res.json();
if (data.success) {
showMessage('验证码已发送', 'success');
// 成功后才允许输入验证码
if (codeInput) {
codeInput.disabled = false;
codeInput.placeholder = "请输入验证码";
codeInput.focus();
}
btn.innerText = `${count}s`;
const timer = setInterval(() => {
count--;
btn.innerText = `${count}s`;
if (count <= 0) {
clearInterval(timer);
btn.disabled = false;
btn.innerText = originalText;
}
}, 1000);
} else {
showMessage(data.message || '发送失败', 'error');
btn.disabled = false;
btn.innerText = originalText;
}
} catch (e) {
console.error(e);
showMessage('网络错误', 'error');
btn.disabled = false;
btn.innerText = originalText;
}
}
</script>
</body>
</html>

890
templates/wall.html Normal file
View File

@@ -0,0 +1,890 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ config.event_title }} - 签到大屏</title>
<style>
:root {
--primary-color: {{ config.primary_color }};
--secondary-color: {{ config.secondary_color }};
--bg-color: {{ config.bg_color }};
--card-bg: rgba(12, 24, 50, 0.6);
--text-color: #ffffff;
--header-img: url('{{ config.header_image }}');
--bg-opacity: {{ config.wall_config.bg_opacity if config.wall_config and config.wall_config.bg_opacity is not none else 0.3 }};
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
overflow: hidden;
height: 100vh;
width: 100vw;
position: relative;
}
/* Simplified Background */
.bg-layer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: var(--header-img);
background-size: cover;
background-position: center;
opacity: var(--bg-opacity);
z-index: -3;
/* Dynamic blur: no blur if opacity is 1 */
filter: {{ 'none' if config.wall_config and config.wall_config.bg_opacity == 1 else 'blur(10px)' }};
}
/* Subtle overlay to ensure text contrast */
.clean-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.2);
z-index: -2;
}
/* Header */
header {
position: absolute;
top: 30px;
left: 0;
width: 100%;
text-align: center;
z-index: 20; /* Above bubbles */
pointer-events: none; /* Let clicks pass through */
}
h1 {
font-size: 3rem;
color: #ffffff;
font-weight: 900;
text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
margin: 0;
letter-spacing: 2px;
}
.subtitle {
font-size: 1.2rem;
color: var(--primary-color);
letter-spacing: 4px;
text-transform: uppercase;
margin-bottom: 10px;
opacity: 0.9;
text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
/* Container for User Bubbles */
#bubble-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
overflow: hidden;
}
.user-bubble {
position: absolute;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 60px;
height: 60px; /* Reduced from 80px */
transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease;
will-change: transform, left, top;
}
.bubble-avatar {
width: 100%; /* Fill container */
height: 100%; /* Fill container */
border-radius: 50%;
background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
border: 2px solid rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 0.9rem; /* Reduced font size */
color: #fff;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
margin-bottom: 0; /* Removed margin */
overflow: hidden;
text-align: center;
padding: 2px;
line-height: 1.1;
word-break: break-all;
}
.bubble-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.bubble-name {
font-size: 0.9rem;
color: #fff;
text-shadow: 0 2px 4px rgba(0,0,0,0.8);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100px;
text-align: center;
background: rgba(0,0,0,0.3);
padding: 2px 6px;
border-radius: 10px;
}
/* 座位标签样式 */
.bubble-seat {
position: absolute;
top: -8px;
right: -8px;
background: linear-gradient(135deg, #ff6b6b, #ff4757);
color: white;
font-size: 0.65rem;
font-weight: bold;
padding: 2px 6px;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
white-space: nowrap;
border: 2px solid rgba(255, 255, 255, 0.8);
}
/* Central Spotlight Card */
.spotlight-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -45%);
width: 80%;
max-width: 900px;
z-index: 10;
pointer-events: none;
}
.spotlight-card {
background: rgba(10, 20, 40, 0.85);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 20px;
padding: 50px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
text-align: center;
opacity: 0;
transform: scale(0.9) translateY(20px);
transition: all 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.spotlight-card.active {
opacity: 1;
transform: scale(1) translateY(0);
}
.user-info {
font-size: 1.8rem;
color: #b0c4de;
margin-bottom: 30px;
display: flex;
align-items: center;
justify-content: center;
gap: 15px;
}
.user-avatar-large {
width: 80px;
height: 80px;
border-radius: 50%;
background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 2rem;
color: #fff;
border: 3px solid rgba(255,255,255,0.5);
}
.company-name {
font-size: 3rem;
font-weight: 800;
color: #fff;
margin-bottom: 20px;
background: linear-gradient(90deg, #fff, #b3d9ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.card-position {
font-size: 1.2rem;
color: var(--primary-color);
margin-bottom: 15px;
}
.card-vision {
font-size: 1.4rem;
color: #dbe4ff;
font-style: italic;
margin-top: 15px;
}
.card-scope {
font-size: 1.2rem;
color: #dbe4ff;
margin-top: 10px;
}
.card-custom-field {
font-size: 1.2rem;
color: #dbe4ff;
margin-top: 10px;
padding: 8px 15px;
background: rgba(255,255,255,0.05);
border-radius: 8px;
display: inline-block;
}
/* Stats Counter */
.stats-counter {
position: absolute;
bottom: 30px;
right: 40px;
text-align: right;
z-index: 20;
background: rgba(0,0,0,0.3);
padding: 10px 20px;
border-radius: 10px;
border: 1px solid rgba(255,255,255,0.1);
}
.stats-number {
font-size: 2rem;
font-weight: bold;
color: var(--primary-color);
}
.stats-label {
font-size: 0.8rem;
color: #aaa;
}
/* 二维码容器 */
.qrcode-container {
position: fixed;
top: 50%;
right: 40px;
transform: translateY(-50%);
z-index: 25;
animation: fadeInUp 0.6s ease-out;
}
.qrcode-box {
background: rgba(10, 20, 40, 0.9);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 2px solid rgba(0, 242, 255, 0.5);
border-radius: 16px;
padding: 20px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 255, 0.2);
}
.qrcode-title {
font-size: 1rem;
font-weight: bold;
color: #fff;
text-align: center;
margin-bottom: 12px;
text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}
.qrcode-image {
width: 150px;
height: 150px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(-50%) translateX(20px);
}
to {
opacity: 1;
transform: translateY(-50%) translateX(0);
}
}
/* Mobile Learn More Button */
.mobile-btn-container {
display: none;
position: absolute;
bottom: 80px;
left: 50%;
transform: translateX(-50%);
z-index: 30;
width: 80%;
text-align: center;
}
.learn-more-btn {
background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
color: white;
padding: 12px 30px;
border-radius: 50px;
text-decoration: none;
font-weight: bold;
box-shadow: 0 5px 20px rgba(0, 242, 255, 0.4);
display: inline-block;
transition: transform 0.3s;
}
.learn-more-btn:active {
transform: scale(0.95);
}
/* Mobile Optimization */
@media (max-width: 768px) {
.mobile-btn-container {
display: block;
}
h1 {
font-size: 1.8rem;
}
.subtitle {
font-size: 0.8rem;
letter-spacing: 2px;
}
.spotlight-card {
padding: 20px;
width: 90%;
}
.company-name {
font-size: 1.5rem;
}
.user-info {
font-size: 1.2rem;
flex-direction: column;
gap: 5px;
}
.user-avatar-large {
width: 60px;
height: 60px;
font-size: 1.5rem;
}
.stats-counter {
bottom: 10px;
right: 10px;
padding: 5px 10px;
}
.stats-number {
font-size: 1.5rem;
}
.qrcode-container {
position: fixed;
top: auto;
bottom: 80px;
right: 50%;
transform: translateX(50%);
}
.qrcode-box {
padding: 12px;
}
.qrcode-title {
font-size: 0.9rem;
}
.qrcode-image {
width: 100px;
height: 100px;
}
}
</style>
</head>
<body>
{% set wc = config.wall_config if config.wall_config else {} %}
{% if wc.show_title != false %}
<header>
<div class="subtitle">{{ config.event_sub_title }}</div>
<h1>{{ config.event_title }}</h1>
</header>
{% endif %}
<div class="bg-layer"></div>
<div class="clean-overlay"></div>
<div id="bubble-container"></div>
{% set wc = config.wall_config if config.wall_config else {} %}
{% set show = wc.show_fields if wc.show_fields else {} %}
<div class="spotlight-container">
<div class="spotlight-card" id="card">
<div class="user-info" id="card-header">
<div class="user-avatar-large" id="card-avatar">?</div>
<div>
<span id="card-name" style="font-weight: bold; color: white;"></span>
</div>
</div>
<div id="card-fields" style="margin-top: 20px;">
<!-- 动态字段将在这里渲染 -->
</div>
</div>
</div>
<!-- 扫码签到二维码 -->
<div class="qrcode-container" id="qrcode-container" style="display: none;">
<div class="qrcode-box">
<div class="qrcode-title">扫码签到</div>
<img src="/static/qrcode.png" alt="签到二维码" class="qrcode-image" id="wall-qrcode">
</div>
</div>
{% if wc.learn_more_url %}
<div class="mobile-btn-container">
<a href="{{ wc.learn_more_url }}" class="learn-more-btn" target="_blank">了解我们</a>
</div>
{% endif %}
<div class="stats-counter">
<div class="stats-number" id="checkin-count">0</div>
<div class="stats-label">已签到嘉宾</div>
</div>
<script>
// --- Configuration ---
const CONFIG = {
gridThreshold: 20, // Switch to grid when users > 20
maxDisplay: 30, // Maximum bubbles to display at once
rotationInterval: 10000, // Rotation interval in ms (10s)
bubbleSize: 60, // Width of bubble
bubbleHeight: 60, // Height of bubble
speed: 1.5, // Floating speed
};
const isMobile = () => window.innerWidth <= 768;
// 大屏显示字段配置(从后端获取)
const WALL_SHOW_FIELDS = {{ config.wall_config.show_fields | tojson if config.wall_config and config.wall_config.show_fields else '{}' }};
const CHECKIN_FIELD_CONFIG = {{ config.checkin_field_config | tojson if config.checkin_field_config else '{}' }};
const WALL_CONFIG = {{ config.wall_config | tojson if config.wall_config else '{}' }};
// --- State ---
let allUsers = []; // All fetched users
let displayedUsers = []; // Currently displayed users
let bubbles = []; // Array of UserBubble instances
let currentIndex = 0; // For spotlight
let rotationIndex = 0; // For batch rotation
let rotationTimer = null;
let isGridMode = false;
const container = document.getElementById('bubble-container');
let width = window.innerWidth;
let height = window.innerHeight;
window.addEventListener('resize', () => {
width = window.innerWidth;
height = window.innerHeight;
if (isGridMode) arrangeGrid();
});
// 控制二维码显示/隐藏
const qrcodeContainer = document.getElementById('qrcode-container');
if (qrcodeContainer) {
// 如果 show_qrcode 为 true 则显示,默认为 false
if (WALL_CONFIG.show_qrcode === true) {
qrcodeContainer.style.display = 'block';
}
}
// 随机图标列表
const RANDOM_ICONS = ['🎯', '⭐', '🌟', '💫', '✨', '🎊', '🎉', '🎈', '🚀', '💎', '🏆', '🎖️', '🌈', '🦄', '🎪', '🎨', '🎭', '🎪', '🎯', '🎲'];
// --- Class: UserBubble ---
class UserBubble {
constructor(user) {
this.user = user;
this.id = user.gsdh_id || user.name + Math.random(); // Fallback ID
this.element = document.createElement('div');
this.element.className = 'user-bubble';
const showName = WALL_SHOW_FIELDS.name !== false;
let bubbleContent;
let fontSize = '0.9rem';
if (showName) {
const name = user.name || '嘉宾';
if (name.length > 3) fontSize = '0.7rem';
if (name.length > 4) fontSize = '0.6rem';
bubbleContent = name;
} else {
const randomIndex = Math.floor(Math.random() * RANDOM_ICONS.length);
bubbleContent = RANDOM_ICONS[randomIndex];
fontSize = '1.5rem';
}
this.element.innerHTML = `
<div class="bubble-avatar" style="font-size: ${fontSize}">${bubbleContent}</div>
`;
// 显示座位信息(如果启用且用户有座位号)
if (WALL_CONFIG.show_seating === true && user.location) {
const seatElement = document.createElement('div');
seatElement.className = 'bubble-seat';
seatElement.textContent = user.location;
this.element.appendChild(seatElement);
}
// Interaction: Click to show in spotlight
this.element.style.cursor = 'pointer';
this.element.addEventListener('click', (e) => {
e.stopPropagation();
showUserManual(this.user);
});
// Initial Fade In
this.element.style.opacity = '0';
container.appendChild(this.element);
// Trigger reflow for transition
requestAnimationFrame(() => {
this.element.style.opacity = '1';
});
// Initial Position (Random)
this.x = Math.random() * (width - CONFIG.bubbleSize);
this.y = Math.random() * (height - CONFIG.bubbleHeight);
// Velocity for floating
this.vx = (Math.random() - 0.5) * CONFIG.speed;
this.vy = (Math.random() - 0.5) * CONFIG.speed;
// Set initial DOM position
this.updatePosition();
}
updatePosition() {
this.element.style.transform = `translate(${this.x}px, ${this.y}px)`;
}
float() {
if (isGridMode) return; // Do not float in grid mode
this.x += this.vx;
this.y += this.vy;
// Bounce off edges
if (this.x <= 0 || this.x >= width - CONFIG.bubbleSize) this.vx *= -1;
if (this.y <= 0 || this.y >= height - CONFIG.bubbleHeight) this.vy *= -1;
this.updatePosition();
}
moveTo(targetX, targetY) {
// Use CSS transition for smooth movement to grid
this.x = targetX;
this.y = targetY;
this.updatePosition();
}
remove() {
this.element.style.opacity = '0';
this.element.style.transform = `translate(${this.x}px, ${this.y}px) scale(0.5)`;
setTimeout(() => {
if (this.element.parentNode) {
this.element.parentNode.removeChild(this.element);
}
}, 500); // Wait for transition
}
}
// --- Logic: Layout & Display Manager ---
function updateDisplay() {
// Determine which users to show
let targetUsers = [];
if (allUsers.length <= CONFIG.maxDisplay) {
targetUsers = [...allUsers];
// Reset rotation index if we fit in one page
rotationIndex = 0;
} else {
// Rotation Logic
// If rotationIndex is out of bounds, reset
if (rotationIndex >= allUsers.length) rotationIndex = 0;
// Get slice
targetUsers = allUsers.slice(rotationIndex, rotationIndex + CONFIG.maxDisplay);
// Wrap around if needed (though user asked for "batch", maybe wrapping to fill page is better?)
// If we want to maintain constant count:
if (targetUsers.length < CONFIG.maxDisplay) {
const remaining = CONFIG.maxDisplay - targetUsers.length;
targetUsers = targetUsers.concat(allUsers.slice(0, remaining));
}
}
displayedUsers = targetUsers;
syncBubbles(targetUsers);
// Update Grid/Float mode based on DISPLAYED count (usually maxDisplay if full)
// But config says switch to grid when users > 20.
// If maxDisplay is 30, then 20-30 will be grid.
const count = displayedUsers.length;
const wasGrid = isGridMode;
isGridMode = count > CONFIG.gridThreshold;
if (isGridMode) {
arrangeGrid();
} else if (wasGrid && !isGridMode) {
// Switching back to float, ensure they have random velocities if needed
// But typically we don't go back from grid to float unless people leave.
}
}
function syncBubbles(targetUsers) {
const targetIds = new Set(targetUsers.map(u => u.gsdh_id || u.name));
// 1. Remove bubbles not in target
// Filter bubbles in place
const keptBubbles = [];
for (const b of bubbles) {
if (!targetIds.has(b.id)) {
b.remove();
} else {
keptBubbles.push(b);
}
}
bubbles = keptBubbles;
// 2. Add new bubbles
const currentIds = new Set(bubbles.map(b => b.id));
for (const u of targetUsers) {
const uid = u.gsdh_id || u.name;
if (!currentIds.has(uid)) {
bubbles.push(new UserBubble(u));
}
}
// Re-arrange if grid
if (isGridMode) {
// Delay slightly to let new bubbles exist in DOM?
// arrangeGrid uses 'bubbles' array, so it's fine.
// We might want to call arrangeGrid immediately.
setTimeout(arrangeGrid, 50);
}
}
function arrangeGrid() {
// Simple Grid Algorithm
const count = bubbles.length;
if (count === 0) return;
const cols = Math.ceil(Math.sqrt(count * (width / height)));
const rows = Math.ceil(count / cols);
const cellW = width / cols;
const cellH = height / rows;
bubbles.forEach((bubble, index) => {
const col = index % cols;
const row = Math.floor(index / cols);
// Center in cell
const targetX = col * cellW + (cellW - CONFIG.bubbleSize) / 2;
const targetY = row * cellH + (cellH - CONFIG.bubbleHeight) / 2;
bubble.moveTo(targetX, targetY);
});
}
function startRotationTimer() {
if (rotationTimer) clearInterval(rotationTimer);
rotationTimer = setInterval(() => {
if (allUsers.length > CONFIG.maxDisplay) {
rotationIndex += CONFIG.maxDisplay;
if (rotationIndex >= allUsers.length) rotationIndex = 0;
updateDisplay();
}
}, CONFIG.rotationInterval);
}
// --- Animation Loop ---
function animate() {
if (!isGridMode) {
bubbles.forEach(b => b.float());
}
requestAnimationFrame(animate);
}
animate(); // Start loop
// --- Data Fetching ---
async function fetchData() {
try {
const res = await fetch('/api/wall/data');
const json = await res.json();
if (json.success) {
const fetchedUsers = json.data;
document.getElementById('checkin-count').textContent = fetchedUsers.length;
// Check if new data arrived
if (fetchedUsers.length !== allUsers.length) {
const oldCount = allUsers.length;
allUsers = fetchedUsers;
// If we have more users than before
if (allUsers.length > oldCount) {
// Strategy: If we are rotating, jump to the NEWEST users immediately
// The API returns users sorted by created_at DESC (Newest first).
// So new users are at index 0.
// Wait, API says: ORDER BY created_at DESC
// So new users are at the TOP (0).
// If we want to show new users immediately:
rotationIndex = 0; // Show the first batch (newest)
updateDisplay();
// Reset timer to keep this view for a full interval
startRotationTimer();
// Trigger spotlight for newest
if (currentIndex === 0 && allUsers.length > 0 && !isMobile()) {
// Maybe spotlight the very first one
updateCard(allUsers[0]);
// Restart spotlight loop
startSpotlight();
}
} else {
// Users removed? Just update
updateDisplay();
}
} else {
// Data didn't change count, but maybe content changed?
// For simplicity, assume count change triggers update.
// Or if it's the first load
if (bubbles.length === 0 && allUsers.length > 0) {
updateDisplay();
startRotationTimer();
if (!isMobile()) startSpotlight();
}
}
}
} catch (e) {
console.error("Fetch error", e);
}
}
// --- Spotlight Logic ---
let spotlightInterval = null;
function updateCard(user) {
const card = document.getElementById('card');
card.classList.remove('active');
setTimeout(() => {
const showName = WALL_SHOW_FIELDS.name !== false;
const cardHeader = document.getElementById('card-header');
if (showName) {
cardHeader.style.display = 'flex';
if(document.getElementById('card-name')) document.getElementById('card-name').textContent = user.name || '';
if(document.getElementById('card-avatar')) document.getElementById('card-avatar').textContent = user.name ? user.name.charAt(0) : '?';
} else {
cardHeader.style.display = 'none';
}
renderCardFields(user);
card.classList.add('active');
}, 800);
}
/**
* 根据配置动态渲染卡片字段
*/
function renderCardFields(user) {
const container = document.getElementById('card-fields');
container.innerHTML = '';
let html = '';
Object.keys(WALL_SHOW_FIELDS).forEach(key => {
if (!WALL_SHOW_FIELDS[key]) return;
const fieldConfig = CHECKIN_FIELD_CONFIG[key];
if (!fieldConfig) return;
const fieldValue = user[key] || '';
if (!fieldValue) return;
if (key === 'company_name') {
html += `<div class="company-name">${fieldValue}</div>`;
} else if (key === 'vision_2026') {
html += `<div class="card-vision">🎯 ${fieldValue}</div>`;
} else if (key === 'business_scope') {
html += `<div class="card-scope">${fieldValue}</div>`;
} else if (key === 'position') {
html += `<div class="card-position">${fieldValue}</div>`;
} else {
html += `<div class="card-custom-field">${fieldValue}</div>`;
}
});
container.innerHTML = html;
}
function startSpotlight() {
if (isMobile()) return;
if (spotlightInterval) clearInterval(spotlightInterval);
showNextUser();
spotlightInterval = setInterval(showNextUser, 8000);
}
function showNextUser() {
if (displayedUsers.length === 0) return;
const user = displayedUsers[currentIndex];
currentIndex = (currentIndex + 1) % displayedUsers.length;
updateCard(user);
}
function showUserManual(user) {
// Pause auto-rotation
if (spotlightInterval) clearInterval(spotlightInterval);
// Show clicked user immediately
updateCard(user);
// Resume auto-rotation after 15 seconds (only on desktop)
if (!isMobile()) {
spotlightInterval = setTimeout(() => {
startSpotlight();
}, 15000);
}
}
// Initial Load
fetchData();
setInterval(fetchData, 5000); // Check every 5s
</script>
</body>
</html>

1
vercel.json Normal file
View File

@@ -0,0 +1 @@
{"rewrites":[{"source":"/(.*)","destination":"/index.html"}]}