v1.0.18: 小程序虚拟支付上线 + 定价调整为整数
- 新增虚拟支付 (short_series_coin 代币模式,1:1 兑换) - 后端 修复为正确 VP 格式,返回 mode 参数 - 前端 VP 调用补齐 、 格式调整 - 套餐价格调整:成长版 ¥19.9 → ¥19,冲刺版 ¥49.9 → ¥49 - 数据库定价同步更新为 1900/4900(分) - 会员页未登录时也拉取 ,套餐对比数据由服务端返回 - 文档统一更新定价和 VP 说明 - 修正 AGENTS.md 引力值数据(250/600 → 80/200)
This commit is contained in:
@@ -96,14 +96,15 @@ zhiyin/
|
|||||||
- 主用不可用时自动切换(在 `ai` 模块处理)
|
- 主用不可用时自动切换(在 `ai` 模块处理)
|
||||||
- 环境变量: `AI_PRIMARY_KEY`, `AI_BACKUP_KEY`
|
- 环境变量: `AI_PRIMARY_KEY`, `AI_BACKUP_KEY`
|
||||||
|
|
||||||
### 支付(微信支付 v3)
|
### 支付(微信支付 v3 + 虚拟支付)
|
||||||
- Native 支付(H5 扫码): `POST /payment/create-product`(按量购买引力值)
|
- Native 支付(H5 扫码): `POST /payment/create-product`(按量购买引力值)
|
||||||
- JSAPI 支付(小程序内): `POST /payment/jsapi-product`(按量购买引力值)
|
- JSAPI 支付(小程序内): `POST /payment/jsapi-product`(按量购买引力值)
|
||||||
|
- 虚拟支付(小程序内直接购买): `POST /virtual-payment/create`(mode=`short_series_coin`,代币名「引力值」,1 币 = 1 元)
|
||||||
- 支付回调: `POST /payment/notify`(@Public,验签 + 解密 + 自动到账)
|
- 支付回调: `POST /payment/notify`(@Public,验签 + 解密 + 自动到账)
|
||||||
- 支付结果轮询: `GET /payment/check/:outTradeNo`
|
- 支付结果轮询: `GET /payment/check/:outTradeNo`
|
||||||
- 产品定价: `GET /member/plans`(含 products 字段,定义引力值单价和赠送量)
|
- 产品定价: `GET /member/plans`(含 products 字段,定义引力值单价和赠送量)
|
||||||
- 需要微信商户证书文件(通过 postbuild 复制到 dist)
|
- 需要微信商户证书文件(通过 postbuild 复制到 dist)
|
||||||
- **注意**: 当前会员体系已从按月订阅制改为按量购买引力值制(小程序内复制链接到浏览器打开购买,H5 直接扫码支付)
|
- **注意**: 当前会员体系已从按月订阅制改为按量购买引力值制(小程序内虚拟支付直接购买,H5 扫码支付)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -284,7 +285,7 @@ VITE_APP_NAME=AI磁场
|
|||||||
6. **API 限流**: 100 次/60 秒(在 `app.module.ts` 中配置),注意避免在定时任务和批量操作中被限
|
6. **API 限流**: 100 次/60 秒(在 `app.module.ts` 中配置),注意避免在定时任务和批量操作中被限
|
||||||
7. **验证码**: 生产模式(`NODE_ENV=production`)使用真实 SMTP 发邮件验证码;非生产模式手机验证码固定为 `123456`、邮件验证码在响应中返回 `devCode`
|
7. **验证码**: 生产模式(`NODE_ENV=production`)使用真实 SMTP 发邮件验证码;非生产模式手机验证码固定为 `123456`、邮件验证码在响应中返回 `devCode`
|
||||||
8. **MongoDB**: 8 个核心集合 + 2 个分享集合
|
8. **MongoDB**: 8 个核心集合 + 2 个分享集合
|
||||||
9. **引力值体系**: 所有计划统一走引力值消耗(面试 5、优化 3、下载 2)。VIP 不再免额度,成长版每月 250 引力值,冲刺版每月 600 引力值,每日凌晨 2 点定时补给。免费用户注册送 5 引力值。小程序内通过分享得引力值/贡献面经/复制官网链接到浏览器打开购买三种方式获取引力值;H5 直接扫码支付按量购买(¥5/份)。
|
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 后经常丢失这行声明,需手动补回
|
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`
|
11. **H5 构建 assets 清理**: `assets/` 中的旧 hash 文件不能随意删除——`index-*.js`(主 bundle)动态 import 了所有 page chunk,删除仍在引用的文件会导致浏览器 `NS_ERROR_CORRUPTED_CONTENT`
|
||||||
12. **管理后台自动验证**: `admin.vue` 中 `onMounted` 自动调用 `doVerify()`,进入后台即检测 JWT 中 `role` 是否为 `admin`,不再需要手动点击"验证管理员身份"按钮
|
12. **管理后台自动验证**: `admin.vue` 中 `onMounted` 自动调用 `doVerify()`,进入后台即检测 JWT 中 `role` 是否为 `admin`,不再需要手动点击"验证管理员身份"按钮
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ interface PricingConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_PRICING: PricingConfig = {
|
const DEFAULT_PRICING: PricingConfig = {
|
||||||
interview: { pricePerSession: 500, creditsPerPurchase: 1 },
|
interview: { pricePerSession: 600, creditsPerPurchase: 1 },
|
||||||
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 },
|
resumeOptimize: { freeLimit: 3, pricePerOptimize: 400, creditsPerPurchase: 1 },
|
||||||
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
|
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
|
||||||
gravityRates: { interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 },
|
gravityRates: { interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 },
|
||||||
plans: {
|
plans: {
|
||||||
growth: { price: 1990, durationDays: 30, gravityPerMonth: 250, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 数字人面试每次 3 引力值(折扣价)', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'] },
|
growth: { price: 1900, durationDays: 30, gravityPerMonth: 80, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 模拟面试(每次消耗 5 引力值,无限次)', '详细面试报告(四维评分 + 语音复盘)', '进步轨迹雷达图 + 打卡日历', '每日一题推送 + 参考思路', '公司真题库', '每月赠送 80 引力值,可用于面试/优化/下载'] },
|
||||||
sprint: { price: 4990, durationDays: 30, gravityPerMonth: 600, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先', '简历优化 50 次/月', '简历下载 30 次/月'] },
|
sprint: { price: 4900, durationDays: 30, gravityPerMonth: 200, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', 'AI 语音深度分析(语气词/语速/停顿检测)', '技能缺口分析报告', '公司真题库精选', '每月赠送 200 引力值,可用于面试/优化/下载'] },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -162,14 +162,14 @@
|
|||||||
- [x] 面经贡献系统 + 公司题库
|
- [x] 面经贡献系统 + 公司题库
|
||||||
- [x] 每日一题(API 读取)
|
- [x] 每日一题(API 读取)
|
||||||
- [x] 手机/邮箱/密码/微信登录
|
- [x] 手机/邮箱/密码/微信登录
|
||||||
- [x] 会员系统(¥19.9 成长版)
|
- [x] 会员系统(¥19 成长版)
|
||||||
- [x] 微信支付对接(Native + JSAPI)
|
- [x] 微信支付对接(Native + JSAPI)
|
||||||
- [x] 公司真题库(用户贡献驱动)
|
- [x] 公司真题库(用户贡献驱动)
|
||||||
- [x] **面试复盘(音频 ASR + AI 评析 + 口语分析)**
|
- [x] **面试复盘(音频 ASR + AI 评析 + 口语分析)**
|
||||||
|
|
||||||
### P1(待实现)
|
### P1(待实现)
|
||||||
- [ ] 每日一题定时推送
|
- [ ] 每日一题定时推送
|
||||||
- [ ] 冲刺版 ¥49.9/月
|
- [ ] 冲刺版 ¥49/月
|
||||||
- [ ] AI 岗位专属题库
|
- [ ] AI 岗位专属题库
|
||||||
- [ ] 连续打卡激励(7 天解锁高级报告)
|
- [ ] 连续打卡激励(7 天解锁高级报告)
|
||||||
- [ ] 生产环境部署
|
- [ ] 生产环境部署
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
},
|
},
|
||||||
"plans": {
|
"plans": {
|
||||||
"growth": {
|
"growth": {
|
||||||
"price": 1990,
|
"price": 1900,
|
||||||
"durationDays": 30,
|
"durationDays": 30,
|
||||||
"credits": {
|
"credits": {
|
||||||
"interview": 999,
|
"interview": 999,
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sprint": {
|
"sprint": {
|
||||||
"price": 4990,
|
"price": 4900,
|
||||||
"durationDays": 30,
|
"durationDays": 30,
|
||||||
"credits": {
|
"credits": {
|
||||||
"interview": 999,
|
"interview": 999,
|
||||||
@@ -267,7 +267,7 @@ Puppeteer PDF 生成 (`resume-pdf.service.ts`):
|
|||||||
│ 首次面试免费 [✓] │
|
│ 首次面试免费 [✓] │
|
||||||
│ │
|
│ │
|
||||||
│ ─── 成长版 ─── │
|
│ ─── 成长版 ─── │
|
||||||
│ 价格 ¥ [ 19.9 ] /月 │
|
│ 价格 ¥ [ 19 ] /月 │
|
||||||
│ 面试额度 [ 999 ] 次 │
|
│ 面试额度 [ 999 ] 次 │
|
||||||
│ 优化额度 [ 20 ] 次 │
|
│ 优化额度 [ 20 ] 次 │
|
||||||
│ 下载额度 [ 10 ] 次 │
|
│ 下载额度 [ 10 ] 次 │
|
||||||
|
|||||||
@@ -65,14 +65,14 @@
|
|||||||
| 版本 | 价格 | 核心权益 | 定位 |
|
| 版本 | 价格 | 核心权益 | 定位 |
|
||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| 免费版 | ¥0 | 日 2 次基础面试(通用题库,5 轮/次) | 引流 |
|
| 免费版 | ¥0 | 日 2 次基础面试(通用题库,5 轮/次) | 引流 |
|
||||||
| **成长版** | **¥19.9/月** | 无限面试 + 高级报告 + 进步轨迹 + 真题库 | **主力** |
|
| **成长版** | **¥19/月** | 无限面试 + 高级报告 + 进步轨迹 + 真题库 | **主力** |
|
||||||
|
|
||||||
> 冲刺版 ¥49.9/月(含真人导师点评 + 简历精修)待实现
|
> 冲刺版 ¥49/月(含真人导师点评 + 简历精修)待实现
|
||||||
|
|
||||||
### 3.2 收入来源
|
### 3.2 收入来源
|
||||||
|
|
||||||
```
|
```
|
||||||
C 端订阅收入(基本盘:¥19.9 × 付费用户数)
|
C 端订阅收入(基本盘:¥19 × 付费用户数)
|
||||||
↓
|
↓
|
||||||
├── B 端合作(高校就业办/求职机构)
|
├── B 端合作(高校就业办/求职机构)
|
||||||
├── 内容变现(面经课程)
|
├── 内容变现(面经课程)
|
||||||
@@ -83,9 +83,9 @@ C 端订阅收入(基本盘:¥19.9 × 付费用户数)
|
|||||||
|
|
||||||
| 阶段 | C 端 | B 端 | 月收入 |
|
| 阶段 | C 端 | B 端 | 月收入 |
|
||||||
|------|------|------|--------|
|
|------|------|------|--------|
|
||||||
| MVP 上线(6-8月) | 200 付费 × ¥19.9 | 0 | ¥3,980 |
|
| MVP 上线(6-8月) | 200 付费 × ¥19 | 0 | ¥3,800 |
|
||||||
| 秋招旺季(9-11月) | 1000 付费 × ¥19.9 | 2 高校 ¥5000 | ¥29,900 |
|
| 秋招旺季(9-11月) | 1000 付费 × ¥19 | 2 高校 ¥5000 | ¥24,000 |
|
||||||
| 稳定运营(次年) | 2000 付费 × ¥19.9 | 5 机构 + 企业 | ¥60,000+ |
|
| 稳定运营(次年) | 2000 付费 × ¥19 | 5 机构 + 企业 | ¥48,000+ |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -103,14 +103,14 @@ C 端订阅收入(基本盘:¥19.9 × 付费用户数)
|
|||||||
| 面经贡献系统 + 公司题库 | ✅ 完成 |
|
| 面经贡献系统 + 公司题库 | ✅ 完成 |
|
||||||
| 每日一题(API) | ✅ 完成 |
|
| 每日一题(API) | ✅ 完成 |
|
||||||
| 简历诊断 + 优化 | ✅ 完成 |
|
| 简历诊断 + 优化 | ✅ 完成 |
|
||||||
| 会员系统(成长版 ¥19.9/月) | ✅ 完成 |
|
| 会员系统(成长版 ¥19/月) | ✅ 完成 |
|
||||||
| 微信支付(Native + JSAPI) | ✅ 完成 |
|
| 微信支付(Native + JSAPI) | ✅ 完成 |
|
||||||
|
|
||||||
### 待实现
|
### 待实现
|
||||||
| 功能 | 计划 |
|
| 功能 | 计划 |
|
||||||
|------|------|
|
|------|------|
|
||||||
| 每日一题定时推送(微信订阅消息) | Phase 1 |
|
| 每日一题定时推送(微信订阅消息) | Phase 1 |
|
||||||
| 冲刺版 ¥49.9/月 | Phase 1.5 |
|
| 冲刺版 ¥49/月 | Phase 1.5 |
|
||||||
| 微信登录真实 appid 联调 | Phase 1 |
|
| 微信登录真实 appid 联调 | Phase 1 |
|
||||||
| 生产环境部署 | Phase 1 |
|
| 生产环境部署 | Phase 1 |
|
||||||
| AI 岗位专属题库 | Phase 2 |
|
| AI 岗位专属题库 | Phase 2 |
|
||||||
|
|||||||
+2
-2
@@ -28,7 +28,7 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
|||||||
## 二、Phase 0: 战略升级(✅ 已完成)
|
## 二、Phase 0: 战略升级(✅ 已完成)
|
||||||
|
|
||||||
**已完成**:
|
**已完成**:
|
||||||
- [x] 定价重构:免费 + ¥19.9/月 两段式
|
- [x] 定价重构:免费 + ¥19/月 两段式
|
||||||
- [x] 三层壁垒设计(数据飞轮 + 留存入围 + 合规信任)
|
- [x] 三层壁垒设计(数据飞轮 + 留存入围 + 合规信任)
|
||||||
- [x] 收入来源多元化策略
|
- [x] 收入来源多元化策略
|
||||||
- [x] 文档体系全面更新
|
- [x] 文档体系全面更新
|
||||||
@@ -54,7 +54,7 @@ Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
|
|||||||
### 3.3 会员系统重构
|
### 3.3 会员系统重构
|
||||||
| 功能 | 描述 | 状态 |
|
| 功能 | 描述 | 状态 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| 定价更新 | ¥19.9/月 成长版 | ✅ 完成 |
|
| 定价更新 | ¥19/月 成长版 | ✅ 完成 |
|
||||||
| 会员权益对比 | 三版对比展示 | ✅ 完成 |
|
| 会员权益对比 | 三版对比展示 | ✅ 完成 |
|
||||||
| 微信支付对接 | Native + JSAPI 支付 | ✅ 完成 |
|
| 微信支付对接 | Native + JSAPI 支付 | ✅ 完成 |
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
|
||||||
<view class="page fade-in">
|
<view class="page fade-in">
|
||||||
<view class="placeholder-wrap">
|
<!-- 状态栏:当前方案 + 引力值 -->
|
||||||
<text class="placeholder-icon">✨</text>
|
<view class="status-bar">
|
||||||
<text class="placeholder-text">功能已整合到各模块</text>
|
<view class="status-left">
|
||||||
<text class="placeholder-hint">请返回使用引力值充值功能</text>
|
<text class="status-label">当前方案</text>
|
||||||
<text class="placeholder-back" @click="goBack">返回首页</text>
|
<text class="status-plan">{{ currentPlanName || '免费版' }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="status-right">
|
||||||
|
<text class="grav-label">⚡ 引力值</text>
|
||||||
|
<text class="grav-num">{{ gravity }}</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
|
||||||
<!-- #ifdef H5 -->
|
|
||||||
<view class="page fade-in">
|
|
||||||
<view class="hero">
|
|
||||||
<text class="hero-icon">⚡</text>
|
|
||||||
<text class="hero-title">补充引力值</text>
|
|
||||||
<text class="hero-desc">购买后可获得相应引力值,用于面试、简历优化、下载</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="product-card">
|
<!-- 未登录提示 -->
|
||||||
<view class="qty-section">
|
<view class="login-bar" v-if="!isLoggedIn">
|
||||||
<text class="section-label">购买数量</text>
|
<text class="login-text">登录后可购买引力值、查看套餐</text>
|
||||||
|
<text class="login-btn" @click="goLogin">去登录</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 购买引力值(最上面,登录后可见) -->
|
||||||
|
<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">
|
<view class="qty-controls">
|
||||||
<text class="qty-btn" :class="{ disabled: buyQty <= 1 }" @click="changeQty(-1)">−</text>
|
<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="clampQty" />
|
<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="changeQty(1)">+</text>
|
<text class="qty-btn" :class="{ disabled: buyQty >= 99 }" @click="buyQty = Math.min(99, buyQty + 1)">+</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="summary">
|
<view class="summary">
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text class="summary-label">单价</text>
|
<text class="summary-label">单价</text>
|
||||||
@@ -34,115 +37,274 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text class="summary-label">可得引力值</text>
|
<text class="summary-label">可得引力值</text>
|
||||||
<text class="summary-val highlight">{{ buyQty * gravityPerUnit }} 引力值</text>
|
<text class="summary-val highlight">{{ buyQty * gravityPerUnit }} ⚡</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-row total">
|
<view class="summary-row total">
|
||||||
<text class="summary-label">合计</text>
|
<text class="summary-label">合计</text>
|
||||||
<text class="summary-val total-price">¥{{ (buyQty * unitPrice / 100).toFixed(2) }}</text>
|
<text class="summary-val total-price">¥{{ (buyQty * unitPrice / 100).toFixed(2) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<button class="buy-btn" :disabled="payLoading" @click="startGravityPay">
|
||||||
<button class="buy-btn" :disabled="payLoading" @click="startPay">
|
{{ payLoading ? '处理中...' : '立即购买' }}
|
||||||
<text v-if="!payLoading">立即购买</text>
|
|
||||||
<text v-else>处理中...</text>
|
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
</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">{{ 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="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>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 支付弹窗 -->
|
<!-- 支付弹窗 -->
|
||||||
<view class="modal-overlay" v-if="showPayModal" @click="cancelPay">
|
<view class="modal-overlay" v-if="showPayModal" @click="cancelPay">
|
||||||
<view class="modal-content" @click.stop>
|
<view class="modal-content" @click.stop>
|
||||||
<template v-if="payLoading">
|
<template v-if="payLoading">
|
||||||
<text class="modal-title">正在创建订单...</text>
|
<text class="modal-title">正在创建支付...</text>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="payCodeUrl">
|
<template v-else-if="!isMp && payCodeUrl">
|
||||||
<text class="modal-title">微信扫码支付</text>
|
<text class="modal-title">微信扫码支付</text>
|
||||||
<image class="qrcode" :src="'https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=' + encodeURIComponent(payCodeUrl)" mode="widthFix" />
|
<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>
|
<text class="modal-close" @click="cancelPay">取消支付</text>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="paySuccess">
|
<template v-else-if="vpStatus">
|
||||||
<text class="modal-title">✅ 支付成功</text>
|
<text class="modal-title" :class="vpSuccess ? '' : 'pay-error'">{{ vpSuccess ? '✅ 支付成功' : '支付失败' }}</text>
|
||||||
<text class="modal-hint">引力值已到账,返回继续使用吧</text>
|
<text class="modal-hint">{{ vpStatusText }}</text>
|
||||||
<text class="modal-close" @click="cancelPay">关闭</text>
|
<text class="modal-close" @click="cancelPay">关闭</text>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="payError">
|
<template v-if="payError && !vpStatus">
|
||||||
<text class="modal-title pay-error">支付失败</text>
|
<text class="modal-title pay-error">支付异常</text>
|
||||||
<text class="modal-hint">{{ payError }}</text>
|
<text class="modal-hint">{{ payError }}</text>
|
||||||
<text class="modal-close" @click="cancelPay">关闭</text>
|
<text class="modal-close" @click="cancelPay">关闭</text>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup>
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
// #ifdef MP-WEIXIN
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
|
||||||
// #endif
|
|
||||||
import { api } from '../../config'
|
import { api } from '../../config'
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
const isLoggedIn = ref(false)
|
||||||
onShareAppMessage(() => ({ title: '职引 - 引力值购买 | AI模拟面试', path: '/pages/member/member' }))
|
const isMp = ref(false)
|
||||||
onShareTimeline(() => ({ title: '职引 - 引力值购买 | AI模拟面试' }))
|
const plan = ref('free')
|
||||||
// #endif
|
const currentPlanName = ref('免费版')
|
||||||
|
const gravity = ref(0)
|
||||||
|
const planList = ref([])
|
||||||
|
|
||||||
const goBack = () => uni.switchTab({ url: '/pages/user/user' })
|
// 购买引力值
|
||||||
|
|
||||||
// #ifdef H5
|
|
||||||
const buyQty = ref(1)
|
const buyQty = ref(1)
|
||||||
const unitPrice = ref(500)
|
const unitPrice = ref(500)
|
||||||
const gravityPerUnit = ref(5)
|
const gravityPerUnit = ref(5)
|
||||||
const payLoading = ref(false)
|
const payLoading = ref(false)
|
||||||
|
|
||||||
|
// 支付弹窗
|
||||||
const showPayModal = ref(false)
|
const showPayModal = ref(false)
|
||||||
const payCodeUrl = ref('')
|
const payCodeUrl = ref('')
|
||||||
const paySuccess = ref(false)
|
|
||||||
const payError = ref('')
|
const payError = ref('')
|
||||||
|
const currentOutTradeNo = ref('')
|
||||||
|
const payingPlan = ref('')
|
||||||
|
const paySuccess = ref(false)
|
||||||
|
const vpStatus = ref(false)
|
||||||
|
const vpSuccess = ref(false)
|
||||||
|
const vpStatusText = ref('')
|
||||||
|
|
||||||
onMounted(async () => {
|
// 套餐特征后备值(API 取不到时使用)
|
||||||
|
const defaultFreeFeatures = ['AI 模拟面试 1 次(体验)', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费)']
|
||||||
|
const defaultGrowthFeatures = ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库']
|
||||||
|
const defaultSprintFeatures = ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选']
|
||||||
|
|
||||||
|
const token = () => uni.getStorageSync('token') || ''
|
||||||
|
|
||||||
|
const refreshState = async () => {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
isMp.value = true
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
const t = token()
|
||||||
|
isLoggedIn.value = !!t
|
||||||
|
|
||||||
|
// 1. 先拉套餐配置(公开接口,未登录也拉)
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({ url: api('/member/plans'), method: 'GET' })
|
const pres = await uni.request({ url: api('/member/plans'), method: 'GET' })
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.products) {
|
if (pres.statusCode >= 200 && pres.statusCode < 300 && pres.data) {
|
||||||
const prod = res.data.products.interview
|
const d = pres.data
|
||||||
if (prod) {
|
if (d.products?.interview) {
|
||||||
unitPrice.value = prod.price || 500
|
unitPrice.value = d.products.interview.price || 500
|
||||||
gravityPerUnit.value = prod.gravity || 5
|
gravityPerUnit.value = d.products.interview.gravity || 5
|
||||||
}
|
}
|
||||||
|
planList.value = buildPlanList(d.plans)
|
||||||
|
} else {
|
||||||
|
planList.value = buildPlanList(null)
|
||||||
}
|
}
|
||||||
} catch (e) { /* silent */ }
|
} catch (e) { /* silent */ }
|
||||||
})
|
|
||||||
|
|
||||||
const changeQty = (delta: number) => {
|
// 2. 用户信息需要登录
|
||||||
const next = buyQty.value + delta
|
if (!t) return
|
||||||
if (next >= 1 && next <= 99) buyQty.value = next
|
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] || '免费版'
|
||||||
}
|
}
|
||||||
const clampQty = () => {
|
} catch (e) { /* silent */ }
|
||||||
if (buyQty.value < 1) buyQty.value = 1
|
|
||||||
if (buyQty.value > 99) buyQty.value = 99
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const startPay = async () => {
|
const buildPlanList = (plans) => {
|
||||||
const token = uni.getStorageSync('token') || ''
|
const growth = plans?.find?.(p => p.id === 'growth')
|
||||||
if (!token) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
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' })
|
||||||
|
|
||||||
|
const cancelPay = () => {
|
||||||
|
showPayModal.value = false
|
||||||
|
payCodeUrl.value = ''
|
||||||
|
payLoading.value = false
|
||||||
|
payError.value = ''
|
||||||
|
paySuccess.value = false
|
||||||
|
vpStatus.value = false
|
||||||
|
vpSuccess.value = false
|
||||||
|
vpStatusText.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 购买引力值 → MP 用 VP / H5 用扫码 */
|
||||||
|
const startGravityPay = async () => {
|
||||||
|
const t = token()
|
||||||
|
if (!t) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
||||||
|
|
||||||
showPayModal.value = true
|
showPayModal.value = true
|
||||||
payLoading.value = true
|
payLoading.value = true
|
||||||
payCodeUrl.value = ''
|
|
||||||
payError.value = ''
|
payError.value = ''
|
||||||
paySuccess.value = false
|
vpStatus.value = false
|
||||||
|
|
||||||
|
if (isMp.value) {
|
||||||
|
// 小程序:虚拟支付 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('/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.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] 支付成功')
|
||||||
|
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 = err2?.errMsg || '支付取消'
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const msg = res.data?.message || res.data?.msg || `请求失败(${res.statusCode})`
|
||||||
|
payError.value = msg
|
||||||
|
console.error('[VP] 订单创建失败:', res.statusCode, JSON.stringify(res.data))
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
payLoading.value = false
|
||||||
|
payError.value = '网络错误,请重试'
|
||||||
|
console.error('[VP] 异常:', e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// H5:扫码支付
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({
|
const res = await uni.request({
|
||||||
url: api('/payment/create-product'), method: 'POST',
|
url: api('/payment/create-product'), method: 'POST',
|
||||||
data: { type: 'interview', quantity: buyQty.value },
|
data: { type: 'interview', quantity: buyQty.value },
|
||||||
header: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||||
})
|
})
|
||||||
payLoading.value = false
|
payLoading.value = false
|
||||||
|
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
|
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
|
||||||
payCodeUrl.value = res.data.codeUrl
|
payCodeUrl.value = res.data.codeUrl
|
||||||
pollPayResult(res.data.outTradeNo)
|
currentOutTradeNo.value = res.data.outTradeNo
|
||||||
|
pollPayResult(res.data.outTradeNo, 'growth')
|
||||||
} else {
|
} else {
|
||||||
payError.value = res.data?.message || '创建订单失败'
|
payError.value = res.data?.message || '创建订单失败'
|
||||||
}
|
}
|
||||||
@@ -151,79 +313,212 @@ const startPay = async () => {
|
|||||||
payError.value = '网络错误,请重试'
|
payError.value = '网络错误,请重试'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const pollPayResult = (outTradeNo: string) => {
|
/** 套餐升级 → 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 (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 = 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 {
|
||||||
|
payError.value = res.data?.message || '创建订单失败'
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
payLoading.value = false
|
||||||
|
payError.value = '网络错误,请重试'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 轮询订单状态 */
|
||||||
|
const pollPayResult = (outTradeNo, selectedPlan) => {
|
||||||
if (!outTradeNo) return
|
if (!outTradeNo) return
|
||||||
const token = uni.getStorageSync('token') || ''
|
|
||||||
let attempts = 0
|
let attempts = 0
|
||||||
const poll = async () => {
|
const poll = async () => {
|
||||||
attempts++
|
attempts++
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({
|
const res = await uni.request({
|
||||||
url: api(`/payment/check/${outTradeNo}`), method: 'GET',
|
url: api(`/payment/check/${outTradeNo}`), method: 'GET',
|
||||||
header: { 'Authorization': `Bearer ${token}` },
|
header: { 'Authorization': `Bearer ${token()}` },
|
||||||
})
|
})
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.status === 'success') {
|
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.status === 'success') {
|
||||||
paySuccess.value = true
|
await activatePlan(outTradeNo, selectedPlan)
|
||||||
payCodeUrl.value = ''
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} catch (e) { /* ignore */ }
|
} catch (e) { /* ignore */ }
|
||||||
if (attempts < 30) setTimeout(poll, 2000)
|
if (attempts < 30) setTimeout(poll, 2000)
|
||||||
|
else { payError.value = '支付结果查询超时,请联系客服' }
|
||||||
}
|
}
|
||||||
setTimeout(poll, 2000)
|
setTimeout(poll, 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelPay = () => {
|
/** 激活套餐 */
|
||||||
|
const activatePlan = async (outTradeNo, selectedPlan) => {
|
||||||
|
try {
|
||||||
|
const res = await uni.request({
|
||||||
|
url: api('/payment/activate'), method: 'POST',
|
||||||
|
data: { outTradeNo },
|
||||||
|
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
|
||||||
|
})
|
||||||
|
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.success) {
|
||||||
|
paySuccess.value = true
|
||||||
showPayModal.value = false
|
showPayModal.value = false
|
||||||
payCodeUrl.value = ''
|
plan.value = selectedPlan
|
||||||
payError.value = ''
|
currentPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
|
||||||
payLoading.value = false
|
uni.showToast({ title: '🎉 开通成功!', icon: 'success' })
|
||||||
|
refreshState()
|
||||||
|
} else {
|
||||||
|
uni.showToast({ title: res.data?.message || '激活失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
payError.value = '激活失败,请联系客服'
|
||||||
|
uni.showToast({ title: '激活失败', icon: 'none' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// #endif
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page { min-height: 100vh; background: var(--color-bg); }
|
.page { min-height: 100vh; background: var(--color-bg); padding-bottom: 40rpx; }
|
||||||
.placeholder-wrap { display: flex; flex-direction: column; align-items: center; gap: 16rpx; padding: 80rpx 40rpx; }
|
|
||||||
.placeholder-icon { font-size: 80rpx; }
|
|
||||||
.placeholder-text { font-size: 30rpx; font-weight: 600; color: var(--color-text); }
|
|
||||||
.placeholder-hint { font-size: 24rpx; color: var(--color-text-tertiary); }
|
|
||||||
.placeholder-back { font-size: 26rpx; color: var(--color-primary); padding: 16rpx 40rpx; border-radius: var(--radius-md); background: #F3F4F6; margin-top: 24rpx; }
|
|
||||||
|
|
||||||
/* H5 购买页 */
|
/* 状态栏 */
|
||||||
.hero { display: flex; flex-direction: column; align-items: center; padding: 48rpx 32rpx 24rpx; }
|
.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; }
|
||||||
.hero-icon { font-size: 72rpx; }
|
.status-left { display: flex; flex-direction: column; gap: 4rpx; }
|
||||||
.hero-title { font-size: 36rpx; font-weight: 700; color: var(--color-text); margin-top: 12rpx; }
|
.status-label { font-size: 22rpx; opacity: 0.85; }
|
||||||
.hero-desc { font-size: 24rpx; color: var(--color-text-secondary); margin-top: 8rpx; text-align: center; }
|
.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; }
|
||||||
|
|
||||||
.product-card { background: #fff; border-radius: var(--radius-lg); margin: 0 32rpx; padding: 32rpx; box-shadow: var(--shadow-sm); }
|
/* 登录提示 */
|
||||||
|
.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); }
|
||||||
|
|
||||||
.qty-section { margin-bottom: 24rpx; }
|
/* 区块 */
|
||||||
.section-label { font-size: 26rpx; font-weight: 600; color: var(--color-text); display: block; margin-bottom: 16rpx; }
|
.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-controls { display: flex; align-items: center; justify-content: center; gap: 24rpx; }
|
||||||
.qty-btn { width: 64rpx; height: 64rpx; border-radius: 50%; background: #F3F4F6; display: flex; align-items: center; justify-content: center; font-size: 36rpx; font-weight: 500; color: var(--color-text); }
|
.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-btn.disabled { color: #D1D5DB; background: #F9FAFB; }
|
||||||
.qty-input { width: 120rpx; height: 72rpx; text-align: center; font-size: 36rpx; font-weight: 700; color: var(--color-text); border: 2rpx solid #E5E7EB; border-radius: var(--radius-sm); }
|
.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 { margin-bottom: 32rpx; }
|
.summary-row { display: flex; justify-content: space-between; padding: 8rpx 0; border-bottom: 1rpx solid #F3F4F6; }
|
||||||
.summary-row { display: flex; justify-content: space-between; padding: 12rpx 0; border-bottom: 1rpx solid #F3F4F6; }
|
.summary-row.total { border-bottom: none; padding-top: 12rpx; }
|
||||||
.summary-row.total { border-bottom: none; padding-top: 16rpx; }
|
.summary-label { font-size: 22rpx; color: var(--color-text-secondary); }
|
||||||
.summary-label { font-size: 24rpx; color: var(--color-text-secondary); }
|
.summary-val { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
|
||||||
.summary-val { font-size: 26rpx; font-weight: 600; color: var(--color-text); }
|
|
||||||
.summary-val.highlight { color: var(--color-primary); }
|
.summary-val.highlight { color: var(--color-primary); }
|
||||||
.total-price { font-size: 36rpx; font-weight: 800; 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 { width: 100%; height: 88rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #fff; font-size: 30rpx; 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:active { opacity: 0.85; transform: scale(0.98); }
|
|
||||||
.buy-btn[disabled] { opacity: 0.5; }
|
.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: 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); }
|
||||||
|
|
||||||
|
/* 弹窗 */
|
||||||
.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-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; display: flex; flex-direction: column; align-items: center; gap: 16rpx; }
|
.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: 30rpx; font-weight: 700; color: var(--color-text); }
|
.modal-title { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
|
||||||
.pay-error { color: var(--color-error); }
|
.pay-error { color: var(--color-error); }
|
||||||
.modal-hint { font-size: 22rpx; color: #6B7280; text-align: center; }
|
.qr-canvas { width: 400rpx; height: 400rpx; }
|
||||||
.modal-close { font-size: 24rpx; color: #9CA3AF; padding: 12rpx 24rpx; }
|
.modal-hint { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||||
.qrcode { width: 300rpx; height: 300rpx; margin: 8rpx 0; }
|
.modal-close { font-size: 22rpx; color: var(--color-text-tertiary); padding: 8rpx; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user