deotalandAi/apps/frontend/src/views/user/index.js

174 lines
4.2 KiB
JavaScript

import { clientApi, requestUtils } from '@deotaland/utils';
export class UserController {
constructor() {
}
//返回当前用户的邀请码列表及使用状态
async getCodes() {
return await requestUtils.common(clientApi.default.INVITE_CODES);
/*
返回示例:
{
"code": 0,
"success": true,
"data": [
{
"inviteCode": "string",
"codeType": "string",
"isUsed": 1073741824,
"invitedUserNickname": "string",
"usedAt": "2025-12-18T06:33:05.386Z",
"createdAt": "2025-12-18T06:33:05.386Z"
}
],
"message": "操作成功"
}
*/
}
// 返回邀请的用户列表,包含奖励明细
async getInviteRecords() {
return await requestUtils.common(clientApi.default.INVITE_RECORDS);
/*
返回示例:
{
"code": 0,
"success": true,
"data": [
{
"invitedUserId": 9007199254740991,
"invitedUserNickname": "string",
"invitedUserAvatar": "string",
"invitedAt": "2025-12-18T06:33:05.383Z",
"rewards": [
{
"rewardType": 1073741824,
"rewardTypeName": "string",
"rewardScore": 0,
"grantedAt": "2025-12-18T06:33:05.383Z"
}
]
}
],
"message": "操作成功"
}
*/
}
// 返回用户信息
async getUserInfo() {
return await requestUtils.common(clientApi.default.USER_INFO);
/*
返回示例:
{
"code": 0,
"success": true,
"data": {
"id": 9007199254740991,
"nickname": "string",
"email": "string",
"avatarUrl": "string",
"phone": "string",
"lastActive": "2025-12-19T09:45:20.801Z",
"status": "string",
"userRole": 1073741824,
"inviteCode": "string",
"otherInfo": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"createdAt": "2025-12-19T09:45:20.801Z",
"updatedAt": "2025-12-19T09:45:20.801Z"
},
"message": "操作成功"
}
*/
}
// 候补会员使用邀请码升级为正式会员
async upgrade(data) {
let parmas = {
inviteCode:data.inviteCode,
}
return await requestUtils.common(clientApi.default.UPGRADE,parmas);
}
// 修改用户信息
async updateProfile(data) {
let parmas = {
nickname:data.nickname,
avatarUrl:data.avatarUrl,
}
return await requestUtils.common(clientApi.default.USER_PROFILE,parmas);
}
// 查询用户代金券列表
async getVoucherList() {
return await requestUtils.common(clientApi.default.getAvailableCoupon);
/*
{
"code": 0,
"success": true,
"data": [
{
"id": 9007199254740991,
"couponCode": "string",
"amount": 0,
"currency": "string",
"minOrderAmount": 0,
"status": 1073741824,
"statusDesc": "string",
"expireAt": "2026-01-07T08:08:58.652Z",
"sourceType": "string",
"sourceDesc": "string",
"createdAt": "2026-01-07T08:08:58.652Z"
}
],
"message": "操作成功"
}
*/
}
// 查询用户代金券数量统计
async getVoucherCount() {
return await requestUtils.common(clientApi.default.getCouponCount);
/*
{
"code": 0,
"success": true,
"data": {
"availableCount": 1073741824,
"usedCount": 1073741824,
"expiredCount": 1073741824,
"totalCount": 1073741824
},
"message": "操作成功"
}
*/
}
// 查询代金券详情
async getVoucherDetail(data) {
const requestUrl = {
method:clientApi.default.getCouponDetail.method,
url:clientApi.default.getCouponDetail.url.replace('{id}', data.id),
isLoading:clientApi.default.getCouponDetail.isLoading,
}
return await requestUtils.common(requestUrl);
/*
{
"code": 0,
"success": true,
"data": {
"id": 9007199254740991,
"couponCode": "string",
"amount": 0,
"currency": "string",
"minOrderAmount": 0,
"status": 1073741824,
"statusDesc": "string",
"expireAt": "2026-01-07T08:11:33.821Z",
"sourceType": "string",
"sourceDesc": "string",
"createdAt": "2026-01-07T08:11:33.821Z"
},
"message": "操作成功"
}
*/
//详情
}
}