动态生成购买套餐 & 取消初次进后台修改密码的弹窗 & 添加总折扣字段 & 发布v1.5.0版本
This commit is contained in:
12
src/actions/product.ts
Normal file
12
src/actions/product.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {callByUser, callPublic} from './base'
|
||||
import {Product} from '@/lib/models/product'
|
||||
|
||||
export type ProductItem = Product
|
||||
|
||||
export async function listProduct(props: {}) {
|
||||
return callByUser<Product[]>('/api/product/list', props)
|
||||
}
|
||||
|
||||
export async function listProductHome(props: {}) {
|
||||
return callPublic<Product[]>('/api/product/list', props)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export async function payClose(props: {
|
||||
export async function getPrice(props: CreateResourceReq) {
|
||||
return callByDevice<{
|
||||
price: string
|
||||
discounted_price?: string
|
||||
discounted?: number
|
||||
actual?: string
|
||||
discounted?: string
|
||||
}>('/api/resource/price', props)
|
||||
}
|
||||
|
||||
@@ -38,16 +38,16 @@ export async function Identify(props: {
|
||||
}
|
||||
|
||||
export async function update(props: {
|
||||
username: string
|
||||
email: string
|
||||
contact_qq: string
|
||||
contact_wechat: string
|
||||
username?: string
|
||||
email?: string
|
||||
contact_qq?: string
|
||||
contact_wechat?: string
|
||||
}) {
|
||||
return await callByUser('/api/user/update', props)
|
||||
}
|
||||
|
||||
export async function updatePassword(props: {
|
||||
phone: string
|
||||
// phone: string
|
||||
code: string
|
||||
password: string
|
||||
}) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use server'
|
||||
import {ApiResponse} from '@/lib/api'
|
||||
import {callByDevice} from '@/actions/base'
|
||||
import {callByDevice, callByUser} from '@/actions/base'
|
||||
import {getCap} from '@/lib/cap'
|
||||
|
||||
export async function sendSMS(props: {
|
||||
@@ -38,3 +38,35 @@ export async function sendSMS(props: {
|
||||
throw new Error('验证码验证失败', {cause: error})
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateSendSMS(props: {
|
||||
captcha: string
|
||||
}): Promise<ApiResponse> {
|
||||
try {
|
||||
// 人机验证
|
||||
if (!props.captcha?.length) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: '请输入验证码',
|
||||
}
|
||||
}
|
||||
|
||||
const cap = await getCap()
|
||||
const valid = await cap.validateToken(props.captcha)
|
||||
if (!valid) {
|
||||
return {
|
||||
success: false,
|
||||
status: 400,
|
||||
message: '验证码错误或已过期',
|
||||
}
|
||||
}
|
||||
|
||||
// 请求发送短信
|
||||
return await callByUser('/api/verify/sms/password', {})
|
||||
}
|
||||
catch (error) {
|
||||
console.error('验证码验证失败:', error)
|
||||
throw new Error('验证码验证失败', {cause: error})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user