Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a45822a58 | |||
| d74fc74f28 | |||
| b6323f02eb | |||
| 04b30d0024 | |||
| 13b2a764ef | |||
| 70c4f28eb5 | |||
| d37bbd7a61 | |||
| 4d54c8088c |
@@ -202,7 +202,7 @@ cd zhiyin-app && npm run build:mp-weixin && node scripts/upload-mp.js
|
|||||||
|
|
||||||
## 六、项目状态与开发阶段
|
## 六、项目状态与开发阶段
|
||||||
|
|
||||||
**当前**: Phase 1.5(商业化 + 全量部署)— v1.0.17
|
**当前**: Phase 1.5(商业化 + 全量部署)— v1.0.18(开发中)
|
||||||
|
|
||||||
| 阶段 | 状态 | 关键交付 |
|
| 阶段 | 状态 | 关键交付 |
|
||||||
|------|------|---------|
|
|------|------|---------|
|
||||||
@@ -259,7 +259,7 @@ VITE_APP_NAME=AI磁场
|
|||||||
| 账号 | 密码 | 角色 | 说明 |
|
| 账号 | 密码 | 角色 | 说明 |
|
||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| `13701190814@139.com` | `Zhiyin2024!` | admin | 管理员,可访问管理后台 |
|
| `13701190814@139.com` | `Zhiyin2024!` | admin | 管理员,可访问管理后台 |
|
||||||
| `test@yzrcloud.cn` | `123456` | user | 测试账号 |
|
| `test@yzrcloud.cn` | `123456` | user | 测试账号(普通用户,含 5 引力值) |
|
||||||
| `test@test.com` | 验证码 `123456` | admin | 旧管理员(dev 模式可用) |
|
| `test@test.com` | 验证码 `123456` | admin | 旧管理员(dev 模式可用) |
|
||||||
|
|
||||||
管理后台路径:`/pages/admin/admin`,进入后自动验证管理员身份(`onMounted` → `doVerify`)。
|
管理后台路径:`/pages/admin/admin`,进入后自动验证管理员身份(`onMounted` → `doVerify`)。
|
||||||
@@ -270,7 +270,7 @@ VITE_APP_NAME=AI磁场
|
|||||||
|
|
||||||
- 远程仓库: `http://127.0.0.1:2999/txai-dev/zhiyin.git`(本机 Gitea,带 token 认证)
|
- 远程仓库: `http://127.0.0.1:2999/txai-dev/zhiyin.git`(本机 Gitea,带 token 认证)
|
||||||
- 默认分支: `master`
|
- 默认分支: `master`
|
||||||
- 最新 tag: `v1.0.16`(小程序上传版本 v1.0.17 源自 git tag + 末位自增 1)
|
- 最新 tag: `v1.0.17`(小程序上传版本 v1.0.18 源自 git tag v1.0.17 + 末位自增 1)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
})
|
||||||
@@ -85,7 +85,13 @@ export class AdminController {
|
|||||||
filter.$or = [
|
filter.$or = [
|
||||||
{ phone: { $regex: escaped, $options: 'i' } },
|
{ phone: { $regex: escaped, $options: 'i' } },
|
||||||
{ nickname: { $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 skip = (Math.max(1, +page) - 1) * +limit
|
||||||
const [users, total] = await Promise.all([
|
const [users, total] = await Promise.all([
|
||||||
@@ -245,7 +251,7 @@ export class AdminController {
|
|||||||
|
|
||||||
@Get('admins')
|
@Get('admins')
|
||||||
async getAdmins() {
|
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 }
|
return { admins }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export class UserController {
|
|||||||
@Public()
|
@Public()
|
||||||
@Post('login')
|
@Post('login')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async login(@Body('phone') phone: string, @Body('code') code: string) {
|
async login(@Body('phone') phone: string, @Body('code') code: string, @Req() req) {
|
||||||
return this.userService.loginByPhone(phone, code)
|
return this.userService.loginByPhone(phone, code, req.ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 📧 邮箱验证码登录(H5 用)
|
// 📧 邮箱验证码登录(H5 用)
|
||||||
@@ -41,32 +41,32 @@ export class UserController {
|
|||||||
@Public()
|
@Public()
|
||||||
@Post('email-login')
|
@Post('email-login')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async emailLogin(@Body('email') email: string, @Body('code') code: string) {
|
async emailLogin(@Body('email') email: string, @Body('code') code: string, @Req() req) {
|
||||||
return this.userService.loginByEmail(email, code)
|
return this.userService.loginByEmail(email, code, req.ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 密码登录
|
// 密码登录
|
||||||
@Public()
|
@Public()
|
||||||
@Post('password-login')
|
@Post('password-login')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async passwordLogin(@Body('email') email: string, @Body('password') password: string) {
|
async passwordLogin(@Body('email') email: string, @Body('password') password: string, @Req() req) {
|
||||||
return this.userService.loginByPassword(email, password)
|
return this.userService.loginByPassword(email, password, req.ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 邮箱+密码注册
|
// 邮箱+密码注册
|
||||||
@Public()
|
@Public()
|
||||||
@Post('register')
|
@Post('register')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async register(@Body('email') email: string, @Body('password') password: string) {
|
async register(@Body('email') email: string, @Body('password') password: string, @Req() req) {
|
||||||
return this.userService.registerWithPassword(email, password)
|
return this.userService.registerWithPassword(email, password, req.ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信静默登录
|
// 微信静默登录
|
||||||
@Public()
|
@Public()
|
||||||
@Post('wx-login')
|
@Post('wx-login')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async wxLogin(@Body('code') code: string) {
|
async wxLogin(@Body('code') code: string, @Req() req) {
|
||||||
return this.userService.loginByWx(code)
|
return this.userService.loginByWx(code, undefined, req.ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('info')
|
@Get('info')
|
||||||
|
|||||||
@@ -65,13 +65,21 @@ export class User {
|
|||||||
|
|
||||||
@Prop({ default: '', select: false })
|
@Prop({ default: '', select: false })
|
||||||
password?: string
|
password?: string
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
lastLoginAt?: Date
|
||||||
|
|
||||||
|
@Prop({ default: '' })
|
||||||
|
lastLoginIp?: string
|
||||||
|
|
||||||
|
@Prop({ default: '' })
|
||||||
|
lastLoginLocation?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserSchema = SchemaFactory.createForClass(User)
|
export const UserSchema = SchemaFactory.createForClass(User)
|
||||||
|
|
||||||
UserSchema.pre('save', function (next) {
|
UserSchema.pre('save', async function () {
|
||||||
if (!this.phone && !this.wxOpenid && !this.email) {
|
if (!this.phone && !this.wxOpenid && !this.email) {
|
||||||
return next(new Error('用户必须至少有一个联系方式(手机号/微信/邮箱)'))
|
throw new Error('用户必须至少有一个联系方式(手机号/微信/邮箱)')
|
||||||
}
|
}
|
||||||
next()
|
|
||||||
})
|
})
|
||||||
@@ -6,6 +6,18 @@ import { JwtService } from '@nestjs/jwt'
|
|||||||
import { User, UserDocument } from './user.schema'
|
import { User, UserDocument } from './user.schema'
|
||||||
import { EmailService } from '../email/email.service'
|
import { EmailService } from '../email/email.service'
|
||||||
|
|
||||||
|
/** 通过 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
|
// In-memory stores
|
||||||
const codeStore = new Map<string, { code: string; expiresAt: number }>()
|
const codeStore = new Map<string, { code: string; expiresAt: number }>()
|
||||||
const emailCodeStore = new Map<string, { code: string; expiresAt: number }>()
|
const emailCodeStore = new Map<string, { code: string; expiresAt: number }>()
|
||||||
@@ -33,7 +45,7 @@ export class UserService {
|
|||||||
return { message: '验证码已发送' }
|
return { message: '验证码已发送' }
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginByPhone(phone: string, code: string) {
|
async loginByPhone(phone: string, code: string, ip?: string) {
|
||||||
const record = codeStore.get(phone)
|
const record = codeStore.get(phone)
|
||||||
if (!record || record.code !== code) {
|
if (!record || record.code !== code) {
|
||||||
throw new HttpException('验证码错误', HttpStatus.UNAUTHORIZED)
|
throw new HttpException('验证码错误', HttpStatus.UNAUTHORIZED)
|
||||||
@@ -49,10 +61,11 @@ export class UserService {
|
|||||||
user = await this.userModel.create({ phone, nickname: `用户${phone.slice(-4)}`, gravity: 5 })
|
user = await this.userModel.create({ phone, nickname: `用户${phone.slice(-4)}`, gravity: 5 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.recordLogin(user._id.toString(), ip)
|
||||||
return this.generateAuthResponse(user)
|
return this.generateAuthResponse(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginByWx(code: string, userId?: string) {
|
async loginByWx(code: string, userId?: string, ip?: string) {
|
||||||
const appid = process.env.WX_APPID
|
const appid = process.env.WX_APPID
|
||||||
const secret = process.env.WX_SECRET
|
const secret = process.env.WX_SECRET
|
||||||
if (!appid || !secret) {
|
if (!appid || !secret) {
|
||||||
@@ -84,6 +97,7 @@ export class UserService {
|
|||||||
user = await this.userModel.create({ wxOpenid: openid, nickname: '微信用户', gravity: 5 })
|
user = await this.userModel.create({ wxOpenid: openid, nickname: '微信用户', gravity: 5 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.recordLogin(user._id.toString(), ip)
|
||||||
return this.generateAuthResponse(user)
|
return this.generateAuthResponse(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +153,7 @@ export class UserService {
|
|||||||
return { message: '验证码已发送,请查收邮件' }
|
return { message: '验证码已发送,请查收邮件' }
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginByEmail(email: string, code: string) {
|
async loginByEmail(email: string, code: string, ip?: string) {
|
||||||
const record = emailCodeStore.get(email)
|
const record = emailCodeStore.get(email)
|
||||||
if (!record || record.code !== code) {
|
if (!record || record.code !== code) {
|
||||||
throw new HttpException('验证码错误', HttpStatus.UNAUTHORIZED)
|
throw new HttpException('验证码错误', HttpStatus.UNAUTHORIZED)
|
||||||
@@ -158,21 +172,23 @@ export class UserService {
|
|||||||
const nick = email.split('@')[0]
|
const nick = email.split('@')[0]
|
||||||
user = await this.userModel.create({ email, nickname: nick, remaining: 0, gravity: 5 })
|
user = await this.userModel.create({ email, nickname: nick, remaining: 0, gravity: 5 })
|
||||||
}
|
}
|
||||||
|
await this.recordLogin(user._id.toString(), ip)
|
||||||
return { ...this.generateAuthResponse(user), isNew, hasPassword: !!user.password }
|
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()
|
const user = await this.userModel.findOne({ email }).select('+password').exec()
|
||||||
if (!user) throw new HttpException('账号不存在', HttpStatus.NOT_FOUND)
|
if (!user) throw new HttpException('账号不存在', HttpStatus.NOT_FOUND)
|
||||||
if (!user.password) throw new HttpException('该账号未设置密码,请使用验证码登录', HttpStatus.UNAUTHORIZED)
|
if (!user.password) throw new HttpException('该账号未设置密码,请使用验证码登录', HttpStatus.UNAUTHORIZED)
|
||||||
const match = await bcrypt.compare(password, user.password)
|
const match = await bcrypt.compare(password, user.password)
|
||||||
if (!match) throw new HttpException('密码错误', HttpStatus.UNAUTHORIZED)
|
if (!match) throw new HttpException('密码错误', HttpStatus.UNAUTHORIZED)
|
||||||
|
await this.recordLogin(user._id.toString(), ip)
|
||||||
return this.generateAuthResponse(user)
|
return this.generateAuthResponse(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 📝 邮箱+密码注册
|
// 📝 邮箱+密码注册
|
||||||
async registerWithPassword(email: string, password: string) {
|
async registerWithPassword(email: string, password: string, ip?: string) {
|
||||||
if (!email || !email.includes('@')) {
|
if (!email || !email.includes('@')) {
|
||||||
throw new HttpException('请输入正确的邮箱地址', HttpStatus.BAD_REQUEST)
|
throw new HttpException('请输入正确的邮箱地址', HttpStatus.BAD_REQUEST)
|
||||||
}
|
}
|
||||||
@@ -187,11 +203,13 @@ export class UserService {
|
|||||||
// 已有验证码注册的用户,补充设置密码
|
// 已有验证码注册的用户,补充设置密码
|
||||||
existing.password = await bcrypt.hash(password, 10)
|
existing.password = await bcrypt.hash(password, 10)
|
||||||
await existing.save()
|
await existing.save()
|
||||||
|
await this.recordLogin(existing._id.toString(), ip)
|
||||||
return this.generateAuthResponse(existing)
|
return this.generateAuthResponse(existing)
|
||||||
}
|
}
|
||||||
const nick = email.split('@')[0]
|
const nick = email.split('@')[0]
|
||||||
const hashed = await bcrypt.hash(password, 10)
|
const hashed = await bcrypt.hash(password, 10)
|
||||||
const user = await this.userModel.create({ email, nickname: nick, password: hashed, remaining: 0, gravity: 5 })
|
const user = await this.userModel.create({ email, nickname: nick, password: hashed, remaining: 0, gravity: 5 })
|
||||||
|
await this.recordLogin(user._id.toString(), ip)
|
||||||
return this.generateAuthResponse(user)
|
return this.generateAuthResponse(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +237,17 @@ export class UserService {
|
|||||||
|
|
||||||
getModel() { return this.userModel }
|
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) {
|
async getUsage(userId: string) {
|
||||||
const user = await this.userModel.findById(userId).exec()
|
const user = await this.userModel.findById(userId).exec()
|
||||||
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
|
||||||
@@ -260,6 +289,9 @@ export class UserService {
|
|||||||
freeOptimizeUsed: user.freeOptimizeUsed ?? 0,
|
freeOptimizeUsed: user.freeOptimizeUsed ?? 0,
|
||||||
shareCredits: user.shareCredits ?? 0,
|
shareCredits: user.shareCredits ?? 0,
|
||||||
gravity: user.gravity ?? 0,
|
gravity: user.gravity ?? 0,
|
||||||
|
lastLoginAt: user.lastLoginAt,
|
||||||
|
lastLoginIp: user.lastLoginIp,
|
||||||
|
lastLoginLocation: user.lastLoginLocation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# 职引项目 · 状态报告 v4.8
|
# 职引项目 · 状态报告 v4.9
|
||||||
|
|
||||||
> **项目版本**: v4.8
|
> **项目版本**: v4.9
|
||||||
> **更新时间**: 2026-06-21
|
> **更新时间**: 2026-06-22
|
||||||
> **项目状态**: ✅ SEO 优化 + 微信分享全面开启 + 全量部署
|
> **项目状态**: ✅ Mongoose 8 兼容修复 + v1.0.17 发布
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -224,6 +224,7 @@
|
|||||||
|
|
||||||
| 日期 | 版本 | 变更内容 | 操作者 |
|
| 日期 | 版本 | 变更内容 | 操作者 |
|
||||||
|------|------|----------|--------|
|
|------|------|----------|--------|
|
||||||
|
| 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.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-21 | v4.7 | 按量购买引力值体系重构(¥5/份取代月订阅);member.vue 完全重写;微信小程序剪贴板购买链路;客服按钮;管理后台字段全面完善;代码清理;测试数据清理;后端/H5/小程序全量部署上线 | AI |
|
||||||
| 2026-06-19 | v4.6 | 引力值体系统一:VIP 取消无限面试改为月度引力值消耗;管理后台全面完善(搜索/筛选/分页/CRUD/分析tab/岗位描述字段) | AI |
|
| 2026-06-19 | v4.6 | 引力值体系统一:VIP 取消无限面试改为月度引力值消耗;管理后台全面完善(搜索/筛选/分页/CRUD/分析tab/岗位描述字段) | AI |
|
||||||
|
|||||||
+23
-2
@@ -1,15 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch } from '@dcloudio/uni-app'
|
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch((options) => {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
initPrivacy()
|
initPrivacy()
|
||||||
|
handleLaunchParams(options?.query)
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
handleH5UrlParams()
|
handleH5UrlParams()
|
||||||
// #endif
|
// #endif
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
onShow((options) => {
|
||||||
|
if (options?.query) {
|
||||||
|
handleLaunchParams(options.query)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
function handleH5UrlParams() {
|
function handleH5UrlParams() {
|
||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
@@ -28,6 +37,18 @@ function handleH5UrlParams() {
|
|||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #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() {
|
function initPrivacy() {
|
||||||
if (wx.onNeedPrivacyAuthorization) {
|
if (wx.onNeedPrivacyAuthorization) {
|
||||||
wx.onNeedPrivacyAuthorization((resolve) => {
|
wx.onNeedPrivacyAuthorization((resolve) => {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
<!-- 用户 -->
|
<!-- 用户 -->
|
||||||
<view v-if="tab === 'users'" class="section">
|
<view v-if="tab === 'users'" class="section">
|
||||||
<view class="search-bar">
|
<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>
|
<button class="search-btn" @click="loadUsers">搜索</button>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-list" v-if="!usersLoading">
|
<view class="user-list" v-if="!usersLoading">
|
||||||
@@ -87,6 +87,9 @@
|
|||||||
<text class="meta-tag email" v-if="u.email">{{ u.email }}</text>
|
<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>
|
<text class="meta-tag" v-if="u.wxOpenid">openid:{{ u.wxOpenid.slice(0,12) }}..</text>
|
||||||
</view>
|
</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">
|
<view class="user-meta-row">
|
||||||
<text class="meta-tag">引力:{{ u.gravity ?? 0 }}</text>
|
<text class="meta-tag">引力:{{ u.gravity ?? 0 }}</text>
|
||||||
<text class="meta-tag">面试:{{ u.interviewCount ?? 0 }}次</text>
|
<text class="meta-tag">面试:{{ u.interviewCount ?? 0 }}次</text>
|
||||||
@@ -94,10 +97,15 @@
|
|||||||
<text class="meta-tag share" v-if="u.shareCredits > 0">分享:{{ u.shareCredits }}</text>
|
<text class="meta-tag share" v-if="u.shareCredits > 0">分享:{{ u.shareCredits }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-meta-row time-row">
|
<view class="user-meta-row time-row">
|
||||||
<text class="time-label">注册:{{ u.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
<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.vipExpireAt">到期:{{ u.vipExpireAt?.slice(0,10) }}</text>
|
||||||
<text class="time-label" v-if="u.sprintExpireAt">冲刺到期:{{ u.sprintExpireAt?.slice(0,10) }}</text>
|
<text class="time-label" v-if="u.sprintExpireAt">冲刺到期:{{ u.sprintExpireAt?.slice(0,10) }}</text>
|
||||||
</view>
|
</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">
|
<view class="user-actions">
|
||||||
<text class="user-action-btn" v-if="u.plan === 'free'" @click="setVip(u._id)">设为会员</text>
|
<text class="user-action-btn" v-if="u.plan === 'free'" @click="setVip(u._id)">设为会员</text>
|
||||||
<text class="user-action-btn credit" @click="openCreditModal(u)">调整额度</text>
|
<text class="user-action-btn credit" @click="openCreditModal(u)">调整额度</text>
|
||||||
@@ -130,8 +138,8 @@
|
|||||||
<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>
|
||||||
<view class="iv-meta">
|
<view class="iv-meta">
|
||||||
<text class="time-label">开始:{{ iv.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label">开始:{{ toBeijing(iv.createdAt) }}</text>
|
||||||
<text class="time-label" v-if="iv.updatedAt && iv.updatedAt !== iv.createdAt">更新:{{ iv.updatedAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label" v-if="iv.updatedAt && iv.updatedAt !== iv.createdAt">更新:{{ toBeijing(iv.updatedAt) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="iv-summary" v-if="iv.summary">{{ iv.summary.slice(0,60) }}{{ iv.summary.length > 60 ? '...' : '' }}</text>
|
<text class="iv-summary" v-if="iv.summary">{{ iv.summary.slice(0,60) }}{{ iv.summary.length > 60 ? '...' : '' }}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -160,8 +168,8 @@
|
|||||||
<text class="resume-tag paid" v-if="r.paidDownload">付费下载</text>
|
<text class="resume-tag paid" v-if="r.paidDownload">付费下载</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="resume-meta time-row">
|
<view class="resume-meta time-row">
|
||||||
<text class="time-label">创建:{{ r.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label">创建:{{ toBeijing(r.createdAt) }}</text>
|
||||||
<text class="time-label" v-if="r.updatedAt && r.updatedAt !== r.createdAt">更新:{{ r.updatedAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label" v-if="r.updatedAt && r.updatedAt !== r.createdAt">更新:{{ toBeijing(r.updatedAt) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="resume-actions">
|
<view class="resume-actions">
|
||||||
<text class="admin-action-btn del" @click="deleteResume(r._id, r.title)">删除</text>
|
<text class="admin-action-btn del" @click="deleteResume(r._id, r.title)">删除</text>
|
||||||
@@ -200,14 +208,14 @@
|
|||||||
<text class="meta-tag">渠道:{{ o.channel || '--' }}</text>
|
<text class="meta-tag">渠道:{{ o.channel || '--' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-meta-row time-row">
|
<view class="order-meta-row time-row">
|
||||||
<text class="time-label">创建:{{ o.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label">创建:{{ toBeijing(o.createdAt) }}</text>
|
||||||
<text class="time-label" v-if="o.paidAt">支付:{{ o.paidAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label" v-if="o.paidAt">支付:{{ toBeijing(o.paidAt) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-meta-row" v-if="o.wxTransactionId">
|
<view class="order-meta-row" v-if="o.wxTransactionId">
|
||||||
<text class="time-label">微信单号:{{ o.wxTransactionId }}</text>
|
<text class="time-label">微信单号:{{ o.wxTransactionId }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-meta-row" v-if="o.status === 'refunded'">
|
<view class="order-meta-row" v-if="o.status === 'refunded'">
|
||||||
<text class="time-label refund-label">退款:¥{{ (o.refundAmount/100).toFixed(1) }} {{ o.refundedAt?.slice(0,16).replace('T',' ') }}</text>
|
<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>
|
<text class="time-label" v-if="o.refundReason">原因:{{ o.refundReason }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-actions-bar">
|
<view class="order-actions-bar">
|
||||||
@@ -297,6 +305,8 @@
|
|||||||
<text>每月引力值</text>
|
<text>每月引力值</text>
|
||||||
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.gravityPerMonth" />
|
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.gravityPerMonth" />
|
||||||
</view>
|
</view>
|
||||||
|
<view class="cfg-row">
|
||||||
|
<text>面试额度/月</text>
|
||||||
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.credits.interview" />
|
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.credits.interview" />
|
||||||
</view>
|
</view>
|
||||||
<view class="cfg-row">
|
<view class="cfg-row">
|
||||||
@@ -346,7 +356,7 @@
|
|||||||
<text class="share-credited">有效 {{ r.creditedCount }}</text>
|
<text class="share-credited">有效 {{ r.creditedCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="share-meta-row time-row">
|
<view class="share-meta-row time-row">
|
||||||
<text class="time-label">创建:{{ r.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label">创建:{{ toBeijing(r.createdAt) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -365,8 +375,8 @@
|
|||||||
<text class="meta-tag" :class="v.credited ? 'badge-done' : 'badge-pend'">{{ v.credited ? '已积分' : '未积分' }}</text>
|
<text class="meta-tag" :class="v.credited ? 'badge-done' : 'badge-pend'">{{ v.credited ? '已积分' : '未积分' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="share-meta-row time-row">
|
<view class="share-meta-row time-row">
|
||||||
<text class="time-label">访问:{{ v.createdAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label">访问:{{ toBeijing(v.createdAt) }}</text>
|
||||||
<text class="time-label" v-if="v.creditedAt">积分:{{ v.creditedAt?.slice(0,16).replace('T',' ') }}</text>
|
<text class="time-label" v-if="v.creditedAt">积分:{{ toBeijing(v.creditedAt) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -488,24 +498,55 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="section-label">当前管理员</view>
|
<view class="section-label">当前管理员</view>
|
||||||
<view class="user-list">
|
<view class="user-list">
|
||||||
<view class="admin-row" v-for="a in adminList" :key="a._id">
|
<view class="user-row" v-for="a in adminList" :key="a._id">
|
||||||
<text class="admin-phone">{{ a.phone || '--' }}</text>
|
<view class="user-main">
|
||||||
<text class="admin-name">{{ a.nickname || '--' }}</text>
|
<text class="user-phone">{{ a.phone || '--' }}</text>
|
||||||
<text class="admin-email" v-if="a.email">{{ a.email }}</text>
|
<text class="user-name">{{ a.nickname || '--' }}</text>
|
||||||
<text class="admin-badge" v-if="a.isSystemAdmin">系统</text>
|
<text class="user-badge-role">管理</text>
|
||||||
<text class="time-label" style="margin-left:auto">设置:{{ a.createdAt?.slice(0,10) }}</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>
|
</view>
|
||||||
<text class="empty-text" v-if="adminList.length === 0">暂无管理员</text>
|
<text class="empty-text" v-if="adminList.length === 0">暂无管理员</text>
|
||||||
</view>
|
</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="user-list" v-if="searchResult">
|
||||||
<view class="admin-row">
|
<view class="user-row">
|
||||||
<text class="admin-phone">{{ searchResult.phone || '--' }}</text>
|
<view class="user-main">
|
||||||
<text class="admin-name">{{ searchResult.nickname || '--' }}</text>
|
<text class="user-phone">{{ searchResult.phone || '--' }}</text>
|
||||||
<text class="admin-email" v-if="searchResult.email">{{ searchResult.email }}</text>
|
<text class="user-name">{{ searchResult.nickname || '--' }}</text>
|
||||||
<text class="admin-set-btn" v-if="searchResult.role !== 'admin'" @click="setAdmin(searchResult._id)">设为管理员</text>
|
<text class="user-badge-role" v-if="searchResult.role === 'admin'">管理</text>
|
||||||
<text class="admin-set-btn done" v-else>已是管理员</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>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -514,6 +555,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, reactive } from 'vue'
|
import { ref, computed, onMounted, reactive } from 'vue'
|
||||||
import { api, API_ENDPOINTS } from '../../config'
|
import { api, API_ENDPOINTS } from '../../config'
|
||||||
|
import { toBeijing } from '../../utils/format'
|
||||||
|
|
||||||
const verified = ref(false)
|
const verified = ref(false)
|
||||||
const adminName = ref('')
|
const adminName = ref('')
|
||||||
@@ -703,6 +745,7 @@ const switchTab = (t) => {
|
|||||||
if (t === 'pricing') loadPricing()
|
if (t === 'pricing') loadPricing()
|
||||||
if (t === 'orders') loadOrders()
|
if (t === 'orders') loadOrders()
|
||||||
if (t === 'analysis') loadAnalysis()
|
if (t === 'analysis') loadAnalysis()
|
||||||
|
if (t === 'share') loadShareRecords()
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadUsers = async () => {
|
const loadUsers = async () => {
|
||||||
@@ -1028,6 +1071,13 @@ const doAdjustCredits = async () => {
|
|||||||
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
|
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const copyId = (id) => {
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: id,
|
||||||
|
success: () => uni.showToast({ title: 'ID 已复制', icon: 'success' }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => { doVerify() })
|
onMounted(() => { doVerify() })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -1080,9 +1130,6 @@ onMounted(() => { doVerify() })
|
|||||||
.iv-tag.score { background: #EEF2FF; color: var(--color-primary); }
|
.iv-tag.score { background: #EEF2FF; color: var(--color-primary); }
|
||||||
.iv-tag.filler { background: #FFF7ED; color: #D97706; }
|
.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; }
|
.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 { 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-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); }
|
.admin-badge { font-size: 18rpx; background: var(--color-primary); color: #FFF; padding: 2rpx 10rpx; border-radius: var(--radius-round); }
|
||||||
@@ -1162,6 +1209,7 @@ onMounted(() => { doVerify() })
|
|||||||
.meta-tag { font-size: 18rpx; background: #F3F4F6; color: var(--color-text-tertiary); padding: 2rpx 10rpx; border-radius: var(--radius-round); }
|
.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.email { background: #EEF2FF; color: var(--color-primary); }
|
||||||
.meta-tag.share { background: #FFF7ED; color: #D97706; }
|
.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-done { background: #ECFDF5; color: #059669; }
|
||||||
.meta-tag.badge-pend { background: #FEF3C7; color: #D97706; }
|
.meta-tag.badge-pend { background: #FEF3C7; color: #D97706; }
|
||||||
.time-row { display: flex; flex-wrap: wrap; gap: 12rpx; }
|
.time-row { display: flex; flex-wrap: wrap; gap: 12rpx; }
|
||||||
|
|||||||
@@ -175,7 +175,13 @@ import { onShow } from '@dcloudio/uni-app'
|
|||||||
import { api } from '../../config'
|
import { api } from '../../config'
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
onShareAppMessage(() => ({ title: '职引 - 个人中心 | AI模拟面试', path: '/pages/user/user' }))
|
const shareCodeRef = ref('')
|
||||||
|
onShareAppMessage(() => {
|
||||||
|
const path = shareCodeRef.value
|
||||||
|
? `/pages/user/user?share=${shareCodeRef.value}`
|
||||||
|
: '/pages/user/user'
|
||||||
|
return { title: '职引 - 个人中心 | AI模拟面试', path }
|
||||||
|
})
|
||||||
onShareTimeline(() => ({ title: '职引 - 个人中心 | AI模拟面试' }))
|
onShareTimeline(() => ({ title: '职引 - 个人中心 | AI模拟面试' }))
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
@@ -199,8 +205,29 @@ const refreshState = () => {
|
|||||||
loadMemberStatus()
|
loadMemberStatus()
|
||||||
checkAdmin()
|
checkAdmin()
|
||||||
fetchUserInfo()
|
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) return
|
||||||
|
const data = res.data?.data || res.data
|
||||||
|
if (data.shareCode) {
|
||||||
|
shareCodeRef.value = data.shareCode
|
||||||
|
}
|
||||||
|
} catch(e) { /* silent */ }
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
|
||||||
const fetchUserInfo = async () => {
|
const fetchUserInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({ url: api('/user/info'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
|
const res = await uni.request({ url: api('/user/info'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
|
||||||
|
|||||||
@@ -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', ' ')
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user