feat(api): 添加成就系统并升级SDK

- 升级 HaveADrink SDK 从 1.0.16 到 1.0.17 版本
- 新增 GetAchievements API 接口及相关数据类型定义
- 添加 17 个成就定义,包括打卡次数、连续打卡、标准杯累计、酒类探索等类别
- 实现成就解锁逻辑计算,支持 category_records 类型成就判断
- 创建成就徽章对接文档,定义接口格式和存储建议
- 在用户资料页面集成成就展示功能,优化图标匹配逻辑
This commit is contained in:
cg
2026-08-17 23:07:23 +08:00
parent 06ec10cf10
commit 18e7b4fd50
12 changed files with 644 additions and 29 deletions
+178
View File
@@ -65,6 +65,35 @@ export declare class AchievementConditionType extends Enum {
static getLabel(v: number|string): string;
}
/**
* 成就条件类型
*/
export declare class ConditionType extends Enum {
/**
* 总打卡次数
*/
static TotalRecords: ConditionType;
/**
* 连续打卡天数
*/
static StreakDays: ConditionType;
/**
* 累计标准杯数
*/
static TotalStandardCups: ConditionType;
/**
* 尝试过的酒类品种数
*/
static CategoryVariety: ConditionType;
/**
* 某酒类打卡次数(需配合 category 字段)
*/
static CategoryRecords: ConditionType;
static entries(): Array<option>;
static getLabel(v: number|string): string;
}
/**
* 酒类分类
*/
@@ -939,6 +968,146 @@ export declare class AchievementsData {
static fromObject(o: Object): AchievementsData;
}
/**
* 空请求(用于无参接口)
*/
export declare class GetAchievementListReq {
[key: string]: any;
/**
*/
constructor();
/**
* 从对象创建 GetAchievementListReq
*
* @param o Object
*/
static fromObject(o: Object): GetAchievementListReq;
}
/**
* 成就条件详情
*/
export declare class Condition {
[key: string]: any;
/**
* 条件类型
*/
type: ConditionType;
/**
* 目标阈值
*/
value: number;
/**
* 酒类分类(仅当 Type = category_records 时有效)
*/
category,omitempty: string;
/**
* @param type ConditionType 条件类型
* @param value number 目标阈值
* @param category,omitempty string 酒类分类(仅当 Type = category_records 时有效)
*/
constructor(type: ConditionType,value: number,category,omitempty: string,);
/**
* 从对象创建 Condition
*
* @param o Object
* - type: ConditionType, // 条件类型
* - value: number, // 目标阈值
* - category,omitempty: string, // 酒类分类(仅当 Type = category_records 时有效)
*/
static fromObject(o: Object): Condition;
}
/**
* 单个成就项
*/
export declare class AchievementItem {
[key: string]: any;
/**
* 成就唯一标识(如 first_checkin)
*/
id: string;
/**
* 成就名称
*/
name: string;
/**
* 成就描述
*/
desc: string;
/**
* 是否已解锁
*/
unlocked: boolean;
/**
* 解锁时间(ISO 8601),未解锁时为 null
*/
unlockedAt: string;
/**
* 解锁条件
*/
condition: Condition;
/**
* 进度 (0~1)
*/
progress: number;
/**
* 图标资源(前端忽略该字段,后端可省略)
*/
icon,omitempty: string;
/**
* @param id string 成就唯一标识(如 first_checkin)
* @param name string 成就名称
* @param desc string 成就描述
* @param unlocked boolean 是否已解锁
* @param unlockedAt string 解锁时间(ISO 8601),未解锁时为 null
* @param condition Condition 解锁条件
* @param progress number 进度 (0~1)
* @param icon,omitempty string 图标资源(前端忽略该字段,后端可省略)
*/
constructor(id: string,name: string,desc: string,unlocked: boolean,unlockedAt: string,condition: Condition,progress: number,icon,omitempty: string,);
/**
* 从对象创建 AchievementItem
*
* @param o Object
* - id: string, // 成就唯一标识(如 first_checkin)
* - name: string, // 成就名称
* - desc: string, // 成就描述
* - unlocked: boolean, // 是否已解锁
* - unlockedAt: string, // 解锁时间(ISO 8601),未解锁时为 null
* - condition: Condition, // 解锁条件
* - progress: number, // 进度 (0~1)
* - icon,omitempty: string, // 图标资源(前端忽略该字段,后端可省略)
*/
static fromObject(o: Object): AchievementItem;
}
/**
* 获取成就列表响应
*/
export declare class GetAchievementListResp {
[key: string]: any;
/**
* 全量 17 个成就(含未解锁)
*/
achievements: Array<AchievementItem>;
/**
* @param achievements Array<AchievementItem> 全量 17 个成就(含未解锁)
*/
constructor(achievements: Array<AchievementItem>,);
/**
* 从对象创建 GetAchievementListResp
*
* @param o Object
* - achievements: Array<AchievementItem>, // 全量 17 个成就(含未解锁)
*/
static fromObject(o: Object): GetAchievementListResp;
}
/**
* 朋友圈动态项
*/
@@ -5152,6 +5321,14 @@ export default class HaveADrink {
*/
public GetAchievements(req: GetAchievementsReq) : Promise<GetAchievementsResp>;
/**
* 获取用户所有成就列表。需登录认证,返回全量17项及解锁进度
*
* @param req GetAchievementListReq 空请求(用于无参接口)
* @return GetAchievementListResp 获取成就列表响应
*/
public GetAchievementList(req: GetAchievementListReq) : Promise<GetAchievementListResp>;
/**
* 获取朋友圈动态
*
@@ -5254,6 +5431,7 @@ export default class HaveADrink {
/**
* 更新用户偏好
*
* @deprecated 未使用
* @param req UpdatePreferencesReq 更新用户偏好请求
* @return UpdatePreferencesResp 更新用户偏好响应
*/