| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027 |
- /**
- * API 接口配置文件
- */
- // 开发环境和生产环境的 API 基础地址
- // 所有请求通过网关转发
- const BASE_URL = process.env.NODE_ENV === 'development'
- ? 'http://localhost:8083/api' // 开发环境 - 通过网关
- : 'https://your-domain.com/api' // 生产环境
- /**
- * 封装 uni.request
- */
- const request = (options) => {
- return new Promise((resolve, reject) => {
- const token = uni.getStorageSync('token')
- const headers = {
- 'Content-Type': 'application/json'
- }
- if (token) {
- headers['Authorization'] = token
- }
- uni.request({
- url: (/^https?:\/\//.test(options.url) ? options.url : (BASE_URL + options.url)),
- method: options.method || 'GET',
- data: options.data || {},
- header: headers,
- dataType: 'json',
- success: (res) => {
- console.log('API请求成功:', options.url, '状态码:', res.statusCode, '返回数据:', res.data)
- if (res.statusCode === 200) {
- // 根据后端约定的数据格式处理
- if (res.data.code === 200 || res.data.code === 0 || res.data.success) {
- resolve(res.data.data || res.data)
- } else {
- uni.showToast({
- title: res.data.message || res.data.msg || '请求失败',
- icon: 'none'
- })
- reject(res.data)
- }
- } else if (res.statusCode === 401) {
- // 未授权,跳转登录
- uni.navigateTo({
- url: '/pages/page3/page3'
- })
- reject(res)
- } else {
- uni.showToast({
- title: '网络请求失败',
- icon: 'none'
- })
- reject(res)
- }
- },
- fail: (err) => {
- console.error('API请求失败:', options.url, '错误信息:', err)
- uni.showToast({
- title: (err && err.errMsg) ? err.errMsg.replace('request:','') : '网络连接失败',
- icon: 'none'
- })
- reject(err)
- }
- })
- })
- }
- /**
- * API 接口列表
- */
- export default {
- // 地区
- area: {
- // 获取省份列表
- getProvinces: () => request({ url: '/recommend/area/provinces' }),
- // 获取城市列表(可选省份ID)
- getCities: (provinceId) => {
- const url = provinceId ? `/recommend/area/cities?provinceId=${provinceId}` : '/recommend/area/cities'
- return request({ url })
- },
- // 获取区域列表(根据城市ID)
- getAreas: (cityId) => request({ url: `/recommend/area/areas?cityId=${cityId}` })
- },
- // 用户相关
- user: {
- // 获取用户信息
- getInfo: () => request({ url: '/user/info' }),
-
- // 获取指定用户的详细信息(包含简介和照片)
- getDetailInfo: (userId) => request({
- url: `/user/info?userId=${userId}`
- }),
-
- // 获取今日匹配数
- getMatchCount: () => request({ url: '/user/match-count' }),
-
- // 更新用户基本信息(昵称、头像等)
- updateInfo: (data) => request({
- url: '/user/basic',
- method: 'PUT',
- data
- }),
-
- // 更新单个字段
- updateField: (userId, fieldName, fieldValue) => request({
- url: `/user/basic/field?userId=${userId}&fieldName=${fieldName}&fieldValue=${encodeURIComponent(fieldValue)}`,
- method: 'PUT'
- })
- },
- // 认证相关
- auth: {
- // 密码登录(手机号+密码)
- loginByPassword: (phone, password) => request({
- // 直连 login 服务(开发环境),避免网关未配置导致未路由
- url: 'http://localhost:8087/api/login/password',
- method: 'POST',
- data: { phone, password }
- }),
- // 发送登录验证码(走网关 -> 登录服务)
- sendCode: (phone) => request({
- url: '/login/send-code',
- method: 'POST',
- data: { phone }
- }),
- // 验证码登录(走网关 -> 登录服务)
- smsLogin: (phone, code) => request({
- url: '/login/sms-login',
- method: 'POST',
- data: { phone, code }
- }),
- // 微信登录(直连 login 服务)
- wechatLogin: (data) => request({
- url: 'http://localhost:8087/api/login/wechat/login',
- method: 'POST',
- data: data // ✅ 传递完整的登录数据对象(包含code, nickname, avatarUrl, phoneCode)
- }),
- // 获取微信手机号(直连 login 服务)
- wechatPhone: (code) => request({
- url: 'http://localhost:8087/api/login/wechat/phone',
- method: 'POST',
- data: { code }
- })
- },
- // 首页相关
- home: {
- // 获取轮播图
- getBanners: () => request({ url: '/home/banners' }),
-
- // 获取公告列表
- getNotices: () => request({ url: '/announcement/active' }),
-
- // 获取未读消息数
- getUnreadCount: () => request({ url: '/home/unread-count' })
- },
- // 成功案例
- successCase: {
- // 获取成功案例列表
- getList: (params) => request({
- url: '/success-case/list',
- method: 'GET',
- data: params
- }),
-
- // 获取成功案例详情
- getDetail: (caseNo) => request({
- url: `/success-case/detail/${caseNo}`,
- method: 'GET'
- }),
-
- // 获取案例时间线
- getTimeline: (caseNo) => request({
- url: `/success-case/timeline/${caseNo}`,
- method: 'GET'
- })
- },
- // 活动相关
- activity: {
- // 获取活动列表
- getList: (params) => request({
- url: '/activity/list',
- method: 'GET',
- data: params
- }),
-
- // 获取活动详情
- getDetail: (id) => request({
- url: `/activity/detail/${id}`,
- method: 'GET'
- }),
-
- // 报名活动
- register: (activityId, userId) => request({
- url: `/activity/register/${activityId}?userId=${userId}`,
- method: 'POST'
- }),
-
- // 取消报名
- cancelRegister: (activityId) => request({
- url: `/activity/cancel/${activityId}`,
- method: 'POST'
- }),
-
- // 获取我的活动列表
- getMyActivities: (params) => request({
- url: '/activity/my',
- method: 'GET',
- data: params
- })
- },
- // 课程相关
- course: {
- // 获取课程列表
- getList: (params) => request({
- url: '/course/list',
- method: 'GET',
- data: params
- }),
-
- // 获取课程详情(带学习进度)
- getDetail: (courseId, makerId) => request({
- url: `/course/detail/${courseId}${makerId ? '?makerId=' + makerId : ''}`,
- method: 'GET'
- }),
-
- // 更新学习进度
- updateProgress: (makerId, courseId, progress) => request({
- url: '/course/progress',
- method: 'POST',
- data: { makerId, courseId, progress }
- }),
-
- // 完成课程(领取积分)
- complete: (makerId, courseId) => request({
- url: '/course/complete',
- method: 'POST',
- data: { makerId, courseId }
- }),
-
- // 获取我的学习记录
- getMyProgress: (makerId) => request({
- url: `/course/my-progress?makerId=${makerId}`,
- method: 'GET'
- }),
-
- // 购买课程(旧接口-模拟)
- purchase: (courseId, data) => request({
- url: `/course/purchase/${courseId}`,
- method: 'POST',
- data
- }),
-
- // 积分兑换课程(红娘端 - 旧接口,已废弃)
- exchange: (data) => request({
- url: '/course/exchange',
- method: 'POST',
- data
- }),
-
- // 获取已兑换的课程列表(红娘端 - 旧接口,已废弃)
- getPurchasedList: (makerId) => request({
- url: `/course/purchased?makerId=${makerId}`,
- method: 'GET'
- })
- },
- // 红娘课程相关(独立于用户课程)
- matchmakerCourse: {
- // 获取红娘课程列表
- getList: (params = {}) => request({
- url: '/matchmaker-course/list',
- method: 'GET',
- data: params
- }),
-
- // 根据分类获取红娘课程列表
- getListByCategory: (categoryName) => request({
- url: `/matchmaker-course/list/category?categoryName=${encodeURIComponent(categoryName)}`,
- method: 'GET'
- }),
-
- // 获取所有课程分类
- getCategories: () => request({
- url: '/matchmaker-course/categories',
- method: 'GET'
- }),
-
- // 获取红娘课程详情
- getDetail: (id) => request({
- url: `/matchmaker-course/detail/${id}`,
- method: 'GET'
- }),
-
- // 检查是否已兑换
- checkExchanged: (makerId, courseId) => request({
- url: `/matchmaker-course/check-exchanged?makerId=${makerId}&courseId=${courseId}`,
- method: 'GET'
- }),
-
- // 积分兑换课程
- exchange: (data) => request({
- url: '/matchmaker-course/exchange',
- method: 'POST',
- data
- }),
-
- // 获取已兑换的课程列表
- getPurchasedList: (makerId) => request({
- url: `/matchmaker-course/purchased?makerId=${makerId}`,
- method: 'GET'
- })
- },
- // 课程订单相关(微信支付)
- courseOrder: {
- // 购买课程(获取微信支付参数)
- purchase: (data) => request({
- url: '/course-order/purchase',
- method: 'POST',
- data
- }),
-
- // 检查是否已购买课程
- checkPurchased: (userId, courseId) => request({
- url: `/course-order/check?userId=${userId}&courseId=${courseId}`,
- method: 'GET'
- }),
-
- // 获取已购买的课程列表
- getPurchasedCourses: (userId) => request({
- url: `/course-order/purchased?userId=${userId}`,
- method: 'GET'
- })
- },
- // 红娘相关
- matchmaker: {
- // 获取红娘列表
- getList: (params) => request({
- url: '/matchmaker/list',
- method: 'POST',
- data: params
- }),
-
- // 获取全职红娘列表
- getFormalList: (pageNum, pageSize) => request({
- url: `/matchmaker/formal?pageNum=${pageNum}&pageSize=${pageSize}`
- }),
-
- // 获取红娘详情
- getDetail: (id) => request({
- url: `/matchmaker/detail/${id}`
- }),
-
- // 根据userId查询红娘信息
- getByUserId: (userId) => request({
- url: `/matchmaker/by-user/${userId}`
- }),
-
- // 预约红娘
- book: (matchmakerId, data) => request({
- url: `/matchmaker/book/${matchmakerId}`,
- method: 'POST',
- data
- }),
-
- // 提交红娘申请
- submitApply: (data) => request({
- url: '/matchmaker-apply/submit',
- method: 'POST',
- data
- }),
-
- // 工作台相关
- getWorkbenchData: () => request({ url: '/matchmaker/workbench/data' }),
-
- // 获取我的资源
- getMyResources: (params) => request({
- url: '/matchmaker/resources',
- method: 'GET',
- data: params
- }),
-
- // 获取排行榜数据(总排行榜)
- getRankingData: (params) => request({
- url: '/matchmaker/ranking',
- method: 'GET',
- data: params
- }),
-
- // 获取本周排行榜(按点赞数和成功人数平均数排名)
- getWeeklyRanking: (params) => request({
- url: '/matchmaker/weekly-ranking',
- method: 'GET',
- data: params
- }),
-
- // 给红娘点赞(一周只能给同一红娘点赞一次)
- likeMatchmaker: (userId, matchmakerId) => request({
- url: `/matchmaker/like?userId=${userId}&matchmakerId=${matchmakerId}`,
- method: 'POST'
- }),
-
- // 检查是否已点赞
- checkLikeStatus: (userId, matchmakerId) => request({
- url: `/matchmaker/check-like?userId=${userId}&matchmakerId=${matchmakerId}`,
- method: 'GET'
- }),
-
- // 签到相关
- checkinStatus: (makerId) => request({
- url: `/matchmaker/checkin/status?makerId=${makerId}`
- }),
-
- checkinStats: (makerId) => request({
- url: `/matchmaker/checkin/stats?makerId=${makerId}`
- }),
-
- doCheckin: (makerId) => request({
- url: `/matchmaker/checkin/do?makerId=${makerId}`,
- method: 'POST'
- }),
- // 更新红娘资料(编辑资料页使用)
- updateProfile: (matchmakerId, data) => request({
- url: `/matchmaker/update/${matchmakerId}`,
- method: 'PUT',
- data
- }),
-
- // 获取本月签到记录
- checkinList: (makerId, year, month) => request({
- url: `/matchmaker/checkin/list?makerId=${makerId}&year=${year}&month=${month}`
- })
- },
- // 推荐相关
- recommend: {
- // 获取推荐用户列表(网关转发到推荐服务)
- getUsers: ({ userId, oppoOnly = 1, limit = 20, excludeIds }) => {
- let url = `/recommend/users?userId=${userId}&oppoOnly=${oppoOnly}&limit=${limit}`;
- if (excludeIds) {
- url += `&excludeIds=${excludeIds}`;
- }
- return request({ url });
- },
- // 行为反馈:like/dislike
- feedback: ({ userId, targetUserId, type }) => request({
- url: `/recommend/feedback?userId=${userId}&targetUserId=${targetUserId}&type=${type}`
- }),
- // 曝光上报
- exposure: ({ userId, shownUserIds }) => request({
- url: `/recommend/exposure?userId=${userId}&shownUserIds=${encodeURIComponent(shownUserIds)}`
- }),
- // 规则检索
- search: (query) => request({
- url: '/recommend/search',
- method: 'POST',
- data: query
- }),
- // 获取今日推荐
- getTodayRecommend: () => request({
- url: '/recommend/today'
- })
- },
- // 消息相关
- message: {
- // 获取消息列表
- getList: (params) => request({
- url: '/message/list',
- data: params
- }),
-
- // 获取会话列表
- getConversations: () => request({
- url: '/message/conversations'
- }),
-
- // 发送消息
- send: (data) => request({
- url: '/message/send',
- method: 'POST',
- data
- }),
- // ===== 系统消息 =====
- getSystemList: async (userId, pageNum = 1, pageSize = 20) => {
- const res = await request({ url: `/message/system/list?userId=${userId}&pageNum=${pageNum}&pageSize=${pageSize}` })
- // 后端Result包装:{ code, data:{ list,total,page,pageSize } }
- return res.data || res
- },
- getSystemUnreadCount: async (userId) => {
- const res = await request({ url: `/message/system/unread-count?userId=${userId}` })
- return (typeof res.data === 'number') ? res.data : (res.data?.count || 0)
- },
- markSystemRead: (id) => request({
- url: `/message/system/read/${id}`,
- method: 'POST'
- }),
- getSystemDetail: async (id) => {
- const res = await request({ url: `/message/system/detail/${id}` })
- return res.data || res
- },
- markAllSystemRead: (userId) => request({
- url: `/message/system/read-all?userId=${userId}`,
- method: 'POST'
- })
- },
- // 动态相关
- dynamic: {
- // 获取推荐动态列表(广场)
- getRecommendList: (params) => request({
- url: '/dynamic/recommend',
- data: params
- }),
- // 获取动态列表
- getList: (params) => request({
- url: '/dynamic/list',
- data: params
- }),
- // 获取动态详情
- getDetail: (dynamicId, userId) => request({
- url: `/dynamic/detail/${dynamicId}`,
- data: { userId }
- }),
- // 发表评论
- addComment: (dynamicId, content, images, parentCommentId = 0) => request({
- url: `/dynamic/comment`,
- method: 'POST',
- data: { dynamicId, content, images, parentCommentId, userId: 1 },
- header: { 'Content-Type': 'application/json' }
- }),
- // 评论列表
- getComments: (dynamicId, pageNum = 1, pageSize = 10) => request({
- url: `/dynamic/comment/list/${dynamicId}`,
- data: { pageNum, pageSize }
- }),
- // 评论点赞/取消
- likeComment: (commentId, userId) => {
- // 如果没有传入userId,从本地存储获取
- if (!userId) {
- const userInfo = uni.getStorageSync('userInfo');
- userId = userInfo ? (userInfo.userId || userInfo.id) : null;
- }
- if (!userId) {
- return Promise.reject(new Error('用户未登录'));
- }
- return request({
- url: `/dynamic/comment/like?commentId=${commentId}&userId=${userId}`,
- method: 'POST'
- });
- },
- unlikeComment: (commentId, userId) => {
- // 如果没有传入userId,从本地存储获取
- if (!userId) {
- const userInfo = uni.getStorageSync('userInfo');
- userId = userInfo ? (userInfo.userId || userInfo.id) : null;
- }
- if (!userId) {
- return Promise.reject(new Error('用户未登录'));
- }
- return request({
- url: `/dynamic/comment/like/${commentId}?userId=${userId}`,
- method: 'DELETE'
- });
- },
- // 获取用户动态列表
- getUserDynamics: (userId, params) => {
- const { pageNum = 1, pageSize = 10, currentUserId = null } = params || {}
- let url = `/dynamic/user/${userId}?pageNum=${pageNum}&pageSize=${pageSize}`
- if (currentUserId) {
- url += `¤tUserId=${currentUserId}`
- }
- return request({
- url: url,
- method: 'GET'
- })
- },
- // 点赞动态
- like: (dynamicId, userId) => {
- // 如果没有传入userId,从本地存储获取
- if (!userId) {
- const userInfo = uni.getStorageSync('userInfo');
- userId = userInfo ? (userInfo.userId || userInfo.id) : null;
- }
- if (!userId) {
- return Promise.reject(new Error('用户未登录'));
- }
- return request({
- url: `/dynamic/like?dynamicId=${dynamicId}&userId=${userId}`,
- method: 'POST'
- });
- },
- // 取消点赞
- unlike: (dynamicId, userId) => {
- // 如果没有传入userId,从本地存储获取
- if (!userId) {
- const userInfo = uni.getStorageSync('userInfo');
- userId = userInfo ? (userInfo.userId || userInfo.id) : null;
- }
- if (!userId) {
- return Promise.reject(new Error('用户未登录'));
- }
- return request({
- url: `/dynamic/like/${dynamicId}?userId=${userId}`,
- method: 'DELETE'
- });
- },
- // 收藏动态
- favorite: (dynamicId, userId) => {
- // 如果没有传入userId,从本地存储获取
- if (!userId) {
- const userInfo = uni.getStorageSync('userInfo');
- userId = userInfo ? (userInfo.userId || userInfo.id) : null;
- }
- if (!userId) {
- return Promise.reject(new Error('用户未登录'));
- }
- return request({
- url: `/dynamic/favorite?dynamicId=${dynamicId}&userId=${userId}`,
- method: 'POST'
- });
- },
- // 取消收藏
- unfavorite: (dynamicId, userId) => {
- // 如果没有传入userId,从本地存储获取
- if (!userId) {
- const userInfo = uni.getStorageSync('userInfo');
- userId = userInfo ? (userInfo.userId || userInfo.id) : null;
- }
- if (!userId) {
- return Promise.reject(new Error('用户未登录'));
- }
- return request({
- url: `/dynamic/favorite/${dynamicId}?userId=${userId}`,
- method: 'DELETE'
- });
- },
- // 创建个人动态
- createUserDynamic: (payload) => request({
- url: '/dynamic/user',
- method: 'POST',
- data: payload,
- header: { 'Content-Type': 'application/json' }
- }),
- // 更新个人动态
- updateUserDynamic: (dynamicId, userId, payload) => request({
- url: `/dynamic/user/${dynamicId}?userId=${userId}`,
- method: 'PUT',
- data: payload,
- header: { 'Content-Type': 'application/json' }
- }),
- // 删除个人动态
- deleteUserDynamic: (dynamicId, userId) => request({
- url: `/dynamic/user/${dynamicId}?userId=${userId}`,
- method: 'DELETE'
- }),
- // 删除动态(旧接口,保留兼容)
- delete: (dynamicId) => request({
- url: `/dynamic/${dynamicId}`,
- method: 'DELETE'
- }),
- // 发布动态(文本或已存在的媒体URL列表)
- publish: (payload) => request({
- url: '/dynamic/publish',
- method: 'POST',
- data: payload,
- header: { 'Content-Type': 'application/json' }
- }),
- // 单个文件上传方法
- uploadSingle: (filePath) => {
- return new Promise((resolve, reject) => {
- console.log('开始上传文件:', filePath)
- console.log('上传URL:', BASE_URL + '/dynamic/publish/upload')
- uni.uploadFile({
- url: BASE_URL + '/dynamic/publish/upload',
- filePath: filePath,
- name: 'file',
- success: (res) => {
- console.log('上传响应:', res)
- try {
- const data = JSON.parse(res.data)
- console.log('解析后的响应数据:', data)
- if (data.code === 200 || data.code === 0 || data.success) {
- console.log('上传成功,返回URL:', data.data)
- resolve(data.data)
- } else {
- console.error('上传失败,服务器返回错误:', data)
- reject(new Error(data.message || '上传失败'))
- }
- } catch (e) {
- console.error('解析响应数据失败:', e, '原始响应:', res.data)
- reject(new Error('解析响应数据失败'))
- }
- },
- fail: (error) => {
- console.error('上传请求失败:', error)
- reject(new Error('上传请求失败: ' + (error.errMsg || '未知错误')))
- }
- })
- })
- },
- // 批量上传多个文件(遍历调用单个上传)
- uploadBatch: (filePaths) => {
- return new Promise(async (resolve, reject) => {
- const urls = []
- try {
- for (let filePath of filePaths) {
- const url = await new Promise((resolveUpload, rejectUpload) => {
- uni.uploadFile({
- url: BASE_URL + '/dynamic/publish/upload',
- filePath: filePath,
- name: 'file',
- success: (res) => {
- try {
- const data = JSON.parse(res.data)
- if (data.code === 200 || data.code === 0 || data.success) {
- resolveUpload(data.data)
- } else {
- rejectUpload(data)
- }
- } catch (e) {
- rejectUpload(e)
- }
- },
- fail: rejectUpload
- })
- })
- urls.push(url)
- }
- resolve(urls)
- } catch (e) {
- reject(new Error(`批量上传失败: ${e.message || '未知错误'}`))
- }
- })
- },
- // 提交举报
- submitReport: (data) => request({
- url: '/dynamic/report',
- method: 'POST',
- data
- }),
-
- // 获取用户收藏列表
- getFavoritesList: (userId, pageNum = 1, pageSize = 10) => request({
- url: `/dynamic/favorites?userId=${userId}&pageNum=${pageNum}&pageSize=${pageSize}`
- }),
-
- // 获取用户点赞列表
- getLikedList: (userId, pageNum = 1, pageSize = 10) => request({
- url: `/dynamic/likes?userId=${userId}&pageNum=${pageNum}&pageSize=${pageSize}`
- }),
-
- // 获取用户浏览记录列表
- getBrowseHistoryList: (userId, pageNum = 1, pageSize = 10) => request({
- url: `/dynamic/browse-history?userId=${userId}&pageNum=${pageNum}&pageSize=${pageSize}`
- }),
-
- // 清空用户浏览记录
- clearBrowseHistory: (userId) => request({
- url: `/dynamic/browse-history?userId=${userId}`,
- method: 'DELETE'
- })
- },
- // VIP相关
- vip: {
- // 获取VIP信息(状态、套餐等)
- getInfo: (userId) => request({
- url: `/vip/info?userId=${userId}`
- }),
-
- // 获取VIP套餐列表
- getPackages: () => request({
- url: '/vip/packages'
- }),
-
- // 购买VIP套餐(获取支付参数)
- purchase: (userId, packageId) => request({
- url: '/vip/purchase',
- method: 'POST',
- data: { userId, packageId }
- }),
-
- // 查询订单状态
- getOrderStatus: (orderNo) => request({
- url: `/vip/order/status?orderNo=${orderNo}`
- }),
- // 新增:查询支付状态(userId + packageId)
- checkPayStatus: (userId, packageId) => request({
- url: '/vip/checkPayStatus',
- method: 'GET',
- data: { userId, packageId }
- })
- },
-
- // 用户反馈
- feedback: {
- // 提交用户反馈
- submit: (data) => request({
- url: '/feedback/submit',
- method: 'POST',
- data
- }),
- // 上传反馈图片
- uploadImage: (filePath) => {
- return new Promise((resolve, reject) => {
- uni.uploadFile({
- url: BASE_URL + '/feedback/upload',
- filePath: filePath,
- name: 'file',
- success: (res) => {
- try {
- const data = JSON.parse(res.data)
- if (data.code === 200 || data.code === 0 || data.success) {
- resolve(data.data)
- } else {
- reject(new Error(data.message || '上传失败'))
- }
- } catch (e) {
- reject(new Error('解析响应数据失败'))
- }
- },
- fail: (error) => {
- reject(new Error('上传请求失败: ' + (error.errMsg || '未知错误')))
- }
- })
- })
- }
- },
- // 积分商城相关
- pointsMall: {
- // 获取商品列表
- getProducts: (params) => request({
- url: '/points/products',
- method: 'GET',
- data: params
- }),
-
- // 获取推荐商品
- getRecommendProducts: (limit = 10) => request({
- url: `/points/products/recommend?limit=${limit}`,
- method: 'GET'
- }),
-
- // 获取商品详情
- getProductDetail: (id) => request({
- url: `/points/products/${id}`,
- method: 'GET'
- }),
-
- // 获取积分余额
- getBalance: (makerId) => request({
- url: `/points/balance?makerId=${makerId}`,
- method: 'GET'
- }),
-
- // 获取积分明细
- getRecords: (makerId, pageNum = 1, pageSize = 20) => request({
- url: `/points/records?makerId=${makerId}&pageNum=${pageNum}&pageSize=${pageSize}`,
- method: 'GET'
- }),
-
- // 获取积分规则
- getRules: () => request({
- url: '/points/rules',
- method: 'GET'
- }),
-
- // 兑换商品
- exchange: (data) => request({
- url: '/points/exchange',
- method: 'POST',
- data
- }),
-
- // 获取订单列表
- getOrders: (makerId, status, pageNum = 1, pageSize = 10) => {
- let url = `/points/orders?makerId=${makerId}&pageNum=${pageNum}&pageSize=${pageSize}`
- if (status !== undefined && status !== null) {
- url += `&status=${status}`
- }
- return request({ url, method: 'GET' })
- },
-
- // 获取订单详情
- getOrderDetail: (orderNo) => request({
- url: `/points/orders/${orderNo}`,
- method: 'GET'
- }),
-
- // 增加积分(签到等)
- addPoints: (makerId, ruleType, reason) => request({
- url: '/points/add',
- method: 'POST',
- data: { makerId, ruleType, reason }
- })
- },
- // 我的资源相关(通过网关访问8081服务)
- myResource: {
- // 获取资源列表
- getList: (matchmakerId, keyword, pageNum = 1, pageSize = 10) => {
- let url = `/my-resource/list?matchmakerId=${matchmakerId}&pageNum=${pageNum}&pageSize=${pageSize}`
- if (keyword) {
- url += `&keyword=${encodeURIComponent(keyword)}`
- }
- return request({ url })
- },
-
- // 搜索资源(按姓名或手机号)
- search: (matchmakerId, keyword, gender) => {
- let url = `/my-resource/search?matchmakerId=${matchmakerId}`
- if (keyword) {
- url += `&keyword=${encodeURIComponent(keyword)}`
- }
- if (gender) {
- url += `&gender=${gender}`
- }
- return request({ url })
- },
-
- // 获取资源下拉列表
- getDropdown: (matchmakerId, gender) => {
- let url = `/my-resource/dropdown?matchmakerId=${matchmakerId}`
- if (gender) {
- url += `&gender=${gender}`
- }
- return request({ url })
- },
-
- // 获取已注册用户的资源下拉列表(user_id不为空)
- getRegisteredDropdown: (matchmakerId, gender) => {
- let url = `/my-resource/registered-dropdown?matchmakerId=${matchmakerId}`
- if (gender) {
- url += `&gender=${gender}`
- }
- return request({ url })
- },
-
- // 搜索已注册用户的资源(user_id不为空)
- searchRegistered: (matchmakerId, keyword, gender) => {
- let url = `/my-resource/registered-search?matchmakerId=${matchmakerId}`
- if (keyword) {
- url += `&keyword=${encodeURIComponent(keyword)}`
- }
- if (gender) {
- url += `&gender=${gender}`
- }
- return request({ url })
- }
- },
- // 撮合成功案例上传相关(通过网关访问1004服务)
- successCaseUpload: {
- // 提交成功案例
- submit: (data) => request({
- url: '/success-case-upload/submit',
- method: 'POST',
- data
- }),
-
- // 获取成功案例列表
- getList: (matchmakerId, pageNum = 1, pageSize = 10) => request({
- url: `/success-case-upload/list?matchmakerId=${matchmakerId}&pageNum=${pageNum}&pageSize=${pageSize}`
- }),
-
- // 获取审核记录列表
- getAuditRecords: (matchmakerId, auditStatus, pageNum = 1, pageSize = 20) => {
- let url = `/success-case-upload/audit-records?matchmakerId=${matchmakerId}&pageNum=${pageNum}&pageSize=${pageSize}`
- if (auditStatus !== null && auditStatus !== undefined) {
- url += `&auditStatus=${auditStatus}`
- }
- return request({ url })
- },
-
- // 获取审核记录详情
- getAuditRecordDetail: (id) => request({
- url: `/success-case-upload/audit-records/${id}`
- }),
-
- // 标记审核记录为已读
- markAsRead: (id) => request({
- url: `/success-case-upload/audit-records/${id}/read`,
- method: 'POST'
- }),
-
- // 获取未读审核记录数量
- getUnreadCount: (matchmakerId) => request({
- url: `/success-case-upload/audit-records/unread-count?matchmakerId=${matchmakerId}`
- })
- }
- }
- // 导出 request 函数供其他模块使用
- export { request }
|