完成一键登录和支付功能
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import request from "@/utils/request.js"
|
||||
|
||||
/**
|
||||
* 微信小程序登录
|
||||
* @param {object} params - 登录参数 { code: string }
|
||||
*/
|
||||
export function login(params) {
|
||||
return request.post('/member/auth/miniapp/login', params)
|
||||
}
|
||||
@@ -28,23 +32,44 @@ export function oneClickLogin(params) {
|
||||
return request.post('/auth/phone/one-click-login', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
export function logout() {
|
||||
return request.post('/member/auth/logout')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到二维码
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getQRCode(options = { cache: true, cacheTime: 5 * 60 * 1000 }) {
|
||||
return request.get('/checkIn/qrcode', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码签到
|
||||
* @param {object} params - { qrcode: string, memberId: number }
|
||||
*/
|
||||
export function checkIn(params) {
|
||||
return request.post('/checkIn/scan', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到记录(分页)
|
||||
* @param {object} params - { page: number, size: number }
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getCheckInRecords(params = {}, options = {}) {
|
||||
const { page = 0, size = 5 } = params
|
||||
return request.post('/checkIn/page', { page, size }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户未读消息数量
|
||||
* @param {number} userId - 用户ID
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getUnreadMessageCount(userId, options = {}) {
|
||||
return request.get(`/messages/user/${userId}/unread`, {}, options)
|
||||
}
|
||||
@@ -109,12 +134,17 @@ export function deleteMessage(id, options = {}) {
|
||||
return request.delete(`/messages/${id}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息(基础信息缓存)
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getUserInfo(options = { cache: true, cacheTime: 30 * 60 * 1000 }) {
|
||||
return request.get('/member/info', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员详细信息(包含会员卡、积分等)
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getMemberDetail(options = { cache: false }) {
|
||||
return request.get('/member/info', {}, options)
|
||||
@@ -122,14 +152,17 @@ export function getMemberDetail(options = { cache: false }) {
|
||||
|
||||
/**
|
||||
* 获取签到统计
|
||||
* @param {object} params - 查询参数
|
||||
* @param {string} params.startDate - 开始日期(yyyy-MM-dd)
|
||||
* @param {string} params.endDate - 结束日期(yyyy-MM-dd)
|
||||
* @param {object} params - 查询参数 { startDate: string, endDate: string }
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getCheckInStats(params = {}, options = { cache: false }) {
|
||||
return request.get('/checkIn/statistics', params, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param {object} params - 用户信息参数
|
||||
*/
|
||||
export function updateUserInfo(params) {
|
||||
return request.put('/member/info', params)
|
||||
}
|
||||
@@ -145,10 +178,156 @@ export function purchaseMemberCard(params) {
|
||||
return request.post('/member-card-records/purchase', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的会员卡列表
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getMyMemberCards(memberId, options = { cache: false }) {
|
||||
return request.get(`/member-card-records/my-cards/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员的所有会员卡(支持状态筛选)
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {string} status - 状态筛选:all-全部, active-有效, expired-已失效
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getMyMemberCardsWithStatus(memberId, status = 'all', options = { cache: false }) {
|
||||
return request.get(`/member-card-records/my-cards-with-status/${memberId}`, { status }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员的主要有效会员卡(只返回一条)
|
||||
* 优先返回临期卡,其次返回普通有效卡
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getPrimaryMemberCard(memberId, options = { cache: false }) {
|
||||
return request.get(`/member-card-records/primary/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员卡交易/流水记录(按会员ID)
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getMemberCardTransactions(memberId, options = { cache: false }) {
|
||||
return request.get(`/member-card-transactions/member/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员卡交易/流水记录(按会员卡记录ID)
|
||||
* @param {number} recordId - 会员卡记录ID
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getMemberCardTransactionsByRecordId(recordId, options = { cache: false }) {
|
||||
return request.get(`/member-card-transactions/record/${recordId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前有效的会员卡列表
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getActiveMemberCards(options = { cache: false }) {
|
||||
return request.get('/member-cards/active', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取会员卡详情
|
||||
* @param {number} cardId - 会员卡ID
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getMemberCardById(cardId, options = { cache: false }) {
|
||||
return request.get(`/member-cards/${cardId}`, {}, options)
|
||||
}
|
||||
|
||||
// ========== 支付密码相关API ==========
|
||||
|
||||
/**
|
||||
* 检查会员是否已设置支付密码
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function checkPayPasswordSet(memberId, options = {}) {
|
||||
return request.get(`/pay-password/check/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置支付密码
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {string} password - 支付密码
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function setPayPassword(memberId, password, options = {}) {
|
||||
return request.post(`/pay-password/set/${memberId}`, { password }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证支付密码
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {string} password - 支付密码
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function verifyPayPassword(memberId, password, options = {}) {
|
||||
return request.post(`/pay-password/verify/${memberId}`, { password }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置支付密码
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {string} oldPassword - 旧密码
|
||||
* @param {string} newPassword - 新密码
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function resetPayPassword(memberId, oldPassword, newPassword, options = {}) {
|
||||
return request.post(`/pay-password/reset/${memberId}`, { oldPassword, newPassword }, options)
|
||||
}
|
||||
|
||||
// ========== 储值卡相关API ==========
|
||||
|
||||
/**
|
||||
* 获取储值卡信息(包含余额、消费记录等)
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getStoredCardInfo(memberId, options = {}) {
|
||||
return request.get(`/stored-card/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取储值卡余额
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getStoredCardBalance(memberId, options = {}) {
|
||||
return request.get(`/stored-card/${memberId}/balance`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 储值卡支付(验证密码并扣减余额)
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {string} password - 支付密码
|
||||
* @param {number} amount - 支付金额
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function payWithStoredCard(memberId, password, amount, options = {}) {
|
||||
return request.post(`/stored-card/pay/${memberId}`, {
|
||||
password,
|
||||
amount
|
||||
}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询储值卡充值记录
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {number} page - 页码
|
||||
* @param {number} size - 每页数量
|
||||
*/
|
||||
export function getStoredCardRechargeRecords(memberId, page = 1, size = 20, options = {}) {
|
||||
return request.get(`/stored-card/${memberId}/recharges?page=${page}&size=${size}`, {}, options)
|
||||
}
|
||||
|
||||
// ========== 支付相关API ==========
|
||||
|
||||
/**
|
||||
@@ -175,20 +354,50 @@ export function createPayment(params) {
|
||||
|
||||
/**
|
||||
* 创建扫码支付订单
|
||||
* @param {Object} params - 支付参数
|
||||
* @param {object} params - 支付参数
|
||||
*/
|
||||
export function createQrCodePayment(params) {
|
||||
return request.post('/payment/qrcode/create', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付状态
|
||||
* 查询支付状态(本地数据库)
|
||||
* @param {string} orderId - 订单ID
|
||||
*/
|
||||
export function getPaymentStatus(orderId) {
|
||||
return request.get(`/payment/${orderId}`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询汇付官方支付状态
|
||||
* @param {string} outOrdId - 商户订单号
|
||||
* @param {string} hfSeqId - 汇付全局流水号(可选)
|
||||
*/
|
||||
export function queryHuifuTradeByOrderId(outOrdId, hfSeqId = null) {
|
||||
let url = `/payment/huifu/query?outOrdId=${outOrdId}`
|
||||
if (hfSeqId) {
|
||||
url += `&hfSeqId=${hfSeqId}`
|
||||
}
|
||||
return request.get(url, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待支付订单
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {string} orderType - 订单类型
|
||||
*/
|
||||
export function getPendingOrder(memberId, orderType) {
|
||||
return request.get(`/payment/pending/${memberId}?orderType=${orderType}`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
* @param {string} orderId - 订单ID
|
||||
*/
|
||||
export function closeOrder(orderId) {
|
||||
return request.post(`/payment/${orderId}/close`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款
|
||||
* @param {string} orderId - 订单ID
|
||||
@@ -198,14 +407,30 @@ export function refundPayment(orderId, refundAmt) {
|
||||
return request.post(`/payment/${orderId}/refund`, { refundAmt })
|
||||
}
|
||||
|
||||
// ========== 课程相关API ==========
|
||||
|
||||
/**
|
||||
* 获取推荐课程列表
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getRecommendCourses(options = { cache: true, cacheTime: 10 * 60 * 1000 }) {
|
||||
return request.get('/course/recommend', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取课程详情
|
||||
* @param {number} id - 课程ID
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getCourseDetail(id, options = { cache: true, cacheTime: 15 * 60 * 1000 }) {
|
||||
return request.get(`/course/${id}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取团课列表(分页)
|
||||
* @param {object} params - 查询参数 { page: number, size: number, sort: string, order: string, keyword: string }
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getGroupCoursePage(params = {}, options = { cache: true, cacheTime: 5 * 60 * 1000 }) {
|
||||
const { page = 0, size = 10, sort = 'id', order = 'asc', keyword } = params
|
||||
return request.post('/groupCourse/page', { page, size, sort, order, keyword }, options)
|
||||
@@ -278,6 +503,12 @@ export default {
|
||||
updateUserInfo,
|
||||
purchaseMemberCard,
|
||||
getMyMemberCards,
|
||||
getMyMemberCardsWithStatus,
|
||||
getPrimaryMemberCard,
|
||||
getStoredCardInfo,
|
||||
getStoredCardBalance,
|
||||
payWithStoredCard,
|
||||
getStoredCardRechargeRecords,
|
||||
createPayment,
|
||||
createQrCodePayment,
|
||||
getPaymentStatus,
|
||||
|
||||
Reference in New Issue
Block a user