Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3510505d6 | |||
| 7049071b42 | |||
| e9036d2979 | |||
| 4180eae944 | |||
| 4e4e1ca271 | |||
| 50bb3c45ed | |||
| db1b3baa60 | |||
| df7d51d888 | |||
| 462884a321 | |||
| 48354e634b | |||
| 8152278b86 | |||
| b38b38d0c8 | |||
| 07b81f57a6 | |||
| 1422c04b2c | |||
| 656dfabb29 | |||
| fe688096a4 | |||
| 31703af4f2 | |||
| 4023c789b1 | |||
| a9c6b03c67 | |||
| d8e8bcc9a0 | |||
| 2230a95b45 | |||
| d8a7872cd2 | |||
| 59fc35dad9 | |||
| bd398f154a | |||
| f955ecc71d | |||
| b8aaa51eb1 | |||
| 9b1c92464e | |||
| 2fddd39301 | |||
| 52e5350ba0 | |||
| 81f86d995d | |||
| 1a45822a58 | |||
| d74fc74f28 | |||
| b6323f02eb | |||
| 04b30d0024 | |||
| 13b2a764ef | |||
| 70c4f28eb5 | |||
| d37bbd7a61 | |||
| 4d54c8088c | |||
| 1e8e22c9ed | |||
| d8fb8e3bba | |||
| 214571688c | |||
| 8532776fa1 | |||
| b8667395ac | |||
| 1d1c4ab590 | |||
| 19b087a589 | |||
| 310176a11b | |||
| ef4d22a633 | |||
| 8ee27fdd32 | |||
| a1e1f0b3c3 | |||
| 2fbab1072f |
@@ -22,3 +22,7 @@ coverage/
|
||||
!src/**/*.d.ts
|
||||
/1/
|
||||
playwright.config.d.ts
|
||||
|
||||
# Tool artifacts
|
||||
.omo/
|
||||
.playwright-mcp/
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"sessionID": "ses_15492f54bffepl01q9FkaRyN28",
|
||||
"updatedAt": "2026-06-16T01:20:56.855Z",
|
||||
"updatedAt": "2026-06-19T07:14:26.627Z",
|
||||
"sources": {
|
||||
"background-task": {
|
||||
"state": "idle",
|
||||
"updatedAt": "2026-06-16T01:20:56.855Z"
|
||||
"updatedAt": "2026-06-19T07:14:26.627Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,10 @@ zhiyin/
|
||||
├── zhiyin-app/ # uni-app 3.x 前端 (H5 + 微信小程序)
|
||||
│ └── src/
|
||||
│ ├── pages/ # 20 个页面 (pages.json 路由)
|
||||
│ ├── composables/ # 可复用组合式函数(如 useGravityPurchase)
|
||||
│ ├── services/api.ts # API 调用封装 (uni.request)
|
||||
│ ├── config.ts # 端点定义 + api() 辅助函数
|
||||
│ └── App.vue # 设计 Token + 全局样式
|
||||
│ └── App.vue # 设计 Token + 全局样式 + H5 URL 参数处理
|
||||
└── docs/ # 产品/架构/部署/路线图文档
|
||||
```
|
||||
|
||||
@@ -40,7 +41,7 @@ zhiyin/
|
||||
| `payment` | 微信支付 v3(Native + JSAPI + 回调) |
|
||||
| `progress` | 进步轨迹雷达图 / 打卡日历 / 行业基准 / 岗位匹配 |
|
||||
| `contribution` | 面经贡献 + 公司题库(数据飞轮核心) |
|
||||
| `schedule` | 定时任务:VIP 过期降级、每日一题推送、微信 token 刷新 |
|
||||
| `schedule` | 定时任务:VIP 过期降级、每日一题推送、微信 token 刷新、月度引力值补给 |
|
||||
| `share` | 分享链接生成 / 访问追踪 / 积分奖励 |
|
||||
| `tts` | 语音合成(TTS) |
|
||||
| `admin` | 管理后台 API |
|
||||
@@ -95,16 +96,24 @@ zhiyin/
|
||||
- 主用不可用时自动切换(在 `ai` 模块处理)
|
||||
- 环境变量: `AI_PRIMARY_KEY`, `AI_BACKUP_KEY`
|
||||
|
||||
### 支付(微信支付 v3)
|
||||
- Native 支付(H5 扫码): `POST /payment/create`
|
||||
- JSAPI 支付(小程序内): `POST /payment/jsapi`
|
||||
- 支付回调: `POST /payment/notify`(@Public,验签 + 解密 + 自动开会员)
|
||||
### 支付(微信支付 v3 + 虚拟支付)
|
||||
- Native 支付(H5 扫码): `POST /payment/create-product`(按量购买引力值)
|
||||
- JSAPI 支付(小程序内): `POST /payment/jsapi-product`(按量购买引力值)
|
||||
- 虚拟支付(小程序内直接购买): `POST /virtual-payment/create`(mode=`short_series_coin`,代币名「引力值」,1 币 = 1 元)
|
||||
- 支付回调: `POST /payment/notify`(@Public,验签 + 解密 + 自动到账)
|
||||
- 支付结果轮询: `GET /payment/check/:outTradeNo`
|
||||
- 产品定价: `GET /member/plans`(含 products 字段,定义引力值单价和赠送量)
|
||||
- 需要微信商户证书文件(通过 postbuild 复制到 dist)
|
||||
- **注意**: 当前会员体系已从按月订阅制改为按量购买引力值制(小程序内虚拟支付直接购买,H5 扫码支付)
|
||||
|
||||
---
|
||||
|
||||
## 三、开发命令
|
||||
|
||||
> ⚠️ **构建铁律:必须始终使用 `npm run build:*` 命令,禁止直接调用 `npx uni build` 或 `npx nest build`。**
|
||||
> 前端 `npm run build:mp-weixin` 和 `npm run build:h5` 脚本包含头像文件(`avatar-*.png`)复制步骤,
|
||||
> 后端 `npm run build` 是 `nest build` 的别名。直接使用 `npx` 会遗漏这些关键步骤,导致线上数字人头像不显示等问题。
|
||||
|
||||
### 后端
|
||||
```bash
|
||||
# 路径: backend/
|
||||
@@ -130,12 +139,18 @@ npm test # 前端单元测试(vitest,7 个)
|
||||
### 构建检查
|
||||
```bash
|
||||
# 后端构建(注意 OOM:需 NODE_OPTIONS="--max-old-space-size=2048")
|
||||
cd backend && NODE_OPTIONS="--max-old-space-size=2048" npx nest build
|
||||
cd backend && npm run build
|
||||
```
|
||||
|
||||
### 构建产物说明
|
||||
- **H5 构建** (`npm run build:h5`):自动复制 `avatar-*.png` 到 `static/`,复制 `robots.txt` 和 `sitemap.xml` 到输出根目录
|
||||
- **版本号注入**:`vite.config.js` 中 `define.__APP_VERSION__` 自动从 `git describe --tags` 获取版本号,`about.vue` 页面实时显示
|
||||
- **小程序上传版本** (`scripts/upload-mp.js`):自动从 git tag 获取基础版本,末位自增 1(如 tag v1.0.16 → 上传版本 1.0.17)
|
||||
- **微信分享**:所有主页面均已注册 `onShareAppMessage` + `onShareTimeline`,右上角菜单转发/分享到朋友圈可用
|
||||
|
||||
### 部署后端
|
||||
```bash
|
||||
cd backend && npx nest build
|
||||
cd backend && npm run build
|
||||
cp -rf dist/* /www/wwwroot/server/zhiyin/backend/dist/
|
||||
cp -r certs /www/wwwroot/server/zhiyin/backend/dist/src/certs
|
||||
pm2 restart yhl-backend
|
||||
@@ -144,18 +159,22 @@ sleep 3 && curl -s http://localhost:3006/api/user/wx-login -X POST -H "Content-T
|
||||
|
||||
### 部署前端 H5
|
||||
```bash
|
||||
cd zhiyin-app && npx uni build
|
||||
cd zhiyin-app && npm run build:h5
|
||||
rm -rf /www/wwwroot/zhiyin.yzrcloud.cn/assets
|
||||
cp -r dist/build/h5/index.html /www/wwwroot/zhiyin.yzrcloud.cn/
|
||||
cp -r dist/build/h5/assets /www/wwwroot/zhiyin.yzrcloud.cn/
|
||||
chown -R www:www /www/wwwroot/zhiyin.yzrcloud.cn/index.html /www/wwwroot/zhiyin.yzrcloud.cn/assets
|
||||
cp -r dist/build/h5/static /www/wwwroot/zhiyin.yzrcloud.cn/
|
||||
cp -f dist/build/h5/robots.txt dist/build/h5/sitemap.xml /www/wwwroot/zhiyin.yzrcloud.cn/
|
||||
chown -R www:www /www/wwwroot/zhiyin.yzrcloud.cn/
|
||||
# 验证无缺失文件
|
||||
grep -oP '["'"'"']([a-zA-Z0-9_-]+\.[a-z]+(\.js|\.css|\.png|\.svg))["'"'"']' /www/wwwroot/zhiyin.yzrcloud.cn/assets/index-*.js | sort -u
|
||||
```
|
||||
|
||||
### 小程序上传
|
||||
### 小程序上传(先 build 后 upload,两步分开更安全)
|
||||
```bash
|
||||
cd zhiyin-app && npm run build:mp-weixin && node scripts/upload-mp.js
|
||||
# 注意:build:mp-weixin 已自动复制 avatar-*.png 到 dist/build/mp-weixin/static/
|
||||
# 如遇数字人头像不显示,检查是否漏了 cp 步骤,重新用 npm run build:mp-weixin 构建
|
||||
```
|
||||
|
||||
---
|
||||
@@ -171,26 +190,27 @@ cd zhiyin-app && npm run build:mp-weixin && node scripts/upload-mp.js
|
||||
|
||||
---
|
||||
|
||||
## 五、定时任务(3 个 cron,在 schedule 模块)
|
||||
## 五、定时任务(4 个 cron,在 schedule 模块)
|
||||
|
||||
| 服务 | 周期 | 职责 |
|
||||
|------|------|------|
|
||||
| `VipExpiryService` | 每日 00:00 | 扫描过期 VIP 并降级为 free 计划 |
|
||||
| `DailyQuestionPushService` | 每日 09:00 | 通过微信订阅消息推送每日一题(需配置模板 ID) |
|
||||
| `WechatTokenService` | 每 2 小时 | 刷新微信 access_token(缓存到 Redis) |
|
||||
| `GravityTopUpService` | 每日 02:00 | 给所有未过期的成长版/冲刺版用户补给月度引力值 |
|
||||
|
||||
---
|
||||
|
||||
## 六、项目状态与开发阶段
|
||||
|
||||
**当前**: Phase 0.5 完成,Phase 1(MVP 上线)进行中
|
||||
**当前**: Phase 1.5(商业化 + 全量部署)— v1.0.18(开发中)
|
||||
|
||||
| 阶段 | 状态 | 关键交付 |
|
||||
|------|------|---------|
|
||||
| Phase 0: 战略升级 | ✅ 完成 | 定价重构(免费 + ¥19.9/月),三层壁垒设计 |
|
||||
| Phase 0: 战略升级 | ✅ 完成 | 定价重构(免费 + 按量购买),三层壁垒设计 |
|
||||
| Phase 0.5: 壁垒构建 | ✅ 完成 | 数据飞轮(面经贡献+题库),留存入围(进步轨迹+打卡日历+每日一题) |
|
||||
| Phase 1: MVP 上线 | 🚧 当前 | 小程序 v1.0.11 已上传、H5 已部署、生产模式已启用、SMTP 邮箱验证码已配置 |
|
||||
| Phase 1.5: 商业化 | 📋 规划 | 冲刺版 ¥49.9/月、每日一题定时推送、PMF 验证 |
|
||||
| Phase 1: MVP 上线 | ✅ 完成 | 面试复盘(whisper.cpp ASR + AI 评析)、AI 择业顾问 |
|
||||
| Phase 1.5: 商业化 | 🚧 当前 | 按量购买引力值(¥5/份)、管理后台完善、H5/小程序全量部署上线、清理脚本 |
|
||||
| Phase 2: 增强 + 题库 | 📋 规划 | 50+ 校招岗位、技能缺口分析、公司真题库建设 |
|
||||
| Phase 3: 秋招冲刺 | 📋 规划 | 高校合作、B 端服务、KOC 推广 |
|
||||
|
||||
@@ -240,7 +260,7 @@ VITE_APP_NAME=AI磁场
|
||||
| 账号 | 密码 | 角色 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `13701190814@139.com` | `Zhiyin2024!` | admin | 管理员,可访问管理后台 |
|
||||
| `test@yzrcloud.cn` | `123456` | user | 测试账号 |
|
||||
| `test@yzrcloud.cn` | `123456` | user | 测试账号(普通用户,含 5 引力值) |
|
||||
| `test@test.com` | 验证码 `123456` | admin | 旧管理员(dev 模式可用) |
|
||||
|
||||
管理后台路径:`/pages/admin/admin`,进入后自动验证管理员身份(`onMounted` → `doVerify`)。
|
||||
@@ -251,7 +271,7 @@ VITE_APP_NAME=AI磁场
|
||||
|
||||
- 远程仓库: `http://127.0.0.1:2999/txai-dev/zhiyin.git`(本机 Gitea,带 token 认证)
|
||||
- 默认分支: `master`
|
||||
- 最新 tag: `v1.0.11`(小程序上传版本号源自 git tag)
|
||||
- 最新 tag: `v1.0.17`(小程序上传版本 v1.0.18 源自 git tag v1.0.17 + 末位自增 1)
|
||||
|
||||
---
|
||||
|
||||
@@ -265,9 +285,12 @@ VITE_APP_NAME=AI磁场
|
||||
6. **API 限流**: 100 次/60 秒(在 `app.module.ts` 中配置),注意避免在定时任务和批量操作中被限
|
||||
7. **验证码**: 生产模式(`NODE_ENV=production`)使用真实 SMTP 发邮件验证码;非生产模式手机验证码固定为 `123456`、邮件验证码在响应中返回 `devCode`
|
||||
8. **MongoDB**: 8 个核心集合 + 2 个分享集合
|
||||
9. **api.ts 陷阱**: 对象字面量必须在 `export const apiService = {` 或 `const apiService = { ... export default apiService` 中包裹,否则 uni-app 构建报错 `Expected ";" but found ":"`。git pull 后经常丢失这行声明,需手动补回
|
||||
10. **H5 构建 assets 清理**: `assets/` 中的旧 hash 文件不能随意删除——`index-*.js`(主 bundle)动态 import 了所有 page chunk,删除仍在引用的文件会导致浏览器 `NS_ERROR_CORRUPTED_CONTENT`
|
||||
11. **管理后台自动验证**: `admin.vue` 中 `onMounted` 自动调用 `doVerify()`,进入后台即检测 JWT 中 `role` 是否为 `admin`,不再需要手动点击"验证管理员身份"按钮
|
||||
9. **引力值体系**: 所有计划统一走引力值消耗(面试 5、优化 3、下载 2)。VIP 不再免额度,成长版每月赠送 80 引力值,冲刺版每月赠送 200 引力值,每日凌晨 2 点定时补给。免费用户注册送 5 引力值。小程序内通过分享得引力值/贡献面经/虚拟支付购买三种方式获取引力值;H5 直接扫码支付按量购买(¥5/份)。
|
||||
10. **api.ts 陷阱**: 对象字面量必须在 `export const apiService = {` 或 `const apiService = { ... export default apiService` 中包裹,否则 uni-app 构建报错 `Expected ";" but found ":"`。git pull 后经常丢失这行声明,需手动补回
|
||||
11. **H5 构建 assets 清理**: `assets/` 中的旧 hash 文件不能随意删除——`index-*.js`(主 bundle)动态 import 了所有 page chunk,删除仍在引用的文件会导致浏览器 `NS_ERROR_CORRUPTED_CONTENT`
|
||||
12. **管理后台自动验证**: `admin.vue` 中 `onMounted` 自动调用 `doVerify()`,进入后台即检测 JWT 中 `role` 是否为 `admin`,不再需要手动点击"验证管理员身份"按钮
|
||||
13. **分享重定向路由**: `share.controller.ts` 中 `GET /api/share/:shareCode` 是公开路由(泛匹配,放最后避免拦截其他路由),访问时记录访问者 IP → 302 重定向到 H5 首页
|
||||
14. **小程序官网购买走剪贴板**: 小程序内"官网购买"不再使用 webview 内嵌 H5,改为 `uni.setClipboardData` 复制带 JWT token 的 URL 到剪贴板,提示用户在手机浏览器中打开购买(`App.vue` 的 `handleH5UrlParams` 解析 `?token=` 和 `?buy=gravity` 参数自动登录跳转)
|
||||
|
||||
---
|
||||
|
||||
@@ -295,7 +318,7 @@ VITE_APP_NAME=AI磁场
|
||||
|
||||
### Step 4: 测试验证
|
||||
```bash
|
||||
cd backend && NODE_OPTIONS="--max-old-space-size=2048" npx nest build
|
||||
cd backend && npm run build
|
||||
npm test -- --forceExit --detectOpenHandles
|
||||
```
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "zhiyin-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "职引 - AI简历优化后端服务",
|
||||
"description": "宇之然AI磁场 - AI简历优化后端服务",
|
||||
"main": "dist/src/main.js",
|
||||
"scripts": {
|
||||
"start": "nest start",
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
* 测试数据清理脚本
|
||||
* 识别并清理测试用户及其关联数据(订单/面试/简历/分享)
|
||||
* 保留所有管理员账号
|
||||
*
|
||||
* 用法:
|
||||
* 预览模式(推荐先执行): npx ts-node --project tsconfig.json scripts/cleanup-test-data.ts
|
||||
* 执行清理: npx ts-node --project tsconfig.json scripts/cleanup-test-data.ts --execute
|
||||
*/
|
||||
import { NestFactory } from '@nestjs/core'
|
||||
import { AppModule } from '../src/app.module'
|
||||
import { getModelToken } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { User, UserDocument } from '../src/modules/user/user.schema'
|
||||
import { Interview, InterviewDocument } from '../src/modules/interview/interview.schema'
|
||||
import { Resume, ResumeDocument } from '../src/modules/resume/resume.schema'
|
||||
import { PaymentOrder, PaymentOrderDocument } from '../src/modules/payment/payment-order.schema'
|
||||
import { ShareRecord, ShareRecordDocument, ShareVisit, ShareVisitDocument } from '../src/modules/share/share.schema'
|
||||
|
||||
// 已知测试账号(保留这些不清理——防止误伤真实用户)
|
||||
const KNOWN_TEST_ACCOUNTS = [
|
||||
'test@yzrcloud.cn',
|
||||
'test@test.com',
|
||||
]
|
||||
|
||||
// 管理员账号(始终保留)
|
||||
const ADMIN_EMAILS = [
|
||||
'13701190814@139.com',
|
||||
]
|
||||
|
||||
async function bootstrap() {
|
||||
const isExecute = process.argv.includes('--execute')
|
||||
const app = await NestFactory.createApplicationContext(AppModule)
|
||||
|
||||
const userModel = app.get<Model<UserDocument>>(getModelToken(User.name))
|
||||
const interviewModel = app.get<Model<InterviewDocument>>(getModelToken(Interview.name))
|
||||
const resumeModel = app.get<Model<ResumeDocument>>(getModelToken(Resume.name))
|
||||
const orderModel = app.get<Model<PaymentOrderDocument>>(getModelToken(PaymentOrder.name))
|
||||
const shareModel = app.get<Model<ShareRecordDocument>>(getModelToken(ShareRecord.name))
|
||||
const shareVisitModel = app.get<Model<ShareVisitDocument>>(getModelToken(ShareVisit.name))
|
||||
|
||||
// Step 1: 找到所有管理员(保留)
|
||||
const admins = await userModel.find({ role: 'admin' }).lean().exec()
|
||||
const adminIds = admins.map(a => a._id.toString())
|
||||
const adminEmails = admins.map(a => a.email).filter(Boolean)
|
||||
|
||||
// Step 2: 找到测试用户
|
||||
const allUsers = await userModel.find().sort({ createdAt: -1 }).lean().exec()
|
||||
|
||||
const allAdminEmails = [...new Set([...ADMIN_EMAILS, ...adminEmails])]
|
||||
const knownTestEmails = KNOWN_TEST_ACCOUNTS
|
||||
|
||||
// 测试用户识别策略:
|
||||
// a) 已知测试邮箱
|
||||
// b) 非管理员
|
||||
// 实际用户自己补充识别条件
|
||||
const testUserIds: string[] = []
|
||||
const skippedUserIds: string[] = []
|
||||
|
||||
for (const u of allUsers) {
|
||||
const uid = u._id.toString()
|
||||
// 跳过管理员
|
||||
if (adminIds.includes(uid)) {
|
||||
skippedUserIds.push(uid)
|
||||
continue
|
||||
}
|
||||
|
||||
const userEmail = (u.email || '').toLowerCase().trim()
|
||||
|
||||
// 已知测试邮箱 → 标记为测试
|
||||
if (knownTestEmails.includes(userEmail)) {
|
||||
testUserIds.push(uid)
|
||||
console.log(` [TEST] ${u.phone || '--'} / ${userEmail} / ${u.nickname || '--'}`)
|
||||
continue
|
||||
}
|
||||
|
||||
// 找不到匹配条件的用户属于真正用户
|
||||
skippedUserIds.push(uid)
|
||||
}
|
||||
|
||||
console.log(`\n========================================`)
|
||||
console.log(`总用户: ${allUsers.length}`)
|
||||
console.log(`管理员: ${adminIds.length}`)
|
||||
console.log(`测试用户: ${testUserIds.length}`)
|
||||
console.log(`真实用户: ${skippedUserIds.length}`)
|
||||
console.log(`========================================\n`)
|
||||
|
||||
if (testUserIds.length === 0) {
|
||||
console.log('未发现测试用户,无需清理。')
|
||||
await app.close()
|
||||
return
|
||||
}
|
||||
|
||||
// Step 3: 统计关联数据
|
||||
const testInterviews = await interviewModel.find({ userId: { $in: testUserIds } }).lean().exec()
|
||||
const testResumes = await resumeModel.find({ userId: { $in: testUserIds } }).lean().exec()
|
||||
const testOrders = await orderModel.find({ userId: { $in: testUserIds } }).lean().exec()
|
||||
const testShares = await shareModel.find({ userId: { $in: testUserIds } }).lean().exec()
|
||||
|
||||
console.log('将删除的关联数据:')
|
||||
console.log(` - 面试记录: ${testInterviews.length} 条`)
|
||||
console.log(` - 简历: ${testResumes.length} 条`)
|
||||
console.log(` - 订单: ${testOrders.length} 条`)
|
||||
console.log(` - 分享记录: ${testShares.length} 条`)
|
||||
console.log(` - 用户账号: ${testUserIds.length} 个\n`)
|
||||
|
||||
if (!isExecute) {
|
||||
console.log('⚠️ 预览模式,未执行删除。')
|
||||
console.log(' 确认无误后执行: npx ts-node --project tsconfig.json scripts/cleanup-test-data.ts --execute\n')
|
||||
await app.close()
|
||||
return
|
||||
}
|
||||
|
||||
// Step 4: 执行删除(先删关联数据再删用户)
|
||||
console.log('正在清理...')
|
||||
|
||||
// 分享访问记录(通过分享记录找)
|
||||
const shareIds = testShares.map(s => s._id)
|
||||
if (shareIds.length > 0) {
|
||||
const visits = await shareVisitModel.deleteMany({ shareId: { $in: shareIds } }).exec()
|
||||
console.log(` - 删除分享访问记录: ${visits.deletedCount} 条`)
|
||||
}
|
||||
|
||||
if (testShares.length > 0) {
|
||||
const r = await shareModel.deleteMany({ _id: { $in: shareIds } }).exec()
|
||||
console.log(` - 删除分享记录: ${r.deletedCount} 条`)
|
||||
}
|
||||
|
||||
if (testInterviews.length > 0) {
|
||||
const r = await interviewModel.deleteMany({ _id: { $in: testInterviews.map(i => i._id) } }).exec()
|
||||
console.log(` - 删除面试记录: ${r.deletedCount} 条`)
|
||||
}
|
||||
|
||||
if (testResumes.length > 0) {
|
||||
const r = await resumeModel.deleteMany({ _id: { $in: testResumes.map(r => r._id) } }).exec()
|
||||
console.log(` - 删除简历: ${r.deletedCount} 条`)
|
||||
}
|
||||
|
||||
if (testOrders.length > 0) {
|
||||
const r = await orderModel.deleteMany({ _id: { $in: testOrders.map(o => o._id) } }).exec()
|
||||
console.log(` - 删除订单: ${r.deletedCount} 条`)
|
||||
}
|
||||
|
||||
if (testUserIds.length > 0) {
|
||||
const r = await userModel.deleteMany({ _id: { $in: testUserIds } }).exec()
|
||||
console.log(` - 删除测试用户: ${r.deletedCount} 个`)
|
||||
}
|
||||
|
||||
console.log('\n✅ 清理完成!')
|
||||
await app.close()
|
||||
}
|
||||
|
||||
bootstrap().catch((err) => {
|
||||
console.error('清理失败:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 引力值迁移脚本
|
||||
* 将现有用户的多维额度合并到 gravity 字段
|
||||
* 公式: gravity = interviewCredits×5 + resumeOptimizeCredits×3 + resumeDownloadCredits×2 + shareCredits×1 + remaining×5
|
||||
* 用法: npx ts-node --project tsconfig.json scripts/migrate-gravity.ts
|
||||
*/
|
||||
import { NestFactory } from '@nestjs/core'
|
||||
import { AppModule } from '../src/app.module'
|
||||
import { getModelToken } from '@nestjs/mongoose'
|
||||
import { User, UserDocument } from '../src/modules/user/user.schema'
|
||||
import { Model } from 'mongoose'
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createApplicationContext(AppModule)
|
||||
const userModel = app.get<Model<UserDocument>>(getModelToken(User.name))
|
||||
|
||||
const total = await userModel.countDocuments().exec()
|
||||
console.log(`Total users: ${total}`)
|
||||
|
||||
let migrated = 0
|
||||
let skipped = 0
|
||||
const cursor = userModel.find().cursor()
|
||||
|
||||
for await (const user of cursor) {
|
||||
const interviewVal = (user.interviewCredits ?? 0) * 5
|
||||
const optimizeVal = (user.resumeOptimizeCredits ?? 0) * 3
|
||||
const downloadVal = (user.resumeDownloadCredits ?? 0) * 2
|
||||
const oldRemainVal = (user.remaining ?? 0) * 5
|
||||
const shareVal = (user.shareCredits ?? 0) * 1
|
||||
const totalGravity = interviewVal + optimizeVal + downloadVal + oldRemainVal + shareVal
|
||||
|
||||
if (totalGravity <= 0 && (user.gravity ?? 0) === 0) {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
|
||||
await userModel.findByIdAndUpdate(user._id, {
|
||||
$set: {
|
||||
gravity: Math.max(user.gravity ?? 0, totalGravity),
|
||||
interviewCredits: 0,
|
||||
resumeOptimizeCredits: 0,
|
||||
resumeDownloadCredits: 0,
|
||||
remaining: 0,
|
||||
shareCredits: 0,
|
||||
},
|
||||
}).exec()
|
||||
migrated++
|
||||
}
|
||||
|
||||
console.log(`Migrated: ${migrated}, Skipped (no credits): ${skipped}`)
|
||||
await app.close()
|
||||
}
|
||||
|
||||
bootstrap().catch(console.error)
|
||||
@@ -0,0 +1,55 @@
|
||||
import { connect, disconnect } from 'mongoose'
|
||||
import * as bcrypt from 'bcrypt'
|
||||
import * as dotenv from 'dotenv'
|
||||
import * as path from 'path'
|
||||
|
||||
dotenv.config({ path: path.resolve(__dirname, '../.env') })
|
||||
|
||||
async function main() {
|
||||
const uri = process.env.MONGODB_URI
|
||||
if (!uri) {
|
||||
console.error('MONGODB_URI not set')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const conn = await connect(uri)
|
||||
console.log('Connected to MongoDB')
|
||||
|
||||
const users = conn.connection.db!.collection('users')
|
||||
|
||||
const email = 'test@yzrcloud.cn'
|
||||
const password = '123456'
|
||||
const hashed = await bcrypt.hash(password, 10)
|
||||
|
||||
const existing = await users.findOne({ email })
|
||||
if (existing) {
|
||||
await users.updateOne(
|
||||
{ email },
|
||||
{ $set: { password: hashed, nickname: '测试用户', role: 'user', gravity: 5, interviewCredits: 1, remaining: 3 } }
|
||||
)
|
||||
console.log(`Updated test user: ${email}`)
|
||||
} else {
|
||||
await users.insertOne({
|
||||
email,
|
||||
password: hashed,
|
||||
nickname: '测试用户',
|
||||
role: 'user',
|
||||
gravity: 5,
|
||||
interviewCredits: 1,
|
||||
remaining: 3,
|
||||
interviewCount: 0,
|
||||
plan: 'free',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
console.log(`Created test user: ${email}`)
|
||||
}
|
||||
|
||||
await disconnect()
|
||||
console.log('Done')
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
console.error('Failed:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -9,6 +9,7 @@ import { APP_GUARD } from '@nestjs/core'
|
||||
import { JwtStrategy } from './common/strategies/jwt.strategy'
|
||||
import { JwtAuthGuard } from './common/guards/jwt-auth.guard'
|
||||
import { AiModule } from './modules/ai/ai.module'
|
||||
import { FeedbackModule } from './modules/feedback/feedback.module'
|
||||
import { UserModule } from './modules/user/user.module'
|
||||
import { InterviewModule } from './modules/interview/interview.module'
|
||||
import { ResumeModule } from './modules/resume/resume.module'
|
||||
@@ -25,9 +26,11 @@ import { DailyQuestionModule } from './modules/daily-question/daily-question.mod
|
||||
import { ScheduleModule } from './modules/schedule/schedule.module'
|
||||
import { TtsModule } from './modules/tts/tts.module'
|
||||
import { PricingModule } from './modules/schemas/pricing.module'
|
||||
import { GravityTransactionModule } from './modules/schemas/gravity-transaction.module'
|
||||
import { ShareModule } from './modules/share/share.module'
|
||||
import { InterviewReviewModule } from './modules/interview-review/interview-review.module'
|
||||
import { CareerAdviceModule } from './modules/career-advice/career-advice.module'
|
||||
import { VirtualPaymentModule } from './modules/virtual-payment/virtual-payment.module'
|
||||
|
||||
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin'
|
||||
|
||||
@@ -45,6 +48,7 @@ const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin
|
||||
}]),
|
||||
NestScheduleModule.forRoot(),
|
||||
UserModule,
|
||||
FeedbackModule,
|
||||
AiModule,
|
||||
InterviewModule,
|
||||
AnalyzeModule,
|
||||
@@ -64,6 +68,8 @@ const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin
|
||||
ShareModule,
|
||||
InterviewReviewModule,
|
||||
CareerAdviceModule,
|
||||
VirtualPaymentModule,
|
||||
GravityTransactionModule,
|
||||
],
|
||||
providers: [
|
||||
JwtStrategy,
|
||||
|
||||
@@ -16,7 +16,7 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
||||
|
||||
const message = exception instanceof HttpException
|
||||
? exception.getResponse()
|
||||
: '服务器内部错误';
|
||||
: (exception as Error)?.message || '服务器内部错误';
|
||||
|
||||
const errorResponse = {
|
||||
code: status,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Resume, ResumeDocument } from '../resume/resume.schema'
|
||||
import { PaymentOrder, PaymentOrderDocument } from '../payment/payment-order.schema'
|
||||
import { SiteConfig, SiteConfigDocument } from '../schemas/site-config.schema'
|
||||
import { ShareRecord, ShareRecordDocument, ShareVisit, ShareVisitDocument } from '../share/share.schema'
|
||||
import { Feedback, FeedbackDocument } from '../feedback/feedback.schema'
|
||||
import { QuotaService } from '../user/quota.service'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
import { WechatPayService } from '../payment/wechat-pay.service'
|
||||
@@ -27,6 +28,7 @@ export class AdminController {
|
||||
@InjectModel(ShareRecord.name) private shareModel: Model<ShareRecordDocument>,
|
||||
@InjectModel(ShareVisit.name) private shareVisitModel: Model<ShareVisitDocument>,
|
||||
@InjectModel(Resume.name) private resumeModel: Model<ResumeDocument>,
|
||||
@InjectModel(Feedback.name) private feedbackModel: Model<FeedbackDocument>,
|
||||
private quotaService: QuotaService,
|
||||
private pricingService: PricingService,
|
||||
private wechatPay: WechatPayService,
|
||||
@@ -48,7 +50,7 @@ export class AdminController {
|
||||
const [
|
||||
userCount, interviewCount, todayUsers, todayInterviews,
|
||||
resumeCount, paidDownloadCount,
|
||||
planStats,
|
||||
planStats, orderCount, todayOrders, totalRevenue,
|
||||
] = await Promise.all([
|
||||
this.userModel.countDocuments().exec(),
|
||||
this.interviewModel.countDocuments().exec(),
|
||||
@@ -59,12 +61,19 @@ export class AdminController {
|
||||
this.userModel.aggregate([
|
||||
{ $group: { _id: '$plan', count: { $sum: 1 } } },
|
||||
]).exec(),
|
||||
this.orderModel.countDocuments().exec(),
|
||||
this.orderModel.countDocuments({ status: 'success', createdAt: { $gte: new Date(Date.now() - 24 * 60 * 60 * 1000) } }).exec(),
|
||||
this.orderModel.aggregate([
|
||||
{ $match: { status: 'success' } },
|
||||
{ $group: { _id: null, total: { $sum: '$amount' } } },
|
||||
]).exec(),
|
||||
])
|
||||
const planBreakdown: Record<string, number> = {}
|
||||
planStats.forEach(p => { planBreakdown[p._id || 'free'] = p.count })
|
||||
return {
|
||||
userCount, interviewCount, todayUsers, todayInterviews,
|
||||
resumeCount, paidDownloadCount,
|
||||
resumeCount, paidDownloadCount, orderCount, todayOrders,
|
||||
totalRevenue: totalRevenue[0]?.total || 0,
|
||||
planBreakdown,
|
||||
}
|
||||
}
|
||||
@@ -78,7 +87,13 @@ export class AdminController {
|
||||
filter.$or = [
|
||||
{ phone: { $regex: escaped, $options: 'i' } },
|
||||
{ nickname: { $regex: escaped, $options: 'i' } },
|
||||
{ email: { $regex: escaped, $options: 'i' } },
|
||||
{ wxOpenid: { $regex: escaped, $options: 'i' } },
|
||||
]
|
||||
// 支持按 _id 模糊搜索(ObjectId → string → regex)
|
||||
filter.$or.push({
|
||||
$expr: { $regexMatch: { input: { $toString: '$_id' }, regex: escaped, options: 'i' } },
|
||||
})
|
||||
}
|
||||
const skip = (Math.max(1, +page) - 1) * +limit
|
||||
const [users, total] = await Promise.all([
|
||||
@@ -95,8 +110,8 @@ export class AdminController {
|
||||
this.interviewModel.find()
|
||||
.sort({ createdAt: -1 })
|
||||
.skip(skip).limit(+limit)
|
||||
.populate('userId', 'phone nickname')
|
||||
.select('position status totalScore questionCount fillerScore fillerDensity summary createdAt')
|
||||
.populate('userId', 'phone nickname email wxOpenid')
|
||||
.select('position status totalScore questionCount fillerScore fillerDensity summary createdAt updatedAt')
|
||||
.lean().exec(),
|
||||
this.interviewModel.countDocuments().exec(),
|
||||
])
|
||||
@@ -113,7 +128,7 @@ export class AdminController {
|
||||
expireAt.setDate(expireAt.getDate() + (pricing.plans?.growth?.durationDays || VIP_DURATION_DAYS))
|
||||
user.plan = 'growth'
|
||||
user.vipExpireAt = expireAt
|
||||
await this.quotaService.setPlanQuota(targetUserId, 'growth', credits)
|
||||
await this.quotaService.setPlanQuota(targetUserId, pricing.plans?.growth?.gravityPerMonth || 250)
|
||||
return { success: true, plan: 'growth', expireAt }
|
||||
}
|
||||
|
||||
@@ -122,7 +137,7 @@ export class AdminController {
|
||||
if (!userId || !type || amount === undefined) {
|
||||
throw new HttpException('参数不完整', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
const validTypes = ['interviewCredits', 'resumeOptimizeCredits', 'resumeDownloadCredits', 'shareCredits']
|
||||
const validTypes = ['interviewCredits', 'resumeOptimizeCredits', 'resumeDownloadCredits', 'shareCredits', 'gravity']
|
||||
if (!validTypes.includes(type)) {
|
||||
throw new HttpException('无效的额度类型', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
@@ -210,6 +225,16 @@ export class AdminController {
|
||||
return { list, total, page: +page }
|
||||
}
|
||||
|
||||
@Get('feedback')
|
||||
async getFeedback(@Query('page') page = '1', @Query('limit') limit = '10') {
|
||||
const skip = (Math.max(1, +page) - 1) * +limit
|
||||
const [list, total] = await Promise.all([
|
||||
this.feedbackModel.find().sort({ createdAt: -1 }).skip(skip).limit(+limit).lean().exec(),
|
||||
this.feedbackModel.countDocuments().exec(),
|
||||
])
|
||||
return { list, total, page: +page }
|
||||
}
|
||||
|
||||
@Get('resumes')
|
||||
async getResumes(@Query('page') page = '1', @Query('limit') limit = '20') {
|
||||
const skip = (Math.max(1, +page) - 1) * +limit
|
||||
@@ -217,8 +242,8 @@ export class AdminController {
|
||||
this.resumeModel.find()
|
||||
.sort({ createdAt: -1 })
|
||||
.skip(skip).limit(+limit)
|
||||
.populate('userId', 'phone nickname')
|
||||
.select('title targetPosition version paidDownload createdAt')
|
||||
.populate('userId', 'phone nickname email')
|
||||
.select('title targetPosition version paidDownload createdAt updatedAt contentHash')
|
||||
.lean().exec(),
|
||||
this.resumeModel.countDocuments().exec(),
|
||||
])
|
||||
@@ -238,7 +263,7 @@ export class AdminController {
|
||||
|
||||
@Get('admins')
|
||||
async getAdmins() {
|
||||
const admins = await this.userModel.find({ role: 'admin' }).select('phone nickname email createdAt isSystemAdmin').lean().exec()
|
||||
const admins = await this.userModel.find({ role: 'admin' }).select('phone nickname email wxOpenid gravity plan role createdAt isSystemAdmin').lean().exec()
|
||||
return { admins }
|
||||
}
|
||||
|
||||
@@ -291,18 +316,18 @@ export class AdminController {
|
||||
} else {
|
||||
user.vipExpireAt = expireAt
|
||||
}
|
||||
await this.quotaService.setPlanQuota(order.userId, planId, credits)
|
||||
await this.quotaService.setPlanQuota(order.userId, planCfg.gravityPerMonth)
|
||||
}
|
||||
} else {
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
const creditMap: Record<string, number> = {
|
||||
interview: pricing.interview?.creditsPerPurchase || 1,
|
||||
optimize: pricing.resumeOptimize?.creditsPerPurchase || 1,
|
||||
download: pricing.resumeDownload?.creditsPerPurchase || 1,
|
||||
const gravityMap: Record<string, number> = {
|
||||
interview: pricing.gravityRates?.interviewPerUse || 5,
|
||||
optimize: pricing.gravityRates?.optimizePerUse || 3,
|
||||
download: pricing.gravityRates?.downloadPerUse || 2,
|
||||
}
|
||||
const credits = creditMap[order.type]
|
||||
if (credits) {
|
||||
await this.quotaService.grantCredits(order.userId, order.type as any, credits)
|
||||
const g = gravityMap[order.type]
|
||||
if (g) {
|
||||
await this.quotaService.grantGravity(order.userId, g)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,8 +440,8 @@ const DEFAULT_CONFIG = {
|
||||
}
|
||||
|
||||
const DEFAULT_PRICING = {
|
||||
interview: { pricePerSession: 500, creditsPerPurchase: 1 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 },
|
||||
interview: { pricePerSession: 600, creditsPerPurchase: 1 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 400, creditsPerPurchase: 1 },
|
||||
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
|
||||
plans: {
|
||||
growth: {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { AdminGuard } from '../../common/guards/admin.guard'
|
||||
import { SiteConfig, SiteConfigSchema } from '../schemas/site-config.schema'
|
||||
import { ShareRecord, ShareRecordSchema, ShareVisit, ShareVisitSchema } from '../share/share.schema'
|
||||
import { Resume, ResumeSchema } from '../resume/resume.schema'
|
||||
import { Feedback, FeedbackSchema } from '../feedback/feedback.schema'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -21,6 +22,7 @@ import { Resume, ResumeSchema } from '../resume/resume.schema'
|
||||
{ name: ShareRecord.name, schema: ShareRecordSchema },
|
||||
{ name: ShareVisit.name, schema: ShareVisitSchema },
|
||||
{ name: Resume.name, schema: ResumeSchema },
|
||||
{ name: Feedback.name, schema: FeedbackSchema },
|
||||
]),
|
||||
UserModule,
|
||||
],
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common'
|
||||
import { Controller, Get, Param, Query } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
||||
import { Public } from '../../common/decorators/public.decorator'
|
||||
import { DailyQuestion, DailyQuestionDocument } from '../schemas/daily-question.schema'
|
||||
|
||||
@Controller('daily-question')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class DailyQuestionController {
|
||||
constructor(
|
||||
@InjectModel(DailyQuestion.name) private dailyQuestionModel: Model<DailyQuestionDocument>,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
async getToday(@Query('position') position?: string) {
|
||||
const filter: any = {}
|
||||
if (position) filter.position = position
|
||||
@Public()
|
||||
async getRandom(@Query('position') position?: string) {
|
||||
const pipeline: any[] = []
|
||||
if (position) pipeline.push({ $match: { position } })
|
||||
pipeline.push({ $sample: { size: 1 } })
|
||||
|
||||
const question = await this.dailyQuestionModel
|
||||
.findOne(filter)
|
||||
.sort({ date: -1 })
|
||||
.exec()
|
||||
const results = await this.dailyQuestionModel.aggregate(pipeline).exec()
|
||||
if (results.length > 0) return results[0]
|
||||
|
||||
if (!question) {
|
||||
// Return a default question if no specific one found
|
||||
const defaultQ = await this.dailyQuestionModel.findOne().sort({ date: -1 }).exec()
|
||||
if (defaultQ) return defaultQ
|
||||
// Fallback: try without position filter
|
||||
if (position) {
|
||||
const fallback = await this.dailyQuestionModel.aggregate([{ $sample: { size: 1 } }]).exec()
|
||||
if (fallback.length > 0) return fallback[0]
|
||||
}
|
||||
|
||||
return {
|
||||
position: '通用',
|
||||
@@ -34,9 +34,6 @@ export class DailyQuestionController {
|
||||
}
|
||||
}
|
||||
|
||||
return question
|
||||
}
|
||||
|
||||
@Get('position/:position')
|
||||
async getByPosition(@Param('position') position: string) {
|
||||
const questions = await this.dailyQuestionModel
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Controller, Post, Get, Patch, Param, Body, Query, UseGuards, HttpException, HttpStatus } from '@nestjs/common'
|
||||
import { FeedbackService } from './feedback.service'
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
||||
import { AdminGuard } from '../../common/guards/admin.guard'
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
||||
|
||||
@Controller('feedback')
|
||||
export class FeedbackController {
|
||||
constructor(private service: FeedbackService) {}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post()
|
||||
async create(@CurrentUser('userId') userId: string, @Body() body: { type?: string; content: string; contact?: string }) {
|
||||
if (!body.content || body.content.length < 2) {
|
||||
throw new HttpException('请填写反馈内容', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
return this.service.create({ userId, type: body.type || 'suggestion', content: body.content, contact: body.contact })
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, AdminGuard)
|
||||
@Get()
|
||||
async list(@Query('page') page?: string, @Query('limit') limit?: string) {
|
||||
return this.service.findAll(Number(page) || 1, Number(limit) || 20)
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, AdminGuard)
|
||||
@Patch(':id/resolve')
|
||||
async resolve(@Param('id') id: string) {
|
||||
return this.service.markResolved(id)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { MongooseModule } from '@nestjs/mongoose'
|
||||
import { FeedbackController } from './feedback.controller'
|
||||
import { FeedbackService } from './feedback.service'
|
||||
import { Feedback, FeedbackSchema } from './feedback.schema'
|
||||
|
||||
@Module({
|
||||
imports: [MongooseModule.forFeature([{ name: Feedback.name, schema: FeedbackSchema }])],
|
||||
controllers: [FeedbackController],
|
||||
providers: [FeedbackService],
|
||||
exports: [FeedbackService],
|
||||
})
|
||||
export class FeedbackModule {}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
||||
import { Document, Types } from 'mongoose'
|
||||
|
||||
export type FeedbackDocument = Feedback & Document
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
export class Feedback {
|
||||
@Prop({ type: Types.ObjectId, ref: 'User', required: true })
|
||||
userId: Types.ObjectId
|
||||
|
||||
@Prop({ default: 'suggestion' })
|
||||
type: string
|
||||
|
||||
@Prop({ required: true })
|
||||
content: string
|
||||
|
||||
@Prop({ default: '' })
|
||||
contact: string
|
||||
|
||||
@Prop({ default: 'pending' })
|
||||
status: string
|
||||
}
|
||||
|
||||
export const FeedbackSchema = SchemaFactory.createForClass(Feedback)
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { Feedback } from './feedback.schema'
|
||||
|
||||
@Injectable()
|
||||
export class FeedbackService {
|
||||
constructor(@InjectModel(Feedback.name) private model: Model<Feedback>) {}
|
||||
|
||||
async create(data: { userId: string; type: string; content: string; contact?: string }) {
|
||||
return this.model.create(data)
|
||||
}
|
||||
|
||||
async findAll(page = 1, limit = 20) {
|
||||
const skip = (page - 1) * limit
|
||||
const items = await this.model.find().sort({ createdAt: -1 }).skip(skip).limit(limit).lean()
|
||||
let populated: any[] = items
|
||||
try {
|
||||
populated = await this.model.populate(items, { path: 'userId', select: 'nickname phone email' })
|
||||
} catch {}
|
||||
const total = await this.model.countDocuments()
|
||||
return { items: populated, total, page, limit }
|
||||
}
|
||||
|
||||
async markResolved(id: string) {
|
||||
return this.model.findByIdAndUpdate(id, { status: 'resolved' }, { new: true })
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable, HttpException, HttpStatus } from '@nestjs/common'
|
||||
import { Injectable, HttpException, HttpStatus, Logger } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { Interview, InterviewDocument } from './interview.schema'
|
||||
@@ -11,6 +11,8 @@ import { analyzeSpeech } from '../../common/utils/filler-words'
|
||||
|
||||
@Injectable()
|
||||
export class InterviewService {
|
||||
private readonly logger = new Logger(InterviewService.name)
|
||||
|
||||
constructor(
|
||||
@InjectModel(Interview.name) private interviewModel: Model<InterviewDocument>,
|
||||
@InjectModel(Progress.name) private progressModel: Model<ProgressDocument>,
|
||||
@@ -21,13 +23,24 @@ export class InterviewService {
|
||||
) {}
|
||||
|
||||
async create(userId: string, position: string) {
|
||||
await this.quotaService.checkAndDeductInterview(userId)
|
||||
// Step 1: 先检查引力值是否足够(不扣除)
|
||||
const cost = await this.quotaService.checkInterview(userId)
|
||||
|
||||
const firstQuestion = await this.aiService.call({
|
||||
// Step 2: AI 生成第一个问题
|
||||
let firstQuestion: string
|
||||
try {
|
||||
firstQuestion = await this.aiService.call({
|
||||
systemPrompt: `你是一位专业的${position}面试官。请针对校招该岗位提出第一个面试问题,要求具体且有针对性。直接输出问题,不要多余内容。`,
|
||||
userMessage: `请为${position}岗位的校招候选人提出第一个面试问题。`,
|
||||
temperature: 0.8,
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`AI call failed for interview create: ${(e as Error).message}`)
|
||||
throw new HttpException('AI 服务暂时不可用,请稍后重试', HttpStatus.SERVICE_UNAVAILABLE)
|
||||
}
|
||||
|
||||
// Step 3: AI 调用成功后,扣除引力值并创建面试记录
|
||||
await this.quotaService.deductInterview(userId, cost)
|
||||
|
||||
const interview = await this.interviewModel.create({
|
||||
userId,
|
||||
|
||||
@@ -53,7 +53,14 @@ export class MemberController {
|
||||
}
|
||||
|
||||
return {
|
||||
registrationGravity: pricing.registrationGravity,
|
||||
interview: { dailyFreeLimit: FREE_DAILY_LIMIT, maxRoundsFree: 5, maxRoundsVip: 10 },
|
||||
gravityRates: pricing.gravityRates,
|
||||
products: {
|
||||
interview: { price: pricing.interview.pricePerSession, title: 'AI 模拟面试单次', gravity: pricing.gravityRates.interviewPerUse },
|
||||
optimize: { price: pricing.resumeOptimize.pricePerOptimize, title: '简历优化单次', gravity: pricing.gravityRates.optimizePerUse },
|
||||
download: { price: pricing.resumeDownload.pricePerDownload, title: '简历下载', gravity: pricing.gravityRates.downloadPerUse },
|
||||
},
|
||||
plans,
|
||||
}
|
||||
}
|
||||
@@ -66,6 +73,7 @@ export class MemberController {
|
||||
plan: user.plan,
|
||||
planName: user.plan === 'growth' ? '成长版' : user.plan === 'sprint' ? '冲刺版' : '免费版',
|
||||
remaining: user.remaining,
|
||||
gravity: user.gravity ?? 0,
|
||||
dailyLimit: user.plan !== 'free' ? 999 : FREE_DAILY_LIMIT,
|
||||
vipExpireAt: user.vipExpireAt,
|
||||
sprintExpireAt: user.sprintExpireAt,
|
||||
@@ -101,7 +109,7 @@ export class MemberController {
|
||||
user.plan = 'growth'
|
||||
user.vipExpireAt = expireAt
|
||||
}
|
||||
await this.quotaService.setPlanQuota(userId, order.plan, planCfg.credits)
|
||||
await this.quotaService.setPlanQuota(userId, planCfg.gravityPerMonth)
|
||||
return { success: true, plan: user.plan, planName: user.plan === 'growth' ? '成长版' : '冲刺版', expireAt }
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ describe('PaymentController', () => {
|
||||
}
|
||||
mockPricingService = {
|
||||
getConfig: jest.fn().mockResolvedValue({
|
||||
interview: { pricePerSession: 500, creditsPerPurchase: 1 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 },
|
||||
interview: { pricePerSession: 600, creditsPerPurchase: 1 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 400, creditsPerPurchase: 1 },
|
||||
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
|
||||
plans: {
|
||||
growth: { price: 1990, durationDays: 30, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: [] },
|
||||
sprint: { price: 4990, durationDays: 30, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: [] },
|
||||
growth: { price: 1990, durationDays: 30, gravityPerMonth: 80, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: [] },
|
||||
sprint: { price: 4990, durationDays: 30, gravityPerMonth: 200, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: [] },
|
||||
},
|
||||
}),
|
||||
}
|
||||
@@ -51,6 +51,7 @@ describe('PaymentController', () => {
|
||||
providers: [
|
||||
{ provide: getModelToken('User'), useValue: mockUserModel },
|
||||
{ provide: getModelToken('PaymentOrder'), useValue: mockOrderModel },
|
||||
{ provide: getModelToken('GravityTransaction'), useValue: { create: jest.fn() } },
|
||||
{ provide: WechatPayService, useValue: mockWechatPay },
|
||||
{ provide: QuotaService, useValue: mockQuotaService },
|
||||
{ provide: PricingService, useValue: mockPricingService },
|
||||
@@ -150,7 +151,7 @@ describe('PaymentController', () => {
|
||||
|
||||
it('should activate growth plan', async () => {
|
||||
mockOrderModel.findOne.mockReturnValueOnce({ exec: jest.fn().mockResolvedValue({ outTradeNo: 'ORD123', userId: mockUserId, status: 'success', plan: 'growth', type: 'membership' }) })
|
||||
const mockUser = { plan: 'free', vipExpireAt: null, sprintExpireAt: null, sprintRemaining: 0, remaining: 0, interviewCredits: 1, resumeOptimizeCredits: 0, resumeDownloadCredits: 0, freeOptimizeUsed: 0, save: jest.fn().mockResolvedValue(true) }
|
||||
const mockUser = { plan: 'free', vipExpireAt: null, sprintExpireAt: null, sprintRemaining: 0, remaining: 0, gravity: 0, freeOptimizeUsed: 0, save: jest.fn().mockResolvedValue(true) }
|
||||
mockUserModel.findById.mockReturnValueOnce({ exec: jest.fn().mockResolvedValue(mockUser) })
|
||||
|
||||
const result = await controller.activate(mockUserId, 'ORD123')
|
||||
@@ -158,9 +159,8 @@ describe('PaymentController', () => {
|
||||
expect(result.plan).toBe('growth')
|
||||
expect(mockUser.save).toHaveBeenCalled()
|
||||
expect(mockUser.plan).toBe('growth')
|
||||
expect(mockUser.interviewCredits).toBe(999)
|
||||
expect(mockUser.resumeOptimizeCredits).toBe(20)
|
||||
expect(mockUser.resumeDownloadCredits).toBe(10)
|
||||
expect(mockUser.gravity).toBe(80)
|
||||
expect(mockUser.freeOptimizeUsed).toBe(3)
|
||||
})
|
||||
|
||||
it('should activate sprint plan', async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Controller, Post, Get, Param, Body, UseGuards, HttpException, HttpStatus, Logger, Req } from '@nestjs/common'
|
||||
import { Controller, Post, Get, Param, Body, UseGuards, HttpException, HttpStatus, Logger, Req, HttpCode } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { User, UserDocument } from '../user/user.schema'
|
||||
@@ -9,6 +9,7 @@ import { WechatPayService } from './wechat-pay.service'
|
||||
import { QuotaService } from '../user/quota.service'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
import { Public } from '../../common/decorators/public.decorator'
|
||||
import { GravityTransaction } from '../schemas/gravity-transaction.schema'
|
||||
|
||||
@Controller('payment')
|
||||
export class PaymentController {
|
||||
@@ -17,6 +18,7 @@ export class PaymentController {
|
||||
constructor(
|
||||
@InjectModel(User.name) private userModel: Model<UserDocument>,
|
||||
@InjectModel(PaymentOrder.name) private orderModel: Model<PaymentOrderDocument>,
|
||||
@InjectModel(GravityTransaction.name) private gravityTxModel: Model<GravityTransaction>,
|
||||
private wechatPay: WechatPayService,
|
||||
private quotaService: QuotaService,
|
||||
private pricingService: PricingService,
|
||||
@@ -25,6 +27,7 @@ export class PaymentController {
|
||||
/** 创建套餐订单(H5:Native 扫码支付) */
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('create')
|
||||
@HttpCode(200)
|
||||
async create(@CurrentUser('userId') userId: string, @Body('plan') plan: string = 'growth') {
|
||||
if (!['growth', 'sprint'].includes(plan)) throw new HttpException('无效套餐', HttpStatus.BAD_REQUEST)
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
@@ -34,7 +37,7 @@ export class PaymentController {
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
const planCfg = pricing.plans[plan === 'sprint' ? 'sprint' : 'growth']
|
||||
const amount = planCfg.price
|
||||
const title = plan === 'sprint' ? '职引冲刺版月度会员' : '职引成长版月度会员'
|
||||
const title = plan === 'sprint' ? '宇之然AI磁场冲刺版月度会员' : '宇之然AI磁场成长版月度会员'
|
||||
const outTradeNo = `${plan === 'sprint' ? 'SPR' : 'VIP'}${Date.now()}${userId.slice(-6)}`
|
||||
const result = await this.wechatPay.nativePay(title, outTradeNo, amount)
|
||||
|
||||
@@ -49,11 +52,13 @@ export class PaymentController {
|
||||
async createProduct(
|
||||
@CurrentUser('userId') userId: string,
|
||||
@Body('type') type: string,
|
||||
@Body('quantity') quantity: number = 1,
|
||||
@Body('metadata') metadata?: Record<string, any>,
|
||||
) {
|
||||
if (!['interview', 'optimize', 'download'].includes(type)) {
|
||||
throw new HttpException('无效产品类型', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
const qty = Math.max(1, Math.min(99, quantity || 1))
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
|
||||
@@ -63,40 +68,55 @@ export class PaymentController {
|
||||
optimize: pricing.resumeOptimize.pricePerOptimize,
|
||||
download: pricing.resumeDownload.pricePerDownload,
|
||||
}
|
||||
const price = priceMap[type]
|
||||
if (!price) throw new HttpException('价格未配置', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
const price = priceMap[type] * qty
|
||||
if (!priceMap[type]) throw new HttpException('价格未配置', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
|
||||
const titles: Record<string, string> = {
|
||||
interview: 'AI 模拟面试单次',
|
||||
optimize: '简历优化单次',
|
||||
download: '简历下载',
|
||||
}
|
||||
const title = titles[type] || type
|
||||
const title = qty > 1 ? `${titles[type]}×${qty}` : titles[type]
|
||||
const outTradeNo = `${type.slice(0, 3).toUpperCase()}${Date.now()}${userId.slice(-6)}`
|
||||
const result = await this.wechatPay.nativePay(title, outTradeNo, price)
|
||||
|
||||
await this.orderModel.create({ outTradeNo, userId, userPhone: user.phone || '', amount: price, title, status: 'pending', channel: 'native', type, plan: 'growth', metadata })
|
||||
await this.orderModel.create({ outTradeNo, userId, userPhone: user.phone || '', amount: price, title, status: 'pending', channel: 'native', type, plan: 'growth', metadata: { ...metadata, quantity: qty } })
|
||||
|
||||
return { outTradeNo, codeUrl: result.codeUrl, amount: price, title }
|
||||
return { outTradeNo, codeUrl: result.codeUrl, amount: price, title, quantity: qty }
|
||||
}
|
||||
|
||||
/** JSAPI 支付(微信小程序) */
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('jsapi')
|
||||
@HttpCode(200)
|
||||
async jsapi(@CurrentUser('userId') userId: string, @Body('plan') plan: string = 'growth') {
|
||||
this.logger.log(`[jsapi] userId=${userId}, plan=${plan}`)
|
||||
if (!['growth', 'sprint'].includes(plan)) throw new HttpException('无效套餐', HttpStatus.BAD_REQUEST)
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
if (user.plan !== 'free') throw new HttpException('已是会员', HttpStatus.BAD_REQUEST)
|
||||
if (!user) { this.logger.warn(`[jsapi] 用户不存在 userId=${userId}`); throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) }
|
||||
this.logger.log(`[jsapi] 用户查询结果: plan=${user.plan}, wxOpenid=${user.wxOpenid ? '已设置' : '空'}, phone=${user.phone || '无'}`)
|
||||
if (user.plan !== 'free') { this.logger.warn(`[jsapi] 已是会员 plan=${user.plan}`); throw new HttpException('已是会员', HttpStatus.BAD_REQUEST) }
|
||||
const openid = user.wxOpenid
|
||||
if (!openid) throw new HttpException('未绑定微信', HttpStatus.BAD_REQUEST)
|
||||
if (!openid) {
|
||||
this.logger.warn(`[jsapi] 未绑定微信openid userId=${userId}`)
|
||||
throw new HttpException({ message: '未绑定微信openid', needBindWx: true }, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
this.logger.log(`[jsapi] pricing获取成功`)
|
||||
const planCfg = pricing.plans[plan === 'sprint' ? 'sprint' : 'growth']
|
||||
const amount = planCfg.price
|
||||
const title = plan === 'sprint' ? '职引冲刺版月度会员' : '职引成长版月度会员'
|
||||
const title = plan === 'sprint' ? '宇之然AI磁场冲刺版月度会员' : '宇之然AI磁场成长版月度会员'
|
||||
const outTradeNo = `${plan === 'sprint' ? 'SPR' : 'VIP'}${Date.now()}${userId.slice(-6)}`
|
||||
const result = await this.wechatPay.jsapiPay(title, outTradeNo, amount, openid)
|
||||
this.logger.log(`[jsapi] 准备调用微信: outTradeNo=${outTradeNo}, amount=${amount}, openid=${openid}`)
|
||||
let result: any
|
||||
try {
|
||||
result = await this.wechatPay.jsapiPay(title, outTradeNo, amount, openid)
|
||||
this.logger.log(`[jsapi] 微信下单成功 prepayId=${result?.prepayId}`)
|
||||
} catch (e: any) {
|
||||
this.logger.error(`[jsapi] 微信下单失败: ${e.message}`, e.response?.data ? JSON.stringify(e.response.data) : '')
|
||||
throw new HttpException(e.response?.data?.message || '微信支付下单失败', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
await this.orderModel.create({ outTradeNo, userId, userPhone: user.phone || '', amount, title, status: 'pending', channel: 'jsapi', type: 'membership', plan })
|
||||
|
||||
@@ -109,15 +129,19 @@ export class PaymentController {
|
||||
async jsapiProduct(
|
||||
@CurrentUser('userId') userId: string,
|
||||
@Body('type') type: string,
|
||||
@Body('quantity') quantity: number = 1,
|
||||
@Body('metadata') metadata?: Record<string, any>,
|
||||
) {
|
||||
if (!['interview', 'optimize', 'download'].includes(type)) {
|
||||
throw new HttpException('无效产品类型', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
const qty = Math.max(1, Math.min(99, quantity || 1))
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
const openid = user.wxOpenid
|
||||
if (!openid) throw new HttpException('未绑定微信', HttpStatus.BAD_REQUEST)
|
||||
if (!openid) {
|
||||
throw new HttpException({ message: '未绑定微信openid', needBindWx: true }, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
const priceMap: Record<string, number> = {
|
||||
@@ -125,21 +149,21 @@ export class PaymentController {
|
||||
optimize: pricing.resumeOptimize.pricePerOptimize,
|
||||
download: pricing.resumeDownload.pricePerDownload,
|
||||
}
|
||||
const price = priceMap[type]
|
||||
if (!price) throw new HttpException('价格未配置', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
const price = priceMap[type] * qty
|
||||
if (!priceMap[type]) throw new HttpException('价格未配置', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
|
||||
const titles: Record<string, string> = {
|
||||
interview: 'AI 模拟面试单次',
|
||||
optimize: '简历优化单次',
|
||||
download: '简历下载',
|
||||
}
|
||||
const title = titles[type] || type
|
||||
const title = qty > 1 ? `${titles[type]}×${qty}` : titles[type]
|
||||
const outTradeNo = `${type.slice(0, 3).toUpperCase()}${Date.now()}${userId.slice(-6)}`
|
||||
const result = await this.wechatPay.jsapiPay(title, outTradeNo, price, openid)
|
||||
|
||||
await this.orderModel.create({ outTradeNo, userId, userPhone: user.phone || '', amount: price, title, status: 'pending', channel: 'jsapi', type, plan: 'growth', metadata })
|
||||
await this.orderModel.create({ outTradeNo, userId, userPhone: user.phone || '', amount: price, title, status: 'pending', channel: 'jsapi', type, plan: 'growth', metadata: { ...metadata, quantity: qty } })
|
||||
|
||||
return { ...result, outTradeNo }
|
||||
return { ...result, outTradeNo, quantity: qty }
|
||||
}
|
||||
|
||||
/** 支付回调通知 */
|
||||
@@ -201,34 +225,30 @@ export class PaymentController {
|
||||
user.plan = 'growth'
|
||||
user.vipExpireAt = expireAt
|
||||
}
|
||||
const credits = planCfg.credits
|
||||
user.remaining = 999
|
||||
user.interviewCredits = credits.interview
|
||||
user.resumeOptimizeCredits = credits.resumeOptimize
|
||||
user.resumeDownloadCredits = credits.resumeDownload
|
||||
user.gravity = planCfg.gravityPerMonth
|
||||
user.freeOptimizeUsed = 3
|
||||
await user.save()
|
||||
await this.gravityTxModel.create({
|
||||
userId: order.userId,
|
||||
amount: planCfg.gravityPerMonth,
|
||||
balance: planCfg.gravityPerMonth,
|
||||
type: 'plan_set',
|
||||
description: `开通${isSprint ? '冲刺版' : '成长版'}会员,获得 ${planCfg.gravityPerMonth} 引力值`,
|
||||
refId: order.outTradeNo,
|
||||
})
|
||||
}
|
||||
|
||||
private async activateProduct(order: PaymentOrderDocument) {
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
const creditMap: Record<string, number> = {
|
||||
interview: pricing.interview.creditsPerPurchase,
|
||||
optimize: pricing.resumeOptimize.creditsPerPurchase,
|
||||
download: pricing.resumeDownload.creditsPerPurchase,
|
||||
}
|
||||
const credits = creditMap[order.type]
|
||||
if (!credits) return
|
||||
|
||||
const typeMap: Record<string, 'interview' | 'optimize' | 'download'> = {
|
||||
interview: 'interview',
|
||||
optimize: 'optimize',
|
||||
download: 'download',
|
||||
}
|
||||
const mapped = typeMap[order.type]
|
||||
if (mapped) {
|
||||
await this.quotaService.grantCredits(order.userId, mapped, credits)
|
||||
const gravityMap: Record<string, number> = {
|
||||
interview: pricing.gravityRates.interviewPerUse,
|
||||
optimize: pricing.gravityRates.optimizePerUse,
|
||||
download: pricing.gravityRates.downloadPerUse,
|
||||
}
|
||||
const g = gravityMap[order.type]
|
||||
if (!g) return
|
||||
const quantity = order.metadata?.quantity || 1
|
||||
await this.quotaService.grantGravity(order.userId, g * quantity)
|
||||
}
|
||||
|
||||
/** 查询订单(微信侧) */
|
||||
|
||||
@@ -51,6 +51,8 @@ export class WechatPayService {
|
||||
/** 发起 API v3 请求 */
|
||||
private async request(method: string, apiPath: string, body?: any) {
|
||||
const url = `${WX_API_BASE}${apiPath}`
|
||||
const bodyStr = body ? JSON.stringify(body) : ''
|
||||
this.logger.log(`[wxpay-request] ${method} ${apiPath} 请求体: ${bodyStr}`)
|
||||
try {
|
||||
const res = await axios({
|
||||
method,
|
||||
@@ -63,9 +65,12 @@ export class WechatPayService {
|
||||
},
|
||||
data: body,
|
||||
})
|
||||
this.logger.log(`[wxpay-request] ${method} ${apiPath} 成功: ${JSON.stringify(res.data)}`)
|
||||
return res.data
|
||||
} catch (e: any) {
|
||||
this.logger.error(`微信支付请求失败: ${method} ${apiPath}`, e.response?.data || e.message)
|
||||
const errDetail = e.response?.data ? JSON.stringify(e.response.data) : e.message
|
||||
const errStatus = e.response?.status || '无状态码'
|
||||
this.logger.error(`[wxpay-request] ${method} ${apiPath} 失败 status=${errStatus}: ${errDetail}`)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@@ -99,8 +104,15 @@ export class WechatPayService {
|
||||
amount: { total: amount, currency: 'CNY' },
|
||||
payer: { openid },
|
||||
}
|
||||
this.logger.log(`[jsapiPay] 下单参数: description=${description}, outTradeNo=${outTradeNo}, amount=${amount}, openid=${openid}`)
|
||||
this.logger.log(`[jsapiPay] 完整请求体: ${JSON.stringify(body)}`)
|
||||
const result = await this.request('POST', '/v3/pay/transactions/jsapi', body)
|
||||
this.logger.log(`[jsapiPay] 微信返回: ${JSON.stringify(result)}`)
|
||||
const prepayId = result.prepay_id
|
||||
if (!prepayId) {
|
||||
this.logger.error(`[jsapiPay] 微信返回缺少prepay_id: ${JSON.stringify(result)}`)
|
||||
throw new Error('微信下单失败: 缺少prepay_id')
|
||||
}
|
||||
// 生成小程序/JSAPI 调起支付参数
|
||||
const nonce = crypto.randomBytes(16).toString('hex')
|
||||
const timestamp = Math.floor(Date.now() / 1000).toString()
|
||||
|
||||
@@ -74,7 +74,7 @@ export class ResumePdfService {
|
||||
<h1>${this.escapeHtml(params.title)}</h1>
|
||||
<div class="subtitle">${params.targetPosition ? `目标岗位: ${this.escapeHtml(params.targetPosition)}` : ''}</div>
|
||||
<div class="content">${contentHtml}</div>
|
||||
<div class="footer">由 AI磁场·职引 生成</div>
|
||||
<div class="footer">由 AI磁场·宇之然AI磁场 生成</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { Cron, CronExpression } from '@nestjs/schedule'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { User, UserDocument } from '../user/user.schema'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
import { GravityTransaction } from '../schemas/gravity-transaction.schema'
|
||||
|
||||
@Injectable()
|
||||
export class GravityTopUpService {
|
||||
private readonly logger = new Logger(GravityTopUpService.name)
|
||||
|
||||
constructor(
|
||||
@InjectModel(User.name) private userModel: Model<UserDocument>,
|
||||
@InjectModel(GravityTransaction.name) private gravityTxModel: Model<GravityTransaction>,
|
||||
private pricingService: PricingService,
|
||||
) {}
|
||||
|
||||
private async logBulkTopUp(userIds: string[], amount: number, type: string) {
|
||||
const users = await this.userModel.find({ _id: { $in: userIds } }).select('gravity').exec()
|
||||
const docs = users.map(u => ({
|
||||
userId: u._id.toString(),
|
||||
amount,
|
||||
balance: u.gravity,
|
||||
type,
|
||||
description: `月度补给 ${amount} 引力值`,
|
||||
}))
|
||||
if (docs.length > 0) {
|
||||
await this.gravityTxModel.insertMany(docs)
|
||||
}
|
||||
}
|
||||
|
||||
@Cron(CronExpression.EVERY_DAY_AT_2AM)
|
||||
async topUpVipGravity() {
|
||||
this.logger.log('Topping up gravity for active VIP members...')
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
const now = new Date()
|
||||
|
||||
// 成长版 —— vipExpireAt 未过期
|
||||
const growthPlan = pricing.plans.growth
|
||||
const growthUsers = await this.userModel.find(
|
||||
{ plan: 'growth', vipExpireAt: { $gt: now } },
|
||||
).select('_id').exec()
|
||||
const growthIds = growthUsers.map(u => u._id.toString())
|
||||
if (growthIds.length > 0) {
|
||||
await this.userModel.updateMany(
|
||||
{ _id: { $in: growthIds } },
|
||||
{ $inc: { gravity: growthPlan.gravityPerMonth } },
|
||||
).exec()
|
||||
await this.logBulkTopUp(growthIds, growthPlan.gravityPerMonth, 'monthly_topup')
|
||||
this.logger.log(`Growth plan: topped up ${growthIds.length} users with ${growthPlan.gravityPerMonth} gravity each`)
|
||||
}
|
||||
|
||||
// 冲刺版 —— sprintExpireAt 未过期
|
||||
const sprintPlan = pricing.plans.sprint
|
||||
const sprintUsers = await this.userModel.find(
|
||||
{ plan: 'sprint', sprintExpireAt: { $gt: now } },
|
||||
).select('_id').exec()
|
||||
const sprintIds = sprintUsers.map(u => u._id.toString())
|
||||
if (sprintIds.length > 0) {
|
||||
await this.userModel.updateMany(
|
||||
{ _id: { $in: sprintIds } },
|
||||
{ $inc: { gravity: sprintPlan.gravityPerMonth } },
|
||||
).exec()
|
||||
await this.logBulkTopUp(sprintIds, sprintPlan.gravityPerMonth, 'monthly_topup')
|
||||
this.logger.log(`Sprint plan: topped up ${sprintIds.length} users with ${sprintPlan.gravityPerMonth} gravity each`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { MongooseModule } from '@nestjs/mongoose'
|
||||
import { DailyQuestionPushService } from './daily-question-push.service'
|
||||
import { WechatTokenService } from './wechat-token.service'
|
||||
import { VipExpiryService } from './vip-expiry.service'
|
||||
import { GravityTopUpService } from './gravity-top-up.service'
|
||||
import { DailyQuestion, DailyQuestionSchema } from '../schemas/daily-question.schema'
|
||||
import { User, UserSchema } from '../user/user.schema'
|
||||
|
||||
@@ -13,6 +14,6 @@ import { User, UserSchema } from '../user/user.schema'
|
||||
{ name: User.name, schema: UserSchema },
|
||||
]),
|
||||
],
|
||||
providers: [WechatTokenService, DailyQuestionPushService, VipExpiryService],
|
||||
providers: [WechatTokenService, DailyQuestionPushService, VipExpiryService, GravityTopUpService],
|
||||
})
|
||||
export class ScheduleModule {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Document } from 'mongoose'
|
||||
|
||||
export type DailyQuestionDocument = DailyQuestion & Document
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
@Schema({ timestamps: true, collection: 'dailyquestions' })
|
||||
export class DailyQuestion {
|
||||
@Prop({ required: true })
|
||||
position: string // 适用岗位
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Module, Global } from '@nestjs/common'
|
||||
import { MongooseModule } from '@nestjs/mongoose'
|
||||
import { GravityTransaction, GravityTransactionSchema } from './gravity-transaction.schema'
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [MongooseModule.forFeature([{ name: GravityTransaction.name, schema: GravityTransactionSchema }])],
|
||||
exports: [MongooseModule],
|
||||
})
|
||||
export class GravityTransactionModule {}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
||||
import { Document } from 'mongoose'
|
||||
|
||||
export type GravityTransactionDocument = GravityTransaction & Document
|
||||
|
||||
export type GravityTransactionType =
|
||||
| 'registration' // 注册赠送
|
||||
| 'interview_deduct' // AI 面试消耗
|
||||
| 'optimize_deduct' // 简历优化消耗
|
||||
| 'download_deduct' // 简历下载消耗
|
||||
| 'purchase' // 充值购买
|
||||
| 'monthly_topup' // 月度补给
|
||||
| 'migration' // 旧额度迁移
|
||||
| 'plan_set' // 套餐设置
|
||||
| 'share' // 分享所得
|
||||
| 'contribution' // 面经贡献奖励
|
||||
| 'share_credits_fallback' // 分享币后备抵扣
|
||||
| 'admin_adjust' // 管理员调整
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
export class GravityTransaction {
|
||||
@Prop({ required: true, index: true })
|
||||
userId: string
|
||||
|
||||
@Prop({ required: true })
|
||||
amount: number // 变动数量(正=增加,负=减少)
|
||||
|
||||
@Prop({ required: true })
|
||||
balance: number // 变动后余额
|
||||
|
||||
@Prop({ required: true })
|
||||
type: GravityTransactionType
|
||||
|
||||
@Prop({ default: '' })
|
||||
description: string // 描述(如 "AI 模拟面试消耗")
|
||||
|
||||
@Prop()
|
||||
refId?: string // 关联 ID(订单号、面试ID 等)
|
||||
}
|
||||
|
||||
export const GravityTransactionSchema = SchemaFactory.createForClass(GravityTransaction)
|
||||
|
||||
GravityTransactionSchema.index({ userId: 1, createdAt: -1 })
|
||||
@@ -3,23 +3,34 @@ import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { SiteConfig, SiteConfigDocument } from './site-config.schema'
|
||||
|
||||
export interface GravityRates {
|
||||
interviewPerUse: number // 每次面试消耗引力值
|
||||
optimizePerUse: number // 每次优化消耗引力值
|
||||
downloadPerUse: number // 每次下载消耗引力值
|
||||
}
|
||||
|
||||
interface PricingConfig {
|
||||
/** 新用户注册赠送引力值 */
|
||||
registrationGravity: number
|
||||
interview: { pricePerSession: number; creditsPerPurchase: number }
|
||||
resumeOptimize: { freeLimit: number; pricePerOptimize: number; creditsPerPurchase: number }
|
||||
resumeDownload: { pricePerDownload: number; creditsPerPurchase: number }
|
||||
gravityRates: GravityRates
|
||||
plans: {
|
||||
growth: { price: number; durationDays: number; credits: { interview: number; resumeOptimize: number; resumeDownload: number }; features: string[] }
|
||||
sprint: { price: number; durationDays: number; credits: { interview: number; resumeOptimize: number; resumeDownload: number }; features: string[] }
|
||||
growth: { price: number; durationDays: number; gravityPerMonth: number; credits: { interview: number; resumeOptimize: number; resumeDownload: number }; features: string[] }
|
||||
sprint: { price: number; durationDays: number; gravityPerMonth: number; credits: { interview: number; resumeOptimize: number; resumeDownload: number }; features: string[] }
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_PRICING: PricingConfig = {
|
||||
interview: { pricePerSession: 500, creditsPerPurchase: 1 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 },
|
||||
registrationGravity: 50,
|
||||
interview: { pricePerSession: 600, creditsPerPurchase: 1 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 400, creditsPerPurchase: 1 },
|
||||
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
|
||||
gravityRates: { interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 },
|
||||
plans: {
|
||||
growth: { price: 1990, durationDays: 30, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'] },
|
||||
sprint: { price: 4990, durationDays: 30, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先', '简历优化 50 次/月', '简历下载 30 次/月'] },
|
||||
growth: { price: 1900, durationDays: 30, gravityPerMonth: 80, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 模拟面试(每次消耗 5 引力值,无限次)', '详细面试报告(四维评分 + 语音复盘)', '进步轨迹雷达图 + 打卡日历', '每日一题推送 + 参考思路', '公司真题库', '每月赠送 80 引力值,可用于面试/优化/下载'] },
|
||||
sprint: { price: 4900, durationDays: 30, gravityPerMonth: 200, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', 'AI 语音深度分析(语气词/语速/停顿检测)', '技能缺口分析报告', '公司真题库精选', '每月赠送 200 引力值,可用于面试/优化/下载'] },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -54,9 +65,11 @@ export class PricingService {
|
||||
|
||||
private mergeDefaults(value: any): PricingConfig {
|
||||
return {
|
||||
registrationGravity: value?.registrationGravity ?? DEFAULT_PRICING.registrationGravity,
|
||||
interview: { ...DEFAULT_PRICING.interview, ...value?.interview },
|
||||
resumeOptimize: { ...DEFAULT_PRICING.resumeOptimize, ...value?.resumeOptimize },
|
||||
resumeDownload: { ...DEFAULT_PRICING.resumeDownload, ...value?.resumeDownload },
|
||||
gravityRates: { ...DEFAULT_PRICING.gravityRates, ...value?.gravityRates },
|
||||
plans: {
|
||||
growth: { ...DEFAULT_PRICING.plans.growth, ...value?.plans?.growth, credits: { ...DEFAULT_PRICING.plans.growth.credits, ...value?.plans?.growth?.credits } },
|
||||
sprint: { ...DEFAULT_PRICING.plans.sprint, ...value?.plans?.sprint, credits: { ...DEFAULT_PRICING.plans.sprint.credits, ...value?.plans?.sprint?.credits } },
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Controller, Get, Post, Body, Param, Query, HttpException, HttpStatus, UseGuards } from '@nestjs/common'
|
||||
import { Controller, Get, Post, Body, Param, Query, HttpException, HttpStatus, UseGuards, Req, Res } from '@nestjs/common'
|
||||
import { Request, Response } from 'express'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { ShareService } from './share.service'
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
||||
import { Public } from '../../common/decorators/public.decorator'
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
@Controller('share')
|
||||
export class ShareController {
|
||||
@@ -66,4 +68,27 @@ export class ShareController {
|
||||
) {
|
||||
return this.shareService.visitors(userId, Number(page) || 1, Number(pageSize) || 20)
|
||||
}
|
||||
|
||||
// 泛匹配路由放在最后,避免拦截 stats/records/visitors 等
|
||||
@Public()
|
||||
@Get(':shareCode')
|
||||
async redirect(
|
||||
@Param('shareCode') shareCode: string,
|
||||
@Req() req: Request,
|
||||
@Res() res: Response,
|
||||
) {
|
||||
try {
|
||||
const ip = req.ip || req.socket?.remoteAddress || 'unknown'
|
||||
const visitorId = crypto.createHash('md5').update(ip).digest('hex').slice(0, 16)
|
||||
let visitorUserId: string | undefined
|
||||
const token = req.query.token as string | undefined
|
||||
if (token) {
|
||||
try { const payload = this.jwtService.verify(token) as any; visitorUserId = payload.userId } catch {}
|
||||
}
|
||||
await this.shareService.visit(shareCode, visitorId, visitorUserId)
|
||||
} catch (e) {
|
||||
// 访问记录失败不影响跳转
|
||||
}
|
||||
res.redirect(HttpStatus.FOUND, `https://zhiyin.yzrcloud.cn/?share=${shareCode}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export class ShareService {
|
||||
shareCode,
|
||||
type: body.type || 'app',
|
||||
refId: body.refId || '',
|
||||
title: body.title || '我在职引发现了好东西',
|
||||
title: body.title || '我在宇之然AI磁场发现了好东西',
|
||||
description: body.description || '快来一起体验吧',
|
||||
})
|
||||
return {
|
||||
@@ -83,8 +83,11 @@ export class ShareService {
|
||||
|
||||
if (todayCredited >= DAILY_LIMIT) return { dailyLimitReached: true, visitorUserId }
|
||||
|
||||
const shareCreditsResult = await this.quotaService.grantShareCredits(sharerIdStr)
|
||||
if (!shareCreditsResult) return { creditFailed: true, visitorUserId }
|
||||
try {
|
||||
await this.quotaService.grantGravity(sharerIdStr, 1)
|
||||
} catch (e) {
|
||||
return { creditFailed: true, visitorUserId }
|
||||
}
|
||||
|
||||
await this.visitModel.updateOne(
|
||||
{ shareId: share._id, visitorId },
|
||||
@@ -125,7 +128,7 @@ export class ShareService {
|
||||
totalVisits: visitAgg[0]?.totalVisits ?? 0,
|
||||
creditedCount: visitAgg[0]?.creditedCount ?? 0,
|
||||
todayCredited: todayAgg,
|
||||
shareCredits: user?.shareCredits ?? 0,
|
||||
gravity: user?.gravity ?? 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Post, Body, Param, Res, HttpException, HttpStatus, UseGuards, UploadedFile, UseInterceptors } from '@nestjs/common'
|
||||
import { Controller, Get, Post, Body, Param, Res, HttpException, HttpStatus, UseGuards, UploadedFile, UseInterceptors, Logger } from '@nestjs/common'
|
||||
import { FileInterceptor } from '@nestjs/platform-express'
|
||||
import { Response } from 'express'
|
||||
import * as fs from 'fs'
|
||||
@@ -10,6 +10,7 @@ import { Public } from '../../common/decorators/public.decorator'
|
||||
|
||||
@Controller('tts')
|
||||
export class TtsController {
|
||||
private readonly logger = new Logger(TtsController.name)
|
||||
constructor(private ttsService: TtsService) {}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@@ -42,28 +43,64 @@ export class TtsController {
|
||||
if (!file) throw new HttpException('请上传音频文件', HttpStatus.BAD_REQUEST)
|
||||
const uploadDir = '/tmp/asr_uploads'
|
||||
if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir, { recursive: true })
|
||||
const ext = path.extname(file.originalname) || '.mp3'
|
||||
const ext = file.originalname ? path.extname(file.originalname) || '.aac' : '.aac'
|
||||
const dest = path.join(uploadDir, file.filename + ext)
|
||||
fs.renameSync(file.path, dest)
|
||||
|
||||
// 拒绝损坏/空音频文件,避免 whisper 调用 ffmpeg 解码失败刷错误日志
|
||||
const stat = fs.statSync(dest)
|
||||
if (!stat.size || stat.size < 500) {
|
||||
this.logger.warn(`ASR: empty audio upload (size=${stat.size}), ext=${ext}`)
|
||||
try { fs.unlinkSync(dest) } catch {}
|
||||
return { text: '' }
|
||||
}
|
||||
|
||||
let wavPath = dest
|
||||
if (ext.toLowerCase() !== '.wav') {
|
||||
const potentialWav = dest.replace(/\.[^.]+$/, '.wav')
|
||||
try {
|
||||
execSync(`ffmpeg -y -i "${dest}" -ar 16000 -ac 1 -c:a pcm_s16le "${potentialWav}"`, {
|
||||
timeout: 30000, encoding: 'utf8', stdio: 'pipe',
|
||||
})
|
||||
wavPath = potentialWav
|
||||
} catch (e: any) {
|
||||
this.logger.warn(`FFmpeg conversion failed: ${e.message}, using original format`)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
let text = ''
|
||||
if (process.env.OPENAI_API_KEY) {
|
||||
try {
|
||||
const result = execSync(
|
||||
`curl -s -X POST https://api.openai.com/v1/audio/transcriptions \
|
||||
-H "Authorization: Bearer ${process.env.OPENAI_API_KEY}" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "file=@${dest}" \
|
||||
-F "file=@${wavPath}" \
|
||||
-F "model=whisper-1" \
|
||||
-F "language=zh"`,
|
||||
{ encoding: 'utf8', timeout: 30000 },
|
||||
)
|
||||
const parsed = JSON.parse(result)
|
||||
if (parsed.text) return { text: parsed.text.trim() }
|
||||
if (parsed.text) text = parsed.text.trim()
|
||||
} catch (e: any) {
|
||||
this.logger.warn(`OpenAI ASR failed, falling back to local: ${e.message}`)
|
||||
}
|
||||
const whisperResult = execSync(`python3 -c 'import sys, whisper; model = whisper.load_model("tiny"); print(model.transcribe(sys.argv[1], language="zh")["text"].strip())' "${dest}"`, { encoding: 'utf8', timeout: 60000 })
|
||||
if (whisperResult && whisperResult.trim()) {
|
||||
return { text: whisperResult.trim() }
|
||||
}
|
||||
} catch {}
|
||||
if (!text) {
|
||||
const whisperResult = execSync(
|
||||
`python3 -c 'import sys, whisper; model = whisper.load_model("tiny"); print(model.transcribe(sys.argv[1], language="zh")["text"].strip())' "${wavPath}"`,
|
||||
{ encoding: 'utf8', timeout: 60000 },
|
||||
)
|
||||
if (whisperResult?.trim()) text = whisperResult.trim()
|
||||
}
|
||||
return { text }
|
||||
} catch (e: any) {
|
||||
this.logger.error(`ASR failed: ${e?.message || e}`)
|
||||
return { text: '' }
|
||||
} finally {
|
||||
try { if (dest) fs.unlinkSync(dest) } catch {}
|
||||
try { if (wavPath && wavPath !== dest) fs.unlinkSync(wavPath) } catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Injectable, HttpException, HttpStatus, Logger } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { User, UserDocument } from './user.schema'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
import { GravityTransaction, GravityTransactionType } from '../schemas/gravity-transaction.schema'
|
||||
|
||||
const FREE_OPTIMIZE_LIMIT = 3
|
||||
|
||||
@@ -11,119 +13,188 @@ export class QuotaService {
|
||||
|
||||
constructor(
|
||||
@InjectModel(User.name) private userModel: Model<UserDocument>,
|
||||
@InjectModel(GravityTransaction.name) private gravityTxModel: Model<GravityTransaction>,
|
||||
private pricingService: PricingService,
|
||||
) {}
|
||||
|
||||
private async logTransaction(userId: string, amount: number, type: GravityTransactionType, description: string, refId?: string) {
|
||||
const u = await this.userModel.findById(userId).select('gravity').exec()
|
||||
const balance = u?.gravity ?? 0
|
||||
await this.gravityTxModel.create({ userId, amount, balance, type, description, refId })
|
||||
}
|
||||
|
||||
/** 仅检查面试引力值是否充足,不扣除(用于先 AI 后扣款模式) */
|
||||
async checkInterview(userId: string): Promise<number> {
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
|
||||
// 迁移旧字段到 gravity
|
||||
if ((user.gravity ?? 0) <= 0 && this.hasOldCredits(user)) {
|
||||
await this.migrateOldCredits(userId)
|
||||
}
|
||||
|
||||
const rates = (await this.pricingService.getConfig()).gravityRates
|
||||
const cost = rates.interviewPerUse
|
||||
|
||||
// 检查 gravity 或 shareCredits 是否足够
|
||||
const gravOk = (user.gravity ?? 0) >= cost
|
||||
const shareOk = (user.shareCredits ?? 0) > 0
|
||||
if (!gravOk && !shareOk) {
|
||||
throw new HttpException('引力值不足,请充值或分享获取', HttpStatus.FORBIDDEN)
|
||||
}
|
||||
return cost
|
||||
}
|
||||
|
||||
/** 扣除面试引力值(在 AI 调用成功后调用) */
|
||||
async deductInterview(userId: string, cost: number) {
|
||||
const result = await this.deductGravityOrFallback(userId, cost)
|
||||
if (!result) {
|
||||
throw new HttpException('引力值不足', HttpStatus.FORBIDDEN)
|
||||
}
|
||||
}
|
||||
|
||||
/** 检查并扣除面试引力值(所有计划统一走引力值) */
|
||||
async checkAndDeductInterview(userId: string) {
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
if (user.plan !== 'free') return
|
||||
|
||||
// Backward compat: migrate remaining → interviewCredits
|
||||
if ((user.interviewCredits ?? 0) <= 0 && (user.remaining ?? 0) > 0) {
|
||||
await this.userModel.findByIdAndUpdate(userId, {
|
||||
$set: { interviewCredits: user.remaining, remaining: 0 },
|
||||
}).exec()
|
||||
// 迁移旧字段到 gravity
|
||||
if ((user.gravity ?? 0) <= 0 && this.hasOldCredits(user)) {
|
||||
await this.migrateOldCredits(userId)
|
||||
}
|
||||
|
||||
const result = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, interviewCredits: { $gt: 0 } },
|
||||
{ $inc: { interviewCredits: -1, interviewCount: 1 } },
|
||||
{ new: true },
|
||||
).exec()
|
||||
const rates = (await this.pricingService.getConfig()).gravityRates
|
||||
const cost = rates.interviewPerUse
|
||||
|
||||
// 用 gravity 支付,后备 shareCredits
|
||||
const result = await this.deductGravityOrFallback(userId, cost)
|
||||
if (result) return
|
||||
|
||||
// Fallback to share credits
|
||||
const shareResult = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, shareCredits: { $gt: 0 } },
|
||||
{ $inc: { shareCredits: -1, interviewCount: 1 } },
|
||||
).exec()
|
||||
if (shareResult) return
|
||||
|
||||
throw new HttpException('面试次数已用完,请购买面试次数或开通会员', HttpStatus.FORBIDDEN)
|
||||
throw new HttpException('引力值不足,请充值或分享获取', HttpStatus.FORBIDDEN)
|
||||
}
|
||||
|
||||
/** 检查并扣除优化引力值(所有计划统一走引力值) */
|
||||
async checkAndDeductOptimize(userId: string) {
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
if (user.plan !== 'free') return
|
||||
|
||||
// Try paid credits first
|
||||
const paid = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, resumeOptimizeCredits: { $gt: 0 } },
|
||||
{ $inc: { resumeOptimizeCredits: -1 } },
|
||||
).exec()
|
||||
if (paid) return
|
||||
// 迁移旧字段
|
||||
if ((user.gravity ?? 0) <= 0 && this.hasOldCredits(user)) {
|
||||
await this.migrateOldCredits(userId)
|
||||
}
|
||||
|
||||
// Try old remaining credits (backward compat)
|
||||
const oldRemaining = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, remaining: { $gt: 0 } },
|
||||
{ $inc: { remaining: -1 } },
|
||||
).exec()
|
||||
if (oldRemaining) return
|
||||
|
||||
// Then free limit
|
||||
// 免费优化次数
|
||||
const freeResult = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, freeOptimizeUsed: { $lt: FREE_OPTIMIZE_LIMIT } },
|
||||
{ $inc: { freeOptimizeUsed: 1 } },
|
||||
).exec()
|
||||
if (freeResult) return
|
||||
|
||||
// Fallback to share credits
|
||||
const rates = (await this.pricingService.getConfig()).gravityRates
|
||||
const cost = rates.optimizePerUse
|
||||
|
||||
const result = await this.deductGravityOrFallback(userId, cost)
|
||||
if (result) return
|
||||
|
||||
throw new HttpException('引力值不足,请充值或分享获取', HttpStatus.FORBIDDEN)
|
||||
}
|
||||
|
||||
/** 检查并扣除下载引力值 */
|
||||
async checkAndDeductDownload(userId: string, paidDownload: boolean): Promise<boolean> {
|
||||
if (paidDownload) return true
|
||||
|
||||
const rates = (await this.pricingService.getConfig()).gravityRates
|
||||
const cost = rates.downloadPerUse
|
||||
|
||||
const result = await this.deductGravityOrFallback(userId, cost)
|
||||
if (result) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/** 从 gravity 扣除,后备从 shareCredits 扣除(兼容旧数据) */
|
||||
private async deductGravityOrFallback(userId: string, cost: number): Promise<boolean> {
|
||||
const gravResult = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, gravity: { $gte: cost } },
|
||||
{ $inc: { gravity: -cost } },
|
||||
).exec()
|
||||
if (gravResult) {
|
||||
await this.logTransaction(userId, -cost, 'interview_deduct', `AI 模拟面试消耗 ${cost} 引力值`)
|
||||
return true
|
||||
}
|
||||
|
||||
const shareResult = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, shareCredits: { $gt: 0 } },
|
||||
{ $inc: { shareCredits: -1 } },
|
||||
).exec()
|
||||
if (shareResult) return
|
||||
|
||||
throw new HttpException('简历优化次数已用完,请购买优化次数或开通会员', HttpStatus.FORBIDDEN)
|
||||
if (shareResult) {
|
||||
await this.logTransaction(userId, 0, 'share_credits_fallback', '分享币后备抵扣 1 次')
|
||||
return true
|
||||
}
|
||||
|
||||
async grantShareCredits(userId: string, amount = 1): Promise<boolean> {
|
||||
const result = await this.userModel.findByIdAndUpdate(
|
||||
userId,
|
||||
{ $inc: { shareCredits: amount } },
|
||||
).exec()
|
||||
return !!result
|
||||
return false
|
||||
}
|
||||
|
||||
async checkAndDeductDownload(userId: string, paidDownload: boolean): Promise<boolean> {
|
||||
if (paidDownload) return true
|
||||
|
||||
const result = await this.userModel.findOneAndUpdate(
|
||||
{ _id: userId, resumeDownloadCredits: { $gt: 0 } },
|
||||
{ $inc: { resumeDownloadCredits: -1 } },
|
||||
).exec()
|
||||
return !!result
|
||||
}
|
||||
|
||||
async grantCredits(userId: string, type: 'interview' | 'optimize' | 'download', amount: number) {
|
||||
/** 增加引力值 */
|
||||
async grantGravity(userId: string, amount: number) {
|
||||
if (amount <= 0) throw new HttpException('无效数量', HttpStatus.BAD_REQUEST)
|
||||
|
||||
const fieldMap: Record<string, string> = {
|
||||
interview: 'interviewCredits',
|
||||
optimize: 'resumeOptimizeCredits',
|
||||
download: 'resumeDownloadCredits',
|
||||
}
|
||||
const field = fieldMap[type]
|
||||
if (!field) throw new HttpException('无效类型', HttpStatus.BAD_REQUEST)
|
||||
|
||||
const result = await this.userModel.findByIdAndUpdate(
|
||||
userId,
|
||||
{ $inc: { [field]: amount } },
|
||||
{ $inc: { gravity: amount } },
|
||||
).exec()
|
||||
if (!result) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
await this.logTransaction(userId, amount, 'purchase', `充值获得 ${amount} 引力值`)
|
||||
}
|
||||
|
||||
async setPlanQuota(userId: string, _plan: string, credits: { interview: number; resumeOptimize: number; resumeDownload: number }) {
|
||||
/** 设置 VIP 套餐引力值额度 */
|
||||
async setPlanQuota(userId: string, gravityAmount: number) {
|
||||
const result = await this.userModel.findByIdAndUpdate(userId, {
|
||||
$set: {
|
||||
remaining: 999,
|
||||
interviewCredits: credits.interview,
|
||||
resumeOptimizeCredits: credits.resumeOptimize,
|
||||
resumeDownloadCredits: credits.resumeDownload,
|
||||
gravity: gravityAmount,
|
||||
freeOptimizeUsed: FREE_OPTIMIZE_LIMIT,
|
||||
},
|
||||
}).exec()
|
||||
if (!result) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
await this.logTransaction(userId, gravityAmount, 'plan_set', `套餐开通,获得 ${gravityAmount} 引力值`)
|
||||
}
|
||||
|
||||
/** 是否为非会员用户授予初始引力值 */
|
||||
async grantFreeGravity(userId: string) {
|
||||
await this.userModel.findByIdAndUpdate(userId, {
|
||||
$set: { interviewCredits: 1, gravity: 5 },
|
||||
}).exec()
|
||||
await this.logTransaction(userId, 5, 'registration', '注册赠送 5 引力值')
|
||||
}
|
||||
|
||||
/** 判断是否有旧额度需要迁移 */
|
||||
private hasOldCredits(user: UserDocument): boolean {
|
||||
return (user.interviewCredits ?? 0) > 0
|
||||
|| (user.resumeOptimizeCredits ?? 0) > 0
|
||||
|| (user.resumeDownloadCredits ?? 0) > 0
|
||||
|| (user.remaining ?? 0) > 0
|
||||
}
|
||||
|
||||
/** 迁移旧额度到 gravity */
|
||||
private async migrateOldCredits(userId: string) {
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) return
|
||||
const interviewVal = (user.interviewCredits ?? 0) * 5
|
||||
const optimizeVal = (user.resumeOptimizeCredits ?? 0) * 3
|
||||
const downloadVal = (user.resumeDownloadCredits ?? 0) * 2
|
||||
const oldRemainVal = (user.remaining ?? 0) * 5
|
||||
const shareVal = (user.shareCredits ?? 0) * 1
|
||||
const total = interviewVal + optimizeVal + downloadVal + oldRemainVal + shareVal
|
||||
if (total <= 0) return
|
||||
await this.userModel.findByIdAndUpdate(userId, {
|
||||
$inc: { gravity: total },
|
||||
$set: {
|
||||
interviewCredits: 0,
|
||||
resumeOptimizeCredits: 0,
|
||||
resumeDownloadCredits: 0,
|
||||
remaining: 0,
|
||||
shareCredits: 0,
|
||||
},
|
||||
}).exec()
|
||||
await this.logTransaction(userId, total, 'migration', `旧额度迁移,获得 ${total} 引力值`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Controller, Post, Get, Put, Body, Req, HttpCode, HttpStatus } from '@nestjs/common'
|
||||
import { Controller, Post, Get, Put, Query, Body, Req, HttpCode, HttpStatus, UseGuards } from '@nestjs/common'
|
||||
import { UserService } from './user.service'
|
||||
import { Public } from '../../common/decorators/public.decorator'
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
||||
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
@@ -17,8 +18,8 @@ export class UserController {
|
||||
@Public()
|
||||
@Post('login')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async login(@Body('phone') phone: string, @Body('code') code: string) {
|
||||
return this.userService.loginByPhone(phone, code)
|
||||
async login(@Body('phone') phone: string, @Body('code') code: string, @Req() req) {
|
||||
return this.userService.loginByPhone(phone, code, req.ip)
|
||||
}
|
||||
|
||||
// 📧 邮箱验证码登录(H5 用)
|
||||
@@ -29,35 +30,43 @@ export class UserController {
|
||||
return this.userService.sendEmailCode(email)
|
||||
}
|
||||
|
||||
/** 绑定微信 openid 到当前登录用户 */
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('bind-wx')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async bindWx(@CurrentUser('userId') userId: string, @Body('code') code: string) {
|
||||
return this.userService.bindWxOpenid(userId, code)
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('email-login')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async emailLogin(@Body('email') email: string, @Body('code') code: string) {
|
||||
return this.userService.loginByEmail(email, code)
|
||||
async emailLogin(@Body('email') email: string, @Body('code') code: string, @Req() req) {
|
||||
return this.userService.loginByEmail(email, code, req.ip)
|
||||
}
|
||||
|
||||
// 密码登录
|
||||
@Public()
|
||||
@Post('password-login')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async passwordLogin(@Body('email') email: string, @Body('password') password: string) {
|
||||
return this.userService.loginByPassword(email, password)
|
||||
async passwordLogin(@Body('email') email: string, @Body('password') password: string, @Req() req) {
|
||||
return this.userService.loginByPassword(email, password, req.ip)
|
||||
}
|
||||
|
||||
// 邮箱+密码注册
|
||||
@Public()
|
||||
@Post('register')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async register(@Body('email') email: string, @Body('password') password: string) {
|
||||
return this.userService.registerWithPassword(email, password)
|
||||
async register(@Body('email') email: string, @Body('password') password: string, @Req() req) {
|
||||
return this.userService.registerWithPassword(email, password, req.ip)
|
||||
}
|
||||
|
||||
// 微信静默登录
|
||||
@Public()
|
||||
@Post('wx-login')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async wxLogin(@Body('code') code: string) {
|
||||
return this.userService.loginByWx(code)
|
||||
async wxLogin(@Body('code') code: string, @Req() req) {
|
||||
return this.userService.loginByWx(code, undefined, req.ip)
|
||||
}
|
||||
|
||||
@Get('info')
|
||||
@@ -79,4 +88,13 @@ export class UserController {
|
||||
async setPassword(@CurrentUser('userId') userId: string, @Body('password') password: string) {
|
||||
return this.userService.setPassword(userId, password)
|
||||
}
|
||||
|
||||
@Get('gravity-transactions')
|
||||
async getGravityTransactions(
|
||||
@CurrentUser('userId') userId: string,
|
||||
@Query('page') page = '1',
|
||||
@Query('limit') limit = '20',
|
||||
) {
|
||||
return this.userService.getGravityTransactions(userId, parseInt(page), parseInt(limit))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ export type UserDocument = User & Document
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
export class User {
|
||||
@Prop({ sparse: true })
|
||||
@Prop({ unique: true, sparse: true })
|
||||
phone?: string
|
||||
|
||||
@Prop({ sparse: true })
|
||||
@Prop({ unique: true, sparse: true })
|
||||
wxOpenid?: string
|
||||
|
||||
@Prop({ default: '' })
|
||||
@@ -49,7 +49,10 @@ export class User {
|
||||
freeOptimizeUsed: number // 已使用免费优化次数(上限 3)
|
||||
|
||||
@Prop({ default: 0 })
|
||||
shareCredits: number // 分享积分,每 3 次有效访问获 1 积分
|
||||
gravity: number // 引力值(统一额度),面试 5、优化 3、下载 2
|
||||
|
||||
@Prop({ default: 0 })
|
||||
shareCredits: number // 已合并到 gravity,保留字段防报错
|
||||
|
||||
@Prop({ default: 'user' })
|
||||
role: string // 'user' | 'admin'
|
||||
@@ -57,11 +60,26 @@ export class User {
|
||||
@Prop({ default: false })
|
||||
isSystemAdmin: boolean
|
||||
|
||||
@Prop({ sparse: true })
|
||||
@Prop({ unique: true, sparse: true })
|
||||
email?: string
|
||||
|
||||
@Prop({ default: '', select: false })
|
||||
password?: string
|
||||
|
||||
@Prop()
|
||||
lastLoginAt?: Date
|
||||
|
||||
@Prop({ default: '' })
|
||||
lastLoginIp?: string
|
||||
|
||||
@Prop({ default: '' })
|
||||
lastLoginLocation?: string
|
||||
}
|
||||
|
||||
export const UserSchema = SchemaFactory.createForClass(User)
|
||||
|
||||
UserSchema.pre('save', async function () {
|
||||
if (!this.phone && !this.wxOpenid && !this.email) {
|
||||
throw new Error('用户必须至少有一个联系方式(手机号/微信/邮箱)')
|
||||
}
|
||||
})
|
||||
@@ -4,6 +4,7 @@ import { JwtService } from '@nestjs/jwt'
|
||||
import { HttpException } from '@nestjs/common'
|
||||
import { UserService } from './user.service'
|
||||
import { EmailService } from '../email/email.service'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
|
||||
describe('UserService', () => {
|
||||
let service: UserService
|
||||
@@ -44,8 +45,10 @@ describe('UserService', () => {
|
||||
providers: [
|
||||
UserService,
|
||||
{ provide: getModelToken('User'), useValue: mockUserModel },
|
||||
{ provide: getModelToken('GravityTransaction'), useValue: { create: jest.fn() } },
|
||||
{ provide: JwtService, useValue: mockJwtService },
|
||||
{ provide: EmailService, useValue: mockEmailService },
|
||||
{ provide: PricingService, useValue: { getConfig: jest.fn().mockResolvedValue({ registrationGravity: 50, gravityRates: { interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 }, plans: { growth: { gravityPerMonth: 80 }, sprint: { gravityPerMonth: 200 } } }) } },
|
||||
],
|
||||
}).compile()
|
||||
|
||||
|
||||
@@ -2,9 +2,23 @@
|
||||
import { Injectable, HttpException, HttpStatus, Logger } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { User, UserDocument } from './user.schema'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { EmailService } from '../email/email.service'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
import { GravityTransaction, GravityTransactionType } from '../schemas/gravity-transaction.schema'
|
||||
|
||||
/** 通过 IP 查询粗略地理位置(ip-api.com 免费接口) */
|
||||
async function lookupIpLocation(ip: string): Promise<string> {
|
||||
if (!ip || ip === '127.0.0.1' || ip === '::1' || ip.startsWith('192.168.') || ip.startsWith('10.')) return ''
|
||||
try {
|
||||
const res = await fetch(`http://ip-api.com/json/${ip}?fields=country,regionName,city&lang=zh-CN`, { signal: AbortSignal.timeout(3000) })
|
||||
if (!res.ok) return ''
|
||||
const data: any = await res.json()
|
||||
if (data.status !== 'success') return ''
|
||||
return [data.country, data.regionName, data.city].filter(Boolean).join(' ')
|
||||
} catch { return '' }
|
||||
}
|
||||
|
||||
// In-memory stores
|
||||
const codeStore = new Map<string, { code: string; expiresAt: number }>()
|
||||
@@ -16,10 +30,18 @@ export class UserService {
|
||||
|
||||
constructor(
|
||||
@InjectModel(User.name) private userModel: Model<UserDocument>,
|
||||
@InjectModel(GravityTransaction.name) private gravityTxModel: Model<GravityTransaction>,
|
||||
private jwtService: JwtService,
|
||||
private emailService: EmailService,
|
||||
private pricingService: PricingService,
|
||||
) {}
|
||||
|
||||
private async logTransaction(userId: string, amount: number, type: GravityTransactionType, description: string) {
|
||||
const u = await this.userModel.findById(userId).select('gravity').exec()
|
||||
const balance = u?.gravity ?? 0
|
||||
await this.gravityTxModel.create({ userId, amount, balance, type, description })
|
||||
}
|
||||
|
||||
async sendCode(phone: string) {
|
||||
const code = process.env.NODE_ENV === 'production'
|
||||
? String(Math.floor(100000 + Math.random() * 900000))
|
||||
@@ -33,7 +55,7 @@ export class UserService {
|
||||
return { message: '验证码已发送' }
|
||||
}
|
||||
|
||||
async loginByPhone(phone: string, code: string) {
|
||||
async loginByPhone(phone: string, code: string, ip?: string) {
|
||||
const record = codeStore.get(phone)
|
||||
if (!record || record.code !== code) {
|
||||
throw new HttpException('验证码错误', HttpStatus.UNAUTHORIZED)
|
||||
@@ -45,15 +67,21 @@ export class UserService {
|
||||
codeStore.delete(phone)
|
||||
|
||||
let user = await this.userModel.findOne({ phone }).exec()
|
||||
let isNew = false
|
||||
if (!user) {
|
||||
user = await this.userModel.create({ phone, nickname: `用户${phone.slice(-4)}` })
|
||||
isNew = true
|
||||
user = await this.userModel.create({ phone, nickname: `用户${phone.slice(-4)}`, gravity: (await this.pricingService.getConfig()).registrationGravity })
|
||||
}
|
||||
|
||||
await this.recordLogin(user._id.toString(), ip)
|
||||
if (isNew) {
|
||||
const amount = (await this.pricingService.getConfig()).registrationGravity
|
||||
await this.logTransaction(user._id.toString(), amount, 'registration', '注册赠送引力值')
|
||||
}
|
||||
return this.generateAuthResponse(user)
|
||||
}
|
||||
|
||||
async loginByWx(code: string) {
|
||||
// WeChat silent login - exchange code for openid
|
||||
async loginByWx(code: string, userId?: string, ip?: string) {
|
||||
const appid = process.env.WX_APPID
|
||||
const secret = process.env.WX_SECRET
|
||||
if (!appid || !secret) {
|
||||
@@ -70,15 +98,66 @@ export class UserService {
|
||||
}
|
||||
|
||||
const openid = wxData.openid
|
||||
let user = await this.userModel.findOne({ wxOpenid: openid }).exec()
|
||||
if (!user) {
|
||||
user = await this.userModel.create({ wxOpenid: openid, nickname: '微信用户' })
|
||||
|
||||
if (userId) {
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
if (user.wxOpenid) throw new HttpException('该账号已绑定微信', HttpStatus.CONFLICT)
|
||||
user.wxOpenid = openid
|
||||
await user.save()
|
||||
return this.generateAuthResponse(user)
|
||||
}
|
||||
|
||||
let user = await this.userModel.findOne({ wxOpenid: openid }).exec()
|
||||
let isNew = false
|
||||
if (!user) {
|
||||
isNew = true
|
||||
user = await this.userModel.create({ wxOpenid: openid, nickname: '微信用户', gravity: (await this.pricingService.getConfig()).registrationGravity })
|
||||
}
|
||||
|
||||
await this.recordLogin(user._id.toString(), ip)
|
||||
if (isNew) {
|
||||
const amount = (await this.pricingService.getConfig()).registrationGravity
|
||||
await this.logTransaction(user._id.toString(), amount, 'registration', '注册赠送引力值')
|
||||
}
|
||||
return this.generateAuthResponse(user)
|
||||
}
|
||||
|
||||
// 📧 邮箱验证码
|
||||
async bindWxOpenid(userId: string, code: string) {
|
||||
this.logger.log(`[bindWx] userId=${userId}, code=${code ? '已提供' : '空'}`)
|
||||
const appid = process.env.WX_APPID
|
||||
const secret = process.env.WX_SECRET
|
||||
if (!appid || !secret) {
|
||||
this.logger.error(`[bindWx] 微信配置不完整`)
|
||||
throw new HttpException('微信登录未配置', HttpStatus.SERVICE_UNAVAILABLE)
|
||||
}
|
||||
|
||||
const wxRes = await fetch(
|
||||
`https://api.weixin.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${code}&grant_type=authorization_code`,
|
||||
)
|
||||
const wxData: any = await wxRes.json()
|
||||
this.logger.log(`[bindWx] 微信接口返回: ${JSON.stringify(wxData)}`)
|
||||
|
||||
if (wxData.errcode) {
|
||||
this.logger.error(`[bindWx] 微信登录失败: ${wxData.errmsg}, rid: ${wxData.rid || '无'}`)
|
||||
throw new HttpException(`微信登录失败: ${wxData.errmsg}`, HttpStatus.UNAUTHORIZED)
|
||||
}
|
||||
|
||||
const openid = wxData.openid
|
||||
this.logger.log(`[bindWx] 获取到openid=${openid}`)
|
||||
const existing = await this.userModel.findOne({ wxOpenid: openid }).exec()
|
||||
if (existing) {
|
||||
this.logger.warn(`[bindWx] openid=${openid} 已绑定到其他用户 ${existing._id}`)
|
||||
throw new HttpException('该微信号已绑定其他账号', HttpStatus.CONFLICT)
|
||||
}
|
||||
|
||||
const user = await this.userModel.findByIdAndUpdate(userId, { wxOpenid: openid }, { new: true }).exec()
|
||||
if (!user) { this.logger.error(`[bindWx] 用户不存在 userId=${userId}`); throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) }
|
||||
this.logger.log(`[bindWx] openid=${openid} 绑定到用户 ${userId} 成功`)
|
||||
return { message: '微信绑定成功', wxOpenid: openid }
|
||||
}
|
||||
|
||||
async sendEmailCode(email: string) {
|
||||
if (!email || !email.includes('@')) {
|
||||
throw new HttpException('请输入正确的邮箱地址', HttpStatus.BAD_REQUEST)
|
||||
@@ -96,7 +175,7 @@ export class UserService {
|
||||
return { message: '验证码已发送,请查收邮件' }
|
||||
}
|
||||
|
||||
async loginByEmail(email: string, code: string) {
|
||||
async loginByEmail(email: string, code: string, ip?: string) {
|
||||
const record = emailCodeStore.get(email)
|
||||
if (!record || record.code !== code) {
|
||||
throw new HttpException('验证码错误', HttpStatus.UNAUTHORIZED)
|
||||
@@ -113,23 +192,29 @@ export class UserService {
|
||||
if (!user) {
|
||||
isNew = true
|
||||
const nick = email.split('@')[0]
|
||||
user = await this.userModel.create({ email, nickname: nick, remaining: 3 })
|
||||
user = await this.userModel.create({ email, nickname: nick, remaining: 0, gravity: (await this.pricingService.getConfig()).registrationGravity })
|
||||
}
|
||||
await this.recordLogin(user._id.toString(), ip)
|
||||
if (isNew) {
|
||||
const amount = (await this.pricingService.getConfig()).registrationGravity
|
||||
await this.logTransaction(user._id.toString(), amount, 'registration', '注册赠送引力值')
|
||||
}
|
||||
return { ...this.generateAuthResponse(user), isNew, hasPassword: !!user.password }
|
||||
}
|
||||
|
||||
// 🔐 密码登录
|
||||
async loginByPassword(email: string, password: string) {
|
||||
async loginByPassword(email: string, password: string, ip?: string) {
|
||||
const user = await this.userModel.findOne({ email }).select('+password').exec()
|
||||
if (!user) throw new HttpException('账号不存在', HttpStatus.NOT_FOUND)
|
||||
if (!user.password) throw new HttpException('该账号未设置密码,请使用验证码登录', HttpStatus.UNAUTHORIZED)
|
||||
const match = await bcrypt.compare(password, user.password)
|
||||
if (!match) throw new HttpException('密码错误', HttpStatus.UNAUTHORIZED)
|
||||
await this.recordLogin(user._id.toString(), ip)
|
||||
return this.generateAuthResponse(user)
|
||||
}
|
||||
|
||||
// 📝 邮箱+密码注册
|
||||
async registerWithPassword(email: string, password: string) {
|
||||
async registerWithPassword(email: string, password: string, ip?: string) {
|
||||
if (!email || !email.includes('@')) {
|
||||
throw new HttpException('请输入正确的邮箱地址', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
@@ -144,11 +229,15 @@ export class UserService {
|
||||
// 已有验证码注册的用户,补充设置密码
|
||||
existing.password = await bcrypt.hash(password, 10)
|
||||
await existing.save()
|
||||
await this.recordLogin(existing._id.toString(), ip)
|
||||
return this.generateAuthResponse(existing)
|
||||
}
|
||||
const nick = email.split('@')[0]
|
||||
const hashed = await bcrypt.hash(password, 10)
|
||||
const user = await this.userModel.create({ email, nickname: nick, password: hashed, remaining: 3 })
|
||||
const user = await this.userModel.create({ email, nickname: nick, password: hashed, remaining: 0, gravity: (await this.pricingService.getConfig()).registrationGravity })
|
||||
const amount = (await this.pricingService.getConfig()).registrationGravity
|
||||
await this.logTransaction(user._id.toString(), amount, 'registration', '注册赠送引力值')
|
||||
await this.recordLogin(user._id.toString(), ip)
|
||||
return this.generateAuthResponse(user)
|
||||
}
|
||||
|
||||
@@ -176,6 +265,17 @@ export class UserService {
|
||||
|
||||
getModel() { return this.userModel }
|
||||
|
||||
/** 记录登录时间/IP/归属地 */
|
||||
async recordLogin(userId: string, ip?: string) {
|
||||
const update: any = { lastLoginAt: new Date() }
|
||||
if (ip) {
|
||||
update.lastLoginIp = ip
|
||||
const location = await lookupIpLocation(ip)
|
||||
if (location) update.lastLoginLocation = location
|
||||
}
|
||||
await this.userModel.findByIdAndUpdate(userId, { $set: update }).exec()
|
||||
}
|
||||
|
||||
async getUsage(userId: string) {
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
@@ -191,6 +291,15 @@ export class UserService {
|
||||
await user.save()
|
||||
}
|
||||
|
||||
async getGravityTransactions(userId: string, page = 1, limit = 20) {
|
||||
const skip = (page - 1) * limit
|
||||
const [items, total] = await Promise.all([
|
||||
this.gravityTxModel.find({ userId }).sort({ createdAt: -1 }).skip(skip).limit(limit).exec(),
|
||||
this.gravityTxModel.countDocuments({ userId }),
|
||||
])
|
||||
return { items, total, page, limit, totalPages: Math.ceil(total / limit) }
|
||||
}
|
||||
|
||||
private generateAuthResponse(user: UserDocument) {
|
||||
const payload = { userId: user._id.toString(), phone: user.phone || '', role: user.role || 'user' }
|
||||
return {
|
||||
@@ -216,6 +325,10 @@ export class UserService {
|
||||
resumeDownloadCredits: user.resumeDownloadCredits ?? 0,
|
||||
freeOptimizeUsed: user.freeOptimizeUsed ?? 0,
|
||||
shareCredits: user.shareCredits ?? 0,
|
||||
gravity: user.gravity ?? 0,
|
||||
lastLoginAt: user.lastLoginAt,
|
||||
lastLoginIp: user.lastLoginIp,
|
||||
lastLoginLocation: user.lastLoginLocation,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
import { Controller, Post, Get, Param, Body, Query, UseGuards, HttpException, HttpStatus, Logger, Req, HttpCode } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { User, UserDocument } from '../user/user.schema'
|
||||
import { PaymentOrder, PaymentOrderDocument } from '../payment/payment-order.schema'
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
||||
import { VirtualPaymentService } from './virtual-payment.service'
|
||||
import { PricingService } from '../schemas/pricing.service'
|
||||
import { QuotaService } from '../user/quota.service'
|
||||
import { Public } from '../../common/decorators/public.decorator'
|
||||
|
||||
@Controller('virtual-payment')
|
||||
export class VirtualPaymentController {
|
||||
private readonly logger = new Logger(VirtualPaymentController.name)
|
||||
|
||||
constructor(
|
||||
@InjectModel(User.name) private userModel: Model<UserDocument>,
|
||||
@InjectModel(PaymentOrder.name) private orderModel: Model<PaymentOrderDocument>,
|
||||
private vpService: VirtualPaymentService,
|
||||
private pricingService: PricingService,
|
||||
private quotaService: QuotaService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 创建虚拟支付订单(小程序代币充值)
|
||||
* 返回前端调起 wx.requestVirtualPayment 所需的全部参数
|
||||
*/
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('create')
|
||||
@HttpCode(200)
|
||||
async create(
|
||||
@CurrentUser('userId') userId: string,
|
||||
@Body('type') type: string,
|
||||
@Body('quantity') quantity: number = 1,
|
||||
@Body('wxCode') wxCode: string,
|
||||
@Req() req: any,
|
||||
) {
|
||||
if (!['interview', 'optimize', 'download', 'growth', 'sprint'].includes(type)) {
|
||||
throw new HttpException('无效产品类型', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
const user = await this.userModel.findById(userId).exec()
|
||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||
if (!user.wxOpenid) {
|
||||
throw new HttpException({ message: '未绑定微信', needBindWx: true }, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
if (!wxCode) {
|
||||
throw new HttpException('缺少 wxCode,请先调用 wx.login()', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
const isPlan = type === 'growth' || type === 'sprint'
|
||||
if (isPlan && user.plan !== 'free') {
|
||||
throw new HttpException('已是会员', HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
|
||||
let totalFee: number
|
||||
let qty = 1
|
||||
let productQty = Math.max(1, Math.min(99, quantity || 1))
|
||||
|
||||
if (isPlan) {
|
||||
const planCfg = pricing.plans[type]
|
||||
if (!planCfg) throw new HttpException('套餐未配置', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
totalFee = planCfg.price
|
||||
} else {
|
||||
const priceMap: Record<string, number> = {
|
||||
interview: pricing.interview.pricePerSession,
|
||||
optimize: pricing.resumeOptimize.pricePerOptimize,
|
||||
download: pricing.resumeDownload.pricePerDownload,
|
||||
}
|
||||
qty = productQty
|
||||
totalFee = priceMap[type] * qty
|
||||
if (!totalFee) throw new HttpException('价格未配置', HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
const mode = 'short_series_coin'
|
||||
const buyQuantity = totalFee / 100 // 控制台配 1 币 = 1 元,totalFee 单位分
|
||||
const outTradeNo = `VP${type.slice(0, 2).toUpperCase()}${Date.now()}${userId.slice(-6)}`
|
||||
const env = process.env.VP_SANDBOX === 'true' ? 1 : (process.env.NODE_ENV === 'production' ? 0 : 1)
|
||||
const userIp = req.ip || '127.0.0.1'
|
||||
|
||||
// 1. 用 wx.login code 换取 session_key + openid,计算用户态签名
|
||||
let openid: string
|
||||
let signature: string
|
||||
try {
|
||||
const signData = this.vpService.buildSignData(outTradeNo, user.wxOpenid, totalFee, userIp, env, mode, buyQuantity)
|
||||
const result = await this.vpService.exchangeCodeAndSign(wxCode, signData)
|
||||
openid = result.openid
|
||||
signature = result.signature
|
||||
} catch (e: any) {
|
||||
this.logger.error(`[VP] code2session 失败: userId=${userId}, wxCode=${wxCode?.slice(0, 20)}, error=${e.message}, stack=${e.stack?.slice(0, 300)}`)
|
||||
throw new HttpException(`微信身份验证失败: ${e.message}`, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
// 校验 openid 一致
|
||||
this.logger.log(`[VP] code2session 成功: userId=${userId}, wxOpenid=${user.wxOpenid}, code2session_openid=${openid}`)
|
||||
if (openid !== user.wxOpenid) {
|
||||
this.logger.warn(`[VP] openid 不匹配: userId=${userId}, stored=${user.wxOpenid}, got=${openid}`)
|
||||
throw new HttpException('微信身份不匹配', HttpStatus.FORBIDDEN)
|
||||
}
|
||||
|
||||
// 2. 计算支付签名 pay_sig
|
||||
const signData = this.vpService.buildSignData(outTradeNo, openid, totalFee, userIp, env, mode, buyQuantity)
|
||||
const paySig = this.vpService.computePaySig('requestVirtualPayment', signData, env)
|
||||
|
||||
// 3. 创建本地订单
|
||||
let title: string
|
||||
const titles: Record<string, string> = {
|
||||
interview: 'AI 模拟面试',
|
||||
optimize: '简历优化',
|
||||
download: '简历下载',
|
||||
growth: '成长版月度会员',
|
||||
sprint: '冲刺版月度会员',
|
||||
}
|
||||
if (isPlan) {
|
||||
title = titles[type]
|
||||
} else {
|
||||
title = qty > 1 ? `${titles[type]} ×${qty}` : titles[type]
|
||||
}
|
||||
await this.orderModel.create({
|
||||
outTradeNo,
|
||||
userId,
|
||||
userPhone: user.phone || '',
|
||||
amount: totalFee,
|
||||
title,
|
||||
status: 'pending',
|
||||
channel: 'virtual',
|
||||
type,
|
||||
plan: isPlan ? type : 'growth',
|
||||
metadata: { quantity: qty },
|
||||
})
|
||||
|
||||
return {
|
||||
outTradeNo,
|
||||
env,
|
||||
mode,
|
||||
offerId: this.vpService.getOfferId(),
|
||||
signData,
|
||||
paySig,
|
||||
signature,
|
||||
openid,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信消息推送回调——虚拟支付通知
|
||||
* 在小程序管理后台 → 开发 → 开发管理 → 消息推送 中配置服务器地址指向此接口
|
||||
*/
|
||||
@Public()
|
||||
@Post('callback')
|
||||
async callback(@Body() body: any, @Req() req: any) {
|
||||
try {
|
||||
// 微信消息体可能是 XML 或 JSON
|
||||
const msg = body.xml || body
|
||||
const event = msg.Event || msg.event
|
||||
|
||||
this.logger.log(`[vp-callback] event=${event}, body=${JSON.stringify(body).slice(0, 500)}`)
|
||||
|
||||
if (event === 'xpay_coin_pay_notify') {
|
||||
await this.handleCoinPayNotify(msg)
|
||||
} else if (event === 'xpay_goods_deliver_notify') {
|
||||
await this.handleGoodsDeliverNotify(msg)
|
||||
} else if (event === 'xpay_refund_notify') {
|
||||
await this.handleRefundNotify(msg)
|
||||
} else {
|
||||
this.logger.warn(`[vp-callback] 未知事件: ${event}`)
|
||||
}
|
||||
|
||||
return { ErrCode: 0, ErrMsg: 'success' }
|
||||
} catch (e: any) {
|
||||
this.logger.error(`[vp-callback] 处理失败: ${e.message}`)
|
||||
return { ErrCode: -1, ErrMsg: e.message }
|
||||
}
|
||||
}
|
||||
|
||||
private async handleCoinPayNotify(msg: any) {
|
||||
const outTradeNo = msg.OutTradeNo || msg.out_trade_no
|
||||
if (!outTradeNo) {
|
||||
this.logger.warn('[vp-callback] 代币支付通知缺少 outTradeNo')
|
||||
return
|
||||
}
|
||||
|
||||
const order = await this.orderModel.findOne({ outTradeNo }).exec()
|
||||
if (!order) {
|
||||
this.logger.warn(`[vp-callback] 订单不存在: ${outTradeNo}`)
|
||||
return
|
||||
}
|
||||
if (order.status !== 'pending') {
|
||||
this.logger.log(`[vp-callback] 订单已处理: ${outTradeNo} status=${order.status}`)
|
||||
return
|
||||
}
|
||||
|
||||
order.status = 'success'
|
||||
order.paidAt = new Date()
|
||||
order.description = `虚拟支付代币充值成功 env=${msg.Env ?? ''}`
|
||||
await order.save()
|
||||
|
||||
const pricing = await this.pricingService.getConfig()
|
||||
|
||||
if (order.type === 'growth' || order.type === 'sprint') {
|
||||
// 套餐激活
|
||||
const planCfg = pricing.plans[order.type]
|
||||
if (!planCfg) return
|
||||
const expireAt = new Date()
|
||||
expireAt.setDate(expireAt.getDate() + planCfg.durationDays)
|
||||
await this.userModel.findByIdAndUpdate(order.userId, {
|
||||
$set: {
|
||||
plan: order.type,
|
||||
[order.type === 'sprint' ? 'sprintExpireAt' : 'vipExpireAt']: expireAt,
|
||||
...(order.type === 'sprint' ? { sprintRemaining: 10 } : {}),
|
||||
},
|
||||
}).exec()
|
||||
await this.quotaService.setPlanQuota(order.userId, planCfg.gravityPerMonth)
|
||||
this.logger.log(`[vp-callback] 套餐已激活: userId=${order.userId}, plan=${order.type}, gravityPerMonth=${planCfg.gravityPerMonth}`)
|
||||
} else {
|
||||
// 发放引力值(按次购买)
|
||||
const gravityMap: Record<string, number> = {
|
||||
interview: pricing.gravityRates.interviewPerUse,
|
||||
optimize: pricing.gravityRates.optimizePerUse,
|
||||
download: pricing.gravityRates.downloadPerUse,
|
||||
}
|
||||
const g = gravityMap[order.type]
|
||||
const quantity = order.metadata?.quantity || 1
|
||||
if (g) {
|
||||
await this.quotaService.grantGravity(order.userId, g * quantity)
|
||||
this.logger.log(`[vp-callback] 引力值已发放: userId=${order.userId}, gravity=${g * quantity}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async handleGoodsDeliverNotify(msg: any) {
|
||||
// 道具发货通知——代币模式下通常不需要额外处理
|
||||
this.logger.log(`[vp-callback] 道具发货通知: outTradeNo=${msg.OutTradeNo}`)
|
||||
}
|
||||
|
||||
private async handleRefundNotify(msg: any) {
|
||||
const outTradeNo = msg.MchOrderId || msg.MchOrderNo
|
||||
if (!outTradeNo) return
|
||||
const order = await this.orderModel.findOne({ outTradeNo }).exec()
|
||||
if (!order) return
|
||||
|
||||
order.status = 'refunded'
|
||||
order.refundAmount = msg.RefundFee || order.amount
|
||||
order.refundedAt = new Date()
|
||||
await order.save()
|
||||
this.logger.log(`[vp-callback] 订单已退款: ${outTradeNo}`)
|
||||
}
|
||||
|
||||
/** 查询本地订单状态(前端轮询) */
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('check/:outTradeNo')
|
||||
async checkOrder(@Param('outTradeNo') outTradeNo: string, @CurrentUser('userId') userId: string) {
|
||||
const order = await this.orderModel.findOne({ outTradeNo, userId }).exec()
|
||||
if (!order) throw new HttpException('订单不存在', HttpStatus.NOT_FOUND)
|
||||
return { status: order.status, type: order.type, paidAt: order.paidAt }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { MongooseModule } from '@nestjs/mongoose'
|
||||
import { VirtualPaymentController } from './virtual-payment.controller'
|
||||
import { VirtualPaymentService } from './virtual-payment.service'
|
||||
import { User, UserSchema } from '../user/user.schema'
|
||||
import { PaymentOrder, PaymentOrderSchema } from '../payment/payment-order.schema'
|
||||
import { PricingModule } from '../schemas/pricing.module'
|
||||
import { UserModule } from '../user/user.module'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MongooseModule.forFeature([
|
||||
{ name: User.name, schema: UserSchema },
|
||||
{ name: PaymentOrder.name, schema: PaymentOrderSchema },
|
||||
]),
|
||||
PricingModule,
|
||||
UserModule,
|
||||
],
|
||||
controllers: [VirtualPaymentController],
|
||||
providers: [VirtualPaymentService],
|
||||
})
|
||||
export class VirtualPaymentModule {}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { Injectable, Logger, InternalServerErrorException } from '@nestjs/common'
|
||||
import * as crypto from 'crypto'
|
||||
import axios from 'axios'
|
||||
|
||||
const WX_APPID = requireEnv('WX_APPID')
|
||||
const WX_SECRET = requireEnv('WX_SECRET')
|
||||
const VP_APPKEY = requireEnv('VP_APPKEY')
|
||||
const VP_APPKEY_SANDBOX = requireEnv('VP_APPKEY_SANDBOX')
|
||||
const VP_OFFER_ID = requireEnv('VP_OFFER_ID')
|
||||
|
||||
function requireEnv(name: string): string {
|
||||
const val = process.env[name]
|
||||
if (!val) throw new InternalServerErrorException(`环境变量 ${name} 未配置`)
|
||||
return val
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class VirtualPaymentService {
|
||||
private readonly logger = new Logger(VirtualPaymentService.name)
|
||||
|
||||
/** 计算支付签名 pay_sig */
|
||||
computePaySig(uri: string, postBody: string, env: number): string {
|
||||
const appKey = env === 1 ? VP_APPKEY_SANDBOX : VP_APPKEY
|
||||
const data = `${uri}&${postBody}`
|
||||
return crypto.createHmac('sha256', appKey).update(data).digest('hex')
|
||||
}
|
||||
|
||||
/** 通过 wx.login code 换取 session_key 并计算用户态签名 */
|
||||
async exchangeCodeAndSign(code: string, signData: string): Promise<{ openid: string; signature: string }> {
|
||||
const res = await axios.get('https://api.weixin.qq.com/sns/jscode2session', {
|
||||
params: { appid: WX_APPID, secret: WX_SECRET, js_code: code, grant_type: 'authorization_code' },
|
||||
timeout: 10000,
|
||||
})
|
||||
if (res.data.errcode) {
|
||||
throw new Error(`code2session 失败: ${res.data.errmsg}`)
|
||||
}
|
||||
const { openid, session_key } = res.data
|
||||
if (!session_key) {
|
||||
throw new Error('未获取到 session_key')
|
||||
}
|
||||
const signature = crypto.createHmac('sha256', session_key).update(signData).digest('hex')
|
||||
return { openid, signature }
|
||||
}
|
||||
|
||||
/** 构建 signData JSON 字符串(与 wx.requestVirtualPayment 要求的格式一致) */
|
||||
buildSignData(outTradeNo: string, openid: string, totalFee: number, userIp: string, env: number, mode: string, buyQuantity?: number): string {
|
||||
const base = {
|
||||
offerId: VP_OFFER_ID,
|
||||
env,
|
||||
outTradeNo,
|
||||
attach: outTradeNo,
|
||||
currencyType: 'CNY' as const,
|
||||
platform: 'android' as const,
|
||||
zoneId: '',
|
||||
}
|
||||
if (mode === 'short_series_coin') {
|
||||
// 代币充值
|
||||
return JSON.stringify({
|
||||
...base,
|
||||
buyQuantity: buyQuantity || 1,
|
||||
})
|
||||
}
|
||||
// short_series_goods — 道具直购
|
||||
return JSON.stringify({
|
||||
...base,
|
||||
productId: openid,
|
||||
goodsPrice: totalFee,
|
||||
})
|
||||
}
|
||||
|
||||
getOfferId(): string { return VP_OFFER_ID }
|
||||
|
||||
/** 验证消息推送签名(可选,依赖配置的 Token) */
|
||||
verifyPushSignature(signature: string, timestamp: string, nonce: string, token: string): boolean {
|
||||
const arr = [token, timestamp, nonce].sort()
|
||||
const sha1 = crypto.createHash('sha1').update(arr.join('')).digest('hex')
|
||||
return sha1 === signature
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,26 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
|
||||
const BASE = 'http://localhost:3006/api'
|
||||
|
||||
function getJwtSecret(): string {
|
||||
const envPath = path.resolve(__dirname, '..', '.env')
|
||||
const envContent = fs.readFileSync(envPath, 'utf8')
|
||||
const match = envContent.match(/^JWT_SECRET=(.+)$/m)
|
||||
return match ? match[1].trim() : 'test-jwt-secret-for-e2e-tests'
|
||||
}
|
||||
|
||||
function signToken(payload: object): string {
|
||||
return jwt.sign(payload, getJwtSecret(), { expiresIn: '1h' })
|
||||
}
|
||||
|
||||
const testUserId = '000000000000000000000001'
|
||||
const testAdminId = '000000000000000000000002'
|
||||
const userToken = signToken({ userId: testUserId, phone: '13800138000', role: 'user' })
|
||||
const adminToken = signToken({ userId: testAdminId, phone: '13800138001', role: 'admin' })
|
||||
|
||||
test.describe('Backend API (Playwright)', () => {
|
||||
test('GET /api/user/info returns 401 without token', async ({ request }) => {
|
||||
const res = await request.get(`${BASE}/user/info`)
|
||||
@@ -12,7 +31,7 @@ test.describe('Backend API (Playwright)', () => {
|
||||
const res = await request.post(`${BASE}/user/send-code`, {
|
||||
data: { phone: '13800138000' },
|
||||
})
|
||||
expect(res.status()).toBe(201)
|
||||
expect(res.status()).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.message).toBe('验证码已发送')
|
||||
})
|
||||
@@ -45,4 +64,47 @@ test.describe('Backend API (Playwright)', () => {
|
||||
const res = await request.get(`${BASE}/admin/check`)
|
||||
expect(res.status()).toBe(401)
|
||||
})
|
||||
|
||||
// --- Feedback API ---
|
||||
|
||||
test('POST /api/feedback returns 401 without token', async ({ request }) => {
|
||||
const res = await request.post(`${BASE}/feedback`, {
|
||||
data: { type: 'suggestion', content: 'test feedback' },
|
||||
})
|
||||
expect(res.status()).toBe(401)
|
||||
})
|
||||
|
||||
test('POST /api/feedback returns 400 with empty content', async ({ request }) => {
|
||||
const res = await request.post(`${BASE}/feedback`, {
|
||||
data: { content: '' },
|
||||
headers: { Authorization: `Bearer ${userToken}` },
|
||||
})
|
||||
expect(res.status()).toBe(400)
|
||||
})
|
||||
|
||||
test('POST /api/feedback returns 201 with valid data', async ({ request }) => {
|
||||
const res = await request.post(`${BASE}/feedback`, {
|
||||
data: { type: 'bug', content: 'Playwright浏览器端测试提交的问题反馈', contact: 'test@test.com' },
|
||||
headers: { Authorization: `Bearer ${userToken}` },
|
||||
})
|
||||
expect(res.status()).toBe(201)
|
||||
})
|
||||
|
||||
test('GET /api/feedback returns 403 for non-admin', async ({ request }) => {
|
||||
const res = await request.get(`${BASE}/feedback`, {
|
||||
headers: { Authorization: `Bearer ${userToken}` },
|
||||
})
|
||||
expect(res.status()).toBe(403)
|
||||
})
|
||||
|
||||
test('GET /api/feedback returns 200 for admin', async ({ request }) => {
|
||||
const res = await request.get(`${BASE}/feedback`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
})
|
||||
expect(res.status()).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.items).toBeDefined()
|
||||
expect(Array.isArray(body.items)).toBe(true)
|
||||
expect(body.total).toBeGreaterThanOrEqual(0)
|
||||
})
|
||||
})
|
||||
|
||||
+10
-2
@@ -1,6 +1,6 @@
|
||||
# 职引 - 部署文档
|
||||
|
||||
> **最后更新**: 2026-06-09
|
||||
> **最后更新**: 2026-07-04 12:51
|
||||
> **生产环境**: 已部署(服务器已购 + 域名已配)
|
||||
|
||||
## 目录
|
||||
@@ -128,7 +128,11 @@ npm run build:h5
|
||||
|
||||
### 3. 部署到 Web 服务器
|
||||
```bash
|
||||
# 构建含 SEO 文件(robots.txt, sitemap.xml, 数字人头像)
|
||||
npm run build:h5
|
||||
# 部署所有产物
|
||||
scp -r dist/build/h5/* user@your-server:/www/wwwroot/zhiyin.yzrcloud.cn/
|
||||
# 或者使用服务端脚本(自动复制 static/、robots.txt、sitemap.xml)
|
||||
```
|
||||
|
||||
### 4. Nginx 配置
|
||||
@@ -223,7 +227,7 @@ node scripts/upload-mp.js
|
||||
```
|
||||
|
||||
### 版本号
|
||||
当前线上版本:**1.0.3**(见 note.txt)
|
||||
当前线上版本:**1.0.22**(小程序上传版本,git tag v1.0.21 + 脚本末位自增 1)
|
||||
|
||||
---
|
||||
|
||||
@@ -249,3 +253,7 @@ node scripts/upload-mp.js
|
||||
|------|----------|--------|
|
||||
| 2026-06-09 | 初版 | AI |
|
||||
| 2026-06-09 | 更新生产域名:zhiyinwx.yzrcloud.cn(API :3006)、zhiyin.yzrcloud.cn(H5 静态目录) | 小之 |
|
||||
| 2026-06-21 | 更新部署版本至 v1.0.16;小程序上传工具使用 git tag 自动获取版本号 | 小之 |
|
||||
| 2026-06-21 | v4.8 SEO + 分享全面优化:部署新增 robots.txt、sitemap.xml、static/ 目录;版本号自动注入(Vite define);13 页面微信分享全部开启;上传脚本版本号末位自增 1 | AI |
|
||||
| 2026-07-04 | v4.10 引力值变动记录系统 + 前端 401/错误处理完善;v1.0.21 发布;H5 + 小程序全量部署 | AI |
|
||||
| 2026-07-04 | ASR 语音识别 AAC→WAV 转换修复 + share.vue 分享记录去重修复;后端 + H5 + 小程序 v1.0.22 部署 | AI |
|
||||
|
||||
+16
-13
@@ -1,8 +1,8 @@
|
||||
# 职引 · 完整功能清单 v4.3
|
||||
# 职引 · 完整功能清单 v4.10
|
||||
|
||||
> **版本**: v4.5
|
||||
> **日期**: 2026-06-17
|
||||
> **状态**: Phase 1.5 启动:面试复盘 + AI 择业顾问 MVP 就绪
|
||||
> **版本**: v4.10
|
||||
> **日期**: 2026-07-04
|
||||
> **状态**: Phase 1.5 引力值变动记录 + 前端错误处理完善
|
||||
> **定位**: 应届生/实习生 AI 面试教练
|
||||
|
||||
---
|
||||
@@ -86,6 +86,7 @@
|
||||
| 简历管理 | ✅ 完成 | 多份简历 CRUD + AI 分析 |
|
||||
| 面试复盘 | ✅ 完成 | 音频上传 → ASR → AI 评析 → 口语分析 |
|
||||
| 会员中心 | ✅ 完成 | 套餐对比 + 支付 |
|
||||
| 引力值明细 | ✅ 完成 | 分页查看引力值变动记录(注册/消耗/购买/补给/迁移) |
|
||||
|
||||
---
|
||||
|
||||
@@ -94,13 +95,13 @@
|
||||
### 3.1 会员系统
|
||||
| 功能 | 状态 | 描述 | 优先级 |
|
||||
|------|------|------|--------|
|
||||
| 免费版 | ✅ 完成 | 日 2 次面试,5 轮/次 | P0 |
|
||||
| 成长版 ¥19.9/月 | ✅ 完成 | 无限面试 + 高级报告 + 进步轨迹 | P0 |
|
||||
| 冲刺版 ¥49.9/月 | ❌ 未实现 | 高客单价缺失 | P1 |
|
||||
| 微信支付 Native(扫码) | ✅ 完成 | H5 支付 | P0 |
|
||||
| 微信支付 JSAPI | ✅ 完成 | 小程序内支付 | P0 |
|
||||
| 支付回调/自动开会员 | ✅ 完成 | 回调验签 + 解密 + 会员激活 | P0 |
|
||||
| 会员权益对比 | ✅ 完成 | 免费/成长版对比展示 | P0 |
|
||||
| 免费版 | ✅ 完成 | 注册送 5 引力值,面试消耗 5/次 | P0 |
|
||||
| 按量购买引力值 | ✅ 完成 | ¥5/份,含 5 引力值,H5 扫码支付 | P0 |
|
||||
| 微信支付 Native(扫码) | ✅ 完成 | H5 扫码支付 | P0 |
|
||||
| 支付回调/自动到账 | ✅ 完成 | 回调验签 + 解密 + 引力值自动到账 | P0 |
|
||||
| 小程序剪贴板购买 | ✅ 完成 | 复制官网链接到手机浏览器打开购买 | P0 |
|
||||
| 会员权益展示 | ✅ 完成 | 引力值 + 获取入口 | P0 |
|
||||
| 客服按钮 | ✅ 完成 | 用户页 + 关于页 `<button open-type="contact">` | P1 |
|
||||
|
||||
### 3.2 B 端服务(Q4 启动)
|
||||
| 功能 | 状态 | 描述 |
|
||||
@@ -162,14 +163,14 @@
|
||||
- [x] 面经贡献系统 + 公司题库
|
||||
- [x] 每日一题(API 读取)
|
||||
- [x] 手机/邮箱/密码/微信登录
|
||||
- [x] 会员系统(¥19.9 成长版)
|
||||
- [x] 会员系统(¥19 成长版)
|
||||
- [x] 微信支付对接(Native + JSAPI)
|
||||
- [x] 公司真题库(用户贡献驱动)
|
||||
- [x] **面试复盘(音频 ASR + AI 评析 + 口语分析)**
|
||||
|
||||
### P1(待实现)
|
||||
- [ ] 每日一题定时推送
|
||||
- [ ] 冲刺版 ¥49.9/月
|
||||
- [ ] 冲刺版 ¥49/月
|
||||
- [ ] AI 岗位专属题库
|
||||
- [ ] 连续打卡激励(7 天解锁高级报告)
|
||||
- [ ] 生产环境部署
|
||||
@@ -192,3 +193,5 @@
|
||||
| 2026-06-09 | 同步代码:Phase 0.5 功能标记完成,修正状态 | AI |
|
||||
| 2026-06-16 | **v4.2**:新增面试复盘功能(whisper.cpp ASR + AI 评析 + 口语分析) | AI |
|
||||
| 2026-06-17 | **v4.3**:新增 AI 择业顾问功能(专业分析 + 岗位匹配 + 多轮对话) | AI |
|
||||
| 2026-06-21 | **v4.7**:按量购买引力值重构(¥5/份取代月订阅);微信小程序剪贴板购买链路;客服按钮;管理后台全面完善;生产环境全量部署上线 | AI |
|
||||
| 2026-07-04 | **v4.10**:引力值变动记录系统(GravityTransaction schema + 全埋点 + 用户端分页明细弹窗);前端 401/错误处理完善;面试创建 201 兼容;AI 错误友好提示 | AI |
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
"plans": {
|
||||
"growth": {
|
||||
"price": 1990,
|
||||
"price": 1900,
|
||||
"durationDays": 30,
|
||||
"credits": {
|
||||
"interview": 999,
|
||||
@@ -76,7 +76,7 @@
|
||||
]
|
||||
},
|
||||
"sprint": {
|
||||
"price": 4990,
|
||||
"price": 4900,
|
||||
"durationDays": 30,
|
||||
"credits": {
|
||||
"interview": 999,
|
||||
@@ -267,7 +267,7 @@ Puppeteer PDF 生成 (`resume-pdf.service.ts`):
|
||||
│ 首次面试免费 [✓] │
|
||||
│ │
|
||||
│ ─── 成长版 ─── │
|
||||
│ 价格 ¥ [ 19.9 ] /月 │
|
||||
│ 价格 ¥ [ 19 ] /月 │
|
||||
│ 面试额度 [ 999 ] 次 │
|
||||
│ 优化额度 [ 20 ] 次 │
|
||||
│ 下载额度 [ 10 ] 次 │
|
||||
|
||||
@@ -65,14 +65,14 @@
|
||||
| 版本 | 价格 | 核心权益 | 定位 |
|
||||
|------|------|------|------|
|
||||
| 免费版 | ¥0 | 日 2 次基础面试(通用题库,5 轮/次) | 引流 |
|
||||
| **成长版** | **¥19.9/月** | 无限面试 + 高级报告 + 进步轨迹 + 真题库 | **主力** |
|
||||
| **成长版** | **¥19/月** | 无限面试 + 高级报告 + 进步轨迹 + 真题库 | **主力** |
|
||||
|
||||
> 冲刺版 ¥49.9/月(含真人导师点评 + 简历精修)待实现
|
||||
> 冲刺版 ¥49/月(含真人导师点评 + 简历精修)待实现
|
||||
|
||||
### 3.2 收入来源
|
||||
|
||||
```
|
||||
C 端订阅收入(基本盘:¥19.9 × 付费用户数)
|
||||
C 端订阅收入(基本盘:¥19 × 付费用户数)
|
||||
↓
|
||||
├── B 端合作(高校就业办/求职机构)
|
||||
├── 内容变现(面经课程)
|
||||
@@ -83,9 +83,9 @@ C 端订阅收入(基本盘:¥19.9 × 付费用户数)
|
||||
|
||||
| 阶段 | C 端 | B 端 | 月收入 |
|
||||
|------|------|------|--------|
|
||||
| MVP 上线(6-8月) | 200 付费 × ¥19.9 | 0 | ¥3,980 |
|
||||
| 秋招旺季(9-11月) | 1000 付费 × ¥19.9 | 2 高校 ¥5000 | ¥29,900 |
|
||||
| 稳定运营(次年) | 2000 付费 × ¥19.9 | 5 机构 + 企业 | ¥60,000+ |
|
||||
| MVP 上线(6-8月) | 200 付费 × ¥19 | 0 | ¥3,800 |
|
||||
| 秋招旺季(9-11月) | 1000 付费 × ¥19 | 2 高校 ¥5000 | ¥24,000 |
|
||||
| 稳定运营(次年) | 2000 付费 × ¥19 | 5 机构 + 企业 | ¥48,000+ |
|
||||
|
||||
---
|
||||
|
||||
@@ -103,14 +103,14 @@ C 端订阅收入(基本盘:¥19.9 × 付费用户数)
|
||||
| 面经贡献系统 + 公司题库 | ✅ 完成 |
|
||||
| 每日一题(API) | ✅ 完成 |
|
||||
| 简历诊断 + 优化 | ✅ 完成 |
|
||||
| 会员系统(成长版 ¥19.9/月) | ✅ 完成 |
|
||||
| 会员系统(成长版 ¥19/月) | ✅ 完成 |
|
||||
| 微信支付(Native + JSAPI) | ✅ 完成 |
|
||||
|
||||
### 待实现
|
||||
| 功能 | 计划 |
|
||||
|------|------|
|
||||
| 每日一题定时推送(微信订阅消息) | Phase 1 |
|
||||
| 冲刺版 ¥49.9/月 | Phase 1.5 |
|
||||
| 冲刺版 ¥49/月 | Phase 1.5 |
|
||||
| 微信登录真实 appid 联调 | Phase 1 |
|
||||
| 生产环境部署 | Phase 1 |
|
||||
| AI 岗位专属题库 | Phase 2 |
|
||||
|
||||
+31
-20
@@ -1,8 +1,8 @@
|
||||
# 职引项目 · 状态报告 v4.5
|
||||
# 职引项目 · 状态报告 v4.10
|
||||
|
||||
> **项目版本**: v4.5
|
||||
> **更新时间**: 2026-06-17
|
||||
> **项目状态**: ✅ 面试复盘上线 + AI 择业顾问 MVP
|
||||
> **项目版本**: v4.10
|
||||
> **更新时间**: 2026-07-04
|
||||
> **项目状态**: ✅ 引力值变动记录系统 + 前端 401/错误处理完善 + v1.0.21 发布
|
||||
|
||||
---
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
| 项目名称 | 职引(ZhiYin) |
|
||||
| 定位 | 应届生/实习生 AI 面试教练 |
|
||||
| 技术栈 | NestJS + MongoDB + Uni-App(Vue3) |
|
||||
| 定价 | 免费版 / ¥19.9/月(成长版) / ¥49.9/月(冲刺版) |
|
||||
| 定价 | 免费版 / 按量购买引力值(¥5/份) |
|
||||
| AI 模型 | DeepSeek V4-Flash(主) + Step-3.5-Flash(备) |
|
||||
| ASR | whisper.cpp(本地部署,tiny/base 模型,无需 API Key) |
|
||||
| 后端模块 | user, interview, resume, member, payment, positions, ai, analyze, upload, admin, email, progress, contribution, daily-question, schedule, interview-review, career-advice |
|
||||
| 后端模块 | user, interview, resume, member, payment, positions, ai, analyze, upload, admin, email, progress, contribution, daily-question, schedule, interview-review, career-advice, gravity-transaction |
|
||||
|
||||
---
|
||||
|
||||
@@ -25,17 +25,20 @@
|
||||
| 模块 | 完成度 | 说明 |
|
||||
|------|------|------|
|
||||
| 后端 API | **99%** | 核心 + 护城河 P0-P5 全部实现 |
|
||||
| 前端页面 | **88%** | 17 个页面含真实 API 调用 |
|
||||
| 前端页面 | **95%** | 20 个页面含真实 API 调用 |
|
||||
| AI 面试模拟 | **95%** | 多轮对话 + 评分 + 报告 + 进度追踪 |
|
||||
| 简历诊断/优化 | **95%** | 文件上传 + AI 分析 + 下载 |
|
||||
| 支付系统(微信) | **95%** | API v3 完整对接,含真实证书 |
|
||||
| 会员系统 | **100%** | 成长版 + 冲刺版,含权益扣减 |
|
||||
| 支付系统(微信) | **95%** | API v3 完整对接,含真实证书,H5 扫码支付可用 |
|
||||
| 引力值变动记录 | **100%** | 全量日志(注册/消耗/购买/补给/迁移)+ 前端分页查看 |
|
||||
| 会员系统 | **100%** | 改为按量购买引力值体系(¥5/份),免费版注册送 5 引力值 |
|
||||
| 护城河 P0-P5 | **100%** | AI 结构化 / 行业基准 / VIP 过期 / 分享卡片 / 打卡积分 / 岗位匹配 |
|
||||
| 面试复盘 | **100%** | 音频上传 → whisper.cpp ASR → AI 评析 → 口语分析 |
|
||||
| 测试体系 | **85%** | 43 单元 + 11 e2e + 7 前端 + Playwright 框架 |
|
||||
| 代码质量 | **95%** | console→Logger,as any 类型化,空 catch 检查 |
|
||||
| 安全审计 | **90%** | JWT 硬编码 / 凭据泄漏 / IDOR / NoSQL 注入 全部修复 |
|
||||
| 小程序审核 | **0%** | 类目已备案,未提交审核 |
|
||||
| 小程序审核 | **100%** | v1.0.17 已提交审核,类目已备案 |
|
||||
| 生产部署 | **100%** | 后端 PM2 / H5 已部署 / 小程序 v1.0.17 已上传 |
|
||||
| SEO / 分享优化 | **100%** | H5 canonical + robots.txt + sitemap + 结构化数据;小程序 13 页面全量开启分享 |
|
||||
|
||||
---
|
||||
|
||||
@@ -75,9 +78,11 @@
|
||||
### 3.4 商业化
|
||||
| 功能 | 后端 | 前端 | 状态 |
|
||||
|------|------|------|------|
|
||||
| 免费版额度(日2次/5轮) | ✅ | ✅ | **完成** |
|
||||
| 成长版 ¥19.9/月 | ✅ | ✅ | **完成** |
|
||||
| 冲刺版 ¥49.9/月(含权益扣减) | ✅ | ✅ | **完成** |
|
||||
| 免费版注册送 5 引力值 | ✅ | ✅ | **完成** |
|
||||
| 按量购买引力值(¥5/份) | ✅ | ✅ | **完成** |
|
||||
| 引力值统一体系(全部按引力值消耗) | ✅ | ✅ | **完成** |
|
||||
| 会员月度引力值自动补给(cron) | ✅ | N/A | **完成** |
|
||||
| 微信小程序剪贴板购买链路 | N/A | ✅ | **完成** |
|
||||
| 微信支付 Native QR / JSAPI | ✅ | ✅ H5+MP | **完成** |
|
||||
| 支付回调/自动开会员 | ✅ | N/A | **完成** |
|
||||
| 每日一题定时推送 | ✅ | N/A | **完成**(需配置模板ID) |
|
||||
@@ -129,7 +134,7 @@
|
||||
|
||||
| 命令 | 用途 |
|
||||
|------|------|
|
||||
| `npm test` | 43 个单元测试 |
|
||||
| `npm test` | 43 个单元测试(构建检查通过) |
|
||||
| `npm run test:e2e` | 11 个集成测试 |
|
||||
| `npm run test:cov` | 覆盖率报告 |
|
||||
| `npm run test:browser` | Playwright API 测试 |
|
||||
@@ -174,10 +179,11 @@
|
||||
| `payment` | controller + service + schema | ✅ | 微信支付 v3,含证书 |
|
||||
| `progress` | controller + schema + benchmark service | ✅ | 打卡/积分/基准/匹配 |
|
||||
| `contribution` | controller + schema (×2) | ✅ | 面经 + AI 结构化 + 公司题库 |
|
||||
| `schedule` | module + service (×3) | ✅ | VIP 过期 / 每日一题 / 微信 token |
|
||||
| `schedule` | module + service (×4) | ✅ | VIP 过期 / 每日一题 / 微信 token / 月度引力值补给 |
|
||||
| `interview-review` | controller + service + schema + asr service | ✅ | 面试复盘:音频 ASR + AI 评析 + 口语分析 |
|
||||
| `career-advice` | controller + service + module | ✅ | AI 择业顾问:专业分析 + 岗位匹配 + 多轮对话 |
|
||||
| `admin` | controller + module | ✅ | 管理后台 |
|
||||
| `gravity-transaction` | schema (shared) | ✅ | 引力值变动全量日志:注册/面试消耗/购买/月度补给/迁移等 |
|
||||
| `email` | module + service | ✅ | 邮件发送 |
|
||||
| `upload` | controller + module | ✅ | 文件上传 |
|
||||
|
||||
@@ -192,15 +198,15 @@
|
||||
| 面试模拟 | interview/interview | ✅ 多轮对话 + 计时 |
|
||||
| 面试报告 | report/report | ✅ 评分/分析/全文回放/分享卡片 |
|
||||
| 历史记录 | history/history | ✅ 筛选/统计 |
|
||||
| 个人中心 | user/user | ✅ 信息/统计/管理员入口 + 面试复盘入口 + 择业顾问入口 |
|
||||
| 会员中心 | member/member | ✅ 套餐对比 + 支付 |
|
||||
| 个人中心 | user/user | ✅ 引力值卡片(含明细弹窗)+ 信息/统计/管理员入口 + 面试复盘入口 + 择业顾问入口 + 客服按钮 |
|
||||
| 会员中心 | member/member | ✅ 引力值按量购买(H5 扫码支付/小程序剪贴板链路) |
|
||||
| 进步轨迹 | progress/progress | ✅ 雷达图 + 打卡日历 |
|
||||
| 面经贡献 | contribute/contribute | ✅ 表单提交 |
|
||||
| 简历优化 | resume/resume | ✅ 诊断/优化/上传/下载 |
|
||||
| 面试复盘 | review/review | ✅ 三种模式(列表/上传/报告) |
|
||||
| 择业顾问 | career/career | ✅ AI 专业分析 + 岗位匹配 + 多轮对话 |
|
||||
| 实习搜索 | internship/internship | ✅ 热门岗位 |
|
||||
| 管理后台 | admin/admin | ✅ 仪表盘 |
|
||||
| 管理后台 | admin/admin | ✅ 仪表盘/用户/面试/简历/订单/定价/分享/岗位/诊断/管理员 · 全 CRUD |
|
||||
| 关于/协议/隐私 | about/agreement/privacy | ✅ |
|
||||
|
||||
---
|
||||
@@ -217,11 +223,16 @@
|
||||
---
|
||||
|
||||
## 十、变更记录
|
||||
| 2026-06-17 | v4.5 | AI 择业顾问 MVP:后端模块 + 前端职业分析页面 + 热门岗位联动 | AI |
|
||||
|
||||
| 日期 | 版本 | 变更内容 | 操作者 |
|
||||
|------|------|----------|--------|
|
||||
| 2026-06-02 | v1.0 | 项目状态初版 | AI |
|
||||
| 2026-07-04 | **v4.11** | **ASR 语音识别修复**(TTS controller AAC→WAV 转换,解决小程序录音格式不兼容 whisper);**分享记录去重**(share.vue loadData 有缓存时不再创建新分享);**引力值明细**后端部署;**用户端 401/错误处理**完善 | AI |
|
||||
| 2026-07-04 | **v4.10** | **引力值变动记录系统**:新建 GravityTransaction schema + 全量日志埋点(注册/面试消耗/购买/月度补给/迁移/套餐设置等);新增 `GET /user/gravity-transactions` 接口;用户端「引力值明细」弹窗(分页);前端 401/错误处理完善(checkAuth 全局检测);面试创建 201 状态码兼容 fix;AI 错误友好提示 | AI |
|
||||
| 2026-06-22 | **v4.9** | **Mongoose 8 兼容修复**(pre-save hook 回调→async);v1.0.17 tag 发布;测试账号 test@yzrcloud.cn 重建 | AI |
|
||||
| 2026-06-21 | **v4.8** | **SEO 全量优化**(canonical URL、robots.txt、sitemap.xml、结构化数据);**微信分享全面开启**(13 个页面 onShareAppMessage + onShareTimeline);**版本号自动注入**(Vite define __APP_VERSION__);**导航栏/Tab标题关键词优化**;manifest 描述更新;页面描述统一增强 | AI |
|
||||
| 2026-06-21 | v4.7 | 按量购买引力值体系重构(¥5/份取代月订阅);member.vue 完全重写;微信小程序剪贴板购买链路;客服按钮;管理后台字段全面完善;代码清理;测试数据清理;后端/H5/小程序全量部署上线 | AI |
|
||||
| 2026-06-19 | v4.6 | 引力值体系统一:VIP 取消无限面试改为月度引力值消耗;管理后台全面完善(搜索/筛选/分页/CRUD/分析tab/岗位描述字段) | AI |
|
||||
| 2026-06-17 | v4.5 | AI 择业顾问 MVP:后端模块 + 前端职业分析页面 + 热门岗位联动 | AI |
|
||||
| 2026-06-05 | v2.0 | 战略升级:文档重构 + 新增功能启动 | 小之 |
|
||||
| 2026-06-09 | v4.2 | 冲刺版+每日推送+支付修复+全量代码评审 | AI |
|
||||
| 2026-06-11 | v4.3 | 安全修复 5 项 + 代码质量 14 处 + 测试体系 61 项 + 护城河 P0-P5 全部验证 | AI |
|
||||
|
||||
+25
-20
@@ -1,8 +1,8 @@
|
||||
# 职引 · 产品路线图 v4.3
|
||||
# 职引 · 产品路线图 v4.7
|
||||
|
||||
> **版本**: v4.3
|
||||
> **日期**: 2026-06-17
|
||||
> **状态**: Phase 1.5 启动:AI 择业顾问 MVP
|
||||
> **版本**: v4.7
|
||||
> **日期**: 2026-06-21
|
||||
> **状态**: Phase 1.5 按量购买引力值上线 + 全量部署
|
||||
> **定位**: 应届生/实习生 AI 面试教练
|
||||
|
||||
---
|
||||
@@ -16,7 +16,7 @@ Phase 0.5: 壁垒构建(✅ 已完成)
|
||||
↓
|
||||
Phase 1: MVP 开发(✅ 已完成)→ 面试复盘 + whisper.cpp ASR 集成
|
||||
↓
|
||||
Phase 1.5: 商业化(D30-60)→ PMF 验证
|
||||
Phase 1.5: 商业化 + 部署上线(D30-60)→ PMF 验证
|
||||
↓
|
||||
Phase 2: 增强 + 题库(D60-90)→ 秋招准备
|
||||
↓
|
||||
@@ -28,7 +28,7 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
||||
## 二、Phase 0: 战略升级(✅ 已完成)
|
||||
|
||||
**已完成**:
|
||||
- [x] 定价重构:免费 + ¥19.9/月 两段式
|
||||
- [x] 定价重构:免费 + ¥19/月 两段式
|
||||
- [x] 三层壁垒设计(数据飞轮 + 留存入围 + 合规信任)
|
||||
- [x] 收入来源多元化策略
|
||||
- [x] 文档体系全面更新
|
||||
@@ -54,7 +54,7 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
||||
### 3.3 会员系统重构
|
||||
| 功能 | 描述 | 状态 |
|
||||
|------|------|------|
|
||||
| 定价更新 | ¥19.9/月 成长版 | ✅ 完成 |
|
||||
| 定价更新 | ¥19/月 成长版 | ✅ 完成 |
|
||||
| 会员权益对比 | 三版对比展示 | ✅ 完成 |
|
||||
| 微信支付对接 | Native + JSAPI 支付 | ✅ 完成 |
|
||||
|
||||
@@ -78,9 +78,9 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
||||
|------|------|------|
|
||||
| 前端页面完善 | 17 个页面全部就绪 | ✅ 完成 |
|
||||
| 微信登录联调 | 真实 appid 验证 | ⏳ 待进行 |
|
||||
| 移除开发绕过 | `member/pay` 直接激活 | ⏳ 待进行 |
|
||||
| 生产环境部署 | 服务器 + MongoDB + Nginx + PM2 | ✅ 服务器已购,域名已配 |
|
||||
| 小程序审核提交 | 资质齐全 | ⏳ 待进行 |
|
||||
| 移除开发绕过 | `member/pay` 直接激活 | ✅ 已完成 |
|
||||
| 生产环境部署 | 服务器 + MongoDB + Nginx + PM2 | ✅ 已部署 |
|
||||
| 小程序审核提交 | v1.0.16 已上传 | ⏳ 待审核 |
|
||||
| 内测版发布 | 邀请码方式,100 人内测 | ⏳ 待进行 |
|
||||
|
||||
### 4.3 内测指标
|
||||
@@ -92,15 +92,18 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
||||
|
||||
## 五、Phase 1.5:辅助功能 + 商业化(D30-60)
|
||||
|
||||
| 功能 | 描述 | 优先级 |
|
||||
|------|------|--------|
|
||||
| 每日一题定时推送 | 微信订阅消息推送 | P0 |
|
||||
| 冲刺版 ¥49.9/月 | 高客单价 | P1 |
|
||||
| 连续打卡激励 | 7 天解锁高级报告 | P1 |
|
||||
| ASR 生产化调优 | 多模型切换、模型量化、推理优化 | P1 |
|
||||
| AI 择业顾问 MVP | AI 专业分析 + 岗位匹配 + 多轮对话 | P0 |
|
||||
| 付费转化验证 | 100 内测用户 → 10+ 付费 | P0 |
|
||||
| PMF 决策 | 转化率 > 5% → 继续 | P0 |
|
||||
| 功能 | 描述 | 优先级 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 每日一题定时推送 | 微信订阅消息推送 | P0 | ✅ 已完成 |
|
||||
| 按量购买引力值 | 取消月订阅,改为 ¥5/份 | P0 | ✅ 已完成 |
|
||||
| 连续打卡激励 | 7 天解锁高级报告 | P1 | 📋 规划中 |
|
||||
| ASR 生产化调优 | 多模型切换、模型量化、推理优化 | P1 | 📋 规划中 |
|
||||
| AI 择业顾问 MVP | AI 专业分析 + 岗位匹配 + 多轮对话 | P0 | ✅ 已完成 |
|
||||
| 小程序剪贴板购买链路 | 复制链接到浏览器购买 | P0 | ✅ 已完成 |
|
||||
| H5 扫码支付部署 | ¥5/份 H5 直接支付 | P0 | ✅ 已完成 |
|
||||
| 生产环境全量部署 | 后端 PM2 + H5 Nginx + 小程序上传 | P0 | ✅ 已完成 |
|
||||
| 付费转化验证 | 100 内测用户 → 10+ 付费 | P0 | ⏳ 待进行 |
|
||||
| PMF 决策 | 转化率 > 5% → 继续 | P0 | ⏳ 待进行 |
|
||||
|
||||
---
|
||||
|
||||
@@ -154,9 +157,10 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
||||
| M0: 战略升级 | ✅ D1 | 文档 + 定价 | 已完成 |
|
||||
| M0.5: 壁垒构建 | ✅ D7 | 进步轨迹 + 面经贡献 + 每日一题 | 功能可用 |
|
||||
| M1: MVP 开发 | ✅ D14 | 面试复盘 + whisper.cpp ASR | 功能可用,build + test 通过 |
|
||||
| M1.5: 商业化重构 | ✅ D21 | 按量购买引力值 + 管理后台完善 + H5/小程序部署 | 构建通过,已推送上线 |
|
||||
| M2: 上线内测 | D30 | 小程序审核通过,内测启动 | 100 内测用户 |
|
||||
| M3: PMF 验证 | D60 | 100 用户反馈 | 转化率 > 5% |
|
||||
| M4: 付费上线 | D75 | 冲刺版 + 定时推送 | 50+ 付费用户 |
|
||||
| M4: 付费增长 | D75 | 引力值运营 + 推送 | 50+ 付费用户 |
|
||||
| M5: 秋招冲刺 | D90+ | 秋招推广 | 1000+ 付费用户 |
|
||||
|
||||
---
|
||||
@@ -202,3 +206,4 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
||||
| 2026-06-09 | Phase 0.5 标记完成,调整后续里程碑时间 | AI |
|
||||
| 2026-06-16 | **v4.2**:Phase 1 MVP 开发完成,面试复盘上线,里程碑 M1 完成 | AI |
|
||||
| 2026-06-17 | **v4.3**:AI 择业顾问 MVP 上线,里程碑 M1.5 完成 | AI |
|
||||
| 2026-06-21 | **v4.7**:按量购买引力值重构(¥5/份取代月订阅);管理后台全面完善;微信小程序剪贴板购买链路;客服按钮;全量生产部署上线(后端 PM2/H5 Nginx/小程序 v1.0.16) | AI |
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
# 宇之然AI磁场 · 营销推广总方案 v1.0
|
||||
|
||||
> 日期: 2026-07-06
|
||||
> 定位: 应届生/实习生 AI 面试教练
|
||||
> 目标: 三端平台(微信公众号 / 知乎 / 小红书)内容矩阵,配合 2026 秋招季(9-11 月)获取种子用户
|
||||
|
||||
---
|
||||
|
||||
## 一、产品核心卖点
|
||||
|
||||
| 卖点 | 一句话表达 | 对应痛点 |
|
||||
|------|-----------|----------|
|
||||
| AI 面试模拟 | "校招面试,先模拟再上场" | 面试紧张、不知道会被问什么 |
|
||||
| 公司真题库 | "真实面经 + 公司题库,不是通用模板" | 面试题太泛、不针对目标公司 |
|
||||
| 四维评分报告 | "每轮回答都有 AI 评分和改进建议" | 面完了不知道好不好、如何改进 |
|
||||
| 进步轨迹图 | "能力提升看得见,四维雷达图追踪" | 练习无反馈、不知道进步 |
|
||||
| 面试复盘 | "真实面试录音 → AI 分析表现" | 面试完不知道怎么复盘 |
|
||||
| AI 择业顾问 | "AI 帮你分析适合什么岗位" | 求职方向迷茫 |
|
||||
| 免费可用 | "注册送 5 引力值,0 元体验" | 担心付费后不好用 |
|
||||
| 按量购买 | "¥5/份,用多少买多少" | 不想被月订阅绑定 |
|
||||
|
||||
## 二、目标用户画像
|
||||
|
||||
| 画像 | 特征 | 平台偏好 |
|
||||
|------|------|----------|
|
||||
| 25 届/26 届毕业生 | 正在或即将经历秋招 | 微信(群/朋友圈)、小红书 |
|
||||
| 双非/普通本科学生 | 缺乏名校背书,求职焦虑高 | 知乎、小红书 |
|
||||
| 计算机/产品/运营专业 | 面试竞争激烈 | 知乎、微信公众号 |
|
||||
| 考研/考公失利转求职 | 准备时间紧迫 | 小红书、微信 |
|
||||
|
||||
## 三、平台策略对比
|
||||
|
||||
| 维度 | 微信公众号 | 知乎 | 小红书 |
|
||||
|------|-----------|------|--------|
|
||||
| 内容形式 | 长图文(2000-3000 字) | 问答/专栏(1500-2500 字) | 笔记+图片(500-800 字) |
|
||||
| 核心策略 | SEO 搜索 + 朋友圈转发 | 关键词排名 + 问题截流 | 发现页推荐 + 话题标签 |
|
||||
| 内容定位 | 深度干货,建立专业信任 | 方法论输出,展现权威 | 真实分享,情感共鸣 |
|
||||
| 产品露出 | 文章中部自然植入 | 回答末尾推荐工具 | 图片标签 + 正文轻提 |
|
||||
| 发布频率 | 2 篇/周(秋招季 3 篇) | 4-5 回答/周 + 1 专栏/周 | 5-7 条/周 |
|
||||
| 转化路径 | 阅读→关注→菜单→小程序 | 阅读→收藏→点赞→私信→小程序 | 种草→搜小程序→使用 |
|
||||
|
||||
## 四、SEO 关键词矩阵
|
||||
|
||||
| 关键词 | 搜索意图 | 平台 | 竞争度 |
|
||||
|--------|---------|------|--------|
|
||||
| 校招面试技巧 | 信息需求 | 知乎/公众号 | 高 |
|
||||
| AI面试 | 产品需求 | 知乎/小红书 | 中 |
|
||||
| 面试模拟 | 产品需求 | 知乎 | 低 |
|
||||
| 秋招准备 | 信息+产品 | 全平台 | 高 |
|
||||
| 应届生求职 | 信息需求 | 全平台 | 高 |
|
||||
| 面试题库 | 产品需求 | 知乎/小红书 | 中 |
|
||||
| 面试评分 | 产品需求 | 知乎 | 低 |
|
||||
| 简历诊断 | 产品需求 | 小红书 | 中 |
|
||||
| 无领导小组面试 | 信息需求 | 知乎 | 低-中 |
|
||||
| 面试复盘 | 信息+产品 | 知乎/小红书 | 低 |
|
||||
|
||||
## 五、内容日历(2026 秋招季)
|
||||
|
||||
| 阶段 | 时间 | 主题方向 | 核心内容 |
|
||||
|------|------|----------|----------|
|
||||
| 预热期 | 7 月 | 面试准备方法论 | 简历修改、岗位选择、面试基础 |
|
||||
| 爆发期 | 8-9 月 | 秋招实战 | 各家面试风格、AI 模拟练习 |
|
||||
| 高峰期 | 10 月 | 面经 + 题库 | 真实面经分享、公司真题解析 |
|
||||
| 收尾期 | 11-12 月 | 补录 + 春招准备 | 补录信息、复盘总结、春招规划 |
|
||||
|
||||
## 六、内容复用策略
|
||||
|
||||
1. **微信公众号**发深度长文 → 提炼核心观点发**知乎**回答 → 拆成 3-5 条**小红书**笔记
|
||||
2. **小红书**爆款笔记 → 扩展成**知乎**专栏 → 再丰富成**公众号**深度文章
|
||||
3. 用户面经(脱敏后)→ 全平台内容素材(标注"来自用户贡献"增加可信度)
|
||||
|
||||
## 七、数据追踪
|
||||
|
||||
| 指标 | 公众号 | 知乎 | 小红书 |
|
||||
|------|--------|------|--------|
|
||||
| 曝光 | 阅读量 | 浏览量 | 小眼睛 |
|
||||
| 互动 | 点赞/在看/留言 | 赞同/收藏/评论 | 点赞/收藏/评论 |
|
||||
| 转化 | 关注数 → 菜单点击 | 私信咨询 | 搜索"宇之然AI磁场" |
|
||||
| 归因 | 菜单点击量 | 专属二维码 | 品牌搜索量 |
|
||||
|
||||
## 八、合规注意事项
|
||||
|
||||
- 不使用绝对化用语("最好"、"第一"、"最"等)
|
||||
- 不虚构用户案例("身边朋友"类必须有真实授权)
|
||||
- 不直接留联系方式诱导引流(小红书限流高风险)
|
||||
- 知乎不出售软文,以干货回答获取自然流量
|
||||
- 公众号不刷阅读量,不诱导分享(违者封号)
|
||||
@@ -0,0 +1,189 @@
|
||||
# 微信公众号 · 营销文案
|
||||
|
||||
> 定位: 深度干货长文,建立专业信任,通过 SEO 搜索和朋友圈传播获客
|
||||
> 风格: 专业 + 温度 + 数据驱动
|
||||
> 建议配图: 数据图表 / AI 面试截图 / 雷达图
|
||||
|
||||
---
|
||||
|
||||
## 文章一:校招季 | 那些面试挂了的人,后来都怎么样了?
|
||||
|
||||
**SEO 标题**: 2026 校招面试全攻略:从挂面到 offer,应届生做对了什么?
|
||||
**描述**: 2026 秋招在即,面试挂了不可怕,关键是知道怎么复盘和改进。本文从 300+ 场真实 AI 面试数据中总结出面试失败的核心原因和解决方案。
|
||||
**关键词**: 校招面试, 秋招准备, 面试技巧, 应届生求职, AI面试
|
||||
|
||||
---
|
||||
|
||||
### 正文
|
||||
|
||||
每年 9 月,几百万应届生涌入秋招战场。
|
||||
|
||||
有人拿 offer 到手软,有人面完就杳无音信。差距到底在哪?
|
||||
|
||||
我们分析了 300+ 场 AI 模拟面试的数据,发现一个扎心的事实:**绝大部分面试挂掉的人,不是因为能力不行,而是因为"没准备到点上"。**
|
||||
|
||||
#### 一、面试挂掉的 3 个致命原因
|
||||
|
||||
**1. 回答全是"背稿子"**
|
||||
|
||||
"请自我介绍一下。"
|
||||
|
||||
"我叫 XXX,来自 XX 大学,专业是 XX……"——这种千篇一律的开场,面试官每天听几十遍。
|
||||
|
||||
AI 面试评分数据显示,自我介绍环节平均得分只有 5.8/10。问题出在哪?不是不流利,而是**没有针对性**。面试官想听的不是你的基本信息,而是"你为什么适合这个岗位"。
|
||||
|
||||
**2. 逻辑混乱,答非所问**
|
||||
|
||||
面到深处,面试官会追问细节。很多人这时候开始"编"——编数据、编经历、编成果。
|
||||
|
||||
AI 的追问逻辑检测发现,超过 60% 的候选人在第 3 轮追问后开始出现逻辑断裂。前后矛盾、数据不对应、结论和论据脱节,这些在 AI 评分系统里会被精准捕捉。
|
||||
|
||||
**3. 完全不了解目标公司和岗位**
|
||||
|
||||
"你对我们公司了解多少?"
|
||||
|
||||
"嗯……是大厂,做互联网的……"
|
||||
|
||||
这种回答基本等于给自己发了拒信。公司题库数据显示,面试中涉及目标公司业务的题目占比高达 35%。不做功课就上考场,结果可想而知。
|
||||
|
||||
#### 二、面试能力是一个"可训练"的技能
|
||||
|
||||
很多人把面试当作"展示自己"的过程——我准备好了,你来打分吧。
|
||||
|
||||
错了。面试本质上是**一场结构化的问题应对**。每个问题的背后都有考察意图,你的回答需要同时满足:逻辑性、专业性、表达力、应变力。
|
||||
|
||||
这四个维度对应着面试官打分表上的核心指标。好消息是,这四个维度都是可以被训练的。
|
||||
|
||||
**第一步:大量模拟,建立肌肉记忆**
|
||||
|
||||
研究表明,一个人在面对压力场景时,需要至少 5-10 次模拟才能降低焦虑水平。这就是为什么很多企业用模拟面试提高候选人通过率——只不过以前模拟面试需要找真人,成本高、效率低。
|
||||
|
||||
**第二步:每次练习都要有反馈**
|
||||
|
||||
练习本身不产生进步。**有反馈的练习才产生进步。**
|
||||
|
||||
如果你的回答没有人告诉你"哪里好、哪里不好",你只是在一遍又一遍地强化错误。这就是为什么 AI 面试工具成为了越来越多人选择——它能给出即时、客观、结构化的评分和改进建议。
|
||||
|
||||
**第三步:拆解目标公司的出题风格**
|
||||
|
||||
不同公司、不同岗位的面试风格差异很大:
|
||||
|
||||
- 字节跳动爱考行为面试和快速反应
|
||||
- 腾讯注重项目深度和协作经历
|
||||
- 美团关注数据分析和业务思维
|
||||
- 阿里看重价值观匹配和抗压能力
|
||||
|
||||
如果没有针对性地准备,拿 A 公司的模板去面 B 公司,大概率会被面试官识破。
|
||||
|
||||
#### 三、2026 秋招备战时间表
|
||||
|
||||
| 时间 | 任务 | 产出 |
|
||||
|------|------|------|
|
||||
| 7 月 | 简历打磨 + 岗位调研 | 3 版针对性简历 |
|
||||
| 8 月 | 模拟面试 + 反馈改进 | 20+ 次模拟 |
|
||||
| 9 月 | 海投 + 高频面试 | 每周至少 3 场 |
|
||||
| 10 月 | 复盘 + 补录冲刺 | 面经整理 + 题库刷题 |
|
||||
|
||||
#### 四、一个值得尝试的 AI 面试工具
|
||||
|
||||
如果你正在准备 2026 校招,想找个低成本的方式大量练习面试,可以试试「宇之然AI磁场」——一款专注校招的 AI 面试教练。
|
||||
|
||||
它和通用 AI 工具最大的区别是:
|
||||
- **针对性**:覆盖 20+ 校招热门岗位,不只是通用问答
|
||||
- **有反馈**:每轮回答后 AI 给出评分 + 改进建议,回答结束生成四维报告(逻辑/表达/专业度/稳定性)
|
||||
- **公司题库**:基于真实用户面经积累的题目,不是网上搜来的大路货
|
||||
- **免费可用**:注册送 5 次面试机会,完全 0 成本体验
|
||||
|
||||
微信小程序搜索「宇之然AI磁场」或浏览器访问 zhiyin.yzrcloud.cn 即可使用。
|
||||
|
||||
面试能力不是天生的,是练出来的。既然校招注定要面几十场,为什么不先拿 AI 练习几场再去?
|
||||
|
||||
> 最后说一句:秋招是一场马拉松,不是百米冲刺。挂掉几场面试不代表你不行,关键是能从每次面试中学到什么。祝各位 2026 届毕业生,秋招顺利。
|
||||
|
||||
---
|
||||
|
||||
## 文章二:2026 秋招提前批已开!这份面试通关攻略请收好
|
||||
|
||||
**SEO 标题**: 2026 秋招提前批面试攻略:简历、面试、谈薪全流程指南
|
||||
**描述**: 秋招提前批已经开放,7 月投递 8 月面试。从简历优化到 AI 模拟面试,手把手教你拿 offer。
|
||||
**关键词**: 秋招提前批, 面试攻略, 简历优化, 校招流程, 应届生
|
||||
|
||||
---
|
||||
|
||||
### 正文
|
||||
|
||||
2026 届秋招提前批已经静悄悄开了。
|
||||
|
||||
大厂提前批集中在 7-8 月,特点是:流程快、hc 多、竞争相对小。可以说,提前批拿 offer 的难度系数比正式批低 30%。
|
||||
|
||||
但问题在于——很多人根本不知道提前批已经开了。
|
||||
|
||||
#### 提前批为什么一定要参加?
|
||||
|
||||
(详细分析提前批优势……)
|
||||
|
||||
#### 简历关:HR 筛选简历的 10 秒法则
|
||||
|
||||
(简历优化方法论……)
|
||||
|
||||
#### 面试关:AI 面试教练帮你练到 90 分
|
||||
|
||||
(这里插入产品推荐……)
|
||||
|
||||
#### 谈薪关:什么时候该要价,什么时候该妥协
|
||||
|
||||
(薪资谈判技巧……)
|
||||
|
||||
> 全文约 2500 字,此处为框架示例。
|
||||
> 发布前根据最新秋招时间线更新具体内容。
|
||||
|
||||
---
|
||||
|
||||
## 文章三:我们分析了 500 场 AI 模拟面试,发现了这 5 个校招面试规律
|
||||
|
||||
**SEO 标题**: 500 场 AI 模拟面试数据分析:校招面试评分最高的候选人做对了什么?
|
||||
**描述**: 基于 500+ 场 AI 面试的真实数据,分析高分候选人的 5 个共同特征,用数据说话,帮你找到面试提升方向。
|
||||
**关键词**: 面试数据分析, 校招面试评分, AI面试, 面试技巧, 数据报告
|
||||
|
||||
---
|
||||
|
||||
### 正文
|
||||
|
||||
数据比经验更可靠。
|
||||
|
||||
我们整理了「宇之然AI磁场」平台上 500+ 场 AI 模拟面试的评分数据,发现了一些有趣的规律。
|
||||
|
||||
**1. 自我介绍环节平均分最低,但对最终得分影响最大**
|
||||
|
||||
(数据分析 + 建议……)
|
||||
|
||||
**2. 专业度得分和回答长度没有正相关**
|
||||
|
||||
(数据 + 分析……)
|
||||
|
||||
**3. 超过 5 轮追问后,逻辑得分断崖式下降**
|
||||
|
||||
(数据 + 训练建议……)
|
||||
|
||||
**4. 稳定性是区分高分和中等分数的关键维度**
|
||||
|
||||
(数据 + 案例……)
|
||||
|
||||
**5. 同一个候选人,第一次和第五次模拟面试平均提分 23%**
|
||||
|
||||
(数据 + 说明练习的有效性……)
|
||||
|
||||
> 全文约 2000 字,发布前需导出最新数据图表。
|
||||
> 此类数据型文章转载率高,适合做品牌背书的长期流量入口。
|
||||
|
||||
---
|
||||
|
||||
## 排版规范
|
||||
|
||||
- 标题: `##` 二级标题
|
||||
- 段落间距: 1 空行
|
||||
- 重点引用: `> ` 引用语法
|
||||
- 列表: 使用 `- ` 无序列表
|
||||
- 重要数字/结论加粗 `**文本**`
|
||||
- 每 300-400 字插入一张配图(截图/数据图/示意图)
|
||||
- 底部放置小程序码 + 引导语
|
||||
@@ -0,0 +1,193 @@
|
||||
<!--
|
||||
========================================
|
||||
微信公众号 · 可直接复制到编辑器
|
||||
使用说明:
|
||||
1. 复制此文件全部内容
|
||||
2. 打开公众号后台图文编辑器
|
||||
3. 粘贴(会自动保留大部分样式)
|
||||
4. 替换 [配图:...] 为实际图片
|
||||
5. 文末替换小程序码
|
||||
========================================
|
||||
-->
|
||||
|
||||
<section style="padding: 10px 0;">
|
||||
|
||||
<!-- 标题 -->
|
||||
<h1 style="font-size: 18px; font-weight: 700; color: #1a1a1a; letter-spacing: 1px; line-height: 1.6; margin-bottom: 10px;">
|
||||
校招季 | 那些面试挂了的人,后来都怎么样了?
|
||||
</h1>
|
||||
|
||||
<!-- 副标题 -->
|
||||
<p style="font-size: 13px; color: #888; margin-bottom: 20px; border-left: 3px solid #4F46E5; padding-left: 10px;">
|
||||
2026 校招面试全攻略:从挂面到 offer,应届生做对了什么?
|
||||
</p>
|
||||
|
||||
<!-- 封面配图 -->
|
||||
<div style="margin: 20px 0; text-align: center;">
|
||||
<img src="https://zhiyin.yzrcloud.cn/static/og-image.png" alt="校招面试配图" style="max-width: 100%; border-radius: 8px;" />
|
||||
<p style="font-size: 12px; color: #aaa; margin-top: 5px;">[配图:面试场景 / 数据图表 / AI 面试截图]</p>
|
||||
</div>
|
||||
|
||||
<!-- 正文 -->
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
每年 9 月,几百万应届生涌入秋招战场。有人拿 offer 到手软,有人面完就杳无音信。差距到底在哪?
|
||||
</p>
|
||||
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
我们分析了 300+ 场 AI 模拟面试的数据,发现一个扎心的事实:<strong>绝大部分面试挂掉的人,不是因为能力不行,而是因为"没准备到点上"。</strong>
|
||||
</p>
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<div style="border-top: 1px solid #eee; margin: 25px 0;"></div>
|
||||
|
||||
<h2 style="font-size: 16px; font-weight: 700; color: #1a1a1a; margin-bottom: 12px; border-left: 4px solid #4F46E5; padding-left: 12px;">
|
||||
一、面试挂掉的 3 个致命原因
|
||||
</h2>
|
||||
|
||||
<h3 style="font-size: 15px; font-weight: 700; color: #333; margin-bottom: 8px;">1. 回答全是"背稿子"</h3>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
"请自我介绍一下。""我叫 XXX,来自 XX 大学,专业是 XX……"——这种千篇一律的开场,面试官每天听几十遍。
|
||||
</p>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
AI 面试评分数据显示,自我介绍环节平均得分只有 5.8/10。问题出在哪?不是不流利,而是<strong>没有针对性</strong>。面试官想听的不是你的基本信息,而是"你为什么适合这个岗位"。
|
||||
</p>
|
||||
|
||||
<!-- 配图 -->
|
||||
<div style="margin: 15px 0; text-align: center; background: #F3F4F6; padding: 30px 15px; border-radius: 8px;">
|
||||
<p style="font-size: 13px; color: #666;">[配图:自我介绍评分数据图表 / 雷达图]</p>
|
||||
</div>
|
||||
|
||||
<h3 style="font-size: 15px; font-weight: 700; color: #333; margin-bottom: 8px;">2. 逻辑混乱,答非所问</h3>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
面到深处,面试官会追问细节。很多人这时候开始"编"——编数据、编经历、编成果。
|
||||
</p>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
AI 的追问逻辑检测发现,超过 60% 的候选人在第 3 轮追问后开始出现逻辑断裂。前后矛盾、数据不对应、结论和论据脱节,这些在 AI 评分系统里会被精准捕捉。
|
||||
</p>
|
||||
|
||||
<h3 style="font-size: 15px; font-weight: 700; color: #333; margin-bottom: 8px;">3. 完全不了解目标公司和岗位</h3>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
"你对我们公司了解多少?""嗯……是大厂,做互联网的……"<strong>这种回答基本等于给自己发了拒信。</strong>公司题库数据显示,面试中涉及目标公司业务的题目占比高达 35%。不做功课就上考场,结果可想而知。
|
||||
</p>
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<div style="border-top: 1px solid #eee; margin: 25px 0;"></div>
|
||||
|
||||
<h2 style="font-size: 16px; font-weight: 700; color: #1a1a1a; margin-bottom: 12px; border-left: 4px solid #4F46E5; padding-left: 12px;">
|
||||
二、面试能力是一个"可训练"的技能
|
||||
</h2>
|
||||
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
很多人把面试当作"展示自己"的过程——我准备好了,你来打分吧。
|
||||
</p>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
错了。面试本质上是<strong>一场结构化的问题应对</strong>。每个问题的背后都有考察意图,你的回答需要同时满足:逻辑性、专业性、表达力、应变力。这四个维度对应着面试官打分表上的核心指标。好消息是,这四个维度都是可以被训练的。
|
||||
</p>
|
||||
|
||||
<h3 style="font-size: 15px; font-weight: 700; color: #333; margin-bottom: 8px;">第一步:大量模拟,建立肌肉记忆</h3>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
研究表明,一个人在面对压力场景时,需要至少 5-10 次模拟才能降低焦虑水平。这就是为什么很多企业用模拟面试提高候选人通过率——只不过以前模拟面试需要找真人,成本高、效率低。
|
||||
</p>
|
||||
|
||||
<h3 style="font-size: 15px; font-weight: 700; color: #333; margin-bottom: 8px;">第二步:每次练习都要有反馈</h3>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
练习本身不产生进步。<strong>有反馈的练习才产生进步。</strong>如果你的回答没有人告诉你"哪里好、哪里不好",你只是在一遍又一遍地强化错误。这就是为什么 AI 面试工具成为了越来越多人选择——它能给出即时、客观、结构化的评分和改进建议。
|
||||
</p>
|
||||
|
||||
<h3 style="font-size: 15px; font-weight: 700; color: #333; margin-bottom: 8px;">第三步:拆解目标公司的出题风格</h3>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
不同公司、不同岗位的面试风格差异很大:
|
||||
</p>
|
||||
<ul style="font-size: 15px; color: #333; line-height: 2; padding-left: 20px; margin-bottom: 15px;">
|
||||
<li>字节跳动爱考行为面试和快速反应</li>
|
||||
<li>腾讯注重项目深度和协作经历</li>
|
||||
<li>美团关注数据分析和业务思维</li>
|
||||
<li>阿里看重价值观匹配和抗压能力</li>
|
||||
</ul>
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
如果没有针对性地准备,拿 A 公司的模板去面 B 公司,大概率会被面试官识破。
|
||||
</p>
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<div style="border-top: 1px solid #eee; margin: 25px 0;"></div>
|
||||
|
||||
<h2 style="font-size: 16px; font-weight: 700; color: #1a1a1a; margin-bottom: 12px; border-left: 4px solid #4F46E5; padding-left: 12px;">
|
||||
三、2026 秋招备战时间表
|
||||
</h2>
|
||||
|
||||
<table style="width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 20px;">
|
||||
<tr style="background: #4F46E5; color: #fff;">
|
||||
<th style="padding: 10px; border: 1px solid #ddd; text-align: center;">时间</th>
|
||||
<th style="padding: 10px; border: 1px solid #ddd; text-align: center;">任务</th>
|
||||
<th style="padding: 10px; border: 1px solid #ddd; text-align: center;">产出</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 10px; border: 1px solid #ddd; text-align: center; font-weight: 700;">7 月</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">简历打磨 + 岗位调研</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">3 版针对性简历</td>
|
||||
</tr>
|
||||
<tr style="background: #F9FAFB;">
|
||||
<td style="padding: 10px; border: 1px solid #ddd; text-align: center; font-weight: 700;">8 月</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">模拟面试 + 反馈改进</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">20+ 次模拟</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 10px; border: 1px solid #ddd; text-align: center; font-weight: 700;">9 月</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">海投 + 高频面试</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">每周至少 3 场</td>
|
||||
</tr>
|
||||
<tr style="background: #F9FAFB;">
|
||||
<td style="padding: 10px; border: 1px solid #ddd; text-align: center; font-weight: 700;">10 月</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">复盘 + 补录冲刺</td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">面经整理 + 题库刷题</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<div style="border-top: 1px solid #eee; margin: 25px 0;"></div>
|
||||
|
||||
<h2 style="font-size: 16px; font-weight: 700; color: #1a1a1a; margin-bottom: 12px; border-left: 4px solid #4F46E5; padding-left: 12px;">
|
||||
四、一个值得尝试的 AI 面试工具
|
||||
</h2>
|
||||
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
如果你正在准备 2026 校招,想找个低成本的方式大量练习面试,可以试试<strong>「宇之然AI磁场(职引)」</strong>——一款专注校招的 AI 面试教练。
|
||||
</p>
|
||||
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 10px;">
|
||||
它和通用 AI 工具最大的区别是:
|
||||
</p>
|
||||
<ul style="font-size: 15px; color: #333; line-height: 2; padding-left: 20px; margin-bottom: 15px;">
|
||||
<li><strong>针对性</strong>:覆盖 20+ 校招热门岗位,不只是通用问答</li>
|
||||
<li><strong>有反馈</strong>:每轮回答后 AI 给出评分 + 改进建议,回答结束生成四维报告(逻辑/表达/专业度/稳定性)</li>
|
||||
<li><strong>公司题库</strong>:基于真实用户面经积累的题目,不是网上搜来的大路货</li>
|
||||
<li><strong>免费可用</strong>:注册送 5 次面试机会,完全 0 成本体验</li>
|
||||
</ul>
|
||||
|
||||
<!-- 小程序码配图 -->
|
||||
<div style="margin: 20px 0; text-align: center;">
|
||||
<img src="https://zhiyin.yzrcloud.cn/static/qr-code.png" alt="小程序码" style="width: 150px; height: 150px; border-radius: 8px;" />
|
||||
<p style="font-size: 12px; color: #999; margin-top: 5px;">微信扫描二维码,立即开始模拟面试</p>
|
||||
</div>
|
||||
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
微信小程序搜索「宇之然AI磁场」或浏览器访问 zhiyin.yzrcloud.cn 即可使用。
|
||||
</p>
|
||||
|
||||
<p style="font-size: 15px; color: #333; line-height: 1.8; margin-bottom: 15px;">
|
||||
面试能力不是天生的,是练出来的。既然校招注定要面几十场,为什么不先拿 AI 练习几场再去?
|
||||
</p>
|
||||
|
||||
<!-- 结尾引用 -->
|
||||
<blockquote style="border-left: 4px solid #4F46E5; padding: 15px 20px; background: #F3F4F6; border-radius: 4px; margin: 25px 0;">
|
||||
<p style="font-size: 14px; color: #555; line-height: 1.8; margin: 0;">
|
||||
最后说一句:秋招是一场马拉松,不是百米冲刺。挂掉几场面试不代表你不行,关键是能从每次面试中学到什么。祝各位 2026 届毕业生,秋招顺利。
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<!-- 底部 -->
|
||||
<p style="font-size: 12px; color: #bbb; text-align: center; margin-top: 30px; border-top: 1px solid #eee; padding-top: 15px;">
|
||||
— END —
|
||||
</p>
|
||||
|
||||
</section>
|
||||
@@ -0,0 +1,242 @@
|
||||
<!--
|
||||
========================================
|
||||
小红书 · 可直接复制到编辑器
|
||||
使用说明:
|
||||
1. 小红书编辑器不支持富文本粘贴
|
||||
2. 每条笔记包含:封面说明 + 正文 + 标签
|
||||
3. 复制正文内容粘贴即可,图片单独上传
|
||||
========================================
|
||||
-->
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- 笔记一:秋招面了 10 场都挂了,直到我发现了这个秘密… -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
📌 封面图:[iPhone 截图风格,展示 AI 面试评分界面 + 大字标题 "面了10场全挂?试试这个"]
|
||||
|
||||
📌 标题:秋招面了 10 场全挂😭后来我做对了这件事
|
||||
|
||||
---
|
||||
|
||||
秋招面了 10 场,挂了 10 场。
|
||||
每次面完都觉得自己说得挺好,结果杳无音信。
|
||||
|
||||
后来学长推荐我用 AI 模拟面试练一下,我才知道自己问题在哪。
|
||||
|
||||
就是这款叫 <strong>「宇之然AI磁场」</strong> 的小程序,专注校招面试的。它的逻辑是:
|
||||
你回答 → AI 立即评分 + 写改进建议 → 整场面完出一份四维报告
|
||||
|
||||
我第一次模拟才 5.2 分…
|
||||
练了 5 次以后稳定在 7.5+
|
||||
(报告里能看到逻辑、表达、专业度、稳定性四个维度的变化)
|
||||
|
||||
最有用的是它有一个 <strong>「公司真题库」</strong>
|
||||
不是网上搜来的通用题,是真实用户贡献的面经
|
||||
直接搜目标公司,就能看到他们家的面试题长什么样
|
||||
|
||||
缺点也有:
|
||||
- 有时候 AI 追问比较狠,面完会有点emo
|
||||
- 免费次数 5 次,用完了需要按量购买(¥5/份)
|
||||
- 岗位覆盖 20+,冷门岗位题库还在积累中
|
||||
|
||||
但整体来说,0 成本试一下不亏
|
||||
至少比直接上真考场当炮灰强…
|
||||
|
||||
评论区求分享:你秋招准备了多久?
|
||||
|
||||
#秋招 #校招面试 #AI面试 #面试技巧 #应届生求职 #求职干货 #面试模拟 #秋招准备
|
||||
|
||||
---
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- 笔记二:救命!原来面试官是这样打分的… -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
📌 封面图:[四维雷达图截图 + "面试评分标准" 大字标题]
|
||||
|
||||
📌 标题:🆘面试官打分标准曝光!难怪我挂了
|
||||
|
||||
---
|
||||
|
||||
面试官手里真的有一张打分表❗
|
||||
|
||||
我用的 AI 面试工具 <strong>「宇之然AI磁场」</strong> 把评分标准做成了四维雷达图,练完发现自己的短板一清二楚👇
|
||||
|
||||
<strong>🔵 逻辑性(权重 30%)</strong>
|
||||
回答有没有结构、能不能说清楚
|
||||
→ 建议用 STAR 法则练 3 次,效果立竿见影
|
||||
|
||||
<strong>🟢 专业度(权重 30%)</strong>
|
||||
对岗位知识的理解深度
|
||||
→ 多做公司调研,少背概念
|
||||
|
||||
<strong>🟡 表达力(权重 20%)</strong>
|
||||
说得清不清楚、自不自然
|
||||
→ 多模拟,对着 AI 练 5 次就会好很多
|
||||
|
||||
<strong>🟠 稳定性(权重 20%)</strong>
|
||||
追问不慌、不会的不硬编
|
||||
→ 这个最难练,但 AI 可以模拟压力场景
|
||||
|
||||
我第一次练只有 5.2 分(尤其是逻辑和稳定性)
|
||||
练了 5 次到 7.5+
|
||||
每次都有评分变化曲线,看得到进步,很有成就感
|
||||
|
||||
秋招党真的可以试试
|
||||
微信搜 <strong>「宇之然AI磁场」</strong> 小程序就行
|
||||
注册就送 5 次,别浪费了~
|
||||
|
||||
#面试技巧 #校招 #秋招 #面试评分 #求职干货 #面试官 #AI面试 #简历
|
||||
|
||||
---
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- 笔记三:双非逆袭大厂|我秋招做对了 3 件事 -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
📌 封面图:[对比风格 — "双非" vs "大厂 offer" + 三个要点图标]
|
||||
|
||||
📌 标题:双非➡️大厂 offer|秋招我只做对了这 3 件事
|
||||
|
||||
---
|
||||
|
||||
bg:双非本,0 大厂实习
|
||||
秋招结果:3 个大厂意向书
|
||||
|
||||
复盘了一下,核心做对了 3 件事:
|
||||
|
||||
<strong>1️⃣ 提前 2 个月开始模拟面试</strong>
|
||||
7 月开始用 <strong>「宇之然AI磁场」</strong> 练 AI 面试
|
||||
到 9 月正式面的时候,已经练了 30+ 次
|
||||
面试官问的问题,80% 都练过类似的
|
||||
紧张感?不存在的
|
||||
|
||||
<strong>2️⃣ 把面经当教材刷</strong>
|
||||
面经真的很有用
|
||||
同一个岗位,不同公司问的风格完全不同
|
||||
提前看过真题,面试时就不会被绕晕
|
||||
|
||||
<strong>3️⃣ 面试完必复盘</strong>
|
||||
以前面完就过去了
|
||||
后来每次面完用 AI 生成四维报告
|
||||
看自己哪方面弱 → 专项练习 → 下次面再看有没有进步
|
||||
|
||||
3 个月从 5.2 分到 7.8 分
|
||||
面试真的是可以练出来的
|
||||
|
||||
双非怎么了?练就完了💪
|
||||
|
||||
#秋招 #双非 #大厂offer #校招面试 #面试技巧 #逆袭 #求职经验 #面试模拟
|
||||
|
||||
---
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- 笔记四:面试复盘神器|录音➡️AI 自动分析你的表现 -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
📌 封面图:[面试复盘流程示意图 — 录音→波形图→分析报告]
|
||||
|
||||
📌 标题:秋招必备!面试录音扔进去,AI 自动出分析报告
|
||||
|
||||
---
|
||||
|
||||
面完了一场面试,但完全不知道哪里说得好、哪里说得不好?
|
||||
|
||||
别怕!我发现 <strong>「宇之然AI磁场」</strong> 新出了一个超强功能👇
|
||||
|
||||
<strong>面试复盘模式</strong>
|
||||
就是把你的面试录音上传
|
||||
或者直接粘贴转录文本
|
||||
AI 会自动分析:
|
||||
|
||||
- ✅ 逐题评估(每道题答得怎么样)
|
||||
- ✅ 四维评分(逻辑/表达/专业度/稳定性)
|
||||
- ✅ 口语分析(你有没有说太多"然后"、"那个"、"就是"这类填充词)
|
||||
|
||||
我第一次用的时候
|
||||
发现自己 10 分钟说了 37 次 "然后" 😅
|
||||
难怪面试官频频皱眉…
|
||||
|
||||
用 AI 给自己做面试复盘的好处是:
|
||||
- 完全客观,不会因为自我感觉良好而忽略问题
|
||||
- 可以反复看,多次复盘
|
||||
- 没录音的话,粘贴文本也行
|
||||
|
||||
秋招加油姐妹们!工具都给你们了,剩下的靠你们了💪
|
||||
|
||||
#面试复盘 #AI面试 #秋招 #校招 #求职工具 #面试技巧 #口语分析
|
||||
|
||||
---
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- 笔记五:2026 秋招时间表|7 月该做什么? -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
📌 封面图:[时间轴信息图 — 7 月到 11 月的关键节点]
|
||||
|
||||
📌 标题:2026 秋招时间线|7 月不准备,9 月徒伤悲
|
||||
|
||||
---
|
||||
|
||||
2026 秋招党注意了⚠️
|
||||
提前批已经开了!7 月是你最后的准备窗口
|
||||
|
||||
<strong>7 月 To Do List 👇</strong>
|
||||
|
||||
✅ 简历定稿(至少改 3 版)
|
||||
✅ 目标公司清单(分梯队:冲刺/稳妥/保底)
|
||||
✅ 每周 3 次模拟面试
|
||||
✅ 研究目标公司业务动态
|
||||
✅ 整理自己的面试问题库
|
||||
|
||||
<strong>8 月:提前批投递</strong>
|
||||
- 大厂提前批 7 月底-8 月
|
||||
- 流程快、hc 多、竞争比正式批小 30%
|
||||
|
||||
<strong>9 月:正式批</strong>
|
||||
- 海投!
|
||||
- 这时候你 7 月的练习就要发挥作用了
|
||||
|
||||
推荐用 <strong>「宇之然AI磁场」</strong> 小程序练习面试
|
||||
我从 7 月开始每周练 3 次
|
||||
到 9 月正式面的时候真的不慌了
|
||||
而且能看到自己的评分在涨
|
||||
那种"我在进步"的感觉太上头了
|
||||
|
||||
收藏这份时间表,从现在开始执行
|
||||
秋招结束后你会感谢自己的💪
|
||||
|
||||
#秋招时间线 #2026秋招 #校招准备 #求职规划 #应届生 #面试模拟 #7月规划
|
||||
|
||||
---
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- 小红书发布指南 -->
|
||||
<!-- ============================================================
|
||||
|
||||
一、图片要求
|
||||
- 封面:1242×1660px(3:4 比例),文字不超过 15 个字
|
||||
- 内图:1080×1440px,3-5 张为宜
|
||||
- 格式:JPG/PNG
|
||||
|
||||
二、正文要求
|
||||
- 每段不超过 3 行
|
||||
- 适当使用 emoji 增加视觉节奏
|
||||
- 关键信息用 **加粗** 或换行突出
|
||||
|
||||
三、标签策略
|
||||
- 大标签(搜索量大):#秋招 #校招面试 #AI面试 #应届生求职
|
||||
- 中小标签(精准):#面试模拟 #面试技巧 #求职干货 #面试复盘
|
||||
|
||||
四、发布节奏
|
||||
- 第 1 周:笔记一(痛点共鸣)+ 笔记五(时间表)
|
||||
- 第 2 周:笔记二(评分科普)+ 笔记四(复盘功能)
|
||||
- 第 3 周:笔记三(用户故事)
|
||||
- 第 4 周:根据数据反馈优化迭代
|
||||
|
||||
五、注意事项
|
||||
- ❌ 正文不出现网址链接
|
||||
- ❌ 不直接留联系方式
|
||||
- ✅ 通过搜索"宇之然AI磁场"引导转化
|
||||
- ✅ 评论区互动引导("你秋招准备了多久?")
|
||||
-->
|
||||
@@ -0,0 +1,235 @@
|
||||
# 小红书 · 营销文案
|
||||
|
||||
> 定位: 短平快笔记,真实感强,通过话题标签触达精准用户
|
||||
> 风格: 口语化 + 故事性 + 高信息密度
|
||||
> 策略: 封面吸引点击 → 正文提供价值 → 标签精准触达
|
||||
> 注意: 小红书对引流行为敏感,正文不直接放链接,通过品牌词搜索转化
|
||||
|
||||
---
|
||||
|
||||
## 笔记一:秋招面了 10 场都挂了,直到我发现了这个秘密…
|
||||
|
||||
**封面设计**: iPhone 截图风格,展示 AI 面试评分界面 + 大字标题
|
||||
**标题选项**:
|
||||
- 秋招面了 10 场全挂😭后来我做对了这件事
|
||||
- 终于有人把校招面试说清楚了!先练再面真的不一样
|
||||
|
||||
**正文**:
|
||||
|
||||
秋招面了 10 场,挂了 10 场。
|
||||
每次面完都觉得自己说得挺好,结果杳无音信。
|
||||
|
||||
后来学长推荐我用 AI 模拟面试练一下,我才知道自己问题在哪。
|
||||
|
||||
就是这款叫「宇之然AI磁场」的小程序,专注校招面试的。它的逻辑是:
|
||||
你回答 → AI 立即评分 + 写改进建议 → 整场面完出一份四维报告
|
||||
|
||||
我第一次模拟才 5.2 分…
|
||||
练了 5 次以后稳定在 7.5+
|
||||
(报告里能看到逻辑、表达、专业度、稳定性四个维度的变化)
|
||||
|
||||
最有用的是它有一个「公司真题库」
|
||||
不是网上搜来的通用题,是真实用户贡献的面经
|
||||
直接搜目标公司,就能看到他们家的面试题长什么样
|
||||
|
||||
缺点也有:
|
||||
- 有时候 AI 追问比较狠,面完会有点emo
|
||||
- 免费次数 5 次,用完了需要按量购买(¥5/份)
|
||||
- 岗位覆盖 20+,冷门岗位题库还在积累中
|
||||
|
||||
但整体来说,0 成本试一下不亏
|
||||
至少比直接上真考场当炮灰强…
|
||||
|
||||
评论区求分享:你秋招准备了多久?
|
||||
|
||||
#秋招 #校招面试 #AI面试 #面试技巧 #应届生求职 #求职干货 #面试模拟 #秋招准备
|
||||
|
||||
---
|
||||
|
||||
## 笔记二:救命!原来面试官是这样打分的…
|
||||
|
||||
**封面设计**: 四维雷达图截图 + "面试评分标准"大字
|
||||
**标题选项**:
|
||||
- 🆘面试官打分标准曝光!难怪我挂了
|
||||
- 校招面试评分标准全公开!四维能力雷达图
|
||||
|
||||
**正文**:
|
||||
|
||||
面试官手里真的有一张打分表❗
|
||||
|
||||
我用的 AI 面试工具「宇之然AI磁场」把评分标准做成了四维雷达图,练完发现自己的短板一清二楚👇
|
||||
|
||||
**🔵逻辑性(权重 30%)**
|
||||
回答有没有结构、能不能说清楚
|
||||
→ 建议用 STAR 法则练 3 次,效果立竿见影
|
||||
|
||||
**🟢专业度(权重 30%)**
|
||||
对岗位知识的理解深度
|
||||
→ 多做公司调研,少背概念
|
||||
|
||||
**🟡表达力(权重 20%)**
|
||||
说得清不清楚、自不自然
|
||||
→ 多模拟,对着 AI 练 5 次就会好很多
|
||||
|
||||
**🟠稳定性(权重 20%)**
|
||||
追问不慌、不会的不硬编
|
||||
→ 这个最难练,但 AI 可以模拟压力场景
|
||||
|
||||
我第一次练只有 5.2 分(尤其是逻辑和稳定性)
|
||||
练了 5 次到 7.5+
|
||||
每次都有评分变化曲线,看得到进步,很有成就感
|
||||
|
||||
秋招党真的可以试试
|
||||
微信搜「宇之然AI磁场」小程序就行
|
||||
注册就送 5 次,别浪费了~
|
||||
|
||||
#面试技巧 #校招 #秋招 #面试评分 #求职干货 #面试官 #AI面试 #简历
|
||||
|
||||
---
|
||||
|
||||
## 笔记三:双非逆袭大厂|我秋招做对了 3 件事
|
||||
|
||||
**封面设计**: 对比风格("双非" vs "大厂 offer")+ 三个要点图标
|
||||
**标题选项**:
|
||||
- 双非➡️大厂 offer|秋招我只做对了这 3 件事
|
||||
- 双非秋招逆袭经验|没背景也能拿大厂 offer
|
||||
|
||||
**正文**:
|
||||
|
||||
bg:双非本,0 大厂实习
|
||||
秋招结果:3 个大厂意向书
|
||||
|
||||
复盘了一下,核心做对了 3 件事:
|
||||
|
||||
**1️⃣ 提前 2 个月开始模拟面试**
|
||||
7 月开始用「宇之然AI磁场」练 AI 面试
|
||||
到 9 月正式面的时候,已经练了 30+ 次
|
||||
面试官问的问题,80% 都练过类似的
|
||||
紧张感?不存在的
|
||||
|
||||
**2️⃣ 把面经当教材刷**
|
||||
面经真的很有用
|
||||
同一个岗位,不同公司问的风格完全不同
|
||||
提前看过真题,面试时就不会被绕晕
|
||||
|
||||
**3️⃣ 面试完必复盘**
|
||||
以前面完就过去了
|
||||
后来每次面完用 AI 生成四维报告
|
||||
看自己哪方面弱 → 专项练习 → 下次面再看有没有进步
|
||||
|
||||
3 个月从 5.2 分到 7.8 分
|
||||
面试真的是可以练出来的
|
||||
|
||||
双非怎么了?练就完了💪
|
||||
|
||||
#秋招 #双非 #大厂offer #校招面试 #面试技巧 #逆袭 #求职经验 #面试模拟
|
||||
|
||||
---
|
||||
|
||||
## 笔记四:面试复盘神器|录音➡️AI 自动分析你的表现
|
||||
|
||||
**封面设计**: 面试复盘流程示意图(录音→波形图→分析报告)
|
||||
**标题选项**:
|
||||
- 面完不知道怎么复盘?这个 AI 工具帮你自动分析
|
||||
- 秋招必备!面试录音扔进去,AI 自动出分析报告
|
||||
|
||||
**正文**:
|
||||
|
||||
面完了一场面试,但完全不知道哪里说得好、哪里说得不好?
|
||||
|
||||
别怕!我发现「宇之然AI磁场」新出了一个超强功能👇
|
||||
|
||||
**面试复盘模式**
|
||||
就是把你的面试录音上传
|
||||
或者直接粘贴转录文本
|
||||
AI 会自动分析:
|
||||
|
||||
- ✅ 逐题评估(每道题答得怎么样)
|
||||
- ✅ 四维评分(逻辑/表达/专业度/稳定性)
|
||||
- ✅ 口语分析(你有没有说太多"然后"、"那个"、"就是"这类填充词)
|
||||
|
||||
我第一次用的时候
|
||||
发现自己 10 分钟说了 37 次"然后"😅
|
||||
难怪面试官频频皱眉…
|
||||
|
||||
用 AI 给自己做面试复盘的好处是:
|
||||
- 完全客观,不会因为自我感觉良好而忽略问题
|
||||
- 可以反复看,多次复盘
|
||||
- 没录音的话,粘贴文本也行
|
||||
|
||||
秋招加油姐妹们!工具都给你们了,剩下的靠你们了💪
|
||||
|
||||
#面试复盘 #AI面试 #秋招 #校招 #求职工具 #面试技巧 #口语分析
|
||||
|
||||
---
|
||||
|
||||
## 笔记五:2026 秋招时间表|7 月该做什么?(附准备清单)
|
||||
|
||||
**封面设计**: 时间轴信息图风格,7 月到 11 月的关键节点
|
||||
**标题选项**:
|
||||
- 2026 秋招时间线|7 月不准备,9 月徒伤悲
|
||||
- 秋招倒计时⏰7 月必须做完这 5 件事
|
||||
|
||||
**正文**:
|
||||
|
||||
2026 秋招党注意了⚠️
|
||||
提前批已经开了!7 月是你最后的准备窗口
|
||||
|
||||
**7 月 To Do List👇**
|
||||
|
||||
✅ 简历定稿(至少改 3 版)
|
||||
✅ 目标公司清单(分梯队:冲刺/稳妥/保底)
|
||||
✅ 每周 3 次模拟面试
|
||||
✅ 研究目标公司业务动态
|
||||
✅ 整理自己的面试问题库
|
||||
|
||||
**8 月:提前批投递**
|
||||
- 大厂提前批 7 月底-8 月
|
||||
- 流程快、hc 多、竞争比正式批小 30%
|
||||
|
||||
**9 月:正式批**
|
||||
- 海投!
|
||||
- 这时候你 7 月的练习就要发挥作用了
|
||||
|
||||
推荐用「宇之然AI磁场」小程序练习面试
|
||||
我从 7 月开始每周练 3 次
|
||||
到 9 月正式面的时候真的不慌了
|
||||
而且能看到自己的评分在涨
|
||||
那种"我在进步"的感觉太上头了
|
||||
|
||||
收藏这份时间表,从现在开始执行
|
||||
秋招结束后你会感谢自己的💪
|
||||
|
||||
#秋招时间线 #2026秋招 #校招准备 #求职规划 #应届生 #面试模拟 #7月规划
|
||||
|
||||
---
|
||||
|
||||
## 排版规范
|
||||
|
||||
- 正文每段不超过 3 行
|
||||
- 使用 emoji 符号增加视觉节奏(❗✅💰💪🔥📌)
|
||||
- 关键信息用 `**加粗**` 突出
|
||||
- 每篇笔记配 3-5 张图片(封面 + 截图 + 示意图)
|
||||
- 末尾 5-10 个精准话题标签(大小号交替:大号用 # 小号不用)
|
||||
- 正文不出现网址链接,通过搜索"宇之然AI磁场"引导
|
||||
- 评论区可互动("求问面了哪家"等引导互动)
|
||||
- 封面图上的文字不超过 15 个字,字体醒目
|
||||
|
||||
## 标签词库
|
||||
|
||||
| 大标签(搜索量大) | 中小标签(精准) |
|
||||
|-------------------|-----------------|
|
||||
| #秋招 | #面试模拟 |
|
||||
| #校招面试 | #面试技巧 |
|
||||
| #应届生求职 | #求职干货 |
|
||||
| #AI面试 | #面试复盘 |
|
||||
| #面试 | #面试准备 |
|
||||
|
||||
## 发布节奏
|
||||
|
||||
| 周次 | 笔记 | 主题 |
|
||||
|------|------|------|
|
||||
| 第 1 周 | 笔记一 + 笔记五 | 痛点共鸣 + 时间表 |
|
||||
| 第 2 周 | 笔记二 + 笔记四 | 干货科普 + 功能亮点 |
|
||||
| 第 3 周 | 笔记三 | 用户故事(真实脱敏) |
|
||||
| 第 4 周 | 笔记一(迭代优化版) | 根据数据反馈调整 |
|
||||
@@ -0,0 +1,188 @@
|
||||
<!--
|
||||
========================================
|
||||
知乎 · 可直接复制到编辑器
|
||||
使用说明:
|
||||
1. 复制此文件全部内容
|
||||
2. 打开知乎「写回答」或「写文章」
|
||||
3. 粘贴(知乎编辑器支持富文本)
|
||||
4. 替换 [配图:...] 为实际图片
|
||||
========================================
|
||||
-->
|
||||
|
||||
<!-- ========== 回答一:2026 秋招,应该如何准备? ========== -->
|
||||
|
||||
<h1>2026 秋招,应该如何准备?</h1>
|
||||
|
||||
<div style="margin: 20px 0; text-align: center;">
|
||||
<img src="https://zhiyin.yzrcloud.cn/static/og-image.png" alt="秋招准备" style="max-width: 100%; border-radius: 8px;" />
|
||||
<p style="font-size: 12px; color: #999; margin-top: 5px;">[配图:秋招时间轴 / 信息图]</p>
|
||||
</div>
|
||||
|
||||
<p>2026 届秋招已经开始了。</p>
|
||||
|
||||
<p>先说时间线:互联网大厂提前批 7 月投递、8 月面试;正式批 8 月底开启、9-10 月密集面试;国企/银行 9-11 月。如果你是 2026 届毕业生,现在就应该开始准备了。</p>
|
||||
|
||||
<p>我从三个角度展开说:<strong>认知准备</strong>、<strong>能力准备</strong>、<strong>信息准备</strong>。</p>
|
||||
|
||||
<h2>一、认知准备:重新理解面试</h2>
|
||||
|
||||
<p>很多人的面试准备方法是错误的——他们以为面试是"展示自己",面试官问什么,他们准备什么。</p>
|
||||
|
||||
<p>但实际情况是:<strong>面试是一场有限时间内的结构化信息交换</strong>。面试官需要在 30-60 分钟内判断你是否胜任这个岗位。这意味着:</p>
|
||||
|
||||
<ul>
|
||||
<li>你说的每一句话都要有目的</li>
|
||||
<li>不是你说的越多越好,而是你说的越精准越好</li>
|
||||
<li>面试官的问题看似随意,背后都有考察维度</li>
|
||||
</ul>
|
||||
|
||||
<p>通用的考察维度无非四个:<strong>逻辑性</strong>(结构化表达)、<strong>专业度</strong>(领域深度)、<strong>表达力</strong>(沟通清晰度)、<strong>稳定性</strong>(抗压和应变)。几乎所有面试问题都可以映射到这四个维度上。</p>
|
||||
|
||||
<h2>二、能力准备:刻意练习 + 有效反馈</h2>
|
||||
|
||||
<p>如果你从 7 月开始准备到 9 月正式面试,有大约 60 天的时间窗口。</p>
|
||||
|
||||
<h3>前 30 天:大量输入 + 模拟输出</h3>
|
||||
<ul>
|
||||
<li>每天花 30 分钟研究目标公司的业务和产品</li>
|
||||
<li>建立自己的"面试问题库",按逻辑/专业/表达/稳定四个维度分类</li>
|
||||
<li>每周至少做 3 次模拟面试</li>
|
||||
</ul>
|
||||
|
||||
<p>这里说一下模拟面试的重要性。很多人觉得自己对着镜子练就行了,但这里的核心问题是:<strong>没有反馈的练习很可能是无效的</strong>。你无法判断自己的回答在面试官眼中是好是坏。这就是为什么现在越来越多同学选择使用 AI 模拟面试工具——它们能提供即时、客观的结构化反馈。</p>
|
||||
|
||||
<div style="margin: 20px 0; text-align: center; background: #F6F8FA; padding: 20px; border-radius: 8px;">
|
||||
<p style="font-size: 13px; color: #666;">[配图:AI 面试评分报告截图 / 四维雷达图]</p>
|
||||
</div>
|
||||
|
||||
<h3>后 30 天:针对性改进 + 真题实战</h3>
|
||||
<ul>
|
||||
<li>根据模拟反馈锁定自己的薄弱维度,集中突破</li>
|
||||
<li>找出目标公司的历年面试题,做针对性练习</li>
|
||||
<li>练习到每个维度的评分都能稳定在 7/10 以上</li>
|
||||
</ul>
|
||||
|
||||
<h2>三、信息准备:打破信息差</h2>
|
||||
|
||||
<p>秋招中最大的不公平不是能力,而是信息差。打破信息差的方法:</p>
|
||||
<ul>
|
||||
<li>关注目标公司的招聘公众号</li>
|
||||
<li>加入校招信息群</li>
|
||||
<li>多刷面经,整理成自己的题库</li>
|
||||
</ul>
|
||||
|
||||
<p>这里顺便推荐一下我们团队做的 AI 面试工具<strong>「宇之然AI磁场(职引)」</strong>,它内置了 20+ 校招热门岗位的模拟面试,每轮回答都有 AI 评分和改进建议,还有基于真实面经的公司题库。关键是注册免费,0 成本体验。微信小程序搜「宇之然AI磁场」就能用。</p>
|
||||
|
||||
<h2>四、核心时间轴</h2>
|
||||
|
||||
<pre style="background: #F6F8FA; padding: 15px; border-radius: 6px; font-size: 14px; line-height: 1.8;">
|
||||
7 月:简历定稿 + 岗位调研 + 模拟面试启动
|
||||
8 月:提前批投递 + 高频模拟
|
||||
9 月:正式批投递 + 真实面试
|
||||
10 月:复盘调整 + 第三批投递
|
||||
11 月:补录捡漏 + 准备春招
|
||||
</pre>
|
||||
|
||||
<hr />
|
||||
|
||||
<!-- ========== 回答二:校招面试中,面试官最看重的是什么? ========== -->
|
||||
|
||||
<h1>校招面试中,面试官最看重的是什么?</h1>
|
||||
|
||||
<div style="margin: 20px 0; text-align: center;">
|
||||
<img src="https://zhiyin.yzrcloud.cn/static/og-image.png" alt="面试评分标准" style="max-width: 100%; border-radius: 8px;" />
|
||||
<p style="font-size: 12px; color: #999; margin-top: 5px;">[配图:四维评分雷达图 / 面试打分表示意图]</p>
|
||||
</div>
|
||||
|
||||
<p>作为校招 AI 面试工具的开发者,我见过 500+ 场模拟面试的评分数据。这个问题我有发言权。</p>
|
||||
|
||||
<p>先给结论:面试官最看重的是 <strong>"这个人未来能不能用"</strong>,而不是"这个人现在有多强"。</p>
|
||||
|
||||
<p>基于这个底层逻辑,面试官的核心考察维度可以分为以下四个:</p>
|
||||
|
||||
<h2>1. 逻辑性(权重约 30%)</h2>
|
||||
<p>能不能把你的经历、观点、方案说清楚?</p>
|
||||
<p>面试官最怕听到"东一榔头西一棒子"的回答。STAR 法则(情境-任务-行动-结果)之所以经典,就是因为它提供了一个清晰的逻辑框架。</p>
|
||||
<p><strong>低分回答</strong>:"我在上家公司做了一个项目,用 Python 做的,效果还不错。"</p>
|
||||
<p><strong>高分回答</strong>:"在上一家公司做支付系统重构时(情境),我负责核心交易模块的设计和开发(任务),采用了分库分表 + 异步对账的方案(行动),最终系统可用性从 99.9% 提升到 99.99%(结果)。"</p>
|
||||
|
||||
<h2>2. 专业度(权重约 30%)</h2>
|
||||
<p>你的知识储备够不够深?这里的新手误区是:把"背概念"当成"懂专业"。面试官随便追一个问题就能识破。</p>
|
||||
|
||||
<h2>3. 表达力(权重约 20%)</h2>
|
||||
<p>面试本质上是沟通。再强的人如果说不清楚,面试官也无法判断。表达力的提升最容易:多练。研究表明,经过 5 次模拟面试后,表达能力平均提升 35%。</p>
|
||||
|
||||
<h2>4. 稳定性(权重约 20%)</h2>
|
||||
<p>被追问时的应变能力、遇到压力场景的情绪控制、承认不足的坦诚度——这些都是稳定性的体现。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<p>这四个维度就是面试官打分表上的核心指标。你可以找一个 AI 面试工具,比如<strong>「宇之然AI磁场(职引)」</strong>,它能按这四个维度给你的回答评分,帮你找到薄弱环节。这些都是可训练的,不用太焦虑。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<!-- ========== 回答三:有哪些好用的 AI 面试工具值得推荐? ========== -->
|
||||
|
||||
<h1>有哪些好用的 AI 面试工具值得推荐?</h1>
|
||||
|
||||
<div style="margin: 20px 0; text-align: center;">
|
||||
<img src="https://zhiyin.yzrcloud.cn/static/og-image.png" alt="AI面试工具" style="max-width: 100%; border-radius: 8px;" />
|
||||
<p style="font-size: 12px; color: #999; margin-top: 5px;">[配图:AI 面试工具对比表 / 功能截图]</p>
|
||||
</div>
|
||||
|
||||
<p>用过 4-5 款 AI 面试工具,说下真实使用体验。</p>
|
||||
|
||||
<p>市面上的 AI 面试工具主要分两类:一类是通用 AI(ChatGPT、Kimi 等),另一类是垂直面试工具。<strong>两类体验差距非常大。</strong></p>
|
||||
|
||||
<h2>通用 AI 的问题</h2>
|
||||
<ul>
|
||||
<li>问它"模拟面试",它真的只是提问,回答完就说"你答得很好"——没有评分、没有反馈</li>
|
||||
<li>对校招场景不了解,问的问题偏社招</li>
|
||||
<li>没有公司维度、没有岗位针对性</li>
|
||||
</ul>
|
||||
|
||||
<h2>垂直 AI 面试工具的选择标准</h2>
|
||||
<ol>
|
||||
<li><strong>有评分体系</strong>:不只是对话,每轮回答要有评分</li>
|
||||
<li><strong>有维度分析</strong>:能告诉你哪方面弱、哪方面强</li>
|
||||
<li><strong>有公司题库</strong>:不是通用模板,是有针对性的题目</li>
|
||||
<li><strong>有复盘功能</strong>:支持录音回放、逐题分析</li>
|
||||
<li><strong>价格合理</strong>:对在校生友好</li>
|
||||
</ol>
|
||||
|
||||
<h2>目前用得比较多的是「宇之然AI磁场(职引)」</h2>
|
||||
<p>特点是专注校招,覆盖 20+ 热门岗位:</p>
|
||||
<ul>
|
||||
<li><strong>AI 模拟面试</strong>:多轮对话 + 实时评分 + 参考回答</li>
|
||||
<li><strong>四维报告</strong>:逻辑/表达/专业度/稳定性 + 优劣势分析</li>
|
||||
<li><strong>公司真题库</strong>:来自用户贡献的真实面经</li>
|
||||
<li><strong>面试复盘</strong>:上传录音或粘贴文本,AI 自动分析</li>
|
||||
<li><strong>AI 择业顾问</strong>:帮你分析适合什么岗位</li>
|
||||
<li><strong>简历诊断</strong>:AI 诊断简历问题</li>
|
||||
</ul>
|
||||
|
||||
<p>免费版注册送 5 次面试机会,完全够你体验一下。微信小程序搜「宇之然AI磁场」就可以。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<!-- ========== 专栏文章:AI 正在改变校招面试的 3 个方式 ========== -->
|
||||
|
||||
<h1>AI 正在改变校招面试的 3 个方式</h1>
|
||||
|
||||
<div style="margin: 20px 0; text-align: center;">
|
||||
<img src="https://zhiyin.yzrcloud.cn/static/og-image.png" alt="AI面试趋势" style="max-width: 100%; border-radius: 8px;" />
|
||||
<p style="font-size: 12px; color: #999; margin-top: 5px;">[配图:AI 面试趋势数据图表]</p>
|
||||
</div>
|
||||
|
||||
<p>2026 年,接近 60% 的应届生在求职中使用 AI 工具。这不是一个趋势预测——这是已经发生的事实。</p>
|
||||
|
||||
<h2>1. 企业端:AI 面试官走向普及</h2>
|
||||
<p>越来越多企业在大规模校招中使用 AI 面试作为初筛工具。AI 可以同时进行数千场面谈,从语言、表情、回答结构等多维度打分。</p>
|
||||
|
||||
<h2>2. 求职端:AI 面试教练成为标配</h2>
|
||||
<p>过去找人模拟面试,要麻烦学长、同学、导师,时间难约、反馈主观。现在 AI 面试工具可以 24 小时在线,提供标准化的评分和反馈。从我们的数据来看,连续使用 AI 模拟面试 5 次的用户,评分平均提升 23%。</p>
|
||||
|
||||
<h2>3. 内容端:UGC 面经 + 题库形成数据飞轮</h2>
|
||||
<p>用户贡献真实面经 → 整理成公司题库 → 题库反哺下一个用户。每个人既是内容消费者也是贡献者。</p>
|
||||
|
||||
<hr />
|
||||
@@ -0,0 +1,225 @@
|
||||
# 知乎 · 营销文案
|
||||
|
||||
> 定位: 专业方法论输出 + 关键词截流,占领校招面试领域的权威认知
|
||||
> 风格: 数据驱动 + 结构化 + 可收藏
|
||||
> 策略: 回答高流量问题 + 发布专栏文章,末尾自然植入工具推荐
|
||||
|
||||
---
|
||||
|
||||
## 回答一:2026 秋招,应该如何准备?
|
||||
|
||||
**问题链接**: `zhihu.com/question/xxx`(搜索截流目标,如未存在则自建问题)
|
||||
**关键词**: 秋招准备, 校招流程, 2026秋招, 应届生求职
|
||||
**覆盖意图**: 信息需求(秋招时间线、准备方法)
|
||||
|
||||
---
|
||||
|
||||
### 回答
|
||||
|
||||
2026 届秋招已经开始了。
|
||||
|
||||
先说时间线:互联网大厂提前批 7 月投递、8 月面试;正式批 8 月底开启、9-10 月密集面试;国企/银行 9-11 月。如果你是 2026 届毕业生,现在就应该开始准备了。
|
||||
|
||||
我从三个角度展开说:**认知准备**、**能力准备**、**信息准备**。
|
||||
|
||||
#### 一、认知准备:重新理解面试
|
||||
|
||||
很多人的面试准备方法是错误的——他们以为面试是"展示自己",面试官问什么,他们准备什么。
|
||||
|
||||
但实际情况是:**面试是一场有限时间内的结构化信息交换**。面试官需要在 30-60 分钟内判断你是否胜任这个岗位。这意味着:
|
||||
- 你说的每一句话都要有目的
|
||||
- 不是你说的越多越好,而是你说的越精准越好
|
||||
- 面试官的问题看似随意,背后都有考察维度
|
||||
|
||||
通用的考察维度无非四个:**逻辑性**(结构化表达)、**专业度**(领域深度)、**表达力**(沟通清晰度)、**稳定性**(抗压和应变)。几乎所有面试问题都可以映射到这四个维度上。
|
||||
|
||||
知道了这个框架,你的准备就有了方向。
|
||||
|
||||
#### 二、能力准备:刻意练习 + 有效反馈
|
||||
|
||||
如果你从 7 月开始准备到 9 月正式面试,有大约 60 天的时间窗口。
|
||||
|
||||
**前 30 天:大量输入 + 模拟输出**
|
||||
|
||||
- 每天花 30 分钟研究目标公司的业务和产品
|
||||
- 建立自己的"面试问题库",按逻辑/专业/表达/稳定四个维度分类
|
||||
- 每周至少做 3 次模拟面试
|
||||
|
||||
这里说一下模拟面试的重要性。很多人觉得自己对着镜子练就行了,但这里的核心问题是:**没有反馈的练习很可能是无效的**。你无法判断自己的回答在面试官眼中是好是坏。这就是为什么现在越来越多同学选择使用 AI 模拟面试工具——它们能提供即时、客观的结构化反馈。
|
||||
|
||||
**后 30 天:针对性改进 + 真题实战**
|
||||
|
||||
- 根据模拟反馈锁定自己的薄弱维度,集中突破
|
||||
- 找出目标公司的历年面试题,做针对性练习
|
||||
- 练习到每个维度的评分都能稳定在 7/10 以上
|
||||
|
||||
#### 三、信息准备:打破信息差
|
||||
|
||||
秋招中最大的不公平不是能力,而是信息差。有的人提前知道了提前批开放、有的人提前知道了面试风格、有的人提前知道了薪资范围。这些信息差直接决定了最终结果。
|
||||
|
||||
打破信息差的方法:
|
||||
- 关注目标公司的招聘公众号
|
||||
- 加入校招信息群
|
||||
- 多刷面经,整理成自己的题库
|
||||
|
||||
这里顺便推荐一下我们团队做的 AI 面试工具「宇之然AI磁场」,它内置了 20+ 校招热门岗位的模拟面试,每轮回答都有 AI 评分和改进建议,还有基于真实面经的公司题库。关键是注册免费,0 成本体验。微信小程序搜「宇之然AI磁场」就能用。
|
||||
|
||||
#### 四、核心时间轴
|
||||
|
||||
```
|
||||
7 月:简历定稿 + 岗位调研 + 模拟面试启动
|
||||
8 月:提前批投递 + 高频模拟
|
||||
9 月:正式批投递 + 真实面试
|
||||
10 月:复盘调整 + 第三批投递
|
||||
11 月:补录捡漏 + 准备春招
|
||||
```
|
||||
|
||||
#### 五、最后说几句
|
||||
|
||||
秋招是一段很难熬的时间。你会被拒绝、被已读不回、被面试官追问到哑口无言。这些都是正常的。
|
||||
|
||||
但你要相信:**面试能力是可训练的**。每一次模拟、每一次复盘、每一次改进,都在让你离 offer 更近一步。
|
||||
|
||||
祝各位秋招顺利。
|
||||
|
||||
---
|
||||
|
||||
## 回答二:校招面试中,面试官最看重的是什么?
|
||||
|
||||
**关键词**: 校招面试评分, 面试官考察点, 面试技巧, AI 面试评分
|
||||
**覆盖意图**: 信息需求(面试官怎么打分)
|
||||
|
||||
---
|
||||
|
||||
### 回答
|
||||
|
||||
作为校招 AI 面试工具的开发者,我见过 500+ 场模拟面试的评分数据。这个问题我有发言权。
|
||||
|
||||
先给结论:面试官最看重的是 **"这个人未来能不能用"**,而不是"这个人现在有多强"。
|
||||
|
||||
基于这个底层逻辑,面试官的核心考察维度可以分为以下四个:
|
||||
|
||||
#### 1. 逻辑性(权重约 30%)
|
||||
|
||||
能不能把你的经历、观点、方案说清楚?
|
||||
|
||||
面试官最怕听到"东一榔头西一棒子"的回答。STAR 法则(情境-任务-行动-结果)之所以经典,就是因为它提供了一个清晰的逻辑框架。
|
||||
|
||||
**低分回答**: "我在上家公司做了一个项目,用 Python 做的,效果还不错。"
|
||||
**高分回答**: "在上一家公司做支付系统重构时(情境),我负责核心交易模块的设计和开发(任务),采用了分库分表 + 异步对账的方案(行动),最终系统可用性从 99.9% 提升到 99.99%(结果)。"
|
||||
|
||||
#### 2. 专业度(权重约 30%)
|
||||
|
||||
你的知识储备够不够深?
|
||||
|
||||
这里的新手误区是:把"背概念"当成"懂专业"。面试官随便追一个问题就能识破。
|
||||
|
||||
专业的体现是:你知道自己知道什么,也知道自己不知道什么。
|
||||
|
||||
#### 3. 表达力(权重约 20%)
|
||||
|
||||
面试本质上是沟通。再强的人如果说不清楚,面试官也无法判断。
|
||||
|
||||
表达力的提升最容易:多练。研究表明,经过 5 次模拟面试后,表达能力平均提升 35%。
|
||||
|
||||
#### 4. 稳定性(权重约 20%)
|
||||
|
||||
被追问时的应变能力、遇到压力场景的情绪控制、承认不足的坦诚度——这些都是稳定性的体现。
|
||||
|
||||
高分候选人有一个共同特征:被问到不会的问题时,不慌不乱,坦诚说"这个我不太了解",然后给出自己的分析和思考方向。低分候选人则是硬编、回避闪躲。
|
||||
|
||||
---
|
||||
|
||||
这四个维度就是面试官打分表上的核心指标。你可以找一个 AI 面试工具,比如「宇之然AI磁场」,它能按这四个维度给你的回答评分,帮你找到薄弱环节。这些都是可训练的,不用太焦虑。
|
||||
|
||||
---
|
||||
|
||||
## 回答三:有哪些好用的 AI 面试工具值得推荐?
|
||||
|
||||
**关键词**: AI 面试工具推荐, 模拟面试, 面试软件, AI 面试
|
||||
**覆盖意图**: 产品需求(搜索工具对比)
|
||||
|
||||
---
|
||||
|
||||
### 回答
|
||||
|
||||
用过 4-5 款 AI 面试工具,说下真实使用体验。
|
||||
|
||||
市面上的 AI 面试工具主要分两类:一类是通用 AI(ChatGPT、Kimi 等),另一类是垂直面试工具。**两类体验差距非常大。**
|
||||
|
||||
#### 通用 AI 的问题
|
||||
- 问它"模拟面试",它真的只是提问,回答完就说"你答得很好"——没有评分、没有反馈
|
||||
- 对校招场景不了解,问的问题偏社招
|
||||
- 没有公司维度、没有岗位针对性
|
||||
|
||||
#### 垂直 AI 面试工具的选择标准
|
||||
1. **有评分体系**:不只是对话,每轮回答要有评分
|
||||
2. **有维度分析**:能告诉你哪方面弱、哪方面强
|
||||
3. **有公司题库**:不是通用模板,是有针对性的题目
|
||||
4. **有复盘功能**:支持录音回放、逐题分析
|
||||
5. **价格合理**:对在校生友好好
|
||||
|
||||
#### 目前用得比较多的是「宇之然AI磁场」
|
||||
|
||||
特点是专注校招,覆盖 20+ 热门岗位:
|
||||
|
||||
- **AI 模拟面试**:多轮对话 + 实时评分 + 参考回答
|
||||
- **四维报告**:逻辑/表达/专业度/稳定性 + 优劣势分析
|
||||
- **公司真题库**:来自用户贡献的真实面经
|
||||
- **面试复盘**:上传录音或粘贴文本,AI 自动分析
|
||||
- **AI 择业顾问**:帮你分析适合什么岗位
|
||||
- **简历诊断**:AI 诊断简历问题
|
||||
|
||||
免费版注册送 5 次面试机会,完全够你体验一下。微信小程序搜「宇之然AI磁场」就可以。
|
||||
|
||||
---
|
||||
|
||||
## 专栏文章:AI 正在改变校招面试的 3 个方式
|
||||
|
||||
**关键词**: AI 面试, 校招趋势, 面试科技, 求职工具
|
||||
**覆盖意图**: 趋势信息(建立专业形象的长尾流量)
|
||||
|
||||
---
|
||||
|
||||
### 正文
|
||||
|
||||
2026 年,接近 60% 的应届生在求职中使用 AI 工具。这不是一个趋势预测——这是已经发生的事实。
|
||||
|
||||
AI 在校招面试领域的影响体现在三个层面:
|
||||
|
||||
#### 1. 企业端:AI 面试官走向普及
|
||||
|
||||
越来越多企业在大规模校招中使用 AI 面试作为初筛工具。这不是替代人类面试官,而是提效——AI 可以同时进行数千场面谈,从语言、表情、回答结构等多维度打分,通过初筛后再由真人面试官深入考察。
|
||||
|
||||
这意味着什么?意味着面试的"第一关"越来越标准化、数据化。**面试能力变成一个可以被客观量化的指标。**
|
||||
|
||||
#### 2. 求职端:AI 面试教练成为标配
|
||||
|
||||
既然企业用 AI 面试,求职者当然也可以用 AI 准备面试。
|
||||
|
||||
过去找人模拟面试,要麻烦学长、同学、导师,时间难约、反馈主观。现在 AI 面试工具可以 24 小时在线,提供标准化的评分和反馈,让练习效率大幅提升。
|
||||
|
||||
从我们的数据来看,连续使用 AI 模拟面试 5 次的用户,评分平均提升 23%。这不是广告话术,是真实数据。
|
||||
|
||||
#### 3. 内容端:UGC 面经 + 题库形成数据飞轮
|
||||
|
||||
这个模式类似大众点评——用户贡献真实面经 → 整理成公司题库 → 题库反哺下一个用户的准备。每个人既是内容消费者也是贡献者。
|
||||
|
||||
这个飞轮一旦转起来,题库质量会持续提升,最终成为求职领域的基础设施。
|
||||
|
||||
#### 对求职者的建议
|
||||
|
||||
AI 工具提高了面试效率,但核心竞争力依然是你的专业技能、逻辑思维和学习能力。工具只是放大器,你的积累才是发动机。
|
||||
|
||||
但反过来想:**当大家都在用 AI 提升效率的时候,不用的人就处在劣势了。**
|
||||
|
||||
---
|
||||
|
||||
## 排版规范
|
||||
|
||||
- 正文使用 `##` / `###` 分级标题
|
||||
- 重要结论用 `**加粗**` 突出
|
||||
- 数据点用引用或列表展示
|
||||
- 回答末尾 1-2 句自然带出产品推荐
|
||||
- 不堆砌关键词,保持自然语感
|
||||
- 每回答配 1-2 张截图(面试界面/评分报告/数据图)
|
||||
@@ -1,4 +1,5 @@
|
||||
# 生产环境变量
|
||||
VITE_API_BASE_URL=https://zhiyinwx.yzrcloud.cn/api
|
||||
VITE_APP_NAME=AI磁场
|
||||
VITE_APP_NAME=宇之然AI磁场
|
||||
VITE_APP_DESC=AI模拟面试·简历优化·面经题库·校招求职一站式平台
|
||||
VITE_PROD_API_HOST=https://zhiyinwx.yzrcloud.cn
|
||||
|
||||
+28
-8
@@ -4,22 +4,42 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
|
||||
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg" />
|
||||
<title>职引 - AI模拟面试 | 宇之然AI磁场 · 智能面试练习 · 简历优化 · 面经题库</title>
|
||||
<meta name="description" content="职引是宇之然AI磁场旗下的AI模拟面试平台,提供AI面试官模拟练习、简历智能诊断优化、大厂面经题库、实习推荐等一站式求职服务,帮助你在真实面试前充分准备。" />
|
||||
<meta name="keywords" content="职引,宇之然AI磁场,AI面试,模拟面试,面试练习,简历优化,求职辅导,AI模拟面试官,面试题库,面经,校招面试,实习面试,简历诊断,面试技巧" />
|
||||
<meta property="og:title" content="职引 - AI模拟面试平台 | 宇之然AI磁场" />
|
||||
<title>宇之然AI磁场(职引)- AI模拟面试 | 智能面试练习 · 简历优化 · 面经题库</title>
|
||||
<meta name="description" content="宇之然AI磁场(原职引)专注校招AI模拟面试,提供AI面试官模拟练习、简历智能诊断优化、大厂面经题库、面试复盘等一站式求职服务,帮助应届生在真实面试前充分准备。" />
|
||||
<meta name="keywords" content="宇之然AI磁场,职引,AI面试,模拟面试,面试练习,简历优化,求职辅导,AI模拟面试官,面试题库,面经,校招面试,实习面试,简历诊断,面试技巧,AI模拟面试官,大模型面试,校招准备" />
|
||||
<meta property="og:title" content="宇之然AI磁场(职引)- AI模拟面试平台 | 智能面试练习" />
|
||||
<meta property="og:description" content="AI驱动的一站式求职准备平台,涵盖AI模拟面试、简历优化、面经分享、实习推荐等核心功能。" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://zhiyin.yzrcloud.cn" />
|
||||
<meta property="og:image" content="https://zhiyin.yzrcloud.cn/static/og-image.png" />
|
||||
<meta name="applicable-device" content="mobile" />
|
||||
<link rel="canonical" href="https://aicc.yzrcloud.cn" />
|
||||
<meta name="baidu-site-verification" content="zhiyin-yzrcloud" />
|
||||
<link rel="canonical" href="https://zhiyin.yzrcloud.cn" />
|
||||
<link rel="alternate" href="https://zhiyin.yzrcloud.cn" hreflang="zh-Hans" />
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebApplication",
|
||||
"name": "宇之然AI磁场",
|
||||
"description": "AI驱动的求职面试模拟与简历优化平台",
|
||||
"name": "宇之然AI磁场 - AI模拟面试",
|
||||
"description": "AI驱动的校招求职准备平台,涵盖AI模拟面试、简历智能优化、大厂面经题库、面试复盘、AI择业顾问等一站式功能。",
|
||||
"applicationCategory": "EducationalApplication",
|
||||
"operatingSystem": "Web, WeChat Mini Program"
|
||||
"operatingSystem": "Web, WeChat Mini Program",
|
||||
"offers": {
|
||||
"@type": "Offer",
|
||||
"price": "0",
|
||||
"priceCurrency": "CNY"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement": [
|
||||
{ "@type": "ListItem", "position": 1, "name": "AI模拟面试", "item": "https://zhiyin.yzrcloud.cn" },
|
||||
{ "@type": "ListItem", "position": 2, "name": "简历优化", "item": "https://zhiyin.yzrcloud.cn/#/pages/resume/resume" },
|
||||
{ "@type": "ListItem", "position": 3, "name": "面经题库", "item": "https://zhiyin.yzrcloud.cn/#/pages/history/history" }
|
||||
]
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev:mp-weixin": "uni -p mp-weixin",
|
||||
"build:mp-weixin": "uni build -p mp-weixin && cp -f static/avatar-*.png dist/build/mp-weixin/static/ 2>/dev/null; true",
|
||||
"dev:h5": "uni",
|
||||
"build:h5": "uni build && cp -f static/avatar-*.png dist/build/h5/static/ 2>/dev/null; true",
|
||||
"build:mp-weixin": "uni build -p mp-weixin && cp -f static/avatar-*.png dist/build/mp-weixin/static/ 2>/dev/null; true",
|
||||
"dev:h5": "uni",
|
||||
"build:h5": "uni build && cp -f static/avatar-*.png dist/build/h5/static/ 2>/dev/null && cp -f static/robots.txt static/sitemap.xml dist/build/h5/ 2>/dev/null; true",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest"
|
||||
},
|
||||
|
||||
@@ -15,11 +15,18 @@ async function main() {
|
||||
ignores: ['node_modules/**/*'],
|
||||
})
|
||||
|
||||
// Get version from git tag or use timestamp
|
||||
// Bump patch version from git tag: v1.0.16 → 1.0.17
|
||||
let version = '1.0.3'
|
||||
try {
|
||||
const gitTag = execSync('git describe --tags --abbrev=0 2>/dev/null || echo ""', { encoding: 'utf8' }).trim()
|
||||
if (gitTag) version = gitTag.replace(/^v/, '')
|
||||
if (gitTag) {
|
||||
const base = gitTag.replace(/^v/, '')
|
||||
const parts = base.split('.')
|
||||
if (parts.length >= 1) {
|
||||
parts[parts.length - 1] = String(Number(parts[parts.length - 1]) + 1)
|
||||
}
|
||||
version = parts.join('.')
|
||||
}
|
||||
} catch {}
|
||||
|
||||
const now = new Date()
|
||||
|
||||
+43
-5
@@ -1,14 +1,54 @@
|
||||
<script setup lang="ts">
|
||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||||
|
||||
onLaunch(() => {
|
||||
console.log('职引 App launched')
|
||||
onLaunch((options) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
initPrivacy()
|
||||
handleLaunchParams(options?.query)
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
handleH5UrlParams()
|
||||
// #endif
|
||||
})
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShow((options) => {
|
||||
if (options?.query) {
|
||||
handleLaunchParams(options.query)
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
function handleH5UrlParams() {
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
const token = params.get('token')
|
||||
const buy = params.get('buy')
|
||||
if (token) {
|
||||
uni.setStorageSync('token', token)
|
||||
}
|
||||
if (buy === 'gravity') {
|
||||
// 延迟等 app 初始化完成再跳转
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: '/pages/member/member' })
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
function handleLaunchParams(query?: Record<string, string>) {
|
||||
if (!query) return
|
||||
const token = query.token
|
||||
if (token) {
|
||||
uni.setStorageSync('token', token)
|
||||
}
|
||||
const shareCode = query.share || query.shareCode
|
||||
if (shareCode) {
|
||||
uni.setStorageSync('shareCode', shareCode)
|
||||
}
|
||||
}
|
||||
|
||||
function initPrivacy() {
|
||||
if (wx.onNeedPrivacyAuthorization) {
|
||||
wx.onNeedPrivacyAuthorization((resolve) => {
|
||||
@@ -29,8 +69,6 @@ function initPrivacy() {
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
onShow(() => { console.log('职引 App shown') })
|
||||
onHide(() => { console.log('职引 App hidden') })
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
import { ref, computed, nextTick } from 'vue'
|
||||
import { api } from '../config'
|
||||
|
||||
export function useGravityPurchase(onPaymentSuccess?: () => void) {
|
||||
const showQuantityModal = ref(false)
|
||||
const buyQuantity = ref(1)
|
||||
const products = ref<any[]>([])
|
||||
const buyProductType = ref('interview')
|
||||
const payLoading = ref(false)
|
||||
const payError = ref('')
|
||||
const showPayModal = ref(false)
|
||||
const payCodeUrl = ref('')
|
||||
const currentOutTradeNo = ref('')
|
||||
const isMp = ref(false)
|
||||
const paySuccess = ref(false)
|
||||
|
||||
const unitPrice = computed(() => {
|
||||
const p = products.value.find(p => p.type === buyProductType.value)
|
||||
return p?.price || 0
|
||||
})
|
||||
const totalPrice = computed(() => unitPrice.value * buyQuantity.value / 100)
|
||||
const buyGravityPerUnit = computed(() => {
|
||||
const p = products.value.find(p => p.type === buyProductType.value)
|
||||
return p?.gravity || 0
|
||||
})
|
||||
|
||||
const changeQty = (delta: number) => {
|
||||
const next = buyQuantity.value + delta
|
||||
if (next >= 1 && next <= 99) buyQuantity.value = next
|
||||
}
|
||||
const clampQty = () => {
|
||||
if (buyQuantity.value < 1) buyQuantity.value = 1
|
||||
if (buyQuantity.value > 99) buyQuantity.value = 99
|
||||
}
|
||||
|
||||
const loadProducts = async () => {
|
||||
try {
|
||||
const res = await uni.request({ url: api('/member/plans'), method: 'GET' })
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.products) {
|
||||
const prodList: any[] = []
|
||||
for (const [key, val] of Object.entries(res.data.products as Record<string, any>)) {
|
||||
if (val?.price > 0) prodList.push({ type: key, ...val })
|
||||
}
|
||||
products.value = prodList
|
||||
}
|
||||
} catch (e) { /* silent */ }
|
||||
}
|
||||
|
||||
const openGravityPurchase = async (productType = 'interview') => {
|
||||
buyProductType.value = productType
|
||||
buyQuantity.value = 1
|
||||
// #ifdef MP-WEIXIN
|
||||
isMp.value = true
|
||||
// #endif
|
||||
// 加载产品信息
|
||||
await loadProducts()
|
||||
showQuantityModal.value = true
|
||||
}
|
||||
|
||||
const cancelPay = () => {
|
||||
showPayModal.value = false
|
||||
payCodeUrl.value = ''
|
||||
payLoading.value = false
|
||||
payError.value = ''
|
||||
}
|
||||
|
||||
const confirmProductBuy = () => {
|
||||
showQuantityModal.value = false
|
||||
startProductPay(buyProductType.value, buyQuantity.value)
|
||||
}
|
||||
|
||||
const startProductPay = async (type: string, quantity = 1) => {
|
||||
const token = uni.getStorageSync('token') || ''
|
||||
if (!token) {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
showPayModal.value = true
|
||||
payLoading.value = true
|
||||
payError.value = ''
|
||||
|
||||
if (isMp.value) {
|
||||
try {
|
||||
const loginRes = await new Promise<{ code: string }>((resolve, reject) => {
|
||||
uni.login({ provider: 'weixin', success: r => resolve(r), fail: reject })
|
||||
})
|
||||
if (!loginRes.code) {
|
||||
payLoading.value = false
|
||||
payError.value = '微信登录失败,请重试'
|
||||
uni.showToast({ title: '微信登录失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const res = await uni.request({
|
||||
url: api('/virtual-payment/create'), method: 'POST',
|
||||
data: { type, quantity, wxCode: loginRes.code },
|
||||
header: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
||||
timeout: 30000,
|
||||
})
|
||||
payLoading.value = false
|
||||
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.paySig) {
|
||||
const vp = res.data as any
|
||||
currentOutTradeNo.value = vp.outTradeNo
|
||||
|
||||
;(wx as any).requestVirtualPayment({
|
||||
env: vp.env,
|
||||
offerId: vp.offerId,
|
||||
signData: vp.signData,
|
||||
paySig: vp.paySig,
|
||||
signature: vp.signature,
|
||||
success: () => {
|
||||
const no = currentOutTradeNo.value || vp.outTradeNo
|
||||
pollPayResult(no)
|
||||
},
|
||||
fail: (err: any) => {
|
||||
payError.value = '支付未完成'
|
||||
uni.showToast({ title: err?.errMsg || '支付未完成', icon: 'none' })
|
||||
},
|
||||
})
|
||||
} else if (!res.statusCode || res.statusCode === 0) {
|
||||
payError.value = '网络连接失败,请检查网络后重试'
|
||||
uni.showToast({ title: '网络连接失败', icon: 'none' })
|
||||
} else {
|
||||
const errMsg = res.data?.message || '购买失败'
|
||||
payError.value = errMsg
|
||||
uni.showToast({ title: errMsg, icon: 'none' })
|
||||
}
|
||||
} catch (e: any) {
|
||||
payLoading.value = false
|
||||
payError.value = e?.errMsg || '网络错误,请重试'
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/payment/create-product'), method: 'POST',
|
||||
data: { type, quantity },
|
||||
header: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
payLoading.value = false
|
||||
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
|
||||
payCodeUrl.value = res.data.codeUrl
|
||||
currentOutTradeNo.value = res.data.outTradeNo
|
||||
// 页面需要自己渲染二维码(依赖 uqrcode)
|
||||
pollPayResult(res.data.outTradeNo)
|
||||
} else if (!res.statusCode || res.statusCode === 0) {
|
||||
payError.value = '网络连接失败,请检查网络后重试'
|
||||
uni.showToast({ title: '网络连接失败', icon: 'none' })
|
||||
} else {
|
||||
payError.value = res.data?.message || '购买失败'
|
||||
uni.showToast({ title: res.data?.message || '购买失败', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const pollPayResult = async (outTradeNo: string) => {
|
||||
if (!outTradeNo) return
|
||||
const maxAttempts = 30
|
||||
let attempts = 0
|
||||
const token = uni.getStorageSync('token') || ''
|
||||
|
||||
const poll = async () => {
|
||||
attempts++
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api(`/payment/check/${outTradeNo}`), method: 'GET',
|
||||
header: { 'Authorization': `Bearer ${token}` },
|
||||
})
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.status === 'success') {
|
||||
paySuccess.value = true
|
||||
showPayModal.value = false
|
||||
uni.showToast({ title: '充值成功!', icon: 'success' })
|
||||
onPaymentSuccess?.()
|
||||
return
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
|
||||
if (attempts < maxAttempts) {
|
||||
setTimeout(poll, 2000)
|
||||
} else {
|
||||
payError.value = '支付结果查询超时,请联系客服'
|
||||
uni.showToast({ title: '支付查询超时', icon: 'none' })
|
||||
}
|
||||
}
|
||||
setTimeout(poll, 2000)
|
||||
}
|
||||
|
||||
return {
|
||||
showQuantityModal, buyQuantity, products, buyProductType,
|
||||
unitPrice, totalPrice, buyGravityPerUnit,
|
||||
payLoading, payError, showPayModal, payCodeUrl, paySuccess,
|
||||
isMp,
|
||||
changeQty, clampQty, loadProducts, openGravityPurchase,
|
||||
confirmProductBuy, cancelPay,
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,10 @@ export const API_ENDPOINTS = {
|
||||
CHAT: '/career-advice/chat',
|
||||
POSITIONS: '/career-advice/positions',
|
||||
},
|
||||
VIRTUAL_PAYMENT: {
|
||||
CREATE: '/virtual-payment/create',
|
||||
CHECK: (outTradeNo: string) => `/virtual-payment/check/${outTradeNo}`,
|
||||
},
|
||||
} as const
|
||||
|
||||
const PROD_API_HOST = import.meta.env.VITE_PROD_API_HOST || 'https://zhiyinwx.yzrcloud.cn'
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "宇之然AI磁场",
|
||||
"name": "宇之然AI磁场 - AI模拟面试",
|
||||
"appid": "__UNI__DEV__",
|
||||
"versionName": "1.0.15",
|
||||
"versionCode": "115",
|
||||
"description": "职引 - 宇之然AI磁场旗下AI模拟面试平台,提供AI面试官模拟练习、简历智能优化、大厂面经题库,助你轻松应对校招面试。",
|
||||
"versionName": "1.0.16",
|
||||
"versionCode": "116",
|
||||
"description": "宇之然AI磁场(原职引)专注校招AI模拟面试。AI面试官模拟练习、简历智能优化、大厂面经题库、面试复盘分析、AI择业顾问,一站式校招求职准备平台。",
|
||||
"h5": {
|
||||
"title": "职引 - AI模拟面试 | 宇之然AI磁场",
|
||||
"title": "宇之然AI磁场(职引)- AI模拟面试 | 智能面试练习 · 简历优化 · 面经题库",
|
||||
"router": {
|
||||
"mode": "hash"
|
||||
}
|
||||
@@ -16,6 +16,17 @@
|
||||
"urlCheck": false,
|
||||
"__usePrivacyCheck__": true
|
||||
},
|
||||
"usingComponents": true
|
||||
"usingComponents": true,
|
||||
"plugins": {
|
||||
"WechatSI": {
|
||||
"version": "0.3.6",
|
||||
"provider": "wx069ba97219f66d99"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"scope.record": {
|
||||
"desc": "用于语音输入回答面试问题"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-19
@@ -1,25 +1,26 @@
|
||||
{
|
||||
"pages": [
|
||||
{ "path": "pages/index/index", "style": { "navigationBarTitleText": "职引 - AI模拟面试" } },
|
||||
{ "path": "pages/interview/interview", "style": { "navigationBarTitleText": "AI模拟面试" } },
|
||||
{ "path": "pages/report/report", "style": { "navigationBarTitleText": "面试报告" } },
|
||||
{ "path": "pages/member/member", "style": { "navigationBarTitleText": "会员中心" } },
|
||||
{ "path": "pages/progress/progress", "style": { "navigationBarTitleText": "进步轨迹" } },
|
||||
{ "path": "pages/contribute/contribute", "style": { "navigationBarTitleText": "面经分享" } },
|
||||
{ "path": "pages/company-bank/bank", "style": { "navigationBarTitleText": "公司真题库" } },
|
||||
{ "path": "pages/login/login", "style": { "navigationBarTitleText": "登录" } },
|
||||
{ "path": "pages/history/history", "style": { "navigationBarTitleText": "面试记录" } },
|
||||
{ "path": "pages/user/user", "style": { "navigationBarTitleText": "我的" } },
|
||||
{ "path": "pages/resume/resume", "style": { "navigationBarTitleText": "简历优化" } },
|
||||
{ "path": "pages/internship/internship", "style": { "navigationBarTitleText": "实习搜索" } },
|
||||
{ "path": "pages/about/about", "style": { "navigationBarTitleText": "关于职引" } },
|
||||
{ "path": "pages/index/index", "style": { "navigationBarTitleText": "AI模拟面试" } },
|
||||
{ "path": "pages/interview/interview", "style": { "navigationBarTitleText": "AI模拟面试练习" } },
|
||||
{ "path": "pages/report/report", "style": { "navigationBarTitleText": "面试报告与评分" } },
|
||||
{ "path": "pages/member/member", "style": { "navigationBarTitleText": "引力值购买" } },
|
||||
{ "path": "pages/progress/progress", "style": { "navigationBarTitleText": "进步轨迹与打卡" } },
|
||||
{ "path": "pages/contribute/contribute", "style": { "navigationBarTitleText": "分享面经" } },
|
||||
{ "path": "pages/company-bank/bank", "style": { "navigationBarTitleText": "公司真题题库" } },
|
||||
{ "path": "pages/login/login", "style": { "navigationBarTitleText": "登录 / 注册" } },
|
||||
{ "path": "pages/history/history", "style": { "navigationBarTitleText": "面经与面试记录" } },
|
||||
{ "path": "pages/user/user", "style": { "navigationBarTitleText": "个人中心" } },
|
||||
{ "path": "pages/resume/resume", "style": { "navigationBarTitleText": "简历诊断与优化" } },
|
||||
{ "path": "pages/internship/internship", "style": { "navigationBarTitleText": "热门岗位" } },
|
||||
{ "path": "pages/about/about", "style": { "navigationBarTitleText": "关于宇之然AI磁场" } },
|
||||
{ "path": "pages/admin/admin", "style": { "navigationBarTitleText": "管理后台" } },
|
||||
{ "path": "pages/result/result", "style": { "navigationBarTitleText": "优化结果" } },
|
||||
{ "path": "pages/agreement/agreement", "style": { "navigationBarTitleText": "用户协议" } },
|
||||
{ "path": "pages/privacy/privacy", "style": { "navigationBarTitleText": "隐私政策" } },
|
||||
{ "path": "pages/share/share", "style": { "navigationBarTitleText": "我的分享" } },
|
||||
{ "path": "pages/review/review", "style": { "navigationBarTitleText": "面试复盘" } },
|
||||
{ "path": "pages/career/career", "style": { "navigationBarTitleText": "择业顾问" } }
|
||||
{ "path": "pages/review/review", "style": { "navigationBarTitleText": "面试复盘分析" } },
|
||||
{ "path": "pages/career/career", "style": { "navigationBarTitleText": "AI择业顾问" } },
|
||||
{ "path": "pages/feedback/feedback", "style": { "navigationBarTitleText": "意见反馈" } }
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#999999",
|
||||
@@ -27,14 +28,14 @@
|
||||
"backgroundColor": "#F3F4F6",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{ "pagePath": "pages/index/index", "text": "面试", "iconPath": "static/tabbar/home.png", "selectedIconPath": "static/tabbar/home-active.png" },
|
||||
{ "pagePath": "pages/history/history", "text": "面经", "iconPath": "static/tabbar/history.png", "selectedIconPath": "static/tabbar/history-active.png" },
|
||||
{ "pagePath": "pages/user/user", "text": "我的", "iconPath": "static/tabbar/user.png", "selectedIconPath": "static/tabbar/user-active.png" }
|
||||
{ "pagePath": "pages/index/index", "text": "AI面试", "iconPath": "static/tabbar/home.png", "selectedIconPath": "static/tabbar/home-active.png" },
|
||||
{ "pagePath": "pages/history/history", "text": "面经题库", "iconPath": "static/tabbar/history.png", "selectedIconPath": "static/tabbar/history-active.png" },
|
||||
{ "pagePath": "pages/user/user", "text": "个人中心", "iconPath": "static/tabbar/user.png", "selectedIconPath": "static/tabbar/user-active.png" }
|
||||
]
|
||||
},
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "职引 - AI模拟面试",
|
||||
"navigationBarTitleText": "宇之然AI磁场 - AI模拟面试",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"backgroundColor": "#f5f6f7"
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="logo-area">
|
||||
<text class="logo">职引</text>
|
||||
<text class="version">v1.0.0</text>
|
||||
<text class="logo">宇之然AI磁场</text>
|
||||
<text class="version">v{{ appVersion }}</text>
|
||||
</view>
|
||||
<view class="info-section">
|
||||
<text class="info-label">产品名称</text>
|
||||
<text class="info-value">职引 · 宇之然AI磁场</text>
|
||||
<text class="info-value">宇之然AI磁场(职引)</text>
|
||||
</view>
|
||||
<view class="info-section">
|
||||
<text class="info-label">开发团队</text>
|
||||
@@ -38,8 +38,14 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const appVersion = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '1.0.0'
|
||||
const goAgreement = () => uni.navigateTo({ url: '/pages/agreement/agreement' })
|
||||
const goPrivacy = () => uni.navigateTo({ url: '/pages/privacy/privacy' })
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - AI模拟面试平台 | 面试练习·简历优化·面经题库', path: '/pages/about/about' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - AI模拟面试平台 | 面试练习·简历优化·面经题库' }))
|
||||
// #endif
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -59,4 +65,6 @@ const goPrivacy = () => uni.navigateTo({ url: '/pages/privacy/privacy' })
|
||||
.disclaimer { margin-top: 40rpx; background: #FFF8E1; border-radius: var(--radius-md); padding: 24rpx; }
|
||||
.disclaimer-title { font-size: 24rpx; font-weight: 700; color: #F59E0B; display: block; margin-bottom: 12rpx; }
|
||||
.disclaimer-text { font-size: 22rpx; color: var(--color-text-secondary); line-height: 1.8; }
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
<text class="tab" :class="{ active: tab === 'pricing' }" @click="switchTab('pricing')">定价</text>
|
||||
<text class="tab" :class="{ active: tab === 'share' }" @click="switchTab('share')">分享</text>
|
||||
<text class="tab" :class="{ active: tab === 'positions' }" @click="switchTab('positions')">岗位</text>
|
||||
<text class="tab" :class="{ active: tab === 'admins' }" @click="switchTab('admins')">管理</text>
|
||||
<text class="tab" :class="{ active: tab === 'analysis' }" @click="switchTab('analysis')">诊断</text>
|
||||
<text class="tab" :class="{ active: tab === 'feedback' }" @click="switchTab('feedback')">反馈</text>
|
||||
<text class="tab" :class="{ active: tab === 'admins' }" @click="switchTab('admins')">管理员</text>
|
||||
</view>
|
||||
|
||||
<!-- 概览 -->
|
||||
@@ -44,6 +46,23 @@
|
||||
<text class="stat-sub">付费下载 {{ overview.paidDownloadCount ?? 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="stat-cards" style="margin-top:12rpx">
|
||||
<view class="stat-card">
|
||||
<text class="stat-num">{{ overview.orderCount ?? 0 }}</text>
|
||||
<text class="stat-label">总订单</text>
|
||||
<text class="stat-sub">今日 +{{ overview.todayOrders ?? 0 }}</text>
|
||||
</view>
|
||||
<view class="stat-card">
|
||||
<text class="stat-num">{{ overview.totalRevenue ? '¥' + (overview.totalRevenue / 100).toFixed(1) : '¥0' }}</text>
|
||||
<text class="stat-label">总营收</text>
|
||||
<text class="stat-sub">已支付订单合计</text>
|
||||
</view>
|
||||
<view class="stat-card" v-if="!(overview.orderCount)">
|
||||
<text class="stat-num">--</text>
|
||||
<text class="stat-label">--</text>
|
||||
<text class="stat-sub" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="plan-cards">
|
||||
<view class="plan-card" v-for="(cnt, plan) in overview.planBreakdown" :key="plan">
|
||||
<text class="plan-num">{{ cnt }}</text>
|
||||
@@ -55,7 +74,7 @@
|
||||
<!-- 用户 -->
|
||||
<view v-if="tab === 'users'" class="section">
|
||||
<view class="search-bar">
|
||||
<input v-model="userKeyword" placeholder="搜索手机号/昵称" class="search-input" @confirm="loadUsers" />
|
||||
<input v-model="userKeyword" placeholder="搜索手机号/邮箱/昵称/ID" class="search-input" @confirm="loadUsers" />
|
||||
<button class="search-btn" @click="loadUsers">搜索</button>
|
||||
</view>
|
||||
<view class="user-list" v-if="!usersLoading">
|
||||
@@ -63,13 +82,30 @@
|
||||
<view class="user-main">
|
||||
<text class="user-phone">{{ u.phone || '--' }}</text>
|
||||
<text class="user-name">{{ u.nickname || '--' }}</text>
|
||||
<text class="user-badge-role" v-if="u.role === 'admin'">管理</text>
|
||||
</view>
|
||||
<view class="user-badges">
|
||||
<text class="user-plan" :class="{ vip: u.plan === 'growth' || u.plan === 'sprint' }">{{ u.plan === 'growth' || u.plan === 'sprint' ? '会员' : '免费' }}</text>
|
||||
<text class="user-credit">面试:{{ u.interviewCredits ?? 0 }}</text>
|
||||
<text class="user-credit">优化:{{ u.resumeOptimizeCredits ?? 0 }}</text>
|
||||
<text class="user-credit">下载:{{ u.resumeDownloadCredits ?? 0 }}</text>
|
||||
<text class="user-credit share">分享:{{ u.shareCredits ?? 0 }}</text>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag email" v-if="u.email">{{ u.email }}</text>
|
||||
<text class="meta-tag" v-if="u.wxOpenid">openid:{{ u.wxOpenid.slice(0,12) }}..</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag id-tag" @click="copyId(u._id)">ID: {{ u._id }}</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag">引力:{{ u.gravity ?? 0 }}</text>
|
||||
<text class="meta-tag">面试:{{ u.interviewCount ?? 0 }}次</text>
|
||||
<text class="user-plan" :class="{ vip: u.plan === 'growth' || u.plan === 'sprint' }">{{ u.plan === 'growth' || u.plan === 'sprint' ? u.plan==='sprint'?'冲刺':'会员' : '免费' }}</text>
|
||||
<text class="meta-tag share" v-if="u.shareCredits > 0">分享:{{ u.shareCredits }}</text>
|
||||
</view>
|
||||
<view class="user-meta-row time-row">
|
||||
<text class="time-label">注册:{{ toBeijing(u.createdAt) }}</text>
|
||||
<text class="time-label" v-if="u.vipExpireAt">到期:{{ u.vipExpireAt?.slice(0,10) }}</text>
|
||||
<text class="time-label" v-if="u.sprintExpireAt">冲刺到期:{{ u.sprintExpireAt?.slice(0,10) }}</text>
|
||||
</view>
|
||||
<view class="user-meta-row time-row" v-if="u.lastLoginAt">
|
||||
<text class="time-label">最后登录:{{ toBeijing(u.lastLoginAt) }}</text>
|
||||
<text class="meta-tag" v-if="u.lastLoginIp">IP:{{ u.lastLoginIp }}</text>
|
||||
<text class="meta-tag" v-if="u.lastLoginLocation">{{ u.lastLoginLocation }}</text>
|
||||
</view>
|
||||
<view class="user-actions">
|
||||
<text class="user-action-btn" v-if="u.plan === 'free'" @click="setVip(u._id)">设为会员</text>
|
||||
@@ -83,45 +119,69 @@
|
||||
|
||||
<!-- 面试 -->
|
||||
<view v-if="tab === 'interviews'" class="section">
|
||||
<view class="search-bar">
|
||||
<input v-model="ivKeyword" placeholder="搜索岗位/用户名" class="search-input" @confirm="loadInterviews" />
|
||||
<picker :range="['全部状态','进行中','已完成']" @change="e => { ivStatusFilter=e.detail.value; loadInterviews() }">
|
||||
<text class="search-btn">{{ ['全部状态','进行中','已完成'][ivStatusFilter] }}</text>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="iv-list" v-if="!ivLoading">
|
||||
<view class="iv-row" v-for="iv in interviews" :key="iv._id">
|
||||
<view class="iv-main">
|
||||
<text class="iv-pos">{{ iv.position }}</text>
|
||||
<text class="iv-user">{{ iv.userId?.phone || iv.userId?.nickname || '--' }}</text>
|
||||
<text class="iv-user email" v-if="iv.userId?.email">{{ iv.userId.email }}</text>
|
||||
</view>
|
||||
<view class="iv-meta">
|
||||
<text class="iv-status" :class="{ done: iv.status === 'completed' }">{{ iv.status === 'completed' ? '已完成' : '进行中' }}</text>
|
||||
<text class="iv-tag">{{ iv.questionCount || 0 }}题</text>
|
||||
<text class="iv-tag score">得分 {{ iv.totalScore ?? '-' }}</text>
|
||||
<text class="iv-tag filler" v-if="iv.fillerScore != null && iv.fillerScore > 0">语分析 {{ iv.fillerScore }}/{{ iv.fillerDensity ?? '-' }}</text>
|
||||
<text class="iv-tag filler" v-if="iv.fillerScore != null && iv.fillerScore > 0">语气 {{ iv.fillerScore }}/{{ iv.fillerDensity ?? '-' }}</text>
|
||||
</view>
|
||||
<view class="iv-meta">
|
||||
<text class="time-label">开始:{{ toBeijing(iv.createdAt) }}</text>
|
||||
<text class="time-label" v-if="iv.updatedAt && iv.updatedAt !== iv.createdAt">更新:{{ toBeijing(iv.updatedAt) }}</text>
|
||||
</view>
|
||||
<text class="iv-summary" v-if="iv.summary">{{ iv.summary.slice(0,60) }}{{ iv.summary.length > 60 ? '...' : '' }}</text>
|
||||
</view>
|
||||
<text class="load-more" v-if="ivTotal > interviews.length" @click="loadMoreInterviews">加载更多</text>
|
||||
<text class="empty-text" v-if="interviews.length === 0 && !ivLoading">暂无面试记录</text>
|
||||
</view>
|
||||
<text class="loading-text" v-if="ivLoading">加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 简历 -->
|
||||
<view v-if="tab === 'resumes'" class="section">
|
||||
<view class="search-bar">
|
||||
<input v-model="resumeKeyword" placeholder="搜索简历标题" class="search-input" @confirm="loadResumes" />
|
||||
<text class="search-btn" @click="loadResumes">搜索</text>
|
||||
</view>
|
||||
<view class="resume-list" v-if="!resumeLoading">
|
||||
<view class="resume-row" v-for="r in resumes" :key="r._id">
|
||||
<view class="resume-main">
|
||||
<text class="resume-title">{{ r.title }}</text>
|
||||
<text class="resume-user">{{ r.userId?.phone || r.userId?.nickname || '--' }}</text>
|
||||
<text class="resume-user email" v-if="r.userId?.email">{{ r.userId.email }}</text>
|
||||
</view>
|
||||
<view class="resume-meta">
|
||||
<text class="resume-tag">v{{ r.version }}</text>
|
||||
<text class="resume-tag" v-if="r.targetPosition">{{ r.targetPosition }}</text>
|
||||
<text class="resume-tag paid" v-if="r.paidDownload">付费下载</text>
|
||||
</view>
|
||||
<text class="resume-time">{{ r.createdAt?.slice(0,10) }}</text>
|
||||
<view class="resume-meta time-row">
|
||||
<text class="time-label">创建:{{ toBeijing(r.createdAt) }}</text>
|
||||
<text class="time-label" v-if="r.updatedAt && r.updatedAt !== r.createdAt">更新:{{ toBeijing(r.updatedAt) }}</text>
|
||||
</view>
|
||||
<view class="resume-actions">
|
||||
<text class="admin-action-btn del" @click="deleteResume(r._id, r.title)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="load-more" v-if="resumeTotal > resumes.length" @click="loadMoreResumes">加载更多</text>
|
||||
</view>
|
||||
<text class="loading-text" v-if="resumeLoading">加载中...</text>
|
||||
<text class="empty-text" v-if="!resumeLoading && resumes.length === 0">暂无简历</text>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<!-- 订单 -->
|
||||
<view v-if="tab === 'orders'" class="section">
|
||||
<view class="tabs in-tab">
|
||||
@@ -133,22 +193,37 @@
|
||||
<view class="order-list" v-if="!orderLoading">
|
||||
<view class="order-row" v-for="o in orders" :key="o._id">
|
||||
<view class="order-info">
|
||||
<text class="order-id">订单号: {{ o.outTradeNo }}</text>
|
||||
<text class="order-user">用户: {{ o.userPhone || o.userId.slice(-6) }}</text>
|
||||
</view>
|
||||
<view class="order-meta">
|
||||
<text class="order-amount">¥{{ (o.amount / 100).toFixed(1) }}</text>
|
||||
<view class="order-status" :class="o.status === 'success' ? 'paid' : o.status === 'refunded' ? 'refund' : 'pend'">
|
||||
<text class="order-id">{{ o.outTradeNo }}</text>
|
||||
<view class="order-status rp" :class="o.status === 'success' ? 'paid' : o.status === 'refunded' ? 'refund' : 'pend'">
|
||||
{{ o.status === 'success' ? '已支付' : o.status === 'refunded' ? '已退款' : '待支付' }}
|
||||
</view>
|
||||
<text class="order-time">{{ o.createdAt ? o.createdAt.slice(0,16).replace('T',' ') : '--' }}</text>
|
||||
<view class="order-actions">
|
||||
</view>
|
||||
<view class="order-meta-row">
|
||||
<text class="order-title">{{ o.title || '--' }}</text>
|
||||
<text class="order-user">用户: {{ o.userPhone || o.userId?.slice(-6) }}</text>
|
||||
</view>
|
||||
<view class="order-meta-row">
|
||||
<text class="order-amount">¥{{ (o.amount / 100).toFixed(1) }}</text>
|
||||
<text class="meta-tag">类型:{{ o.type || '--' }}</text>
|
||||
<text class="meta-tag">渠道:{{ o.channel || '--' }}</text>
|
||||
</view>
|
||||
<view class="order-meta-row time-row">
|
||||
<text class="time-label">创建:{{ toBeijing(o.createdAt) }}</text>
|
||||
<text class="time-label" v-if="o.paidAt">支付:{{ toBeijing(o.paidAt) }}</text>
|
||||
</view>
|
||||
<view class="order-meta-row" v-if="o.wxTransactionId">
|
||||
<text class="time-label">微信单号:{{ o.wxTransactionId }}</text>
|
||||
</view>
|
||||
<view class="order-meta-row" v-if="o.status === 'refunded'">
|
||||
<text class="time-label refund-label">退款:¥{{ (o.refundAmount/100).toFixed(1) }} {{ toBeijing(o.refundedAt) }}</text>
|
||||
<text class="time-label" v-if="o.refundReason">原因:{{ o.refundReason }}</text>
|
||||
</view>
|
||||
<view class="order-actions-bar">
|
||||
<text class="sync-btn" v-if="o.status === 'pending'" @click="syncOrder(o.outTradeNo)">同步</text>
|
||||
<text class="refund-btn" v-if="o.status === 'success'" @click="openRefundModal(o)">退款</text>
|
||||
<text class="sync-btn" v-if="o.status === 'refunded'" @click="queryRefund(o.outTradeNo)">查询</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="load-more" v-if="ordersTotal > orders.length" @click="loadMoreOrders">加载更多</text>
|
||||
<text class="empty-text" v-if="orders.length === 0 && !orderLoading">暂无订单</text>
|
||||
</view>
|
||||
@@ -176,12 +251,32 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="config-card">
|
||||
<view class="cfg-title">引力值消耗</view>
|
||||
<view class="cfg-row">
|
||||
<text>面试消耗引力值/次</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.gravityRates.interviewPerUse" />
|
||||
</view>
|
||||
<view class="cfg-row">
|
||||
<text>优化消耗引力值/次</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.gravityRates.optimizePerUse" />
|
||||
</view>
|
||||
<view class="cfg-row">
|
||||
<text>下载消耗引力值/次</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.gravityRates.downloadPerUse" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="config-card">
|
||||
<view class="cfg-title">成长版 ¥{{ growthPriceDisplay }}</view>
|
||||
<view class="cfg-row">
|
||||
<text>价格(元/月)</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="growthPriceTemp" />
|
||||
</view>
|
||||
<view class="cfg-row">
|
||||
<text>每月引力值</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.plans.growth.gravityPerMonth" />
|
||||
</view>
|
||||
<view class="cfg-row">
|
||||
<text>面试额度/月</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.plans.growth.credits.interview" />
|
||||
@@ -206,6 +301,10 @@
|
||||
<text>价格(元/月)</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="sprintPriceTemp" />
|
||||
</view>
|
||||
<view class="cfg-row">
|
||||
<text>每月引力值</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.gravityPerMonth" />
|
||||
</view>
|
||||
<view class="cfg-row">
|
||||
<text>面试额度/月</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.credits.interview" />
|
||||
@@ -246,13 +345,19 @@
|
||||
<view class="share-row" v-for="r in shareRecords" :key="r.shareCode">
|
||||
<view class="share-main">
|
||||
<text class="share-title">{{ r.title }}</text>
|
||||
<text class="share-meta">{{ r.sharer?.nickname || '--' }} · {{ r.type }}</text>
|
||||
<text class="share-meta">{{ r.sharer?.phone || r.sharer?.nickname || '--' }} · {{ r.type }}</text>
|
||||
</view>
|
||||
<view class="share-meta-row">
|
||||
<text class="meta-tag">code:{{ r.shareCode }}</text>
|
||||
<text class="meta-tag" :class="r.isActive ? 'badge-done' : 'badge-pend'">{{ r.isActive ? '启用' : '停用' }}</text>
|
||||
</view>
|
||||
<view class="share-stats">
|
||||
<text>访问 {{ r.visitCount }}</text>
|
||||
<text class="share-credited">有效 {{ r.creditedCount }}</text>
|
||||
</view>
|
||||
<text class="share-time">{{ r.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
||||
<view class="share-meta-row time-row">
|
||||
<text class="time-label">创建:{{ toBeijing(r.createdAt) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="loading-text" v-if="shareLoading">加载中...</text>
|
||||
@@ -262,13 +367,17 @@
|
||||
<view class="share-list" v-if="!shareLoading">
|
||||
<view class="share-row" v-for="(v, i) in shareVisitors" :key="i">
|
||||
<view class="share-main">
|
||||
<text>分享者: {{ v.sharer?.nickname || '--' }}</text>
|
||||
<text class="share-meta">访客: {{ v.visitor?.nickname || '匿名' }}</text>
|
||||
<text>分享者:{{ v.sharer?.phone || v.sharer?.nickname || '--' }}</text>
|
||||
<text class="share-meta">访客:{{ v.visitor?.phone || v.visitor?.nickname || '匿名' }}</text>
|
||||
</view>
|
||||
<view class="share-stats">
|
||||
<text class="badge" :class="v.credited ? 'badge-done' : 'badge-pend'">{{ v.credited ? '已积分' : '未积分' }}</text>
|
||||
<view class="share-meta-row">
|
||||
<text class="meta-tag">IP:{{ v.visitorId || '--' }}</text>
|
||||
<text class="meta-tag" :class="v.credited ? 'badge-done' : 'badge-pend'">{{ v.credited ? '已积分' : '未积分' }}</text>
|
||||
</view>
|
||||
<view class="share-meta-row time-row">
|
||||
<text class="time-label">访问:{{ toBeijing(v.createdAt) }}</text>
|
||||
<text class="time-label" v-if="v.creditedAt">积分:{{ toBeijing(v.creditedAt) }}</text>
|
||||
</view>
|
||||
<text class="share-time">{{ v.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="loading-text" v-if="shareLoading">加载中...</text>
|
||||
@@ -300,13 +409,27 @@
|
||||
<text class="loading-text" v-if="posLoading">加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 诊断分析 -->
|
||||
<view v-if="tab === 'analysis'" class="section">
|
||||
<view class="config-card">
|
||||
<view class="cfg-title">简历诊断</view>
|
||||
<view class="cfg-row"><text>总诊断次数</text><text class="cfg-val">{{ analysisStats.totalDiagnoses ?? 0 }}</text></view>
|
||||
<view class="cfg-row"><text>今日诊断</text><text class="cfg-val">{{ analysisStats.todayDiagnoses ?? 0 }}</text></view>
|
||||
</view>
|
||||
<view class="config-card">
|
||||
<view class="cfg-title">技能缺口分析</view>
|
||||
<view class="cfg-row"><text>总分析次数</text><text class="cfg-val">{{ analysisStats.totalGapAnalysis ?? 0 }}</text></view>
|
||||
</view>
|
||||
<text class="loading-text" v-if="analysisLoading">加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 额度调整弹窗 -->
|
||||
<view class="modal-mask" v-if="creditModal.show" @click="closeCreditModal">
|
||||
<view class="modal-content" @click.stop>
|
||||
<text class="modal-title">调整 {{ creditModal.user?.nickname || '用户' }} 的额度</text>
|
||||
<view class="cfg-row" v-for="t in creditTypes" :key="t.key">
|
||||
<text>{{ t.label }}</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="t.value" :placeholder="t.key" />
|
||||
<view class="cfg-row">
|
||||
<text>引力值</text>
|
||||
<input class="cfg-input" type="digit" v-model.number="creditGravity" />
|
||||
</view>
|
||||
<view class="modal-actions">
|
||||
<button class="modal-btn cancel" @click="closeCreditModal">取消</button>
|
||||
@@ -333,6 +456,10 @@
|
||||
<text class="cfg-val">{{ posForm.active ? '启用' : '停用' }}</text>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="cfg-row"><text>岗位描述</text></view>
|
||||
<textarea class="cfg-textarea" v-model="posForm.description" placeholder="岗位职责描述,每行一个要点" />
|
||||
<view class="cfg-row"><text>任职要求</text></view>
|
||||
<textarea class="cfg-textarea" v-model="posForm.requirements" placeholder="任职资格要求,每行一个要点" />
|
||||
<view class="modal-actions">
|
||||
<button class="modal-btn cancel" @click="closePositionModal">取消</button>
|
||||
<button class="modal-btn confirm" @click="savePosition">保存</button>
|
||||
@@ -363,6 +490,29 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 反馈 -->
|
||||
<view v-if="tab === 'feedback'" class="section">
|
||||
<view class="feedback-list" v-if="!feedbackLoading">
|
||||
<view class="feedback-row" v-for="f in feedbacks" :key="f._id">
|
||||
<view class="feedback-top">
|
||||
<text class="feedback-type" :class="f.type">{{ f.type === 'bug' ? '🐛问题' : f.type === 'praise' ? '👍点赞' : '💡建议' }}</text>
|
||||
<text class="feedback-status" :class="f.status">{{ f.status === 'resolved' ? '已处理' : '待处理' }}</text>
|
||||
<text class="time-label">{{ toBeijing(f.createdAt) }}</text>
|
||||
</view>
|
||||
<text class="feedback-content">{{ f.content }}</text>
|
||||
<view class="feedback-meta" v-if="f.contact">
|
||||
<text class="meta-tag">联系方式:{{ f.contact }}</text>
|
||||
</view>
|
||||
<view class="feedback-actions" v-if="f.status === 'pending'">
|
||||
<text class="resolve-btn" @click="resolveFeedback(f._id)">标记已处理</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="load-more" v-if="feedbackTotal > feedbacks.length" @click="loadMoreFeedback">加载更多</text>
|
||||
<text class="empty-text" v-if="feedbacks.length === 0 && !feedbackLoading">暂无反馈</text>
|
||||
</view>
|
||||
<text class="loading-text" v-if="feedbackLoading">加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 管理员 -->
|
||||
<view v-if="tab === 'admins'" class="section">
|
||||
<view class="search-bar">
|
||||
@@ -371,18 +521,50 @@
|
||||
</view>
|
||||
<view class="section-label">当前管理员</view>
|
||||
<view class="user-list">
|
||||
<view class="admin-row" v-for="a in adminList" :key="a._id">
|
||||
<text class="admin-phone">{{ a.phone || '--' }}</text>
|
||||
<text class="admin-name">{{ a.nickname || '--' }}</text>
|
||||
<view class="user-row" v-for="a in adminList" :key="a._id">
|
||||
<view class="user-main">
|
||||
<text class="user-phone">{{ a.phone || '--' }}</text>
|
||||
<text class="user-name">{{ a.nickname || '--' }}</text>
|
||||
<text class="user-badge-role">管理</text>
|
||||
<text class="admin-badge" v-if="a.isSystemAdmin">系统</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag email" v-if="a.email">{{ a.email }}</text>
|
||||
<text class="meta-tag" v-if="a.wxOpenid">openid:{{ a.wxOpenid.slice(0,12) }}..</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag id-tag" @click="copyId(a._id)">ID: {{ a._id }}</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag">引力:{{ a.gravity ?? 0 }}</text>
|
||||
<text class="user-plan" :class="{ vip: a.plan === 'growth' || a.plan === 'sprint' }">{{ a.plan === 'growth' || a.plan === 'sprint' ? a.plan==='sprint'?'冲刺':'会员' : '免费' }}</text>
|
||||
</view>
|
||||
<view class="user-meta-row time-row">
|
||||
<text class="time-label">设置:{{ toBeijing(a.createdAt) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="empty-text" v-if="adminList.length === 0">暂无管理员</text>
|
||||
</view>
|
||||
<view class="section-label" v-if="searchResult">搜索结果</view>
|
||||
<view class="section-label" v-if="searchResult" style="margin-top:24rpx">搜索结果</view>
|
||||
<view class="user-list" v-if="searchResult">
|
||||
<view class="admin-row">
|
||||
<text class="admin-phone">{{ searchResult.phone || '--' }}</text>
|
||||
<text class="admin-name">{{ searchResult.nickname || '--' }}</text>
|
||||
<view class="user-row">
|
||||
<view class="user-main">
|
||||
<text class="user-phone">{{ searchResult.phone || '--' }}</text>
|
||||
<text class="user-name">{{ searchResult.nickname || '--' }}</text>
|
||||
<text class="user-badge-role" v-if="searchResult.role === 'admin'">管理</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag email" v-if="searchResult.email">{{ searchResult.email }}</text>
|
||||
<text class="meta-tag" v-if="searchResult.wxOpenid">openid:{{ searchResult.wxOpenid.slice(0,12) }}..</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag id-tag" @click="copyId(searchResult._id)">ID: {{ searchResult._id }}</text>
|
||||
</view>
|
||||
<view class="user-meta-row">
|
||||
<text class="meta-tag">引力:{{ searchResult.gravity ?? 0 }}</text>
|
||||
<text class="user-plan" :class="{ vip: searchResult.plan === 'growth' || searchResult.plan === 'sprint' }">{{ searchResult.plan === 'growth' || searchResult.plan === 'sprint' ? searchResult.plan==='sprint'?'冲刺':'会员' : '免费' }}</text>
|
||||
</view>
|
||||
<view class="user-actions" style="margin-top:8rpx">
|
||||
<text class="admin-set-btn" v-if="searchResult.role !== 'admin'" @click="setAdmin(searchResult._id)">设为管理员</text>
|
||||
<text class="admin-set-btn done" v-else>已是管理员</text>
|
||||
</view>
|
||||
@@ -390,11 +572,13 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import { api, API_ENDPOINTS } from '../../config'
|
||||
import { toBeijing } from '../../utils/format'
|
||||
|
||||
const verified = ref(false)
|
||||
const adminName = ref('')
|
||||
@@ -422,9 +606,10 @@ const pricing = ref({
|
||||
interview: { pricePerSession: 500 },
|
||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300 },
|
||||
resumeDownload: { pricePerDownload: 200 },
|
||||
gravityRates: { interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 },
|
||||
plans: {
|
||||
growth: { price: 1990, durationDays: 30, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 数字人面试无限次'] },
|
||||
sprint: { price: 4990, durationDays: 30, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益'] },
|
||||
growth: { price: 1990, durationDays: 30, gravityPerMonth: 250, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', '每月 250 引力值'] },
|
||||
sprint: { price: 4990, durationDays: 30, gravityPerMonth: 600, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', '每月 600 引力值'] },
|
||||
},
|
||||
})
|
||||
const pricingLoading = ref(false)
|
||||
@@ -432,6 +617,14 @@ const growthPriceTemp = ref(19.9)
|
||||
const sprintPriceTemp = ref(49.9)
|
||||
const growthFeaturesText = ref('')
|
||||
const sprintFeaturesText = ref('')
|
||||
const ivKeyword = ref('')
|
||||
const ivStatusFilter = ref(0)
|
||||
const ivTotal = ref(0)
|
||||
const ivPage = ref(1)
|
||||
const resumeKeyword = ref('')
|
||||
const creditGravity = ref(0)
|
||||
const analysisStats = ref({ totalDiagnoses: 0, todayDiagnoses: 0, totalGapAnalysis: 0 })
|
||||
const analysisLoading = ref(false)
|
||||
|
||||
// Position management
|
||||
const positions = ref([])
|
||||
@@ -445,6 +638,8 @@ const posForm = reactive({
|
||||
sort: 0,
|
||||
active: true,
|
||||
category: 'ai',
|
||||
description: '',
|
||||
requirements: '',
|
||||
})
|
||||
|
||||
const growthPriceDisplay = computed(() => growthPriceTemp.value.toFixed(1))
|
||||
@@ -453,6 +648,11 @@ const sprintPriceDisplay = computed(() => sprintPriceTemp.value.toFixed(1))
|
||||
const calcInterviewPrice = () => {
|
||||
// Handled in savePricing via growthPriceTemp / sprintPriceTemp
|
||||
}
|
||||
const feedbacks = ref([])
|
||||
const feedbackTotal = ref(0)
|
||||
const feedbackPage = ref(1)
|
||||
const feedbackLoading = ref(false)
|
||||
|
||||
const orders = ref([])
|
||||
const ordersTotal = ref(0)
|
||||
const ordersPage = ref(1)
|
||||
@@ -466,12 +666,6 @@ const shareLoading = ref(false)
|
||||
|
||||
// Credit modal
|
||||
const creditModal = ref({ show: false, user: null })
|
||||
const creditTypes = ref([
|
||||
{ key: 'interviewCredits', label: '面试次数', value: 0 },
|
||||
{ key: 'resumeOptimizeCredits', label: '优化次数', value: 0 },
|
||||
{ key: 'resumeDownloadCredits', label: '下载次数', value: 0 },
|
||||
{ key: 'shareCredits', label: '分享积分', value: 0 },
|
||||
])
|
||||
|
||||
// Refund modal
|
||||
const refundModal = ref({ show: false, order: null })
|
||||
@@ -578,13 +772,16 @@ const switchTab = (t) => {
|
||||
if (t === 'admins' && adminList.value.length === 0) loadAdmins()
|
||||
if (t === 'pricing') loadPricing()
|
||||
if (t === 'orders') loadOrders()
|
||||
if (t === 'analysis') loadAnalysis()
|
||||
if (t === 'share') loadShareRecords()
|
||||
if (t === 'feedback') loadFeedback()
|
||||
}
|
||||
|
||||
const loadUsers = async () => {
|
||||
usersLoading.value = true
|
||||
usersPage.value = 1
|
||||
try {
|
||||
const res = await apiAdmin('/users?keyword=' + encodeURIComponent(userKeyword.value) + '&page=1&limit=20')
|
||||
const res = await apiAdmin('/users?keyword=' + encodeURIComponent(userKeyword.value) + '&page=1&limit=10')
|
||||
if (res.statusCode === 200) { users.value = res.data.users || []; usersTotal.value = res.data.total || 0 }
|
||||
} catch (e) { console.error(e) }
|
||||
finally { usersLoading.value = false }
|
||||
@@ -593,29 +790,76 @@ const loadUsers = async () => {
|
||||
const loadMoreUsers = async () => {
|
||||
usersPage.value++
|
||||
try {
|
||||
const res = await apiAdmin('/users?keyword=' + encodeURIComponent(userKeyword.value) + '&page=' + usersPage.value + '&limit=20')
|
||||
const res = await apiAdmin('/users?keyword=' + encodeURIComponent(userKeyword.value) + '&page=' + usersPage.value + '&limit=10')
|
||||
if (res.statusCode === 200) users.value = [...users.value, ...(res.data.users || [])]
|
||||
} catch (e) { console.error(e) }
|
||||
}
|
||||
|
||||
const loadInterviews = async () => {
|
||||
ivLoading.value = true
|
||||
ivPage.value = 1
|
||||
try {
|
||||
const res = await apiAdmin('/interviews?page=1&limit=20')
|
||||
if (res.statusCode === 200) interviews.value = res.data.interviews || []
|
||||
let url = '/interviews?page=1&limit=10&keyword=' + encodeURIComponent(ivKeyword.value)
|
||||
const statusMap = ['', 'in_progress', 'completed']
|
||||
if (ivStatusFilter.value > 0) url += '&status=' + statusMap[ivStatusFilter.value]
|
||||
const res = await apiAdmin(url)
|
||||
if (res.statusCode === 200) { interviews.value = res.data.interviews || []; ivTotal.value = res.data.total || 0 }
|
||||
} catch (e) { console.error(e) }
|
||||
finally { ivLoading.value = false }
|
||||
}
|
||||
|
||||
const loadMoreInterviews = async () => {
|
||||
ivPage.value++
|
||||
try {
|
||||
let url = '/interviews?page=' + ivPage.value + '&limit=10&keyword=' + encodeURIComponent(ivKeyword.value)
|
||||
const statusMap = ['', 'in_progress', 'completed']
|
||||
if (ivStatusFilter.value > 0) url += '&status=' + statusMap[ivStatusFilter.value]
|
||||
const res = await apiAdmin(url)
|
||||
if (res.statusCode === 200) interviews.value = [...interviews.value, ...(res.data.interviews || [])]
|
||||
} catch (e) { console.error(e) }
|
||||
}
|
||||
|
||||
const resumePage = ref(1)
|
||||
const resumeTotal = ref(0)
|
||||
|
||||
const loadResumes = async () => {
|
||||
resumeLoading.value = true
|
||||
resumePage.value = 1
|
||||
try {
|
||||
const res = await apiAdmin('/resumes?page=1&limit=20')
|
||||
if (res.statusCode === 200) resumes.value = res.data.list || []
|
||||
let url = '/resumes?page=1&limit=10'
|
||||
if (resumeKeyword.value) url += '&keyword=' + encodeURIComponent(resumeKeyword.value)
|
||||
const res = await apiAdmin(url)
|
||||
if (res.statusCode === 200) { resumes.value = res.data.list || []; resumeTotal.value = res.data.total || 0 }
|
||||
} catch (e) { console.error(e) }
|
||||
finally { resumeLoading.value = false }
|
||||
}
|
||||
|
||||
const loadMoreResumes = async () => {
|
||||
resumePage.value++
|
||||
try {
|
||||
let url = '/resumes?page=' + resumePage.value + '&limit=10'
|
||||
if (resumeKeyword.value) url += '&keyword=' + encodeURIComponent(resumeKeyword.value)
|
||||
const res = await apiAdmin(url)
|
||||
if (res.statusCode === 200) resumes.value = [...resumes.value, ...(res.data.list || [])]
|
||||
} catch (e) { console.error(e) }
|
||||
}
|
||||
|
||||
const deleteResume = (id, title) => {
|
||||
uni.showModal({
|
||||
title: '删除简历', content: `确定删除"${title}"?`,
|
||||
success: async (r) => {
|
||||
if (!r.confirm) return
|
||||
try {
|
||||
const res = await apiAdmin('/resume/' + id, { method: 'DELETE' })
|
||||
if (res.statusCode === 200) {
|
||||
uni.showToast({ title: '已删除', icon: 'success' })
|
||||
loadResumes()
|
||||
} else throw new Error()
|
||||
} catch { uni.showToast({ title: '删除失败', icon: 'none' }) }
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const loadPricing = async () => {
|
||||
pricingLoading.value = true
|
||||
try {
|
||||
@@ -631,6 +875,15 @@ const loadPricing = async () => {
|
||||
finally { pricingLoading.value = false }
|
||||
}
|
||||
|
||||
const loadAnalysis = async () => {
|
||||
analysisLoading.value = true
|
||||
try {
|
||||
const res = await apiAdmin('/analysis-stats')
|
||||
if (res.statusCode === 200) analysisStats.value = res.data
|
||||
} catch(e) { console.error(e) }
|
||||
finally { analysisLoading.value = false }
|
||||
}
|
||||
|
||||
const savePricing = async () => {
|
||||
pricingLoading.value = true
|
||||
try {
|
||||
@@ -721,6 +974,8 @@ const openPositionModal = (position) => {
|
||||
posForm.sort = position.sort ?? 0
|
||||
posForm.active = position.active ?? true
|
||||
posForm.category = position.category || 'traditional'
|
||||
posForm.description = position.description || ''
|
||||
posForm.requirements = position.requirements || ''
|
||||
posModal.value = { show: true, isNew: false }
|
||||
} else {
|
||||
posForm.name = ''
|
||||
@@ -730,6 +985,8 @@ const openPositionModal = (position) => {
|
||||
posForm.sort = positions.value.length + 1
|
||||
posForm.active = true
|
||||
posForm.category = 'ai'
|
||||
posForm.description = ''
|
||||
posForm.requirements = ''
|
||||
posModal.value = { show: true, isNew: true }
|
||||
}
|
||||
}
|
||||
@@ -834,13 +1091,41 @@ const loadShareVisitors = async () => {
|
||||
finally { shareLoading.value = false }
|
||||
}
|
||||
|
||||
const loadFeedback = async () => {
|
||||
feedbackLoading.value = true
|
||||
feedbackPage.value = 1
|
||||
try {
|
||||
const res = await apiAdmin('/feedback?page=1&limit=10')
|
||||
if (res.statusCode === 200) { feedbacks.value = res.data.list || []; feedbackTotal.value = res.data.total || 0 }
|
||||
} catch(e) { console.error(e) }
|
||||
finally { feedbackLoading.value = false }
|
||||
}
|
||||
|
||||
const loadMoreFeedback = async () => {
|
||||
feedbackPage.value++
|
||||
try {
|
||||
const res = await apiAdmin('/feedback?page=' + feedbackPage.value + '&limit=10')
|
||||
if (res.statusCode === 200) feedbacks.value = [...feedbacks.value, ...(res.data.list || [])]
|
||||
} catch(e) { console.error(e) }
|
||||
}
|
||||
|
||||
const resolveFeedback = async (id) => {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/feedback/' + id + '/resolve'),
|
||||
method: 'PATCH',
|
||||
header: { 'Authorization': 'Bearer ' + token(), 'Content-Type': 'application/json' },
|
||||
})
|
||||
if (res.statusCode === 200) {
|
||||
const f = feedbacks.value.find(x => x._id === id)
|
||||
if (f) f.status = 'resolved'
|
||||
uni.showToast({ title: '已标记处理', icon: 'success' })
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const openCreditModal = (user) => {
|
||||
creditTypes.value = [
|
||||
{ key: 'interviewCredits', label: '面试次数', value: user.interviewCredits ?? 0 },
|
||||
{ key: 'resumeOptimizeCredits', label: '优化次数', value: user.resumeOptimizeCredits ?? 0 },
|
||||
{ key: 'resumeDownloadCredits', label: '下载次数', value: user.resumeDownloadCredits ?? 0 },
|
||||
{ key: 'shareCredits', label: '分享积分', value: user.shareCredits ?? 0 },
|
||||
]
|
||||
creditGravity.value = user.gravity ?? 0
|
||||
creditModal.value = { show: true, user }
|
||||
}
|
||||
|
||||
@@ -852,18 +1137,23 @@ const doAdjustCredits = async () => {
|
||||
const userId = creditModal.value.user?._id
|
||||
if (!userId) return
|
||||
try {
|
||||
for (const t of creditTypes.value) {
|
||||
await apiAdmin('/user/credits', {
|
||||
method: 'POST',
|
||||
data: { userId, type: t.key, amount: t.value },
|
||||
data: { userId, type: 'gravity', amount: creditGravity.value },
|
||||
})
|
||||
}
|
||||
uni.showToast({ title: '调整成功', icon: 'success' })
|
||||
closeCreditModal()
|
||||
loadUsers()
|
||||
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
|
||||
}
|
||||
|
||||
const copyId = (id) => {
|
||||
uni.setClipboardData({
|
||||
data: id,
|
||||
success: () => uni.showToast({ title: 'ID 已复制', icon: 'success' }),
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => { doVerify() })
|
||||
</script>
|
||||
|
||||
@@ -876,8 +1166,8 @@ onMounted(() => { doVerify() })
|
||||
.admin-input { height: 72rpx; background: #FFF; border: 2rpx solid var(--color-border); border-radius: var(--radius-sm); padding: 0 20rpx; font-size: 24rpx; }
|
||||
.btn-verify { height: 72rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; border-radius: var(--radius-sm); font-size: 26rpx; border: none; }
|
||||
.body { padding: 20rpx 32rpx 48rpx; margin-top: -40rpx; }
|
||||
.tabs { display: flex; gap: 8rpx; background: #FFF; border-radius: var(--radius-md); padding: 6rpx; margin-bottom: 20rpx; }
|
||||
.tab { flex: 1; text-align: center; padding: 14rpx; font-size: 24rpx; color: var(--color-text-secondary); border-radius: var(--radius-sm); }
|
||||
.tabs { display: flex; flex-wrap: wrap; gap: 8rpx; background: #FFF; border-radius: var(--radius-md); padding: 6rpx; margin-bottom: 20rpx; }
|
||||
.tab { padding: 14rpx 20rpx; font-size: 24rpx; color: var(--color-text-secondary); border-radius: var(--radius-sm); white-space: nowrap; }
|
||||
.tab.active { background: var(--color-primary); color: #FFF; font-weight: 600; }
|
||||
.stat-cards { display: flex; gap: 16rpx; }
|
||||
.stat-card { flex: 1; background: #FFF; border-radius: var(--radius-lg); padding: 28rpx; text-align: center; box-shadow: var(--shadow-sm); }
|
||||
@@ -916,9 +1206,6 @@ onMounted(() => { doVerify() })
|
||||
.iv-tag.score { background: #EEF2FF; color: var(--color-primary); }
|
||||
.iv-tag.filler { background: #FFF7ED; color: #D97706; }
|
||||
.section-label { font-size: 24rpx; font-weight: 600; color: var(--color-text); margin-bottom: 12rpx; margin-top: 12rpx; }
|
||||
.admin-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; display: flex; flex-wrap: wrap; gap: 8rpx; align-items: center; }
|
||||
.admin-phone { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
|
||||
.admin-name { font-size: 22rpx; color: var(--color-text-secondary); flex: 1; }
|
||||
.admin-set-btn { font-size: 22rpx; color: var(--color-primary); padding: 4rpx 16rpx; border: 2rpx solid var(--color-primary); border-radius: var(--radius-round); }
|
||||
.admin-set-btn.done { color: var(--color-success); border-color: var(--color-success); }
|
||||
.admin-badge { font-size: 18rpx; background: var(--color-primary); color: #FFF; padding: 2rpx 10rpx; border-radius: var(--radius-round); }
|
||||
@@ -988,4 +1275,47 @@ onMounted(() => { doVerify() })
|
||||
.pos-mgr-btn { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: var(--radius-round); }
|
||||
.pos-mgr-btn.edit { color: var(--color-primary); border: 2rpx solid var(--color-primary); }
|
||||
.pos-mgr-btn.del { color: #EF4444; border: 2rpx solid #EF4444; }
|
||||
.iv-time { font-size: 18rpx; color: #D1D5DB; white-space: nowrap; margin-left: auto; }
|
||||
.admin-action-btn { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: var(--radius-round); cursor: pointer; }
|
||||
.admin-action-btn.del { color: #EF4444; border: 2rpx solid #EF4444; }
|
||||
.resume-actions { display: flex; gap: 8rpx; align-items: center; }
|
||||
|
||||
/* ─── 新增字段样式 ───── */
|
||||
.user-meta-row { display: flex; flex-wrap: wrap; gap: 6rpx; margin-bottom: 6rpx; }
|
||||
.meta-tag { font-size: 18rpx; background: #F3F4F6; color: var(--color-text-tertiary); padding: 2rpx 10rpx; border-radius: var(--radius-round); }
|
||||
.meta-tag.email { background: #EEF2FF; color: var(--color-primary); }
|
||||
.meta-tag.share { background: #FFF7ED; color: #D97706; }
|
||||
.meta-tag.id-tag { background: #F5F3FF; color: #7C3AED; font-family: monospace; font-size: 16rpx; }
|
||||
.meta-tag.badge-done { background: #ECFDF5; color: #059669; }
|
||||
.meta-tag.badge-pend { background: #FEF3C7; color: #D97706; }
|
||||
.time-row { display: flex; flex-wrap: wrap; gap: 12rpx; }
|
||||
.time-label { font-size: 18rpx; color: #9CA3AF; }
|
||||
.iv-summary { font-size: 18rpx; color: #6B7280; margin-top: 4rpx; line-height: 1.4; display: block; }
|
||||
.iv-user.email { font-size: 18rpx; color: #6B7280; }
|
||||
.user-badge-role { font-size: 18rpx; background: #FEF3C7; color: #D97706; padding: 0 10rpx; border-radius: var(--radius-round); font-weight: 500; }
|
||||
.share-meta-row { display: flex; gap: 6rpx; margin-top: 4rpx; }
|
||||
.share-meta-row.time-row { gap: 12rpx; }
|
||||
.order-meta-row { display: flex; flex-wrap: wrap; gap: 8rpx; margin-bottom: 4rpx; }
|
||||
.order-meta-row.time-row { gap: 12rpx; }
|
||||
.order-title { font-size: 22rpx; font-weight: 500; color: var(--color-text); }
|
||||
.order-status.rp { font-size: 18rpx; display: inline-block; }
|
||||
.refund-label { color: #EF4444 !important; }
|
||||
.order-actions-bar { display: flex; gap: 8rpx; margin-top: 6rpx; }
|
||||
.admin-email { font-size: 20rpx; color: #6B7280; }
|
||||
.resume-user.email { font-size: 18rpx; color: #6B7280; }
|
||||
|
||||
.feedback-list { display: flex; flex-direction: column; gap: 8rpx; }
|
||||
.feedback-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); }
|
||||
.feedback-top { display: flex; align-items: center; gap: 8rpx; margin-bottom: 8rpx; }
|
||||
.feedback-type { font-size: 20rpx; font-weight: 600; }
|
||||
.feedback-type.bug { color: #EF4444; }
|
||||
.feedback-type.suggestion { color: var(--color-primary); }
|
||||
.feedback-type.praise { color: #059669; }
|
||||
.feedback-status { font-size: 18rpx; padding: 2rpx 10rpx; border-radius: var(--radius-round); }
|
||||
.feedback-status.pending { background: #FEF3C7; color: #D97706; }
|
||||
.feedback-status.resolved { background: #ECFDF5; color: #059669; }
|
||||
.feedback-content { font-size: 24rpx; color: var(--color-text); line-height: 1.6; display: block; margin-bottom: 6rpx; }
|
||||
.feedback-meta { display: flex; gap: 6rpx; }
|
||||
.feedback-actions { margin-top: 8rpx; }
|
||||
.resolve-btn { font-size: 22rpx; color: var(--color-primary); padding: 6rpx 16rpx; border: 2rpx solid var(--color-primary); border-radius: var(--radius-sm); }
|
||||
</style>
|
||||
|
||||
@@ -102,9 +102,19 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - AI择业顾问 | 专业分析+岗位推荐', path: '/pages/career/career' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - AI择业顾问 | 专业分析+岗位推荐' }))
|
||||
// #endif
|
||||
|
||||
const grades = ['大一', '大二', '大三', '大四', '研一', '研二', '研三', '已毕业']
|
||||
|
||||
const step = ref('input')
|
||||
@@ -150,7 +160,7 @@ const doAnalyze = async () => {
|
||||
data: { ...profile },
|
||||
header: { 'Authorization': `Bearer ${token.value}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
if (res.statusCode === 200) {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
if (res.data.error) {
|
||||
error.value = res.data.error
|
||||
return
|
||||
@@ -184,7 +194,7 @@ const doChat = async () => {
|
||||
data: { message: msg, history: chatHistory.value.slice(0, -1) },
|
||||
header: { 'Authorization': `Bearer ${token.value}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
if (res.statusCode === 200) {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
chatHistory.value.push({ role: 'assistant', content: res.data.reply || (res.data.error || '') })
|
||||
} else {
|
||||
chatHistory.value.push({ role: 'assistant', content: '回复失败,请稍后重试' })
|
||||
@@ -211,12 +221,13 @@ const goInterview = (position) => {
|
||||
.hero-title { font-size: 40rpx; font-weight: 700; color: var(--color-text); margin-top: 16rpx; }
|
||||
.hero-desc { font-size: 26rpx; color: var(--color-secondary); margin-top: 8rpx; }
|
||||
|
||||
.form-card { background: #fff; border-radius: var(--radius-lg); padding: 32rpx; box-shadow: var(--shadow-sm); }
|
||||
.form-group { margin-bottom: 28rpx; }
|
||||
.form-card { background: #fff; border-radius: var(--radius-lg); padding: 32rpx; box-shadow: var(--shadow-sm); overflow: hidden; }
|
||||
.form-group { margin-bottom: 28rpx; width: 100%; }
|
||||
.form-group:last-child { margin-bottom: 0; }
|
||||
.form-label { font-size: 26rpx; font-weight: 600; color: var(--color-text); display: block; margin-bottom: 12rpx; }
|
||||
.required { color: var(--color-error); }
|
||||
.form-input { width: 100%; height: 80rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-md); padding: 0 24rpx; font-size: 26rpx; color: var(--color-text); box-sizing: border-box; background: #FAFBFC; }
|
||||
.form-input { width: 100%; height: 80rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-md); padding: 0 24rpx; font-size: 26rpx; color: var(--color-text); box-sizing: border-box; background: #FAFBFC; max-width: 100%; }
|
||||
picker { width: 100%; }
|
||||
.select-trigger { display: flex; align-items: center; }
|
||||
.form-textarea { width: 100%; height: 160rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-md); padding: 20rpx 24rpx; font-size: 26rpx; color: var(--color-text); box-sizing: border-box; background: #FAFBFC; resize: none; }
|
||||
|
||||
|
||||
@@ -76,9 +76,19 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 分享面经 | 共建大厂面试题库', path: '/pages/contribute/contribute' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 分享面经 | 共建大厂面试题库' }))
|
||||
// #endif
|
||||
|
||||
const interviewId = ref('')
|
||||
const urlPosition = ref('')
|
||||
const form = ref({ company: '', position: '', rounds: '', experience: '', tags: [] })
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="form-card">
|
||||
<text class="section-title">反馈类型</text>
|
||||
<view class="type-row">
|
||||
<view class="type-option" :class="{ active: type === 'bug' }" @click="type = 'bug'">
|
||||
<text class="type-icon">🐛</text>
|
||||
<text class="type-label">问题反馈</text>
|
||||
</view>
|
||||
<view class="type-option" :class="{ active: type === 'suggestion' }" @click="type = 'suggestion'">
|
||||
<text class="type-icon">💡</text>
|
||||
<text class="type-label">改进建议</text>
|
||||
</view>
|
||||
<view class="type-option" :class="{ active: type === 'praise' }" @click="type = 'praise'">
|
||||
<text class="type-icon">👍</text>
|
||||
<text class="type-label">点赞鼓励</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-card">
|
||||
<text class="section-title">反馈内容 <text class="required">*</text></text>
|
||||
<textarea class="content-input" v-model="content" placeholder="请详细描述您的问题或建议,这将帮助我们持续改进产品..." :maxlength="1000" :auto-height="true" />
|
||||
<text class="char-count">{{ content.length }}/1000</text>
|
||||
</view>
|
||||
|
||||
<view class="form-card">
|
||||
<text class="section-title">联系方式(选填)</text>
|
||||
<input class="contact-input" v-model="contact" placeholder="手机号或微信号,方便我们联系您" />
|
||||
</view>
|
||||
|
||||
<button class="submit-btn" :class="{ disabled: !content.trim() || submitting }" @click="submitFeedback" :disabled="submitting">
|
||||
{{ submitting ? '提交中...' : '提交反馈' }}
|
||||
</button>
|
||||
|
||||
<view class="toast-success" v-if="submitted">
|
||||
<text class="toast-icon">✅</text>
|
||||
<text class="toast-text">感谢您的反馈!我们会认真处理。</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { api } from '../../config'
|
||||
|
||||
const type = ref('suggestion')
|
||||
const content = ref('')
|
||||
const contact = ref('')
|
||||
const submitting = ref(false)
|
||||
const submitted = ref(false)
|
||||
|
||||
const submitFeedback = async () => {
|
||||
if (!content.value.trim() || submitting.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const token = uni.getStorageSync('token')
|
||||
const res = await uni.request({
|
||||
url: api('/feedback'),
|
||||
method: 'POST',
|
||||
header: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
||||
data: { type: type.value, content: content.value.trim(), contact: contact.value.trim() },
|
||||
})
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
submitted.value = true
|
||||
} else {
|
||||
uni.showToast({ title: res.data?.message || '提交失败', icon: 'none' })
|
||||
}
|
||||
} catch {
|
||||
uni.showToast({ title: '提交失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
onShareAppMessage(() => ({ title: '意见反馈 - 宇之然AI磁场', path: '/pages/feedback/feedback' }))
|
||||
onShareTimeline(() => ({ title: '意见反馈 - 宇之然AI磁场' }))
|
||||
// #endif
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { background: var(--color-bg); min-height: 100vh; padding: 32rpx; }
|
||||
.form-card { background: #FFF; border-radius: var(--radius-lg); padding: 28rpx 32rpx; margin-bottom: 20rpx; }
|
||||
.section-title { font-size: 26rpx; font-weight: 600; color: var(--color-text); display: block; margin-bottom: 20rpx; }
|
||||
.required { color: #EF4444; }
|
||||
.type-row { display: flex; gap: 16rpx; }
|
||||
.type-option {
|
||||
flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8rpx;
|
||||
padding: 20rpx 12rpx; border-radius: var(--radius-md); border: 2rpx solid var(--color-border);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.type-option.active { border-color: var(--color-primary); background: #EEF2FF; }
|
||||
.type-icon { font-size: 36rpx; }
|
||||
.type-label { font-size: 22rpx; color: var(--color-text-secondary); }
|
||||
.type-option.active .type-label { color: var(--color-primary); font-weight: 600; }
|
||||
.content-input { width: 100%; font-size: 26rpx; color: var(--color-text); line-height: 1.7; min-height: 200rpx; padding: 0; }
|
||||
.char-count { text-align: right; font-size: 20rpx; color: var(--color-text-tertiary); margin-top: 8rpx; }
|
||||
.contact-input { width: 100%; font-size: 26rpx; color: var(--color-text); padding: 8rpx 0; }
|
||||
.submit-btn {
|
||||
width: 100%; height: 88rpx; line-height: 88rpx;
|
||||
background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid));
|
||||
color: #FFF; border-radius: var(--radius-md); font-size: 28rpx; font-weight: 600; border: none;
|
||||
}
|
||||
.submit-btn.disabled { background: var(--color-border); }
|
||||
.toast-success {
|
||||
margin-top: 32rpx; background: #ECFDF5; border-radius: var(--radius-md);
|
||||
padding: 24rpx; display: flex; align-items: center; gap: 12rpx;
|
||||
}
|
||||
.toast-icon { font-size: 32rpx; }
|
||||
.toast-text { font-size: 26rpx; color: #065F46; line-height: 1.5; }
|
||||
</style>
|
||||
@@ -61,8 +61,16 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 面经与面试记录 | 大厂面经题库', path: '/pages/history/history' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 面经与面试记录 | 大厂面经题库' }))
|
||||
// #endif
|
||||
|
||||
const filter = ref('all')
|
||||
const interviewList = ref([])
|
||||
const loading = ref(true)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<text class="user-name">{{ userInfo.nickname || '同学' }}</text>
|
||||
<view class="user-tags">
|
||||
<text class="tag tag-plan">{{ userInfo.plan || '免费版' }}</text>
|
||||
<text class="tag tag-remaining">{{ userInfo.interviewCredits > 0 ? '剩余 ' + userInfo.interviewCredits + ' 次' : '已用完' }}</text>
|
||||
<text class="tag tag-remaining">{{ (userInfo.gravity ?? 0) > 0 ? '引力值 ' + (userInfo.gravity ?? 0) : '引力值 0' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
@@ -100,15 +100,14 @@
|
||||
<text class="daily-action primary" @click="goInterview">模拟练习 →</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="daily-guest card" v-else-if="!userInfo" @click="goLogin">
|
||||
<view class="daily-guest card" v-else @click="refreshDaily">
|
||||
<view class="daily-guest-top">
|
||||
<text class="daily-guest-icon">🔒</text>
|
||||
<view class="daily-guest-body">
|
||||
<text class="daily-guest-title">登录后获取今日面试题</text>
|
||||
<text class="daily-guest-title">点击加载面试题目</text>
|
||||
<text class="daily-guest-desc">每日一道校招真题,持续积累面试经验</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="daily-action primary">立即登录 →</text>
|
||||
<text class="daily-action primary">换一题 →</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -122,15 +121,22 @@
|
||||
<text class="section-desc">AI 时代最热方向,点击直接面试</text>
|
||||
</view>
|
||||
<view class="ai-banner card" @click="goInterview">
|
||||
<text class="ai-banner-title">🚀 AI 正在重塑整个行业</text>
|
||||
<view class="ai-banner-icon-wrap">
|
||||
<text class="ai-banner-icon">🤖</text>
|
||||
</view>
|
||||
<view class="ai-banner-body">
|
||||
<text class="ai-banner-title">AI 正在重塑整个行业</text>
|
||||
<text class="ai-banner-desc">大模型应用 / Agent 开发 / Prompt 工程 — 顶尖人才缺口巨大,现在上车正当时</text>
|
||||
</view>
|
||||
<view class="position-list card" v-if="!positionsLoading && aiPositions.length > 0">
|
||||
<view class="pos-item" v-for="(pos, idx) in aiPositions" :key="'ai-' + idx" @click="startInterview(pos)">
|
||||
<text class="ai-banner-arrow">→</text>
|
||||
</view>
|
||||
<view class="position-list card" v-if="!positionsLoading && displayAiPositions.length > 0">
|
||||
<view class="pos-item" v-for="(pos, idx) in displayAiPositions" :key="'ai-' + idx" @click="startInterview(pos)">
|
||||
<view class="pos-left">
|
||||
<text class="pos-icon pos-icon-ai">{{ pos.icon || posIcons[idx % posIcons.length] || '🤖' }}</text>
|
||||
<text class="pos-icon pos-icon-ai">{{ pos.icon || aiPosIcons[idx % aiPosIcons.length] || '🤖' }}</text>
|
||||
<view class="pos-body">
|
||||
<text class="pos-name">{{ pos.name }}</text>
|
||||
<text class="pos-name-tag">AI 方向</text>
|
||||
<view class="pos-meta-row" v-if="pos.company || pos.salary">
|
||||
<text class="pos-company">{{ pos.company }}</text>
|
||||
<text class="pos-salary">{{ pos.salary }}</text>
|
||||
@@ -138,7 +144,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="pos-action">
|
||||
<text class="pos-action-text pos-action-ai">立即模拟</text>
|
||||
<text class="pos-action-btn pos-action-ai">开始面试</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -154,9 +160,10 @@
|
||||
<view class="position-list card" v-if="showMore && !positionsLoading && traditionalPositions.length > 0">
|
||||
<view class="pos-item" v-for="(pos, idx) in traditionalPositions" :key="'tr-' + idx" @click="startInterview(pos)">
|
||||
<view class="pos-left">
|
||||
<text class="pos-icon">{{ pos.icon || posIcons[(aiPositions.length + idx) % posIcons.length] || '💼' }}</text>
|
||||
<text class="pos-icon">{{ pos.icon || posIcons[(displayAiPositions.length + idx) % posIcons.length] || '💼' }}</text>
|
||||
<view class="pos-body">
|
||||
<text class="pos-name">{{ pos.name }}</text>
|
||||
<text class="pos-name-tag pos-name-tag-tr">{{ pos.category === 'intern' ? '实习' : '校招' }}</text>
|
||||
<view class="pos-meta-row" v-if="pos.company || pos.salary">
|
||||
<text class="pos-company">{{ pos.company }}</text>
|
||||
<text class="pos-salary">{{ pos.salary }}</text>
|
||||
@@ -164,7 +171,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="pos-action">
|
||||
<text class="pos-action-text">立即模拟</text>
|
||||
<text class="pos-action-btn">立即模拟</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -177,19 +184,44 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - AI模拟面试 | 校招求职一站式平台', path: '/pages/index/index' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - AI模拟面试 | 校招求职一站式平台' }))
|
||||
// #endif
|
||||
|
||||
const userInfo = ref(null)
|
||||
const greeting = ref('')
|
||||
const hotPositions = ref([])
|
||||
const posIcons = ['💻', '⚙️', '🤖', '📊', '🎨', '🧪', '📱', '🔧']
|
||||
const aiPosIcons = ['🤖', '🧠', '⚡', '🚀', '💡', '🔬']
|
||||
const positionsLoading = ref(true)
|
||||
const dailyQuestion = ref(null)
|
||||
const showAnswer = ref(false)
|
||||
const showMore = ref(false)
|
||||
const showMore = ref(true)
|
||||
|
||||
// 前端兜底 AI 岗位(当 API 返回不足时展示)
|
||||
const FALLBACK_AI_POSITIONS = [
|
||||
{ name: 'AI Agent 开发工程师', category: 'ai', company: '热门方向', salary: '30K-60K', icon: '🧠' },
|
||||
{ name: '大模型应用开发', category: 'ai', company: '热门方向', salary: '25K-50K', icon: '⚡' },
|
||||
]
|
||||
|
||||
const aiPositions = computed(() => hotPositions.value.filter(p => p.category === 'ai'))
|
||||
const displayAiPositions = computed(() => {
|
||||
const fromApi = aiPositions.value
|
||||
if (fromApi.length >= 4) return fromApi
|
||||
// 补充到至少 4 个,去重
|
||||
const existingNames = new Set(fromApi.map(p => p.name))
|
||||
const needed = FALLBACK_AI_POSITIONS.filter(p => !existingNames.has(p.name))
|
||||
return [...fromApi, ...needed]
|
||||
})
|
||||
const traditionalPositions = computed(() => hotPositions.value.filter(p => p.category !== 'ai'))
|
||||
|
||||
const loadUserInfo = () => {
|
||||
@@ -208,15 +240,13 @@ onMounted(async () => {
|
||||
// 每日一题
|
||||
try {
|
||||
const t = uni.getStorageSync('token')
|
||||
if (t) {
|
||||
const qres = await uni.request({
|
||||
url: api('/daily-question'), method: 'GET',
|
||||
header: { 'Authorization': `Bearer ${t}` }
|
||||
header: t ? { 'Authorization': `Bearer ${t}` } : {}
|
||||
})
|
||||
if (qres.statusCode === 200 && qres.data) {
|
||||
dailyQuestion.value = qres.data
|
||||
}
|
||||
}
|
||||
} catch (e) { /* silent */ }
|
||||
|
||||
// 热门岗位
|
||||
@@ -233,13 +263,11 @@ const refreshDaily = async () => {
|
||||
showAnswer.value = false
|
||||
try {
|
||||
const t = uni.getStorageSync('token')
|
||||
if (t) {
|
||||
const qres = await uni.request({
|
||||
url: api('/daily-question'), method: 'GET',
|
||||
header: { 'Authorization': `Bearer ${t}` }
|
||||
header: t ? { 'Authorization': `Bearer ${t}` } : {}
|
||||
})
|
||||
if (qres.statusCode === 200 && qres.data) dailyQuestion.value = qres.data
|
||||
}
|
||||
} catch (e) { /* silent */ }
|
||||
}
|
||||
|
||||
@@ -355,40 +383,60 @@ const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/intervie
|
||||
|
||||
/* AI 岗位专区 */
|
||||
.ai-banner {
|
||||
background: linear-gradient(135deg, #FEF3C7, #FDE68A);
|
||||
background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 50%, #FCD34D 100%);
|
||||
padding: 20rpx 24rpx; border-radius: var(--radius-lg); margin-bottom: 16rpx;
|
||||
cursor: pointer;
|
||||
display: flex; align-items: center; gap: 16rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(251,191,36,0.2);
|
||||
cursor: pointer; transition: transform 0.15s;
|
||||
}
|
||||
.ai-banner:active { transform: scale(0.98); }
|
||||
.ai-banner-title { font-size: 26rpx; font-weight: 700; color: #92400E; display: block; margin-bottom: 6rpx; }
|
||||
.ai-banner:active { transform: scale(0.97); }
|
||||
.ai-banner-icon-wrap {
|
||||
width: 64rpx; height: 64rpx; border-radius: 18rpx;
|
||||
background: rgba(255,255,255,0.6); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
|
||||
}
|
||||
.ai-banner-icon { font-size: 36rpx; }
|
||||
.ai-banner-body { flex: 1; min-width: 0; }
|
||||
.ai-banner-title { font-size: 26rpx; font-weight: 700; color: #92400E; display: block; margin-bottom: 4rpx; }
|
||||
.ai-banner-desc { font-size: 20rpx; color: #A16207; line-height: 1.5; display: block; }
|
||||
.ai-banner-arrow { font-size: 28rpx; color: #B45309; font-weight: 600; flex-shrink: 0; }
|
||||
|
||||
.position-list { border-radius: var(--radius-lg); overflow: hidden; }
|
||||
.pos-item { padding: 24rpx 28rpx; border-bottom: 1rpx solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
|
||||
.pos-item { padding: 26rpx 28rpx; border-bottom: 1rpx solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
|
||||
.pos-item:last-child { border-bottom: none; }
|
||||
.pos-item:active { background: var(--color-bg); }
|
||||
.pos-item:active { background: #F9FAFB; }
|
||||
.pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
|
||||
.pos-icon { font-size: 36rpx; width: 56rpx; height: 56rpx; display: flex; align-items: center; justify-content: center; background: #F3F4F6; border-radius: 14rpx; flex-shrink: 0; }
|
||||
.pos-icon-ai { background: #FEF3C7; }
|
||||
.pos-icon { font-size: 32rpx; width: 60rpx; height: 60rpx; display: flex; align-items: center; justify-content: center; background: #F3F4F6; border-radius: 16rpx; flex-shrink: 0; }
|
||||
.pos-icon-ai { background: linear-gradient(135deg, #FEF3C7, #FDE68A); }
|
||||
.pos-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
|
||||
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
|
||||
.pos-name-tag {
|
||||
font-size: 18rpx; color: #D97706; background: #FFFBEB; padding: 1rpx 10rpx;
|
||||
border-radius: 6rpx; align-self: flex-start; margin-top: 6rpx;
|
||||
}
|
||||
.pos-name-tag-tr { color: var(--color-primary); background: #EEF2FF; }
|
||||
.pos-meta-row { display: flex; align-items: center; gap: 10rpx; margin-top: 4rpx; }
|
||||
.pos-company { font-size: 20rpx; color: var(--color-text-tertiary); }
|
||||
.pos-salary { font-size: 20rpx; color: var(--color-primary); background: #EEF2FF; padding: 2rpx 10rpx; border-radius: 6rpx; }
|
||||
.pos-action { flex-shrink: 0; margin-left: 16rpx; }
|
||||
.pos-action-text { font-size: 22rpx; color: var(--color-primary); font-weight: 600; }
|
||||
.pos-action-ai { color: #D97706; }
|
||||
.pos-action-btn {
|
||||
font-size: 22rpx; font-weight: 600; color: var(--color-primary);
|
||||
padding: 10rpx 24rpx; border-radius: var(--radius-round);
|
||||
background: #EEF2FF; display: inline-block;
|
||||
}
|
||||
.pos-action-btn:active { background: #DBEAFE; }
|
||||
.pos-action-ai { color: #D97706; background: #FFFBEB; }
|
||||
|
||||
/* 更多岗位折叠 */
|
||||
/* 更多岗位 */
|
||||
.more-header {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 20rpx 4rpx; margin-top: 8rpx; cursor: pointer;
|
||||
padding: 24rpx 20rpx 16rpx; margin-top: 8rpx; cursor: pointer;
|
||||
background: #FFFFFF; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
|
||||
}
|
||||
.more-header:active { opacity: 0.7; }
|
||||
.more-header-left { display: flex; align-items: center; gap: 10rpx; }
|
||||
.more-icon { font-size: 28rpx; }
|
||||
.more-title { font-size: 26rpx; font-weight: 600; color: var(--color-text-secondary); }
|
||||
.more-arrow { font-size: 22rpx; color: var(--color-primary); font-weight: 500; }
|
||||
.more-title { font-size: 26rpx; font-weight: 600; color: var(--color-text); }
|
||||
.more-arrow { font-size: 22rpx; color: var(--color-primary); font-weight: 500; background: #EEF2FF; padding: 4rpx 16rpx; border-radius: var(--radius-round); }
|
||||
|
||||
.loading-tip { text-align: center; padding: 40rpx; font-size: 24rpx; color: var(--color-text-tertiary); background: #FFF; border-radius: var(--radius-lg); }
|
||||
.bottom-spacer { height: 40rpx; }
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<view class="progress-fill" :style="{ width: progressPercent + '%' }"></view>
|
||||
</view>
|
||||
<text class="topbar-timer">⏱ {{ formatTime }}</text>
|
||||
<text class="topbar-round" v-if="answeredCount > 0">第 {{ answeredCount }} 题</text>
|
||||
</view>
|
||||
<view class="topbar-right">
|
||||
<text class="avatar-toggle" @click="avatarMode = !avatarMode">
|
||||
@@ -38,10 +39,15 @@
|
||||
<!-- Chat area (both modes) -->
|
||||
<scroll-view class="chat-area" scroll-y :scroll-into-view="scrollToId" :scroll-with-animation="true" :class="{ 'chat-compact': avatarMode }">
|
||||
<view v-for="(msg, idx) in messages" :key="idx" :id="'msg-' + idx" class="msg-row" :class="msg.role">
|
||||
<view v-if="msg.role === 'ai'" class="msg-avatar ai-avatar">🤖</view>
|
||||
<view class="msg-body">
|
||||
<view class="msg-label">{{ msg.role === 'ai' ? '面试官' : '我' }}</view>
|
||||
<view class="msg-bubble" :class="msg.role">
|
||||
<text>{{ msg.content }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="msg.role === 'user'" class="msg-avatar user-avatar">👤</view>
|
||||
</view>
|
||||
|
||||
<view class="msg-row ai" v-if="aiLoading">
|
||||
<view class="typing">
|
||||
@@ -55,14 +61,38 @@
|
||||
</scroll-view>
|
||||
|
||||
<view class="input-bar" v-if="!isComplete">
|
||||
<view class="mic-btn" :class="{ recording: isRecording }" @touchstart="startRecord" @touchend="stopRecord" @touchcancel="stopRecord" @mousedown="startRecord" @mouseup="stopRecord" @mouseleave="stopRecord">
|
||||
<text class="mic-icon">🎤</text>
|
||||
<view class="mic-wrap">
|
||||
<view class="mic-btn" :class="{ recording: isRecording }" @click="toggleRecord">
|
||||
<text class="mic-icon">{{ isRecording ? '🔴' : '🎤' }}</text>
|
||||
<text class="mic-label" v-if="isRecording">{{ recordingDuration }}s</text>
|
||||
</view>
|
||||
<text class="mic-hint" v-if="isRecording">点击结束</text>
|
||||
</view>
|
||||
<view class="input-box">
|
||||
<textarea class="input-area" v-model="inputText" placeholder="输入你的回答..." :auto-height="true" :maxlength="2000" :disabled="aiLoading" @confirm="sendAnswer" />
|
||||
<textarea class="input-area" v-model="inputText" placeholder="点击🎤开始语音面试或直接输入文字回答" :auto-height="true" :maxlength="2000" :disabled="aiLoading || isRecording" @confirm="sendAnswer" />
|
||||
</view>
|
||||
<view class="send-btn" :class="{ disabled: (!inputText.trim() && !isRecording) || aiLoading }" @click="sendAnswer">
|
||||
<text class="send-icon">{{ isRecording ? '◉' : '➤' }}</text>
|
||||
<view class="send-btn" :class="{ disabled: !inputText.trim() || isRecording || aiLoading }" @click="sendAnswer">
|
||||
<text class="send-icon">➤</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 岗位选择弹窗 -->
|
||||
<view class="modal-overlay" v-if="showPositionPicker" @click="showPositionPicker = false">
|
||||
<view class="modal-content" @click.stop>
|
||||
<text class="modal-title">选择面试岗位</text>
|
||||
<view class="pos-list">
|
||||
<view class="pos-option" v-for="(pos, idx) in positions" :key="idx" @click="selectPosition(pos)">
|
||||
<text class="pos-name">{{ pos.name }}</text>
|
||||
<text class="pos-arrow">›</text>
|
||||
</view>
|
||||
<view class="pos-option" v-if="positions.length === 0 && !positionsLoading">
|
||||
<text class="pos-name disabled">暂无可用岗位</text>
|
||||
</view>
|
||||
<view class="pos-option" v-if="positionsLoading">
|
||||
<text class="pos-name disabled">加载中...</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="modal-close" @click="showPositionPicker = false">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -70,40 +100,119 @@
|
||||
|
||||
<view class="complete-bar" v-else>
|
||||
<button class="cta-btn" @click="goResult">查看面试报告</button>
|
||||
<button class="buy-btn" v-if="completedReason === 'noCredits'" @click="goGravityBuy">引力值不足,立即补充 ›</button>
|
||||
</view>
|
||||
|
||||
<!-- 引力值不足弹窗 -->
|
||||
<view class="modal-overlay" v-if="showGravityBuyModal" @click="showGravityBuyModal = false">
|
||||
<view class="modal-content" @click.stop>
|
||||
<text class="modal-title">引力值不足</text>
|
||||
<text class="modal-hint">您的引力值不足,请补充后继续面试(每次面试消耗 5 引力值)</text>
|
||||
<view class="purchase-options">
|
||||
<view class="purchase-option" @click="goGravityBuyAndClose">
|
||||
<text class="purchase-name">购买引力值</text>
|
||||
<text class="purchase-price">前往充值</text>
|
||||
<text class="purchase-desc">小程序内直接购买,微信支付安全便捷</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="modal-close" @click="showGravityBuyModal = false">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api, API_ENDPOINTS } from '../../config'
|
||||
import { checkAuth } from '../../utils/auth'
|
||||
import DigitalHuman from '../../components/digital-human.vue'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - AI模拟面试 | 数字人面试官实战练习', path: '/pages/interview/interview' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - AI模拟面试 | 数字人面试官实战练习' }))
|
||||
// #endif
|
||||
const messages = ref([{ role: 'ai', content: '你好!我是 AI 面试官,请选择岗位开始模拟面试!' }])
|
||||
const inputText = ref('')
|
||||
const aiLoading = ref(false)
|
||||
const interviewId = ref('')
|
||||
const answeredCount = ref(0)
|
||||
const isComplete = ref(false)
|
||||
const completedReason = ref('')
|
||||
const scrollToId = ref('')
|
||||
const position = ref('')
|
||||
const avatarMode = ref(true)
|
||||
const showPositionPicker = ref(false)
|
||||
const showGravityBuyModal = ref(false)
|
||||
const positions = ref([])
|
||||
const positionsLoading = ref(false)
|
||||
const aiSpeechText = ref('')
|
||||
const aiAudioUrl = ref('')
|
||||
const aiAmplitudeData = ref([])
|
||||
const isSpeaking = ref(false)
|
||||
const dhRef = ref(null)
|
||||
const isRecording = ref(false)
|
||||
let recorder = null
|
||||
const recordingDuration = ref(0)
|
||||
let manager = null
|
||||
let recordTimer = null
|
||||
|
||||
let timerSeconds = 0
|
||||
|
||||
function initRecorder() {
|
||||
// #ifdef MP-WEIXIN
|
||||
if (manager) return
|
||||
try {
|
||||
const plugin = requirePlugin('WechatSI')
|
||||
manager = plugin.getRecordRecognitionManager()
|
||||
manager.onStart = () => {
|
||||
console.log('[WechatSI] start')
|
||||
isRecording.value = true
|
||||
inputText.value = ''
|
||||
recordingDuration.value = 0
|
||||
recordTimer = setInterval(() => { recordingDuration.value++ }, 1000)
|
||||
}
|
||||
manager.onRecognize = (res) => {
|
||||
if (res?.result?.trim()) inputText.value = res.result.trim()
|
||||
}
|
||||
manager.onStop = (res) => {
|
||||
isRecording.value = false
|
||||
recordingDuration.value = 0
|
||||
if (recordTimer) { clearInterval(recordTimer); recordTimer = null }
|
||||
const text = res?.result?.trim()
|
||||
if (text && text.length >= 2) {
|
||||
inputText.value = text
|
||||
sendAnswer()
|
||||
} else if (text && text.length === 1) {
|
||||
uni.showToast({ title: '语音过短,请重试', icon: 'none' })
|
||||
} else if (!text) {
|
||||
uni.showToast({ title: '未检测到语音,请重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
manager.onError = (res) => {
|
||||
console.error('[WechatSI] error:', JSON.stringify(res))
|
||||
isRecording.value = false
|
||||
recordingDuration.value = 0
|
||||
if (recordTimer) { clearInterval(recordTimer); recordTimer = null }
|
||||
const msg = res?.errMsg?.includes('permission') ? '请允许录音权限' : '语音识别失败,请重试'
|
||||
uni.showToast({ title: msg, icon: 'none' })
|
||||
manager = null
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('WechatSI plugin init failed:', e)
|
||||
manager = null
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
const timerSeconds = ref(0)
|
||||
let timerInterval = null
|
||||
|
||||
let MAX_QUESTIONS = 10
|
||||
const progressPercent = computed(() => Math.min((answeredCount.value / MAX_QUESTIONS) * 100, 100))
|
||||
const formatTime = computed(() => {
|
||||
const m = Math.floor(timerSeconds / 60); const s = timerSeconds % 60
|
||||
const m = Math.floor(timerSeconds.value / 60); const s = timerSeconds.value % 60
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
})
|
||||
const token = () => uni.getStorageSync('token') || ''
|
||||
@@ -112,13 +221,42 @@ onLoad((options) => {
|
||||
if (options?.position) {
|
||||
const pos = decodeURIComponent(options.position)
|
||||
position.value = pos
|
||||
messages.value = [{ role: 'ai', content: `你好!我是你的专属 ${pos} 面试官,准备好了就开始吧!` }]
|
||||
messages.value = [{ role: 'ai', content: `你好!我是你的专属 ${pos} 面试官。准备好后发送任意消息,我会立即开始面试并给出第一个问题。` }]
|
||||
}
|
||||
})
|
||||
|
||||
/** 加载热门岗位列表 */
|
||||
const loadPositions = async () => {
|
||||
positionsLoading.value = true
|
||||
try {
|
||||
const res = await uni.request({ url: api('/positions/hot'), method: 'GET' })
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && Array.isArray(res.data)) {
|
||||
positions.value = res.data
|
||||
} else if (res.data?.data && Array.isArray(res.data.data)) {
|
||||
positions.value = res.data.data
|
||||
}
|
||||
} catch (e) { console.error('加载岗位列表失败', e) }
|
||||
finally { positionsLoading.value = false }
|
||||
}
|
||||
|
||||
/** 用户选择岗位后开始面试 */
|
||||
const selectPosition = (pos) => {
|
||||
position.value = pos.name
|
||||
showPositionPicker.value = false
|
||||
messages.value = [{ role: 'ai', content: `你好!我是你的专属 ${pos.name} 面试官。准备好后发送任意消息,我会立即开始面试并给出第一个问题。` }]
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
timerInterval = setInterval(() => timerSeconds++, 1000)
|
||||
if (token()) startInterview()
|
||||
initRecorder()
|
||||
timerInterval = setInterval(() => timerSeconds.value++, 1000)
|
||||
if (!position.value) {
|
||||
loadPositions()
|
||||
showPositionPicker.value = true
|
||||
}
|
||||
})
|
||||
|
||||
watch(isComplete, (val) => {
|
||||
if (val) clearInterval(timerInterval)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -145,18 +283,30 @@ const startInterview = async () => {
|
||||
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
|
||||
data: { position: position.value },
|
||||
})
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data) {
|
||||
interviewId.value = res.data.id
|
||||
messages.value = res.data.messages || messages.value
|
||||
answeredCount.value = res.data.questionCount || 0
|
||||
if (res.data.totalQuestions) MAX_QUESTIONS = res.data.totalQuestions
|
||||
// 将后端返回的 AI 消息追加入对话,不替换已有消息(保留用户已发的准备消息)
|
||||
if (res.data.messages?.length) {
|
||||
const aiMsgs = res.data.messages.filter(m => m.role === 'ai')
|
||||
if (aiMsgs.length > 0) messages.value.push(...aiMsgs)
|
||||
}
|
||||
// Speak first question in avatar mode
|
||||
if (avatarMode.value && res.data.messages?.length) {
|
||||
const last = res.data.messages[res.data.messages.length - 1]
|
||||
if (last?.role === 'ai') await speakAiText(last.content)
|
||||
}
|
||||
} else if (res.statusCode === 403) {
|
||||
const errMsg = res.data?.message || '面试次数已用完'
|
||||
messages.value.push({ role: 'ai', content: errMsg + ' 👉 购买后可继续面试' })
|
||||
isComplete.value = true
|
||||
completedReason.value = 'noCredits'
|
||||
} else if (checkAuth(res)) {
|
||||
return // token 过期,已清除并跳转登录
|
||||
} else {
|
||||
const msg = res.data?.message || '创建面试失败'
|
||||
const errMsg = typeof res.data === 'string' ? res.data : (res.data?.message || '')
|
||||
const msg = errMsg || `创建面试失败(${res.statusCode})`
|
||||
messages.value.push({ role: 'ai', content: msg })
|
||||
}
|
||||
} catch {
|
||||
@@ -168,14 +318,20 @@ const startInterview = async () => {
|
||||
}
|
||||
|
||||
const sendAnswer = async () => {
|
||||
if (!inputText.value.trim() || aiLoading.value || isComplete.value) return
|
||||
if (!inputText.value.trim() || aiLoading.value || isRecording.value || isComplete.value) return
|
||||
if (!token()) { checkLogin(); return }
|
||||
const answer = inputText.value.trim()
|
||||
|
||||
// 首次发送:不把用户消息当答案提交,而是先创建面试获取第一个问题
|
||||
if (!interviewId.value) {
|
||||
messages.value.push({ role: 'user', content: answer })
|
||||
inputText.value = ''
|
||||
scrollToBottom()
|
||||
await startInterview()
|
||||
if (!interviewId.value) return // creation failed, don't discard answer
|
||||
// startInterview 成功后已经把第一个问题追加到 messages 了
|
||||
return
|
||||
}
|
||||
|
||||
const answer = inputText.value.trim()
|
||||
messages.value.push({ role: 'user', content: answer })
|
||||
inputText.value = ''
|
||||
scrollToBottom()
|
||||
@@ -187,7 +343,7 @@ const sendAnswer = async () => {
|
||||
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
|
||||
data: avatarMode.value ? { answer, avatar: true } : { answer },
|
||||
})
|
||||
if (res.statusCode === 200 && res.data?.messages) {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.messages) {
|
||||
const aiMsg = res.data.messages.find(m => m.role === 'ai')
|
||||
// Only push AI messages from response to avoid duplicating the user message already added above
|
||||
const newAiMessages = res.data.messages.filter(m => m.role === 'ai')
|
||||
@@ -198,8 +354,12 @@ const sendAnswer = async () => {
|
||||
answeredCount.value = res.data.questionCount || answeredCount.value + 1
|
||||
if (res.data.totalQuestions) MAX_QUESTIONS = res.data.totalQuestions
|
||||
} else if (res.statusCode === 403) {
|
||||
messages.value.push({ role: 'ai', content: res.data?.message || '面试次数已用完' })
|
||||
const errMsg = res.data?.message || '面试次数已用完'
|
||||
messages.value.push({ role: 'ai', content: errMsg + ' 👉 购买后可继续面试' })
|
||||
isComplete.value = true
|
||||
completedReason.value = 'noCredits'
|
||||
} else if (checkAuth(res)) {
|
||||
return
|
||||
} else {
|
||||
messages.value.push({ role: 'ai', content: res.data?.message || '回答提交失败' })
|
||||
}
|
||||
@@ -226,6 +386,8 @@ async function speakAiText(text, ttsHash, ttsAmplitude) {
|
||||
if (synthRes.statusCode === 200 && synthRes.data?.hash) {
|
||||
aiAudioUrl.value = api(API_ENDPOINTS.TTS.AUDIO(synthRes.data.hash))
|
||||
aiAmplitudeData.value = synthRes.data?.amplitudeData || []
|
||||
} else {
|
||||
checkAuth(synthRes)
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
@@ -240,6 +402,15 @@ function onAvatarSilent() {
|
||||
}
|
||||
|
||||
const goResult = () => uni.navigateTo({ url: `/pages/report/report?interviewId=${interviewId.value}` })
|
||||
|
||||
// 购买引力值
|
||||
const goGravityBuy = () => {
|
||||
showGravityBuyModal.value = true
|
||||
}
|
||||
const goGravityBuyAndClose = () => {
|
||||
showGravityBuyModal.value = false
|
||||
uni.navigateTo({ url: '/pages/member/member' })
|
||||
}
|
||||
const scrollToBottom = () => {
|
||||
nextTick(() => { scrollToId.value = ''; setTimeout(() => { scrollToId.value = 'msg-bottom' }, 100) })
|
||||
}
|
||||
@@ -251,50 +422,28 @@ const confirmExit = () => {
|
||||
})
|
||||
}
|
||||
|
||||
function startRecord() {
|
||||
function toggleRecord() {
|
||||
if (aiLoading.value || isComplete.value) return
|
||||
// #ifdef MP-WEIXIN
|
||||
isRecording.value = true
|
||||
recorder = uni.getRecorderManager()
|
||||
recorder.onStart(() => {})
|
||||
recorder.onError(() => { isRecording.value = false })
|
||||
recorder.start({ format: 'mp3' })
|
||||
if (!isRecording.value) {
|
||||
if (!manager) initRecorder()
|
||||
if (!manager) {
|
||||
uni.showToast({ title: '语音功能初始化失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
manager.start({ lang: 'zh_CN', duration: 60000 })
|
||||
uni.vibrateShort({ type: 'medium' })
|
||||
return
|
||||
}
|
||||
if (!manager) { isRecording.value = false; return }
|
||||
if (recordTimer) { clearInterval(recordTimer); recordTimer = null }
|
||||
recordingDuration.value = 0
|
||||
manager.stop()
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.showToast({ title: '语音输入仅支持小程序', icon: 'none' })
|
||||
// #endif
|
||||
}
|
||||
|
||||
function stopRecord() {
|
||||
if (!recorder || !isRecording.value) return
|
||||
isRecording.value = false
|
||||
recorder.stop()
|
||||
recorder.onStop(async (res) => {
|
||||
if (!res.tempFilePath) return
|
||||
const audioPath = res.tempFilePath
|
||||
try {
|
||||
const uploadRes = await uni.uploadFile({
|
||||
url: api(API_ENDPOINTS.TTS.ASR),
|
||||
filePath: audioPath,
|
||||
name: 'audio',
|
||||
header: { 'Authorization': `Bearer ${token()}` },
|
||||
})
|
||||
console.log('[ASR] upload response:', uploadRes.statusCode, typeof uploadRes.data === 'string' ? uploadRes.data.slice(0, 200) : JSON.stringify(uploadRes.data).slice(0, 200))
|
||||
if (uploadRes.statusCode === 200 && uploadRes.data) {
|
||||
const data = typeof uploadRes.data === 'string' ? JSON.parse(uploadRes.data) : uploadRes.data
|
||||
if (data.text) {
|
||||
inputText.value = data.text
|
||||
uni.vibrateShort({ type: 'light' })
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[ASR] upload error:', e?.message || e)
|
||||
}
|
||||
uni.showToast({ title: '语音识别失败,请手动输入', icon: 'none' })
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -319,6 +468,7 @@ function stopRecord() {
|
||||
.progress-track { height: 6rpx; background: rgba(255,255,255,0.2); border-radius: 3rpx; overflow: hidden; }
|
||||
.progress-fill { height: 100%; background: #FFFFFF; border-radius: 3rpx; transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
|
||||
.topbar-timer { font-size: 20rpx; color: rgba(255,255,255,0.7); font-variant-numeric: tabular-nums; }
|
||||
.topbar-round { font-size: 18rpx; color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.15); padding: 2rpx 10rpx; border-radius: 16rpx; margin-left: 8rpx; }
|
||||
.topbar-right { width: 60rpx; flex-shrink: 0; text-align: center; }
|
||||
.avatar-toggle { font-size: 36rpx; cursor: pointer; }
|
||||
|
||||
@@ -331,11 +481,20 @@ function stopRecord() {
|
||||
/* Chat */
|
||||
.chat-area { flex: 1; padding: 24rpx 20rpx; overflow-y: auto; }
|
||||
.chat-compact { max-height: 40vh; }
|
||||
.msg-row { display: flex; margin-bottom: 24rpx; }
|
||||
.msg-row { display: flex; margin-bottom: 32rpx; align-items: flex-start; gap: 12rpx; }
|
||||
.msg-row.ai { justify-content: flex-start; }
|
||||
.msg-row.user { justify-content: flex-end; }
|
||||
|
||||
.msg-bubble { max-width: 560rpx; padding: 20rpx 24rpx; line-height: 1.7; font-size: 26rpx; }
|
||||
.msg-avatar { width: 48rpx; height: 48rpx; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24rpx; flex-shrink: 0; }
|
||||
.ai-avatar { background: #EEF2FF; }
|
||||
.user-avatar { background: #FEF3C7; }
|
||||
|
||||
.msg-body { max-width: 70%; display: flex; flex-direction: column; gap: 6rpx; }
|
||||
.msg-row.user .msg-body { align-items: flex-end; }
|
||||
|
||||
.msg-label { font-size: 20rpx; color: #9CA3AF; padding: 0 8rpx; }
|
||||
|
||||
.msg-bubble { padding: 20rpx 24rpx; line-height: 1.7; font-size: 26rpx; word-break: break-word; }
|
||||
.msg-bubble.ai {
|
||||
background: #FFFFFF; color: var(--color-text);
|
||||
border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
|
||||
@@ -368,14 +527,18 @@ function stopRecord() {
|
||||
}
|
||||
.input-box { flex: 1; background: var(--color-bg); border-radius: var(--radius-md); padding: 12rpx 20rpx; }
|
||||
.input-area { width: 100%; font-size: 26rpx; color: var(--color-text); max-height: 160rpx; line-height: 1.5; }
|
||||
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 4rpx; flex-shrink: 0; }
|
||||
.mic-btn {
|
||||
width: 64rpx; height: 64rpx; border-radius: 50%; background: #F3F4F6;
|
||||
display: flex; align-items: center; justify-content: center; flex-shrink: 0;
|
||||
transition: all 0.2s;
|
||||
width: 80rpx; height: 80rpx; border-radius: 50%; background: #F3F4F6;
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
||||
transition: all 0.2s; gap: 2rpx;
|
||||
}
|
||||
.mic-btn:active { transform: scale(0.9); }
|
||||
.mic-btn.recording { background: #FEE2E2; animation: mic-pulse 1s infinite; }
|
||||
.mic-icon { font-size: 28rpx; }
|
||||
.mic-icon { font-size: 28rpx; line-height: 1; }
|
||||
.mic-label { font-size: 16rpx; color: #9CA3AF; line-height: 1; }
|
||||
.mic-btn.recording .mic-label { color: #EF4444; font-weight: 600; }
|
||||
.mic-hint { font-size: 18rpx; color: #EF4444; font-weight: 500; line-height: 1; white-space: nowrap; }
|
||||
@keyframes mic-pulse {
|
||||
0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
|
||||
50% { box-shadow: 0 0 0 16rpx rgba(239, 68, 68, 0); }
|
||||
@@ -389,7 +552,32 @@ function stopRecord() {
|
||||
.send-btn.disabled { background: var(--color-border); }
|
||||
.send-icon { font-size: 32rpx; color: #FFFFFF; transform: translateY(2rpx); }
|
||||
|
||||
.complete-bar { background: #FFFFFF; padding: 20rpx 24rpx; padding-bottom: calc(20rpx + var(--safe-bottom)); }
|
||||
.complete-bar { background: #FFFFFF; padding: 20rpx 24rpx; padding-bottom: calc(20rpx + var(--safe-bottom)); display: flex; flex-direction: column; gap: 16rpx; }
|
||||
.cta-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFFFFF; border-radius: var(--radius-md); font-size: 28rpx; font-weight: 600; border: none; }
|
||||
.buy-btn { width: 100%; height: 72rpx; line-height: 72rpx; background: #FEF3C7; color: #92400E; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 600; border: 2rpx solid #F59E0B; }
|
||||
.disclaimer-bar { text-align: center; font-size: 20rpx; color: var(--color-text-tertiary); padding: 8rpx 24rpx; background: #FFFFFF; border-top: 1rpx solid var(--color-border); }
|
||||
|
||||
/* 岗位选择弹窗 */
|
||||
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 999; display: flex; align-items: center; justify-content: center; }
|
||||
.modal-content { background: #FFF; border-radius: 20rpx; width: 600rpx; max-height: 70vh; display: flex; flex-direction: column; align-items: center; padding: 40rpx 32rpx 32rpx; }
|
||||
.modal-title { font-size: 30rpx; font-weight: 800; color: var(--color-text); margin-bottom: 24rpx; }
|
||||
.pos-list { width: 100%; max-height: 440rpx; overflow-y: auto; }
|
||||
.pos-option { display: flex; align-items: center; justify-content: space-between; padding: 24rpx 16rpx; border-bottom: 1rpx solid #F3F4F6; }
|
||||
.pos-option:active { background: #F9FAFB; border-radius: 12rpx; }
|
||||
.pos-name { font-size: 28rpx; color: var(--color-text); }
|
||||
.pos-name.disabled { color: #9CA3AF; }
|
||||
.pos-arrow { font-size: 32rpx; color: #9CA3AF; }
|
||||
.modal-close { margin-top: 24rpx; font-size: 26rpx; color: #9CA3AF; padding: 12rpx 32rpx; }
|
||||
|
||||
/* 购买弹窗 */
|
||||
.modal-hint { font-size: 24rpx; color: #6B7280; text-align: center; margin-bottom: 28rpx; padding: 0 16rpx; }
|
||||
.purchase-options { width: 100%; display: flex; flex-direction: column; gap: 16rpx; }
|
||||
.purchase-option { background: #F9FAFB; border-radius: var(--radius-md); padding: 24rpx; border: 2rpx solid #E5E7EB; }
|
||||
.purchase-option.recommended { background: #FFFBEB; border-color: #F59E0B; }
|
||||
.purchase-option:active { transform: scale(0.97); }
|
||||
.purchase-badge { font-size: 18rpx; color: #FFF; background: #F59E0B; padding: 2rpx 12rpx; border-radius: 6rpx; align-self: flex-start; margin-bottom: 8rpx; }
|
||||
.purchase-name { font-size: 28rpx; font-weight: 700; color: var(--color-text); display: block; }
|
||||
.purchase-price { font-size: 36rpx; font-weight: 800; color: var(--color-primary); margin-top: 8rpx; }
|
||||
.purchase-unit { font-size: 22rpx; font-weight: 400; color: #9CA3AF; }
|
||||
.purchase-desc { font-size: 22rpx; color: #6B7280; margin-top: 6rpx; }
|
||||
</style>
|
||||
|
||||
@@ -65,6 +65,13 @@
|
||||
<view class="card" v-if="mainTab === 'register'">
|
||||
<text class="card-title">创建账号</text>
|
||||
<text class="card-sub">注册后享受 AI 面试模拟服务</text>
|
||||
<view class="promo-banner">
|
||||
<text class="promo-icon">🎁</text>
|
||||
<view class="promo-texts">
|
||||
<text class="promo-title">注册即送 {{ registrationGravity }} 引力值</text>
|
||||
<text class="promo-desc">免费体验 AI 面试模拟</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">邮箱</text>
|
||||
<input class="input" type="text" v-model="email" placeholder="请输入邮箱" />
|
||||
@@ -118,13 +125,22 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 登录注册 | AI模拟面试', path: '/pages/login/login' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 登录注册 | AI模拟面试' }))
|
||||
// #endif
|
||||
|
||||
const agreed = ref(false)
|
||||
|
||||
const mainTab = ref('login')
|
||||
const loginMode = ref('password') // 'password' | 'code'
|
||||
const isMp = ref(false)
|
||||
const registrationGravity = ref(50)
|
||||
|
||||
const email = ref('')
|
||||
const password = ref('')
|
||||
@@ -150,6 +166,17 @@ onMounted(() => {
|
||||
isMp.value = true
|
||||
mainTab.value = 'wechat'
|
||||
// #endif
|
||||
// 获取注册赠送引力值配置
|
||||
uni.request({
|
||||
url: api('/member/plans'),
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data?.registrationGravity) {
|
||||
registrationGravity.value = res.data.registrationGravity
|
||||
}
|
||||
},
|
||||
fail: () => {} // 使用默认值 50
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => { if (timer) { clearTimeout(timer); timer = null } })
|
||||
@@ -300,7 +327,6 @@ const doWxLogin = async () => {
|
||||
wxLoading.value = true
|
||||
try {
|
||||
const wxResp = await uni.login()
|
||||
console.log('[wxLogin] uni.login success:', JSON.stringify(wxResp).slice(0, 300))
|
||||
const { code, errMsg } = wxResp
|
||||
if (!code) { console.error('[wxLogin] no code:', errMsg); showToast('获取微信凭证失败'); return }
|
||||
const res = await uni.request({
|
||||
@@ -308,7 +334,6 @@ const doWxLogin = async () => {
|
||||
header: { 'Content-Type': 'application/json' },
|
||||
data: { code },
|
||||
})
|
||||
console.log('[wxLogin] server response:', res.statusCode, JSON.stringify(res.data).slice(0, 500))
|
||||
if (res.statusCode === 200 && res.data?.token) {
|
||||
loginSuccess(res.data)
|
||||
} else {
|
||||
@@ -349,6 +374,12 @@ const goPrivacy = () => uni.navigateTo({ url: '/pages/privacy/privacy' })
|
||||
.card-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); display: block; }
|
||||
.card-sub { font-size: 22rpx; color: var(--color-text-tertiary); margin-top: 6rpx; margin-bottom: 24rpx; display: block; }
|
||||
|
||||
/* ===== Promo Banner ===== */
|
||||
.promo-banner { background: linear-gradient(135deg, #FEF3C7, #FDE68A); border-radius: var(--radius-md); padding: 20rpx 24rpx; margin-bottom: 24rpx; display: flex; align-items: center; gap: 16rpx; }
|
||||
.promo-icon { font-size: 36rpx; }
|
||||
.promo-title { font-size: 26rpx; font-weight: 700; color: #92400E; display: block; }
|
||||
.promo-desc { font-size: 22rpx; color: #B45309; display: block; margin-top: 4rpx; }
|
||||
|
||||
/* ===== Fields ===== */
|
||||
.field { margin-bottom: 20rpx; }
|
||||
.field-label { font-size: 22rpx; color: var(--color-text-secondary); margin-bottom: 8rpx; display: block; }
|
||||
|
||||
@@ -1,56 +1,84 @@
|
||||
<template>
|
||||
<view class="page fade-in">
|
||||
<view class="hero">
|
||||
<text class="hero-title">会员中心</text>
|
||||
<text class="hero-sub" v-if="isLoggedIn">
|
||||
当前:{{ currentPlanName }}
|
||||
</text>
|
||||
<text class="hero-sub" v-else>选择套餐,解锁全部功能</text>
|
||||
<!-- 状态栏:当前方案 + 引力值 -->
|
||||
<view class="status-bar">
|
||||
<view class="status-left">
|
||||
<text class="status-label">当前方案</text>
|
||||
<text class="status-plan">{{ currentPlanName || '免费版' }}</text>
|
||||
</view>
|
||||
<view class="status-right">
|
||||
<text class="grav-label">⚡ 引力值</text>
|
||||
<text class="grav-num">{{ gravity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="plans">
|
||||
<!-- 免费版 -->
|
||||
<view class="plan-card free" :class="{ active: plan === 'free' && isLoggedIn }">
|
||||
<view class="plan-header">
|
||||
<text class="plan-name">免费版</text>
|
||||
<view class="plan-price"><text class="price-num">免费</text></view>
|
||||
</view>
|
||||
<view class="plan-features">
|
||||
<text class="feat" v-for="f in freeFeatures" :key="f">✓ {{ f }}</text>
|
||||
</view>
|
||||
<view class="plan-status" v-if="isLoggedIn && plan === 'free'">当前使用</view>
|
||||
<view class="plan-status hint" v-else-if="!isLoggedIn">注册即用</view>
|
||||
<!-- 未登录提示 -->
|
||||
<view class="login-bar" v-if="!isLoggedIn">
|
||||
<text class="login-text">登录后可购买引力值、查看套餐</text>
|
||||
<text class="login-btn" @click="goLogin">去登录</text>
|
||||
</view>
|
||||
|
||||
<!-- 成长版 -->
|
||||
<view class="plan-card growth recommended" :class="{ active: plan === 'growth' && isLoggedIn }">
|
||||
<view class="plan-badge">⭐ 推荐</view>
|
||||
<view class="plan-header">
|
||||
<text class="plan-name">成长版</text>
|
||||
<text class="plan-price"><text class="price-num">{{ growthPriceText }}</text><text class="price-unit">/月</text></text>
|
||||
<!-- 购买引力值(最上面,登录后可见) -->
|
||||
<view class="section" v-if="isLoggedIn">
|
||||
<text class="section-title">⚡ 补充引力值</text>
|
||||
<view class="buy-card">
|
||||
<view class="qty-row">
|
||||
<text class="qty-label">购买数量</text>
|
||||
<view class="qty-controls">
|
||||
<text class="qty-btn" :class="{ disabled: buyQty <= 1 }" @click="buyQty = Math.max(1, buyQty - 1)">−</text>
|
||||
<input class="qty-input" type="number" v-model.number="buyQty" min="1" max="99" @blur="buyQty = Math.max(1, Math.min(99, buyQty || 1))" />
|
||||
<text class="qty-btn" :class="{ disabled: buyQty >= 99 }" @click="buyQty = Math.min(99, buyQty + 1)">+</text>
|
||||
</view>
|
||||
<view class="plan-features">
|
||||
<text class="feat" v-for="f in growthFeatures" :key="f">✓ {{ f }}</text>
|
||||
</view>
|
||||
<view class="plan-action" v-if="!isLoggedIn" @click="goLogin">登录后开通</view>
|
||||
<view class="plan-action owned" v-else-if="plan !== 'free'">✅ 已开通</view>
|
||||
<view class="plan-action" v-else @click="startPay('growth')">{{ growthPriceText }} 立即开通</view>
|
||||
<view class="summary">
|
||||
<view class="summary-row">
|
||||
<text class="summary-label">单价</text>
|
||||
<text class="summary-val">¥{{ (unitPrice / 100).toFixed(1) }} / 份</text>
|
||||
</view>
|
||||
<view class="summary-row">
|
||||
<text class="summary-label">可得引力值</text>
|
||||
<text class="summary-val highlight">{{ buyQty * gravityPerUnit }} ⚡</text>
|
||||
</view>
|
||||
<view class="summary-row total">
|
||||
<text class="summary-label">合计</text>
|
||||
<text class="summary-val total-price">¥{{ (buyQty * unitPrice / 100).toFixed(2) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<button class="buy-btn" :disabled="payLoading" @click="startGravityPay">
|
||||
{{ payLoading ? '处理中...' : '立即购买' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 冲刺版 -->
|
||||
<view class="plan-card sprint" :class="{ active: plan === 'sprint' && isLoggedIn }">
|
||||
<view class="plan-badge sprint-badge">🚀 冲刺</view>
|
||||
<!-- 套餐对比 -->
|
||||
<view class="section">
|
||||
<text class="section-title">📋 套餐对比</text>
|
||||
<view class="plan-list">
|
||||
<view v-for="p in planList" :key="p.id" class="plan-card"
|
||||
:class="{ current: p.id === plan, popular: p.popular }">
|
||||
<view class="plan-header">
|
||||
<text class="plan-name">冲刺版</text>
|
||||
<text class="plan-price"><text class="price-num price-sprint">{{ sprintPriceText }}</text><text class="price-unit">/月</text></text>
|
||||
<text class="plan-name">{{ p.name }}</text>
|
||||
<view class="plan-price">
|
||||
<text class="price-num">{{ p.priceDisplay }}</text>
|
||||
</view>
|
||||
<view class="plan-badge" v-if="p.id === plan">
|
||||
<text>当前方案</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="plan-features">
|
||||
<text class="feat" v-for="f in sprintFeatures" :key="f">✓ {{ f }}</text>
|
||||
<text class="feature" v-for="(f, i) in p.features" :key="i">✓ {{ f }}</text>
|
||||
</view>
|
||||
<view class="plan-footer" v-if="p.id !== 'free'">
|
||||
<view class="plan-action owned" v-if="p.id === plan">✅ 已开通</view>
|
||||
<view class="plan-action" v-else-if="!isLoggedIn" @click="goLogin">登录后开通</view>
|
||||
<view class="plan-action" v-else-if="plan === 'free'" @click="startPlanPay(p.id)">
|
||||
{{ p.priceDisplay }} 开通
|
||||
</view>
|
||||
<view class="plan-action" v-else @click="startPlanPay(p.id)">
|
||||
升级至{{ p.name }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="plan-action" v-if="!isLoggedIn" @click="goLogin">登录后开通</view>
|
||||
<view class="plan-action owned" v-else-if="plan === 'sprint'">✅ 已开通</view>
|
||||
<view class="plan-action" v-else-if="plan === 'growth'" @click="startPay('sprint')">升级至冲刺版</view>
|
||||
<view class="plan-action" v-else @click="startPay('sprint')">{{ sprintPriceText }}/月 立即开通</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -64,52 +92,57 @@
|
||||
<text class="modal-title">微信扫码支付</text>
|
||||
<canvas canvas-id="payQrcode" class="qr-canvas"></canvas>
|
||||
<text class="modal-hint">请用微信扫码完成支付</text>
|
||||
<text class="modal-hint">支付成功后将自动跳转</text>
|
||||
<text class="modal-close" @click="cancelPay">取消支付</text>
|
||||
</template>
|
||||
<template v-else-if="isMp && !payLoading">
|
||||
<text class="modal-title">微信支付</text>
|
||||
<text class="modal-hint">即将调起微信支付...</text>
|
||||
<template v-else-if="vpStatus">
|
||||
<text class="modal-title" :class="vpSuccess ? '' : 'pay-error'">{{ vpSuccess ? '✅ 支付成功' : '支付失败' }}</text>
|
||||
<text class="modal-hint">{{ vpStatusText }}</text>
|
||||
<text class="modal-close" @click="cancelPay">关闭</text>
|
||||
</template>
|
||||
<template v-if="payError">
|
||||
<template v-if="payError && !vpStatus">
|
||||
<text class="modal-title pay-error">支付异常</text>
|
||||
<text class="modal-hint">{{ payError }}</text>
|
||||
<text class="modal-close" @click="cancelPay">关闭</text>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 支付中提示 -->
|
||||
<view class="pay-success" v-if="paySuccess">
|
||||
<text class="success-icon">🎉</text>
|
||||
<text class="success-text">开通成功!{{ payingPlanName }}已生效</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { api } from '../../config'
|
||||
import UQRCode from 'uqrcodejs'
|
||||
import { checkAuth, friendlyVpError } from '../../utils/auth'
|
||||
|
||||
const isLoggedIn = ref(false)
|
||||
const isMp = ref(false)
|
||||
const plan = ref('free')
|
||||
const currentPlanName = ref('免费版')
|
||||
const paySuccess = ref(false)
|
||||
const gravity = ref(0)
|
||||
const planList = ref([])
|
||||
|
||||
// 购买引力值
|
||||
const buyQty = ref(1)
|
||||
const unitPrice = ref(500)
|
||||
const gravityPerUnit = ref(5)
|
||||
const payLoading = ref(false)
|
||||
|
||||
// 支付弹窗
|
||||
const showPayModal = ref(false)
|
||||
const payCodeUrl = ref('')
|
||||
const payLoading = ref(false)
|
||||
const payError = ref('')
|
||||
const payingPlanName = ref('')
|
||||
const payingPlan = ref('')
|
||||
const growthPriceText = ref('¥19.9')
|
||||
const sprintPriceText = ref('¥49.9')
|
||||
const currentOutTradeNo = ref('')
|
||||
const freeFeatures = ref(['AI 模拟面试 1 次(体验)', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费)'])
|
||||
const growthFeatures = ref(['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库'])
|
||||
const sprintFeatures = ref(['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选'])
|
||||
const payingPlan = ref('')
|
||||
const paySuccess = ref(false)
|
||||
const vpStatus = ref(false)
|
||||
const vpSuccess = ref(false)
|
||||
const vpStatusText = ref('')
|
||||
|
||||
// 套餐特征后备值(API 取不到时使用)
|
||||
const defaultFreeFeatures = ['AI 模拟面试 1 次(体验)', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费)']
|
||||
const defaultGrowthFeatures = ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库']
|
||||
const defaultSprintFeatures = ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选']
|
||||
|
||||
const token = () => uni.getStorageSync('token') || ''
|
||||
|
||||
@@ -119,41 +152,65 @@ const refreshState = async () => {
|
||||
// #endif
|
||||
|
||||
const t = token()
|
||||
if (!t) {
|
||||
isLoggedIn.value = false
|
||||
return
|
||||
}
|
||||
isLoggedIn.value = true
|
||||
isLoggedIn.value = !!t
|
||||
|
||||
// 1. 先拉套餐配置(公开接口,未登录也拉)
|
||||
try {
|
||||
const [sres, lres] = await Promise.all([
|
||||
uni.request({ url: api('/member/status'), method: 'GET', header: { 'Authorization': `Bearer ${t}` } }),
|
||||
uni.request({ url: api('/member/plans'), method: 'GET' }),
|
||||
])
|
||||
if (sres.statusCode === 200) {
|
||||
const d = sres.data
|
||||
plan.value = d.plan || 'free'
|
||||
currentPlanName.value = d.planName || '免费版'
|
||||
const pres = await uni.request({ url: api('/member/plans'), method: 'GET' })
|
||||
if (pres.statusCode >= 200 && pres.statusCode < 300 && pres.data) {
|
||||
const d = pres.data
|
||||
if (d.products?.interview) {
|
||||
unitPrice.value = d.products.interview.price || 500
|
||||
gravityPerUnit.value = d.products.interview.gravity || 5
|
||||
}
|
||||
if (lres.statusCode === 200 && lres.data) {
|
||||
const plans = Array.isArray(lres.data.plans) ? lres.data.plans : (Array.isArray(lres.data) ? lres.data : [])
|
||||
const growth = plans.find((p) => p.id === 'growth')
|
||||
const sprint = plans.find((p) => p.id === 'sprint')
|
||||
if (growth) {
|
||||
growthPriceText.value = `¥${(growth.price / 100).toFixed(1)}`
|
||||
if (growth.features?.length) growthFeatures.value = growth.features
|
||||
planList.value = buildPlanList(d.plans)
|
||||
} else {
|
||||
planList.value = buildPlanList(null)
|
||||
}
|
||||
if (sprint?.features?.length) sprintFeatures.value = sprint.features
|
||||
if (sprint) sprintPriceText.value = `¥${(sprint.price / 100).toFixed(1)}`
|
||||
if (lres.data.price?.monthly) {
|
||||
growthPriceText.value = `¥${(lres.data.price.monthly / 100).toFixed(1)}`
|
||||
} catch (e) { /* silent */ }
|
||||
|
||||
// 2. 用户信息需要登录
|
||||
if (!t) return
|
||||
try {
|
||||
const ures = await uni.request({ url: api('/user/info'), method: 'GET', header: { 'Authorization': `Bearer ${t}` } })
|
||||
if (ures.statusCode >= 200 && ures.statusCode < 300 && ures.data) {
|
||||
const u = ures.data
|
||||
plan.value = u.plan || 'free'
|
||||
gravity.value = u.gravity ?? 0
|
||||
currentPlanName.value = ({ free: '免费版', growth: '成长版', sprint: '冲刺版' })[plan.value] || '免费版'
|
||||
} else if (checkAuth(ures)) {
|
||||
return // token 过期,已清除并跳转登录
|
||||
}
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
} catch (e) { /* silent */ }
|
||||
}
|
||||
|
||||
onMounted(() => { refreshState() })
|
||||
onShow(() => { refreshState() })
|
||||
const buildPlanList = (plans) => {
|
||||
const growth = plans?.find?.(p => p.id === 'growth')
|
||||
const sprint = plans?.find?.(p => p.id === 'sprint')
|
||||
return [
|
||||
{
|
||||
id: 'free', name: '免费版', priceDisplay: '免费',
|
||||
features: defaultFreeFeatures,
|
||||
popular: false,
|
||||
},
|
||||
{
|
||||
id: 'growth', name: '成长版',
|
||||
priceDisplay: growth ? `¥${(growth.price / 100).toFixed(1)}/月` : '¥19/月',
|
||||
features: growth?.features || defaultGrowthFeatures,
|
||||
popular: true,
|
||||
},
|
||||
{
|
||||
id: 'sprint', name: '冲刺版',
|
||||
priceDisplay: sprint ? `¥${(sprint.price / 100).toFixed(1)}/月` : '¥49/月',
|
||||
features: sprint?.features || defaultSprintFeatures,
|
||||
popular: false,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
onLoad(() => { /* silent */ })
|
||||
onMounted(refreshState)
|
||||
onShow(refreshState)
|
||||
|
||||
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
|
||||
|
||||
@@ -162,122 +219,210 @@ const cancelPay = () => {
|
||||
payCodeUrl.value = ''
|
||||
payLoading.value = false
|
||||
payError.value = ''
|
||||
paySuccess.value = false
|
||||
vpStatus.value = false
|
||||
vpSuccess.value = false
|
||||
vpStatusText.value = ''
|
||||
}
|
||||
|
||||
/** 创建支付订单 */
|
||||
const startPay = async (selectedPlan) => {
|
||||
/** 购买引力值 → MP 用 VP / H5 用扫码 */
|
||||
const startGravityPay = async () => {
|
||||
const t = token()
|
||||
if (!t) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
||||
|
||||
payingPlan.value = selectedPlan
|
||||
// #ifdef MP-WEIXIN
|
||||
payingPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
payingPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
|
||||
// #endif
|
||||
|
||||
showPayModal.value = true
|
||||
payLoading.value = true
|
||||
payError.value = ''
|
||||
|
||||
const planLabel = selectedPlan || 'growth'
|
||||
vpStatus.value = false
|
||||
|
||||
if (isMp.value) {
|
||||
// 小程序:JSAPI 支付
|
||||
// 小程序:虚拟支付 VP
|
||||
try {
|
||||
console.log('[VP] wx.login...')
|
||||
const [loginErr, loginRes] = await new Promise((resolve) => {
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: r => { console.log('[VP] wx.login 成功:', JSON.stringify(r)); resolve([null, r]) },
|
||||
fail: e => { console.error('[VP] wx.login 失败:', JSON.stringify(e)); resolve([e, null]) },
|
||||
})
|
||||
})
|
||||
if (loginErr || !loginRes?.code) {
|
||||
payLoading.value = false
|
||||
payError.value = '微信登录失败: ' + (loginErr?.errMsg || 'no code')
|
||||
console.error('[VP] login failed', loginErr, loginRes)
|
||||
uni.showToast({ title: '微信登录失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
console.log('[VP] code:', loginRes.code.slice(0, 20) + '...')
|
||||
const res = await uni.request({
|
||||
url: api('/payment/jsapi'), method: 'POST',
|
||||
data: { plan: planLabel },
|
||||
url: api('/virtual-payment/create'), method: 'POST',
|
||||
data: { type: 'interview', quantity: buyQty.value, wxCode: loginRes.code },
|
||||
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||
timeout: 30000,
|
||||
})
|
||||
console.log('[VP] 创建订单:', res.statusCode, JSON.stringify(res.data).slice(0, 500))
|
||||
payLoading.value = false
|
||||
|
||||
if (res.statusCode === 200 && res.data?.payParams) {
|
||||
const pp = res.data.payParams
|
||||
currentOutTradeNo.value = res.data.outTradeNo || ''
|
||||
// 调起微信支付
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: pp.timeStamp,
|
||||
nonceStr: pp.nonceStr,
|
||||
package: pp.package,
|
||||
signType: pp.signType || 'RSA',
|
||||
paySign: pp.paySign,
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.paySig) {
|
||||
const vp = res.data
|
||||
currentOutTradeNo.value = vp.outTradeNo
|
||||
wx.requestVirtualPayment({
|
||||
env: vp.env, mode: vp.mode, offerId: vp.offerId,
|
||||
signData: vp.signData,
|
||||
paySig: vp.paySig, signature: vp.signature,
|
||||
success: () => {
|
||||
const no = currentOutTradeNo.value || res.data.outTradeNo
|
||||
pollPayResult(no, planLabel)
|
||||
console.log('[VP] 支付成功')
|
||||
vpStatus.value = true
|
||||
vpSuccess.value = true
|
||||
vpStatusText.value = '引力值已到账'
|
||||
uni.showToast({ title: '充值成功!', icon: 'success' })
|
||||
refreshState()
|
||||
},
|
||||
fail: (err2) => {
|
||||
console.error('[VP] 支付失败:', JSON.stringify(err2))
|
||||
vpStatus.value = true
|
||||
vpSuccess.value = false
|
||||
vpStatusText.value = friendlyVpError(err2?.errMsg) || '你已取消支付'
|
||||
},
|
||||
fail: (err) => { payError.value = '支付取消或失败'; uni.showToast({ title: '支付取消', icon: 'none' }) },
|
||||
})
|
||||
} else if (!res.statusCode || res.statusCode === 0) {
|
||||
payLoading.value = false
|
||||
const errMsg = '网络连接失败,请检查网络后重试'
|
||||
payError.value = errMsg
|
||||
uni.showToast({ title: errMsg, icon: 'none' })
|
||||
} else {
|
||||
payLoading.value = false
|
||||
const errMsg = res.data?.message || '创建订单失败'
|
||||
payError.value = errMsg
|
||||
uni.showToast({ title: errMsg, icon: 'none' })
|
||||
const msg = res.data?.message || res.data?.msg || `请求失败(${res.statusCode})`
|
||||
if (checkAuth(res)) return
|
||||
payError.value = msg
|
||||
console.error('[VP] 订单创建失败:', res.statusCode, JSON.stringify(res.data))
|
||||
}
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
console.error('[VP] 异常:', e)
|
||||
}
|
||||
} else {
|
||||
// H5:二维码支付
|
||||
// H5:扫码支付
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/payment/create'), method: 'POST',
|
||||
data: { plan: planLabel },
|
||||
url: api('/payment/create-product'), method: 'POST',
|
||||
data: { type: 'interview', quantity: buyQty.value },
|
||||
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
payLoading.value = false
|
||||
|
||||
if (res.statusCode === 200 && res.data?.codeUrl) {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
|
||||
payCodeUrl.value = res.data.codeUrl
|
||||
currentOutTradeNo.value = res.data.outTradeNo
|
||||
nextTick(() => {
|
||||
try {
|
||||
const ctx = uni.createCanvasContext('payQrcode')
|
||||
const uqrcode = new UQRCode()
|
||||
uqrcode.data = res.data.codeUrl
|
||||
uqrcode.size = 400
|
||||
uqrcode.margin = 20
|
||||
uqrcode.backgroundColor = '#FFFFFF'
|
||||
uqrcode.foregroundColor = '#000000'
|
||||
uqrcode.make()
|
||||
uqrcode.drawCanvas(ctx)
|
||||
} catch(e) { console.error('二维码生成失败', e) }
|
||||
})
|
||||
// 轮询支付结果
|
||||
pollPayResult(res.data.outTradeNo, planLabel)
|
||||
} else if (!res.statusCode || res.statusCode === 0) {
|
||||
payLoading.value = false
|
||||
const errMsg = '网络连接失败,请检查网络后重试'
|
||||
payError.value = errMsg
|
||||
uni.showToast({ title: errMsg, icon: 'none' })
|
||||
pollPayResult(res.data.outTradeNo, 'growth')
|
||||
} else {
|
||||
payError.value = res.data?.message || '支付服务暂不可用'
|
||||
uni.showToast({ title: res.data?.message || '支付服务暂不可用', icon: 'none' })
|
||||
if (checkAuth(res)) return
|
||||
payError.value = res.data?.message || '创建订单失败'
|
||||
}
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 套餐升级 → MP 用虚拟支付 VP / H5 用扫码支付 */
|
||||
const startPlanPay = async (selectedPlan) => {
|
||||
const t = token()
|
||||
if (!t) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
||||
|
||||
payingPlan.value = selectedPlan
|
||||
showPayModal.value = true
|
||||
payLoading.value = true
|
||||
payError.value = ''
|
||||
vpStatus.value = false
|
||||
|
||||
if (isMp.value) {
|
||||
// 小程序:虚拟支付 VP(套餐升级)
|
||||
try {
|
||||
console.log('[VP-plan] wx.login...')
|
||||
const [loginErr, loginRes] = await new Promise((resolve) => {
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: r => { console.log('[VP-plan] wx.login 成功:', JSON.stringify(r)); resolve([null, r]) },
|
||||
fail: e => { console.error('[VP-plan] wx.login 失败:', JSON.stringify(e)); resolve([e, null]) },
|
||||
})
|
||||
})
|
||||
if (loginErr || !loginRes?.code) {
|
||||
payLoading.value = false
|
||||
payError.value = '微信登录失败: ' + (loginErr?.errMsg || 'no code')
|
||||
console.error('[VP-plan] login failed', loginErr, loginRes)
|
||||
uni.showToast({ title: '微信登录失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
console.log('[VP-plan] code:', loginRes.code.slice(0, 20) + '...')
|
||||
const res = await uni.request({
|
||||
url: api('/virtual-payment/create'), method: 'POST',
|
||||
data: { type: selectedPlan, quantity: 1, wxCode: loginRes.code },
|
||||
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||
timeout: 30000,
|
||||
})
|
||||
console.log('[VP-plan] 创建订单:', res.statusCode, JSON.stringify(res.data).slice(0, 500))
|
||||
payLoading.value = false
|
||||
|
||||
if (checkAuth(res)) return
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.paySig) {
|
||||
const vp = res.data
|
||||
currentOutTradeNo.value = vp.outTradeNo
|
||||
wx.requestVirtualPayment({
|
||||
env: vp.env, mode: vp.mode, offerId: vp.offerId,
|
||||
signData: vp.signData,
|
||||
paySig: vp.paySig, signature: vp.signature,
|
||||
success: () => {
|
||||
console.log('[VP-plan] 支付成功')
|
||||
vpStatus.value = true
|
||||
vpSuccess.value = true
|
||||
vpStatusText.value = '套餐已激活'
|
||||
uni.showToast({ title: '开通成功!', icon: 'success' })
|
||||
plan.value = selectedPlan
|
||||
currentPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
|
||||
refreshState()
|
||||
},
|
||||
fail: (err2) => {
|
||||
console.error('[VP-plan] 支付失败:', JSON.stringify(err2))
|
||||
vpStatus.value = true
|
||||
vpSuccess.value = false
|
||||
vpStatusText.value = friendlyVpError(err2?.errMsg) || '你已取消支付'
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const msg = res.data?.message || res.data?.msg || `请求失败(${res.statusCode})`
|
||||
payError.value = msg
|
||||
console.error('[VP-plan] 订单创建失败:', res.statusCode, JSON.stringify(res.data))
|
||||
uni.showToast({ title: msg, icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
console.error('[VP-plan] 异常:', e)
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/payment/create'), method: 'POST',
|
||||
data: { plan: selectedPlan },
|
||||
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
payLoading.value = false
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
|
||||
payCodeUrl.value = res.data.codeUrl
|
||||
currentOutTradeNo.value = res.data.outTradeNo
|
||||
pollPayResult(res.data.outTradeNo, selectedPlan)
|
||||
} else {
|
||||
if (checkAuth(res)) return
|
||||
payError.value = res.data?.message || '创建订单失败'
|
||||
}
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 轮询订单状态 */
|
||||
const pollPayResult = async (outTradeNo, selectedPlan) => {
|
||||
const pollPayResult = (outTradeNo, selectedPlan) => {
|
||||
if (!outTradeNo) return
|
||||
const maxAttempts = 30
|
||||
let attempts = 0
|
||||
|
||||
const poll = async () => {
|
||||
attempts++
|
||||
try {
|
||||
@@ -285,19 +430,14 @@ const pollPayResult = async (outTradeNo, selectedPlan) => {
|
||||
url: api(`/payment/check/${outTradeNo}`), method: 'GET',
|
||||
header: { 'Authorization': `Bearer ${token()}` },
|
||||
})
|
||||
if (res.statusCode === 200 && res.data?.status === 'success') {
|
||||
// 支付成功,激活套餐
|
||||
if (checkAuth(res)) return
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.status === 'success') {
|
||||
await activatePlan(outTradeNo, selectedPlan)
|
||||
return
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
|
||||
if (attempts < maxAttempts) {
|
||||
setTimeout(poll, 2000)
|
||||
} else {
|
||||
payError.value = '支付结果查询超时,请联系客服'
|
||||
uni.showToast({ title: '支付查询超时', icon: 'none' })
|
||||
}
|
||||
if (attempts < 30) setTimeout(poll, 2000)
|
||||
else { payError.value = '支付结果查询超时,请联系客服' }
|
||||
}
|
||||
setTimeout(poll, 2000)
|
||||
}
|
||||
@@ -310,13 +450,15 @@ const activatePlan = async (outTradeNo, selectedPlan) => {
|
||||
data: { outTradeNo },
|
||||
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
if (res.statusCode === 200 && res.data?.success) {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.success) {
|
||||
paySuccess.value = true
|
||||
showPayModal.value = false
|
||||
plan.value = selectedPlan === 'sprint' ? 'sprint' : 'growth'
|
||||
plan.value = selectedPlan
|
||||
currentPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
|
||||
uni.showToast({ title: '🎉 开通成功!', icon: 'success' })
|
||||
refreshState()
|
||||
} else {
|
||||
if (checkAuth(res)) return
|
||||
uni.showToast({ title: res.data?.message || '激活失败', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -327,38 +469,65 @@ const activatePlan = async (outTradeNo, selectedPlan) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; background: var(--color-bg); }
|
||||
.hero { background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid), var(--color-gradient-end)); padding: 48rpx 32rpx 72rpx; border-radius: 0 0 48rpx 48rpx; }
|
||||
.hero-title { font-size: 40rpx; font-weight: 700; color: #FFFFFF; }
|
||||
.hero-sub { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 8rpx; display: block; }
|
||||
.plans { padding: 0 32rpx; margin-top: -40rpx; display: flex; flex-direction: column; gap: 24rpx; }
|
||||
.plan-card { background: #FFFFFF; border-radius: var(--radius-xl); padding: 32rpx; box-shadow: var(--shadow-sm); position: relative; }
|
||||
.plan-card.growth { border: 2rpx solid var(--color-primary); }
|
||||
.plan-card.sprint { border: 2rpx solid #F59E0B; }
|
||||
.plan-card.active { border-color: var(--color-primary); }
|
||||
.plan-badge { position: absolute; top: -12rpx; right: 24rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; font-size: 20rpx; padding: 4rpx 20rpx; border-radius: var(--radius-round); font-weight: 600; }
|
||||
.sprint-badge { background: linear-gradient(135deg, #F59E0B, #F97316); }
|
||||
.plan-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20rpx; }
|
||||
.page { min-height: 100vh; background: var(--color-bg); padding-bottom: 40rpx; }
|
||||
|
||||
/* 状态栏 */
|
||||
.status-bar { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); padding: 32rpx; color: #fff; }
|
||||
.status-left { display: flex; flex-direction: column; gap: 4rpx; }
|
||||
.status-label { font-size: 22rpx; opacity: 0.85; }
|
||||
.status-plan { font-size: 34rpx; font-weight: 700; }
|
||||
.status-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4rpx; }
|
||||
.grav-label { font-size: 22rpx; opacity: 0.85; }
|
||||
.grav-num { font-size: 40rpx; font-weight: 800; }
|
||||
|
||||
/* 登录提示 */
|
||||
.login-bar { display: flex; align-items: center; justify-content: space-between; margin: 24rpx 24rpx 0; background: #FEF3C7; border-radius: var(--radius-lg); padding: 20rpx 24rpx; }
|
||||
.login-text { font-size: 24rpx; color: #92400E; }
|
||||
.login-btn { font-size: 24rpx; color: #FFF; background: var(--color-primary); padding: 8rpx 24rpx; border-radius: var(--radius-sm); }
|
||||
|
||||
/* 区块 */
|
||||
.section { padding: 0 24rpx; margin-top: 24rpx; }
|
||||
.section-title { font-size: 28rpx; font-weight: 700; color: var(--color-text); display: block; margin-bottom: 16rpx; }
|
||||
|
||||
/* 购买区 */
|
||||
.buy-card { background: #fff; border-radius: var(--radius-lg); padding: 24rpx; box-shadow: var(--shadow-sm); }
|
||||
.qty-row { margin-bottom: 16rpx; }
|
||||
.qty-label { font-size: 24rpx; font-weight: 600; color: var(--color-text); display: block; margin-bottom: 12rpx; }
|
||||
.qty-controls { display: flex; align-items: center; justify-content: center; gap: 24rpx; }
|
||||
.qty-btn { width: 60rpx; height: 60rpx; border-radius: 50%; background: #F3F4F6; display: flex; align-items: center; justify-content: center; font-size: 32rpx; font-weight: 500; color: var(--color-text); }
|
||||
.qty-btn.disabled { color: #D1D5DB; background: #F9FAFB; }
|
||||
.qty-input { width: 120rpx; height: 64rpx; text-align: center; font-size: 32rpx; font-weight: 700; color: var(--color-text); border: 2rpx solid #E5E7EB; border-radius: var(--radius-sm); }
|
||||
.summary { margin-bottom: 20rpx; }
|
||||
.summary-row { display: flex; justify-content: space-between; padding: 8rpx 0; border-bottom: 1rpx solid #F3F4F6; }
|
||||
.summary-row.total { border-bottom: none; padding-top: 12rpx; }
|
||||
.summary-label { font-size: 22rpx; color: var(--color-text-secondary); }
|
||||
.summary-val { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
|
||||
.summary-val.highlight { color: var(--color-primary); }
|
||||
.total-price { font-size: 32rpx; font-weight: 800; color: var(--color-primary); }
|
||||
.buy-btn { width: 100%; height: 80rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #fff; font-size: 28rpx; font-weight: 600; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; border: none; }
|
||||
.buy-btn:active { opacity: 0.85; }
|
||||
.buy-btn[disabled] { opacity: 0.5; }
|
||||
|
||||
/* 套餐列表 */
|
||||
.plan-list { display: flex; flex-direction: column; gap: 16rpx; }
|
||||
.plan-card { background: #fff; border-radius: var(--radius-lg); padding: 24rpx; box-shadow: var(--shadow-sm); position: relative; }
|
||||
.plan-card.popular { border: 2rpx solid var(--color-primary); }
|
||||
.plan-card.current { background: #F0F7FF; border: 2rpx solid var(--color-primary); }
|
||||
.plan-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12rpx; }
|
||||
.plan-name { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
|
||||
.price-num { font-size: 44rpx; font-weight: 800; color: var(--color-primary); }
|
||||
.price-unit { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||
.price-sprint { color: #D97706; }
|
||||
.plan-features { display: flex; flex-direction: column; gap: 10rpx; margin-bottom: 24rpx; }
|
||||
.feat { font-size: 24rpx; color: var(--color-text-secondary); }
|
||||
.plan-status { text-align: center; background: #F3F4F6; padding: 14rpx; border-radius: var(--radius-sm); font-size: 24rpx; color: var(--color-text-secondary); }
|
||||
.plan-status.hint { background: transparent; color: var(--color-text-tertiary); }
|
||||
.plan-action { text-align: center; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; padding: 20rpx; border-radius: var(--radius-md); font-size: 28rpx; font-weight: 600; }
|
||||
.price-num { font-size: 32rpx; font-weight: 800; color: var(--color-primary); }
|
||||
.plan-badge { background: var(--color-primary); color: #fff; font-size: 20rpx; padding: 4rpx 14rpx; border-radius: 20rpx; }
|
||||
.plan-features { display: flex; flex-direction: column; gap: 8rpx; margin-bottom: 16rpx; }
|
||||
.feature { font-size: 22rpx; color: var(--color-text-secondary); }
|
||||
.plan-action { text-align: center; padding: 16rpx; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 600; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #fff; }
|
||||
.plan-action.owned { background: #ECFDF5; color: var(--color-success); }
|
||||
.pay-success { margin: 24rpx 32rpx; background: #ECFDF5; border-radius: var(--radius-lg); padding: 32rpx; text-align: center; }
|
||||
.success-icon { font-size: 48rpx; display: block; margin-bottom: 8rpx; }
|
||||
.success-text { font-size: 28rpx; font-weight: 600; color: var(--color-success); }
|
||||
|
||||
/* 弹窗 */
|
||||
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
|
||||
.modal-content { background: #FFF; border-radius: var(--radius-xl); padding: 40rpx; width: 70%; display: flex; flex-direction: column; align-items: center; gap: 20rpx; }
|
||||
.modal-title { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
|
||||
.pay-error { color: var(--color-error); }
|
||||
.qr-canvas { width: 400rpx; height: 400rpx; background: #FFF; border-radius: var(--radius-md); }
|
||||
.qr-canvas { width: 400rpx; height: 400rpx; }
|
||||
.modal-hint { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||
.modal-close { font-size: 22rpx; color: var(--color-text-tertiary); padding: 8rpx; }
|
||||
</style>
|
||||
@@ -134,9 +134,19 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 进步轨迹 | 能力雷达+打卡日历', path: '/pages/progress/progress' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 进步轨迹 | 能力雷达+打卡日历' }))
|
||||
// #endif
|
||||
|
||||
const stats = ref({ completedInterviews: 0, avgScore: 0, streak: 0 })
|
||||
const progress = ref({ dimensions: {}, interviews: [], recentScores: [] })
|
||||
const skillsGap = ref(null)
|
||||
|
||||
@@ -70,9 +70,19 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, nextTick } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 面试报告与评分 | AI多维评分', path: '/pages/report/report' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 面试报告与评分 | AI多维评分' }))
|
||||
// #endif
|
||||
|
||||
const loading = ref(true)
|
||||
const report = ref(null)
|
||||
const dimList = ref([])
|
||||
@@ -285,16 +295,16 @@ async function generateCard() {
|
||||
ctx.setFontSize(20)
|
||||
ctx.setFillStyle('#A5B4FC')
|
||||
ctx.setTextAlign('center')
|
||||
ctx.fillText('「职引」- AI 模拟面试助手', w / 2, 650)
|
||||
ctx.fillText('「宇之然AI磁场」- AI 模拟面试助手', w / 2, 650)
|
||||
ctx.setFontSize(16)
|
||||
ctx.setFillStyle('rgba(165,180,252,0.5)')
|
||||
ctx.fillText('扫码开始你的模拟面试 → 在微信搜索"职引"小程序', w / 2, 690)
|
||||
ctx.fillText('扫码开始你的模拟面试 → 在微信搜索"宇之然AI磁场"小程序', w / 2, 690)
|
||||
|
||||
// QR text hint
|
||||
ctx.setFillStyle('#FFFFFF')
|
||||
ctx.setFontSize(16)
|
||||
ctx.setTextAlign('center')
|
||||
ctx.fillText('在微信搜索「职引」小程序', w / 2, 760)
|
||||
ctx.fillText('在微信搜索「宇之然AI磁场」小程序', w / 2, 760)
|
||||
ctx.fillText('查看完整面试报告', w / 2, 790)
|
||||
|
||||
ctx.draw(false, async () => {
|
||||
|
||||
@@ -148,9 +148,19 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 简历诊断与优化 | AI智能优化', path: '/pages/resume/resume' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 简历诊断与优化 | AI智能优化' }))
|
||||
// #endif
|
||||
|
||||
const currentTab = ref('list')
|
||||
const showForm = ref(false)
|
||||
const formTitle = ref('')
|
||||
@@ -286,7 +296,7 @@ const onFileSelected = async (e) => {
|
||||
const downloadResult = (format) => {
|
||||
if (!result.value) return
|
||||
const content = format === 'html'
|
||||
? `<!DOCTYPE html><html><meta charset="utf-8"><title>职引 - ${resultType.value === 'diagnosis' ? '诊断报告' : '优化结果'}</title><body>${JSON.stringify(result.value)}</body></html>`
|
||||
? `<!DOCTYPE html><html><meta charset="utf-8"><title>宇之然AI磁场 - ${resultType.value === 'diagnosis' ? '诊断报告' : '优化结果'}</title><body>${JSON.stringify(result.value)}</body></html>`
|
||||
: `${resultType.value === 'diagnosis' ? '=== 简历诊断报告 ===\n\n' : '=== 简历优化结果 ===\n\n'}${JSON.stringify(result.value, null, 2)}`
|
||||
const fileName = `简历${resultType.value === 'diagnosis' ? '诊断报告' : '优化结果'}.${format}`
|
||||
|
||||
|
||||
@@ -281,9 +281,19 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({ title: '宇之然AI磁场 - 面试复盘分析 | AI评析+口语分析', path: '/pages/review/review' }))
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 面试复盘分析 | AI评析+口语分析' }))
|
||||
// #endif
|
||||
|
||||
const mode = ref('list')
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<view class="stats-card">
|
||||
<view class="stat-row">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ stats.shareCredits || 0 }}</text>
|
||||
<text class="stat-label">📦 我的积分</text>
|
||||
<text class="stat-value">{{ stats.gravity ?? 0 }}</text>
|
||||
<text class="stat-label">🌌 我的引力值</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="stat-sub-row">
|
||||
@@ -20,12 +20,12 @@
|
||||
</view>
|
||||
<view class="stat-arrow">→</view>
|
||||
<view class="stat-sub-item">
|
||||
<text class="stat-sub-value">{{ stats.shareCredits || 0 }}</text>
|
||||
<text class="stat-sub-label">获得积分</text>
|
||||
<text class="stat-sub-value">{{ stats.gravity || 0 }}</text>
|
||||
<text class="stat-sub-label">获得引力值</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="hint">
|
||||
💡 好友通过你的链接打开并 <text class="hint-em">登录/注册</text> 才算有效,每次有效得 1 积分
|
||||
💡 好友通过你的链接打开并 <text class="hint-em">登录/注册</text> 才算有效,每次有效获 1 引力值(每日上限 3)
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -49,20 +49,42 @@
|
||||
<view class="today-bar">
|
||||
<view class="today-bar-fill" :style="{ width: Math.min(100, (todayStats.credited / 3) * 100) + '%' }"></view>
|
||||
</view>
|
||||
<text class="today-hint">每日最多 3 次有效积分</text>
|
||||
<text class="today-hint">每日最多 3 次有效引力值,分享给朋友圈可获更多</text>
|
||||
</view>
|
||||
|
||||
<!-- 分享按钮 -->
|
||||
<view class="share-actions">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="share-btn-row">
|
||||
<button class="share-btn wx-share" open-type="share">
|
||||
<text class="btn-icon">💬</text>
|
||||
<text>分享给好友</text>
|
||||
</button>
|
||||
<view class="share-btn wx-timeline-hint" @click="showTimelineHint">
|
||||
<text class="btn-icon">🔄</text>
|
||||
<text>分享朋友圈</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef H5 -->
|
||||
<view class="share-btn-row">
|
||||
<button class="share-btn wx-share" @click="shareToWechat" v-if="isWechat">
|
||||
<text class="btn-icon">💬</text>
|
||||
<text>分享给微信好友</text>
|
||||
</button>
|
||||
<button class="share-btn wx-timeline" @click="shareToWechat" v-if="isWechat">
|
||||
<text class="btn-icon">🔄</text>
|
||||
<text>分享朋友圈</text>
|
||||
</button>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<view class="share-btn-row">
|
||||
<button class="share-btn link-share" @click="copyLink">
|
||||
<text class="btn-icon">🔗</text>
|
||||
<text>复制分享链接</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Tab 切换 -->
|
||||
<view class="tab-bar">
|
||||
@@ -113,10 +135,15 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
|
||||
const tab = ref('records')
|
||||
const stats = ref({ totalShares: 0, totalVisits: 0, creditedCount: 0, todayCredited: 0, shareCredits: 0 })
|
||||
const stats = ref({ totalShares: 0, totalVisits: 0, creditedCount: 0, todayCredited: 0, shareCredits: 0, gravity: 0 })
|
||||
const shareLink = ref('')
|
||||
const shareUrlCached = ref('')
|
||||
const records = ref([])
|
||||
const visitors = ref([])
|
||||
|
||||
@@ -127,6 +154,18 @@ const todayStats = computed(() => ({
|
||||
|
||||
const isWechat = ref(false)
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareAppMessage(() => ({
|
||||
title: '宇之然AI磁场 — AI模拟面试+简历优化',
|
||||
path: '/pages/share/share',
|
||||
imageUrl: 'https://zhiyinwx.yzrcloud.cn/static/share-card.png',
|
||||
}))
|
||||
onShareTimeline(() => ({
|
||||
title: '宇之然AI磁场 — AI模拟面试+简历优化',
|
||||
imageUrl: 'https://zhiyinwx.yzrcloud.cn/static/share-card.png',
|
||||
}))
|
||||
// #endif
|
||||
|
||||
onMounted(() => {
|
||||
// #ifdef H5
|
||||
isWechat.value = navigator?.userAgent?.toLowerCase().includes('micromessenger') || false
|
||||
@@ -139,6 +178,23 @@ async function loadData() {
|
||||
if (!token) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
||||
const header = { Authorization: `Bearer ${token}` }
|
||||
|
||||
// 仅在无缓存分享链接时创建新分享记录
|
||||
if (!shareUrlCached.value) {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/share/create'), method: 'POST',
|
||||
data: { type: 'app', title: '我在宇之然AI磁场练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
|
||||
header,
|
||||
})
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
const data = res.data?.data || res.data
|
||||
if (data.shareCode) {
|
||||
shareUrlCached.value = `https://zhiyinwx.yzrcloud.cn/api/share/${data.shareCode}`
|
||||
}
|
||||
}
|
||||
} catch (e) { /* create share is best-effort */ }
|
||||
}
|
||||
|
||||
try {
|
||||
const [statsRes, recordsRes, visitorsRes] = await Promise.all([
|
||||
uni.request({ url: api('/share/stats'), method: 'GET', header }),
|
||||
@@ -159,17 +215,17 @@ async function shareToWechat() {
|
||||
const res = await uni.request({
|
||||
url: api('/share/create'),
|
||||
method: 'POST',
|
||||
data: { type: 'app', title: '我在AI磁场·职引练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
|
||||
data: { type: 'app', title: '我在宇之然AI磁场练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
|
||||
header: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (res.statusCode !== 200) return
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) return
|
||||
|
||||
const data = res.data
|
||||
const path = data.wechatShareInfo?.path || `/pages/share/share?code=${data.shareCode}`
|
||||
|
||||
uni.shareAppMessage({
|
||||
provider: 'weixin',
|
||||
title: data.wechatShareInfo?.title || 'AI磁场·职引',
|
||||
title: data.wechatShareInfo?.title || '宇之然AI磁场',
|
||||
description: data.wechatShareInfo?.description || '',
|
||||
path,
|
||||
imageUrl: 'https://zhiyinwx.yzrcloud.cn/static/share-card.png',
|
||||
@@ -181,19 +237,49 @@ async function shareToWechat() {
|
||||
|
||||
async function copyLink() {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) return
|
||||
if (!token) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
||||
|
||||
if (shareUrlCached.value) {
|
||||
// 使用已缓存的分享链接,避免二次 API 调用
|
||||
uni.setClipboardData({
|
||||
data: shareUrlCached.value,
|
||||
success: () => { uni.showToast({ title: '链接已复制' }); loadData() },
|
||||
fail: () => { uni.showToast({ title: '复制失败,请长按选择复制', icon: 'none' }) },
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 缓存未命中时兜底:调 API 生成
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/share/create'),
|
||||
method: 'POST',
|
||||
data: { type: 'app', title: '我在AI磁场·职引练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
|
||||
url: api('/share/create'), method: 'POST',
|
||||
data: { type: 'app', title: '我在宇之然AI磁场练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
|
||||
header: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (res.statusCode !== 200) return
|
||||
const shareUrl = `https://zhiyinwx.yzrcloud.cn/share/${res.data.shareCode}`
|
||||
uni.setClipboardData({ data: shareUrl, success: () => { uni.showToast({ title: '链接已复制' }); loadData() } })
|
||||
} catch (e) { console.error(e) }
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
uni.showToast({ title: `创建失败(${res.statusCode}),请重试`, icon: 'none' })
|
||||
return
|
||||
}
|
||||
const data = res.data?.data || res.data
|
||||
if (!data.shareCode) {
|
||||
uni.showToast({ title: '返回数据异常,请重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const shareUrl = `https://zhiyinwx.yzrcloud.cn/api/share/${data.shareCode}`
|
||||
shareUrlCached.value = shareUrl
|
||||
uni.setClipboardData({
|
||||
data: shareUrl,
|
||||
success: () => { uni.showToast({ title: '链接已复制' }); loadData() },
|
||||
fail: () => { uni.showToast({ title: '复制失败,请长按选择复制', icon: 'none' }) },
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('[share] copyLink error:', e)
|
||||
uni.showToast({ title: '网络错误,请重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
function showTimelineHint() {
|
||||
uni.showToast({ title: '请点击右上角 ··· 选择分享到朋友圈', icon: 'none', duration: 3000 })
|
||||
}
|
||||
|
||||
function typeLabel(type) {
|
||||
@@ -238,11 +324,18 @@ function formatTime(t) {
|
||||
.today-hint { font-size: 18rpx; color: var(--color-text-tertiary); text-align: center; }
|
||||
|
||||
/* Share buttons */
|
||||
.share-actions { padding: 0 32rpx; display: flex; gap: 20rpx; }
|
||||
.share-btn { flex: 1; display: flex; align-items: center; justify-content: center; height: 88rpx; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 500; border: none; }
|
||||
.share-actions { padding: 0 32rpx; display: flex; flex-direction: column; gap: 16rpx; }
|
||||
.share-btn-row { display: flex; gap: 20rpx; }
|
||||
.share-btn {
|
||||
flex: 1; display: flex; align-items: center; justify-content: center; height: 88rpx; border-radius: var(--radius-md);
|
||||
font-size: 26rpx; font-weight: 500; border: none; padding: 0; white-space: nowrap;
|
||||
}
|
||||
.share-btn:active { transform: scale(0.96); }
|
||||
.btn-icon { margin-right: 8rpx; font-size: 28rpx; }
|
||||
.wx-share { background: #07C160; color: #FFFFFF; }
|
||||
.wx-timeline { background: #FF6600; color: #FFFFFF; }
|
||||
.wx-timeline-hint { flex: 1; display: flex; align-items: center; justify-content: center; height: 88rpx; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 500; background: #FF6600; color: #FFFFFF; white-space: nowrap; }
|
||||
.wx-timeline-hint:active { transform: scale(0.96); }
|
||||
.link-share { background: #FFFFFF; color: var(--color-text); border: 2rpx solid var(--color-border); }
|
||||
|
||||
/* Tabs */
|
||||
|
||||
@@ -39,6 +39,26 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 引力值卡片(代替原配额卡片) -->
|
||||
<view class="gravity-card" v-if="isLoggedIn">
|
||||
<view class="gravity-card-inner">
|
||||
<view class="gravity-top-row">
|
||||
<view class="gravity-header">
|
||||
<text class="gravity-icon">⚡</text>
|
||||
<text class="gravity-label">我的引力值</text>
|
||||
</view>
|
||||
<text class="gravity-num">{{ memberInfo.gravity ?? 0 }}</text>
|
||||
</view>
|
||||
<text class="gravity-hint">每次面试消耗 5 引力值 · 分享好友、贡献面经可获得更多</text>
|
||||
<view class="gravity-actions">
|
||||
<text class="gravity-btn share" @click="goSharePage">分享得引力值</text>
|
||||
<text class="gravity-btn contribute" @click="goContributePage">贡献面经</text>
|
||||
<text class="gravity-btn h5buy" @click="goH5Buy">购买引力值</text>
|
||||
<text class="gravity-btn detail" @click="showGravityDetail = true">明细</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 菜单列表 -->
|
||||
<view class="menu-area">
|
||||
<view class="menu-group">
|
||||
@@ -68,13 +88,27 @@
|
||||
<text class="menu-text">我的简历</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @click="requireLogin(goShare, '我的分享')">
|
||||
<view class="menu-item" @click="requireLogin(goSharePage, '我的分享')">
|
||||
<view class="menu-icon-wrap wrap-orange"><text class="menu-icon">📤</text></view>
|
||||
<text class="menu-text">我的分享</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="menu-group">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="menu-item">
|
||||
<button class="contact-btn-inner" open-type="contact">
|
||||
<view class="menu-icon-wrap wrap-gray"><text class="menu-icon">💬</text></view>
|
||||
<text class="menu-text">联系客服</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</button>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<view class="menu-item" @click="goFeedback">
|
||||
<view class="menu-icon-wrap wrap-gray"><text class="menu-icon">📝</text></view>
|
||||
<text class="menu-text">意见反馈</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @click="goAbout">
|
||||
<view class="menu-icon-wrap wrap-gray"><text class="menu-icon">ℹ️</text></view>
|
||||
<text class="menu-text">关于</text>
|
||||
@@ -90,18 +124,105 @@
|
||||
<button class="logout-btn" @click="doLogout">退出登录</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 引力值获取方式 -->
|
||||
<view class="modal-overlay" v-if="showGetGravityModal" @click="showGetGravityModal = false">
|
||||
<view class="modal-content" @click.stop>
|
||||
<text class="modal-title">获取引力值</text>
|
||||
<text class="modal-hint">引力值可用于面试、简历优化、下载等</text>
|
||||
|
||||
<!-- 分享得引力值 -->
|
||||
<view class="gp-get-method" @click="goSharePage">
|
||||
<view class="gp-method-icon-wrap"><text class="gp-method-icon">🎁</text></view>
|
||||
<view class="gp-method-info">
|
||||
<text class="gp-method-name">分享给好友</text>
|
||||
<text class="gp-method-desc">每成功邀请一位好友注册,可得 5 引力值,上不封顶</text>
|
||||
</view>
|
||||
<text class="gp-method-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<!-- 贡献面经 -->
|
||||
<view class="gp-get-method" @click="goContributePage">
|
||||
<view class="gp-method-icon-wrap"><text class="gp-method-icon">📝</text></view>
|
||||
<view class="gp-method-info">
|
||||
<text class="gp-method-name">贡献面经</text>
|
||||
<text class="gp-method-desc">每发布一篇面经可获得 3 引力值,助力他人也提升自己</text>
|
||||
</view>
|
||||
<text class="gp-method-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<!-- 购买引力值 -->
|
||||
<view class="gp-get-method" @click="goH5Buy">
|
||||
<view class="gp-method-icon-wrap"><text class="gp-method-icon">🛒</text></view>
|
||||
<view class="gp-method-info">
|
||||
<text class="gp-method-name">购买引力值</text>
|
||||
<text class="gp-method-desc">¥5 一份,微信支付安全便捷</text>
|
||||
</view>
|
||||
<text class="gp-method-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<text class="modal-close" @click="showGetGravityModal = false">关闭</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 引力值明细 -->
|
||||
<view class="modal-overlay" v-if="showGravityDetail" @click="showGravityDetail = false">
|
||||
<view class="modal-content detail-content" @click.stop>
|
||||
<text class="modal-title">引力值明细</text>
|
||||
<text class="modal-hint">购买、消耗、补给的引力值变动记录</text>
|
||||
<scroll-view class="detail-list" scroll-y>
|
||||
<view v-if="gravityTxs.length === 0" class="detail-empty">暂无记录</view>
|
||||
<view v-for="tx in gravityTxs" :key="tx._id" class="detail-item">
|
||||
<view class="detail-item-left">
|
||||
<text class="detail-item-desc">{{ tx.description }}</text>
|
||||
<text class="detail-item-time">{{ formatTime(tx.createdAt) }}</text>
|
||||
</view>
|
||||
<view class="detail-item-right">
|
||||
<text :class="['detail-item-amount', tx.amount > 0 ? 'amount-positive' : 'amount-negative']">
|
||||
{{ tx.amount > 0 ? '+' : '' }}{{ tx.amount }}
|
||||
</text>
|
||||
<text class="detail-item-balance">余额 {{ tx.balance }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view v-if="gravityTxTotalPages > 1" class="detail-pagination">
|
||||
<text class="detail-page-btn" @click="loadGravityTxs(gravityTxPage - 1)" v-if="gravityTxPage > 1">上一页</text>
|
||||
<text class="detail-page-info">{{ gravityTxPage }} / {{ gravityTxTotalPages }}</text>
|
||||
<text class="detail-page-btn" @click="loadGravityTxs(gravityTxPage + 1)" v-if="gravityTxPage < gravityTxTotalPages">下一页</text>
|
||||
</view>
|
||||
<text class="modal-close" @click="showGravityDetail = false">关闭</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
// #ifdef MP-WEIXIN
|
||||
import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
// #endif
|
||||
import { api } from '../../config'
|
||||
import { checkAuth } from '../../utils/auth'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
const shareCodeRef = ref('')
|
||||
onShareAppMessage(() => {
|
||||
const path = shareCodeRef.value
|
||||
? `/pages/user/user?share=${shareCodeRef.value}`
|
||||
: '/pages/user/user'
|
||||
return { title: '宇之然AI磁场 - 个人中心 | AI模拟面试', path }
|
||||
})
|
||||
onShareTimeline(() => ({ title: '宇之然AI磁场 - 个人中心 | AI模拟面试' }))
|
||||
// #endif
|
||||
|
||||
const userInfo = ref({})
|
||||
const isAdmin = ref(false)
|
||||
const stats = ref({ interviewCount: 0, avgScore: '--', completedCount: 0 })
|
||||
const token = ref('')
|
||||
const memberInfo = ref({ plan: 'free', planName: '免费版', remaining: 0, gravity: 0 })
|
||||
|
||||
const isLoggedIn = computed(() => !!token.value)
|
||||
const maskedId = computed(() => {
|
||||
@@ -114,16 +235,43 @@ const refreshState = () => {
|
||||
if (!token.value) return
|
||||
try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s) } catch(e) {}
|
||||
loadStats()
|
||||
loadMemberStatus()
|
||||
checkAdmin()
|
||||
fetchUserInfo()
|
||||
// #ifdef MP-WEIXIN
|
||||
preCreateShare()
|
||||
// #endif
|
||||
}
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
async function preCreateShare() {
|
||||
if (shareCodeRef.value) return // already have one
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/share/create'), method: 'POST',
|
||||
data: { type: 'app', title: '我在宇之然AI磁场练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
|
||||
header: { Authorization: `Bearer ${token.value}` },
|
||||
})
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
checkAuth(res)
|
||||
return
|
||||
}
|
||||
const data = res.data?.data || res.data
|
||||
if (data.shareCode) {
|
||||
shareCodeRef.value = data.shareCode
|
||||
}
|
||||
} catch(e) { /* silent */ }
|
||||
}
|
||||
// #endif
|
||||
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
const res = await uni.request({ url: api('/user/info'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
userInfo.value = res.data
|
||||
uni.setStorageSync('userInfo', JSON.stringify(res.data))
|
||||
} else if (checkAuth(res)) {
|
||||
return // token 过期,已清除并跳转登录
|
||||
}
|
||||
} catch(e) { /* silent */ }
|
||||
}
|
||||
@@ -131,10 +279,26 @@ const fetchUserInfo = async () => {
|
||||
onMounted(refreshState)
|
||||
onShow(refreshState)
|
||||
|
||||
const loadMemberStatus = async () => {
|
||||
if (!token.value) return
|
||||
try {
|
||||
const res = await uni.request({ url: api('/member/status'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data) {
|
||||
memberInfo.value = { plan: res.data.plan || 'free', planName: res.data.planName || '免费版', remaining: res.data.remaining ?? 0, gravity: res.data.gravity ?? 0 }
|
||||
} else if (checkAuth(res)) {
|
||||
return
|
||||
}
|
||||
} catch(e) { /* silent */ }
|
||||
}
|
||||
|
||||
const loadStats = async () => {
|
||||
try {
|
||||
const res = await uni.request({ url: api('/interview/stats/mine'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
|
||||
if (res.statusCode === 200) stats.value = res.data
|
||||
if (res.statusCode === 200) {
|
||||
stats.value = res.data
|
||||
} else if (checkAuth(res)) {
|
||||
return
|
||||
}
|
||||
} catch(e) { console.error(e) }
|
||||
}
|
||||
|
||||
@@ -153,13 +317,53 @@ const checkAdmin = () => {
|
||||
}
|
||||
|
||||
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
|
||||
|
||||
// 引力值获取
|
||||
const showGetGravityModal = ref(false)
|
||||
const openBuyModal = () => { showGetGravityModal.value = true }
|
||||
const goH5Buy = () => {
|
||||
uni.navigateTo({ url: '/pages/member/member' })
|
||||
}
|
||||
|
||||
// 引力值明细
|
||||
const showGravityDetail = ref(false)
|
||||
const gravityTxs = ref([])
|
||||
const gravityTxPage = ref(1)
|
||||
const gravityTxTotalPages = ref(1)
|
||||
const loadGravityTxs = async (page = 1) => {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api(`/user/gravity-transactions?page=${page}&limit=20`),
|
||||
method: 'GET',
|
||||
header: { Authorization: `Bearer ${token.value}` },
|
||||
})
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data) {
|
||||
gravityTxs.value = res.data.items || []
|
||||
gravityTxPage.value = res.data.page || 1
|
||||
gravityTxTotalPages.value = res.data.totalPages || 1
|
||||
} else if (checkAuth(res)) {
|
||||
return
|
||||
}
|
||||
} catch(e) { /* silent */ }
|
||||
}
|
||||
const formatTime = (t) => {
|
||||
if (!t) return ''
|
||||
const d = new Date(t)
|
||||
return `${d.getMonth() + 1}/${d.getDate()} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
// 点击明细时打开弹窗并加载数据
|
||||
watch(showGravityDetail, (v) => { if (v) loadGravityTxs() })
|
||||
|
||||
const goCareer = () => uni.navigateTo({ url: '/pages/career/career' })
|
||||
const goHistory = () => uni.switchTab({ url: '/pages/history/history' })
|
||||
const goReviewReview = () => uni.navigateTo({ url: '/pages/review/review' })
|
||||
const goVip = () => uni.navigateTo({ url: '/pages/member/member' })
|
||||
const goResume = () => uni.navigateTo({ url: '/pages/resume/resume' })
|
||||
const goShare = () => uni.navigateTo({ url: '/pages/share/share' })
|
||||
const goSharePage = () => uni.navigateTo({ url: '/pages/share/share' })
|
||||
const goContributePage = () => uni.navigateTo({ url: '/pages/contribute/contribute' })
|
||||
const goAdmin = () => uni.navigateTo({ url: '/pages/admin/admin' })
|
||||
const goFeedback = () => uni.navigateTo({ url: '/pages/feedback/feedback' })
|
||||
const goAbout = () => uni.navigateTo({ url: '/pages/about/about' })
|
||||
|
||||
const doLogout = () => {
|
||||
@@ -197,9 +401,36 @@ const doLogout = () => {
|
||||
.guest-info { flex: 1; }
|
||||
.guest-name { font-size: 30rpx; font-weight: 600; color: #FFFFFF; }
|
||||
|
||||
.menu-area { padding: 0 32rpx 32rpx; margin-top: -40rpx; }
|
||||
/* 引力值卡片(代替原配额卡片) */
|
||||
.gravity-card { margin: -48rpx 32rpx 16rpx; position: relative; z-index: 1; }
|
||||
.gravity-card-inner {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: var(--radius-xl);
|
||||
padding: 28rpx 24rpx 24rpx;
|
||||
box-shadow: 0 8rpx 32rpx rgba(102,126,234,0.25);
|
||||
}
|
||||
.gravity-top-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8rpx; }
|
||||
.gravity-header { display: flex; align-items: center; gap: 8rpx; }
|
||||
.gravity-icon { font-size: 32rpx; }
|
||||
.gravity-label { font-size: 24rpx; color: rgba(255,255,255,0.8); font-weight: 500; }
|
||||
.gravity-num { font-size: 48rpx; font-weight: 800; color: #FFFFFF; line-height: 1; }
|
||||
.gravity-hint { font-size: 20rpx; color: rgba(255,255,255,0.6); margin-bottom: 20rpx; }
|
||||
.gravity-actions { display: flex; gap: 16rpx; }
|
||||
.gravity-btn {
|
||||
flex: 1; text-align: center; padding: 18rpx 0; border-radius: var(--radius-md);
|
||||
font-size: 26rpx; font-weight: 600; white-space: nowrap;
|
||||
}
|
||||
.gravity-btn.share { background: rgba(255,255,255,0.2); color: #FFFFFF; border: 2rpx solid rgba(255,255,255,0.3); }
|
||||
.gravity-btn.h5buy { background: #FFFFFF; color: #667eea; }
|
||||
.gravity-btn.contribute { background: rgba(255,255,255,0.15); color: #FFFFFF; border: 2rpx solid rgba(255,255,255,0.2); }
|
||||
.gravity-btn.detail { background: rgba(255,255,255,0.15); color: #FFFFFF; border: 2rpx solid rgba(255,255,255,0.2); font-size: 22rpx; padding: 18rpx 16rpx; flex: 0.5; }
|
||||
.gravity-btn:active { transform: scale(0.96); }
|
||||
|
||||
.menu-area { padding: 0 32rpx 32rpx; margin-top: 8rpx; }
|
||||
.menu-group { background: #FFFFFF; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24rpx; box-shadow: var(--shadow-sm); }
|
||||
.menu-item { display: flex; align-items: center; padding: 28rpx 32rpx; border-bottom: 1rpx solid var(--color-border); }
|
||||
.contact-btn-inner { width: 100%; background: transparent; border: none; border-radius: 0; padding: 0; margin: 0; line-height: inherit; font-size: inherit; text-align: left; display: flex; align-items: center; min-height: auto; }
|
||||
.contact-btn-inner::after { border: none; }
|
||||
.menu-item:last-child { border-bottom: none; }
|
||||
.menu-item:active { background: #F9FAFB; }
|
||||
.menu-icon-wrap { width: 60rpx; height: 60rpx; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-right: 20rpx; flex-shrink: 0; }
|
||||
@@ -216,4 +447,47 @@ const doLogout = () => {
|
||||
.logout-wrap { margin-top: 8rpx; }
|
||||
.logout-btn { background: #FFFFFF; color: var(--color-error); font-size: 28rpx; font-weight: 500; border-radius: var(--radius-md); height: 88rpx; line-height: 88rpx; border: 2rpx solid #FECACA; }
|
||||
.logout-btn:active { background: #FEF2F2; transform: scale(0.96); }
|
||||
|
||||
/* 弹窗通用 */
|
||||
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
|
||||
.modal-content { background: #FFF; border-radius: var(--radius-xl); padding: 40rpx 32rpx; width: 600rpx; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 16rpx; }
|
||||
.modal-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
|
||||
.modal-hint { font-size: 22rpx; color: #6B7280; text-align: center; }
|
||||
.modal-close { font-size: 24rpx; color: #9CA3AF; padding: 12rpx 24rpx; }
|
||||
|
||||
/* 获取引力值弹窗 - 分享/贡献方法 */
|
||||
.gp-get-method {
|
||||
width: 100%; display: flex; align-items: center; gap: 16rpx;
|
||||
background: #F9FAFB; border-radius: var(--radius-md); padding: 20rpx;
|
||||
border: 2rpx solid #E5E7EB; margin-top: 8rpx;
|
||||
}
|
||||
.gp-get-method:active { transform: scale(0.97); background: #F3F4F6; }
|
||||
.gp-method-icon-wrap {
|
||||
width: 64rpx; height: 64rpx; border-radius: var(--radius-md);
|
||||
background: #EEF2FF; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
|
||||
}
|
||||
.gp-method-icon { font-size: 32rpx; }
|
||||
.gp-method-info { flex: 1; display: flex; flex-direction: column; gap: 4rpx; }
|
||||
.gp-method-name { font-size: 26rpx; font-weight: 600; color: var(--color-text); }
|
||||
.gp-method-desc { font-size: 20rpx; color: #6B7280; line-height: 1.4; }
|
||||
.gp-method-arrow { font-size: 32rpx; color: #D1D5DB; }
|
||||
|
||||
/* 引力值明细弹窗 */
|
||||
.detail-content { width: 650rpx; max-height: 70vh; }
|
||||
.detail-list { width: 100%; max-height: 500rpx; }
|
||||
.detail-empty { text-align: center; padding: 40rpx 0; font-size: 24rpx; color: #9CA3AF; }
|
||||
.detail-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 20rpx 0; border-bottom: 1rpx solid #F3F4F6; }
|
||||
.detail-item:last-child { border-bottom: none; }
|
||||
.detail-item-left { display: flex; flex-direction: column; gap: 4rpx; flex: 1; min-width: 0; }
|
||||
.detail-item-desc { font-size: 26rpx; color: var(--color-text); font-weight: 500; }
|
||||
.detail-item-time { font-size: 20rpx; color: #9CA3AF; }
|
||||
.detail-item-amount { font-size: 30rpx; font-weight: 700; }
|
||||
.detail-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4rpx; flex-shrink: 0; margin-left: 16rpx; }
|
||||
.detail-item-balance { font-size: 20rpx; color: #9CA3AF; font-weight: 400; }
|
||||
.amount-positive { color: #10B981; }
|
||||
.amount-negative { color: #EF4444; }
|
||||
.detail-pagination { display: flex; align-items: center; justify-content: center; gap: 24rpx; width: 100%; margin-top: 8rpx; }
|
||||
.detail-page-btn { font-size: 24rpx; color: var(--color-primary); padding: 8rpx 16rpx; }
|
||||
.detail-page-btn:active { opacity: 0.6; }
|
||||
.detail-page-info { font-size: 24rpx; color: #6B7280; }
|
||||
</style>
|
||||
|
||||
@@ -105,6 +105,12 @@ const apiService = {
|
||||
request(API_ENDPOINTS.CAREER.CHAT, 'POST', { message, history }, true),
|
||||
positions: () => request(API_ENDPOINTS.CAREER.POSITIONS, 'GET', undefined, true),
|
||||
},
|
||||
virtualPayment: {
|
||||
create: (data: { type: string; quantity: number; wxCode: string }) =>
|
||||
request(API_ENDPOINTS.VIRTUAL_PAYMENT.CREATE, 'POST', data, true),
|
||||
check: (outTradeNo: string) =>
|
||||
request(API_ENDPOINTS.VIRTUAL_PAYMENT.CHECK(outTradeNo), 'GET', undefined, true),
|
||||
},
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 清除登录状态 —— token 过期 / 未授权时调用
|
||||
*/
|
||||
export function clearAuth() {
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none' })
|
||||
// 延迟跳转,避免和当前页面操作冲突
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: '/pages/login/login' })
|
||||
}, 800)
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 uni.request 的响应是否为 401,是则自动清除登录态
|
||||
* 返回 true 表示已处理 401(调用方应停止后续逻辑)
|
||||
*/
|
||||
export function checkAuth(res: any): boolean {
|
||||
if (res.statusCode === 401) {
|
||||
clearAuth()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信虚拟支付(VP)错误消息 → 用户友好中文提示
|
||||
* 覆盖 wx.requestVirtualPayment fail 回调中的常见错误码
|
||||
*/
|
||||
export function friendlyVpError(errMsg: string): string {
|
||||
if (!errMsg) return '支付失败,请重试'
|
||||
|
||||
const map: Record<string, string> = {
|
||||
'pay cancel': '你已取消支付',
|
||||
'cancel': '你已取消支付',
|
||||
'access denied': '支付权限不足,请联系客服',
|
||||
'商户收款功能受限': '商户暂不支持收款,请联系客服',
|
||||
'PRODUCT_ID_EMPTY': '商品信息错误',
|
||||
'PRODUCT_NOT_EXIST': '商品不存在',
|
||||
'PRODUCT_NOT_ONLINE': '商品未上架',
|
||||
'PAY_SIG_INVALID': '支付签名异常,请重试',
|
||||
'SIGNATURE_INVALID': '支付验证失败,请重试',
|
||||
'BALANCE_NOT_ENOUGH': '余额不足',
|
||||
'ORDER_NOT_EXIST': '订单不存在',
|
||||
'ORDER_EXPIRED': '订单已过期,请重新下单',
|
||||
'ORDER_PAYED': '订单已支付',
|
||||
'ORDER_CANCELED': '订单已取消',
|
||||
'PRICE_NOT_MATCH': '价格异常,请联系客服',
|
||||
'TOKEN_NOT_EXIST': '登录态失效,请重新登录',
|
||||
'TOKEN_EXPIRED': '登录态已过期,请重新登录',
|
||||
'TOKEN_NOT_MATCH': '登录态不匹配,请重新登录',
|
||||
'internal error': '支付异常,请稍后重试',
|
||||
'system error': '系统繁忙,请稍后重试',
|
||||
'payment limit exceeded': '已超出支付限额',
|
||||
}
|
||||
|
||||
// 尝试精确匹配
|
||||
const lower = errMsg.toLowerCase()
|
||||
for (const [key, msg] of Object.entries(map)) {
|
||||
if (lower.includes(key.toLowerCase())) return msg
|
||||
}
|
||||
|
||||
// fallback:去前缀(requestVirtualPayment:fail xxx → xxx)
|
||||
const cleaned = errMsg.replace(/^requestVirtualPayment:fail\s*/i, '').replace(/^requestPayment:fail\s*/i, '').trim()
|
||||
if (cleaned && cleaned !== errMsg) {
|
||||
for (const [key, msg] of Object.entries(map)) {
|
||||
if (cleaned.toLowerCase().includes(key.toLowerCase())) return msg
|
||||
}
|
||||
}
|
||||
|
||||
return `支付失败(${cleaned || '未知错误'})`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/** 将 ISO 时间字符串转为北京时间(UTC+8)显示 */
|
||||
export function toBeijing(iso?: string): string {
|
||||
if (!iso) return '--'
|
||||
try {
|
||||
return new Date(iso).toLocaleString('zh-CN', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
hour12: false,
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})
|
||||
} catch {
|
||||
return iso.slice(0, 16).replace('T', ' ')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
Sitemap: https://zhiyin.yzrcloud.cn/sitemap.xml
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://zhiyin.yzrcloud.cn</loc>
|
||||
<changefreq>daily</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
</urlset>
|
||||
@@ -1,8 +1,17 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { execSync } from 'child_process';
|
||||
import uni from '@dcloudio/vite-plugin-uni';
|
||||
|
||||
let appVersion = '1.0.0';
|
||||
try {
|
||||
appVersion = execSync('git describe --tags --abbrev=0 2>/dev/null || echo "1.0.0"', { encoding: 'utf8' }).trim().replace(/^v/, '');
|
||||
} catch {}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [uni()],
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(appVersion),
|
||||
},
|
||||
server: {
|
||||
port: 8888,
|
||||
strictPort: true,
|
||||
|
||||
Reference in New Issue
Block a user