135 lines
3.4 KiB
JavaScript
135 lines
3.4 KiB
JavaScript
/**
|
||
* 个人中心相关接口
|
||
*/
|
||
|
||
import { request } from './index.js'
|
||
|
||
/**
|
||
* 获取个人信息
|
||
* @returns {Promise} 返回用户信息
|
||
*/
|
||
export function getUserInfo() {
|
||
return request({
|
||
url: '/app-api/member/user/get',
|
||
method: 'GET',
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 创建实名信息
|
||
export function createRealNameInfo(data) {
|
||
return request({
|
||
url: '/app-api/member/user-real-name/addAndUpdate',
|
||
method: 'POST',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 获得实名信息
|
||
export function getRealNameInfo(data) {
|
||
return request({
|
||
url: '/app-api/member/user-real-name/get',
|
||
method: 'GET',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 我的收藏
|
||
export function getMyCollect(data) {
|
||
return request({
|
||
url: '/app-api/member/labor-union-collect/page',
|
||
method: 'GET',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 业务数据获取,主要是分享,收藏等根据业务id 和类型获取数据
|
||
export function getBusinessData(data) {
|
||
return request({
|
||
url: '/app-api/member/lu-buiness/get',
|
||
method: 'GET',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 创建会员建议
|
||
export function createLaborUnionSuggest(data) {
|
||
return request({
|
||
url: '/app-api/member/labor-union-suggest/create',
|
||
method: 'POST',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 获得会员建议分页
|
||
export function getLaborUnionSuggestPage(data) {
|
||
return request({
|
||
url: '/app-api/member/labor-union-suggest/page',
|
||
method: 'GET',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
// 发布消息
|
||
export function createLaborUnionMessage(data) {
|
||
return request({
|
||
url: '/app-api/member/labor-union-message/create',
|
||
method: 'POST',
|
||
data: data,
|
||
showLoading: false,
|
||
needAuth: true // 需要token认证
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取邀请小程序码图片。入参格式与后端约定一致,支持返回 URL 或 Base64。
|
||
* @param {String} inviteCode 邀请码,格式 邀请类型-用户id,如 '0-123',会作为 scene 传给后端(若后端需数字可传 userId)
|
||
* @returns {Promise<String>} 小程序码图片 URL 或 Data URL(Base64),失败则抛出
|
||
*/
|
||
export function getInviteQRCode(inviteCode) {
|
||
// 入参示例:scene、path、width、autoColor、checkPath、hyaline
|
||
const scene = inviteCode || ''
|
||
const path = 'pages/login/login'
|
||
return request({
|
||
url: '/app-api/member/social-user/wxa-qrcode',
|
||
method: 'POST',
|
||
data: {
|
||
scene,
|
||
path,
|
||
width: 430,
|
||
autoColor: true,
|
||
checkPath: true,
|
||
hyaline: true
|
||
},
|
||
showLoading: false,
|
||
needAuth: true
|
||
}).then(res => {
|
||
if (res == null) return null
|
||
// 接口可能直接返回 base64 字符串(request 里 resolve 的 data 即为该字符串)
|
||
if (typeof res === 'string') {
|
||
const raw = res.trim()
|
||
if (raw.startsWith('data:image')) return raw
|
||
if (raw.length > 0) return 'data:image/png;base64,' + raw
|
||
return null
|
||
}
|
||
const url = res.url || (res.data && res.data.url)
|
||
if (url) return url
|
||
const base64 = res.data && typeof res.data === 'string' ? res.data : (res.data && res.data.data)
|
||
if (typeof base64 === 'string' && base64.length > 0)
|
||
return base64.startsWith('data:image') ? base64 : 'data:image/png;base64,' + base64
|
||
return null
|
||
})
|
||
} |