feat(sdk): 升级HaveADrink SDK并集成邀请系统
- 将HaveADrink依赖从1.0.8升级至1.0.12版本 - 集成邀请码功能,新增common/invite.js处理邀请链路 - 实现发送好友请求返回邀请码的新流程 - 添加删除动态功能,新增DeleteFeed接口 - 集成UniAppWebSocket适配器,重构WebSocket连接管理 - 优化好友请求支持关键词搜索功能 - 在FeedCard组件中添加删除按钮和分享按钮 - 更新SDK类型定义文件以匹配新接口规范
This commit is contained in:
+99
-2
@@ -14,7 +14,7 @@
|
||||
* 6. 社交模块 - 朋友圈动态、点赞
|
||||
|
||||
|
||||
**版本:** v1.0.8
|
||||
**版本:** v1.0.12
|
||||
|
||||
## 安装
|
||||
|
||||
@@ -100,6 +100,7 @@ client.WechatLogin(req).then(...).catch(...)
|
||||
### 获取微信手机号
|
||||
|
||||
|
||||
**已废弃:** 未使用
|
||||
|
||||
<font color="green">POST</font> `/api/have_a_drink/v1/auth/wechat/get_phone_number`
|
||||
|
||||
@@ -222,6 +223,7 @@ client.GetAchievements(req).then(...).catch(...)
|
||||
### 获取朋友圈动态
|
||||
|
||||
|
||||
**已废弃:** 不使用,待移除
|
||||
|
||||
<font color="green">GET</font> `/api/have_a_drink/v1/communication/feed`
|
||||
|
||||
@@ -1236,6 +1238,33 @@ const req = new PublishFeedReq()
|
||||
client.PublishFeed(req).then(...).catch(...)
|
||||
```
|
||||
|
||||
### 删除动态
|
||||
|
||||
|
||||
|
||||
<font color="green">DELETE</font> `/api/have_a_drink/v1/moments/feeds`
|
||||
|
||||
#### 请求参数
|
||||
|名称|类型|校验规则|说明|
|
||||
|:-|:-|:-|:-|
|
||||
|id|`string\|number`|required| 动态ID|
|
||||
|
||||
|
||||
|
||||
|
||||
#### 返回值
|
||||
|名称|类型|说明|
|
||||
|:-|:-:|:-|
|
||||
|ok|`boolean`| 是否成功<br>|
|
||||
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
const req = new DeleteFeedReq()
|
||||
client.DeleteFeed(req).then(...).catch(...)
|
||||
```
|
||||
|
||||
### 点赞
|
||||
|
||||
|
||||
@@ -1408,6 +1437,7 @@ client.GetFriends(req).then(...).catch(...)
|
||||
#### 请求参数
|
||||
|名称|类型|校验规则|说明|
|
||||
|:-|:-|:-|:-|
|
||||
|keyword|`string`|| 搜索关键词|
|
||||
|
||||
|
||||
|
||||
@@ -1445,7 +1475,6 @@ client.GetFriendRequests(req).then(...).catch(...)
|
||||
#### 请求参数
|
||||
|名称|类型|校验规则|说明|
|
||||
|:-|:-|:-|:-|
|
||||
|userId|`string\|number`|| 酒友ID|
|
||||
|message|`string`|| 消息|
|
||||
|
||||
|
||||
@@ -1454,6 +1483,7 @@ client.GetFriendRequests(req).then(...).catch(...)
|
||||
#### 返回值
|
||||
|名称|类型|说明|
|
||||
|:-|:-:|:-|
|
||||
|inviteCode|`string\|number`| 好友请求ID<br>|
|
||||
|
||||
|
||||
|
||||
@@ -1687,6 +1717,73 @@ const req = new CreateEventReq()
|
||||
client.CreateEvent(req).then(...).catch(...)
|
||||
```
|
||||
|
||||
### 修改酒局
|
||||
|
||||
|
||||
|
||||
<font color="green">POST</font> `/api/have_a_drink/v1/events/events/update`
|
||||
|
||||
#### 请求参数
|
||||
|名称|类型|校验规则|说明|
|
||||
|:-|:-|:-|:-|
|
||||
|id|`string\|number`|required| 酒局ID|
|
||||
|title|`string`|| 酒局标题|
|
||||
|time|`string`|| 酒局时间|
|
||||
|location|`string`|| 酒局地点|
|
||||
|maxPeople|`number`|| 最大人数|
|
||||
|geo|`GeoPoint`|| 坐标信息|
|
||||
|note|`string`|| 酒局备注|
|
||||
|
||||
|
||||
|
||||
**GeoPoint**
|
||||
|名称|类型|校验规则|说明|
|
||||
|:-|:-|:-|:-|
|
||||
|latitude|`number`|| 纬度|
|
||||
|longitude|`number`|| 经度|
|
||||
|
||||
|
||||
|
||||
#### 返回值
|
||||
|名称|类型|说明|
|
||||
|:-|:-:|:-|
|
||||
|ok|`boolean`| 是否成功<br>|
|
||||
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
const req = new UpdateEventReq()
|
||||
client.UpdateEvent(req).then(...).catch(...)
|
||||
```
|
||||
|
||||
### 删除酒局
|
||||
|
||||
|
||||
|
||||
<font color="green">POST</font> `/api/have_a_drink/v1/events/events/delete`
|
||||
|
||||
#### 请求参数
|
||||
|名称|类型|校验规则|说明|
|
||||
|:-|:-|:-|:-|
|
||||
|id|`string\|number`|required| 酒局ID|
|
||||
|
||||
|
||||
|
||||
|
||||
#### 返回值
|
||||
|名称|类型|说明|
|
||||
|:-|:-:|:-|
|
||||
|ok|`boolean`| 是否成功<br>|
|
||||
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
const req = new DeleteEventReq()
|
||||
client.DeleteEvent(req).then(...).catch(...)
|
||||
```
|
||||
|
||||
### 报名酒局
|
||||
|
||||
|
||||
|
||||
+257
-13
@@ -17,6 +17,15 @@ export declare interface option {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface WebsocketInterface {
|
||||
close: ((this: WebsocketInterface, ev: CloseEvent) => any) | null;
|
||||
onopen: ((this: WebsocketInterface, ev: Event) => any) | null;
|
||||
onmessage: ((this: WebsocketInterface, ev: MessageEvent) => any) | null;
|
||||
onclose(event: CloseEvent): void;
|
||||
onerror(event: ErrorEvent): void;
|
||||
send(data: string | BufferSource | Blob): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 枚举类型基类
|
||||
*/
|
||||
@@ -2934,6 +2943,52 @@ export declare class PublishFeedResp {
|
||||
static fromObject(o: Object): PublishFeedResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态请求(路径参数)
|
||||
*/
|
||||
export declare class DeleteFeedReq {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 动态ID
|
||||
*/
|
||||
id: string|number;
|
||||
|
||||
/**
|
||||
* @param id string|number 动态ID
|
||||
*/
|
||||
constructor(id: string|number,);
|
||||
/**
|
||||
* 从对象创建 DeleteFeedReq
|
||||
*
|
||||
* @param o Object
|
||||
* - id: string|number, // 动态ID
|
||||
*/
|
||||
static fromObject(o: Object): DeleteFeedReq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态响应
|
||||
*/
|
||||
export declare class DeleteFeedResp {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
ok: boolean;
|
||||
|
||||
/**
|
||||
* @param ok boolean 是否成功
|
||||
*/
|
||||
constructor(ok: boolean,);
|
||||
/**
|
||||
* 从对象创建 DeleteFeedResp
|
||||
*
|
||||
* @param o Object
|
||||
* - ok: boolean, // 是否成功
|
||||
*/
|
||||
static fromObject(o: Object): DeleteFeedResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞/取消点赞请求(路径参数)
|
||||
*/
|
||||
@@ -3265,14 +3320,20 @@ export declare class Friend {
|
||||
*/
|
||||
export declare class GetFriendRequestsReq {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 搜索关键词
|
||||
*/
|
||||
keyword: string;
|
||||
|
||||
/**
|
||||
* @param keyword string 搜索关键词
|
||||
*/
|
||||
constructor();
|
||||
constructor(keyword: string,);
|
||||
/**
|
||||
* 从对象创建 GetFriendRequestsReq
|
||||
*
|
||||
* @param o Object
|
||||
* - keyword: string, // 搜索关键词
|
||||
*/
|
||||
static fromObject(o: Object): GetFriendRequestsReq;
|
||||
}
|
||||
@@ -3405,24 +3466,18 @@ export declare class FriendRequestListData {
|
||||
export declare class SendFriendRequestReq {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 酒友ID
|
||||
*/
|
||||
userId: string|number;
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* @param userId string|number 酒友ID
|
||||
* @param message string 消息
|
||||
*/
|
||||
constructor(userId: string|number,message: string,);
|
||||
constructor(message: string,);
|
||||
/**
|
||||
* 从对象创建 SendFriendRequestReq
|
||||
*
|
||||
* @param o Object
|
||||
* - userId: string|number, // 酒友ID
|
||||
* - message: string, // 消息
|
||||
*/
|
||||
static fromObject(o: Object): SendFriendRequestReq;
|
||||
@@ -3433,14 +3488,20 @@ export declare class SendFriendRequestReq {
|
||||
*/
|
||||
export declare class SendFriendRequestResp {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 好友请求ID
|
||||
*/
|
||||
inviteCode: string|number;
|
||||
|
||||
/**
|
||||
* @param inviteCode string|number 好友请求ID
|
||||
*/
|
||||
constructor();
|
||||
constructor(inviteCode: string|number,);
|
||||
/**
|
||||
* 从对象创建 SendFriendRequestResp
|
||||
*
|
||||
* @param o Object
|
||||
* - inviteCode: string|number, // 好友请求ID
|
||||
*/
|
||||
static fromObject(o: Object): SendFriendRequestResp;
|
||||
}
|
||||
@@ -3788,6 +3849,134 @@ export declare class CreateEventResp {
|
||||
static fromObject(o: Object): CreateEventResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改酒局请求
|
||||
*/
|
||||
export declare class UpdateEventReq {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 酒局ID
|
||||
*/
|
||||
id: string|number;
|
||||
/**
|
||||
* 酒局标题
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 酒局时间
|
||||
*/
|
||||
time: string;
|
||||
/**
|
||||
* 酒局地点
|
||||
*/
|
||||
location: string;
|
||||
/**
|
||||
* 最大人数
|
||||
*/
|
||||
maxPeople: number;
|
||||
/**
|
||||
* 坐标信息
|
||||
*/
|
||||
geo: GeoPoint;
|
||||
/**
|
||||
* 酒局备注
|
||||
*/
|
||||
note: string;
|
||||
|
||||
/**
|
||||
* @param id string|number 酒局ID
|
||||
* @param title string 酒局标题
|
||||
* @param time string 酒局时间
|
||||
* @param location string 酒局地点
|
||||
* @param maxPeople number 最大人数
|
||||
* @param geo GeoPoint 坐标信息
|
||||
* @param note string 酒局备注
|
||||
*/
|
||||
constructor(id: string|number,title: string,time: string,location: string,maxPeople: number,geo: GeoPoint,note: string,);
|
||||
/**
|
||||
* 从对象创建 UpdateEventReq
|
||||
*
|
||||
* @param o Object
|
||||
* - id: string|number, // 酒局ID
|
||||
* - title: string, // 酒局标题
|
||||
* - time: string, // 酒局时间
|
||||
* - location: string, // 酒局地点
|
||||
* - maxPeople: number, // 最大人数
|
||||
* - geo: GeoPoint, // 坐标信息
|
||||
* - note: string, // 酒局备注
|
||||
*/
|
||||
static fromObject(o: Object): UpdateEventReq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改酒局响应
|
||||
*/
|
||||
export declare class UpdateEventResp {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
ok: boolean;
|
||||
|
||||
/**
|
||||
* @param ok boolean 是否成功
|
||||
*/
|
||||
constructor(ok: boolean,);
|
||||
/**
|
||||
* 从对象创建 UpdateEventResp
|
||||
*
|
||||
* @param o Object
|
||||
* - ok: boolean, // 是否成功
|
||||
*/
|
||||
static fromObject(o: Object): UpdateEventResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒局请求
|
||||
*/
|
||||
export declare class DeleteEventReq {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 酒局ID
|
||||
*/
|
||||
id: string|number;
|
||||
|
||||
/**
|
||||
* @param id string|number 酒局ID
|
||||
*/
|
||||
constructor(id: string|number,);
|
||||
/**
|
||||
* 从对象创建 DeleteEventReq
|
||||
*
|
||||
* @param o Object
|
||||
* - id: string|number, // 酒局ID
|
||||
*/
|
||||
static fromObject(o: Object): DeleteEventReq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒局响应
|
||||
*/
|
||||
export declare class DeleteEventResp {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
ok: boolean;
|
||||
|
||||
/**
|
||||
* @param ok boolean 是否成功
|
||||
*/
|
||||
constructor(ok: boolean,);
|
||||
/**
|
||||
* 从对象创建 DeleteEventResp
|
||||
*
|
||||
* @param o Object
|
||||
* - ok: boolean, // 是否成功
|
||||
*/
|
||||
static fromObject(o: Object): DeleteEventResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 报名/取消/签到请求(路径参数)
|
||||
*/
|
||||
@@ -4617,6 +4806,29 @@ export declare class ChatWebSocketResp {
|
||||
static fromObject(o: Object): ChatWebSocketResp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export declare class ChatWebSocketReq {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 连接 token
|
||||
*/
|
||||
token: string;
|
||||
|
||||
/**
|
||||
* @param token string 连接 token
|
||||
*/
|
||||
constructor(token: string,);
|
||||
/**
|
||||
* 从对象创建 ChatWebSocketReq
|
||||
*
|
||||
* @param o Object
|
||||
* - token: string, // 连接 token
|
||||
*/
|
||||
static fromObject(o: Object): ChatWebSocketReq;
|
||||
}
|
||||
|
||||
export type ClientMessage = ClientChatData | ClientTypingData | ClientReadData | ClientPingData | null
|
||||
export type ServerMessage = ServerChatData | ServerTypingData | ServerReadData | ServerAckData | ServerPongData | ServerConnectedData | ServerKickedData | null
|
||||
|
||||
@@ -4645,6 +4857,12 @@ export class ChatWebSocketConn {
|
||||
public close(): void;
|
||||
}
|
||||
|
||||
export class Config {
|
||||
host: string;
|
||||
http_request: (url: string, params: any) => Promise<any>;
|
||||
upload: (url: string, params: any) => Promise<any>;
|
||||
websocket: WebsocketInterface | undefined;
|
||||
}
|
||||
/**
|
||||
* * 喝酒了么 - 后端接口 API
|
||||
* 小程序:喝酒了么(uni-app 微信小程序)
|
||||
@@ -4660,9 +4878,9 @@ export class ChatWebSocketConn {
|
||||
*/
|
||||
export default class HaveADrink {
|
||||
host: string;
|
||||
http_request: any;
|
||||
upload: any;
|
||||
constructor(conf: any);
|
||||
http_request: (url: string, params: any) => Promise<any>;
|
||||
upload: (url: string, params: any) => Promise<any>;
|
||||
constructor(conf: Config);
|
||||
|
||||
/**
|
||||
* 设置 token
|
||||
@@ -4682,6 +4900,7 @@ export default class HaveADrink {
|
||||
/**
|
||||
* 获取微信手机号
|
||||
*
|
||||
* @deprecated 未使用
|
||||
* @param req WechatGetPhoneNumberReq 获取微信手机号
|
||||
* @return WechatGetPhoneNumberResp 获取微信手机号返回值
|
||||
*/
|
||||
@@ -4706,6 +4925,7 @@ export default class HaveADrink {
|
||||
/**
|
||||
* 获取朋友圈动态
|
||||
*
|
||||
* @deprecated 不使用,待移除
|
||||
* @param req GetFeedReq 获取朋友圈动态请求
|
||||
* @return GetFeedResp 获取朋友圈动态响应
|
||||
*/
|
||||
@@ -4831,6 +5051,14 @@ export default class HaveADrink {
|
||||
*/
|
||||
public PublishFeed(req: PublishFeedReq) : Promise<PublishFeedResp>;
|
||||
|
||||
/**
|
||||
* 删除动态
|
||||
*
|
||||
* @param req DeleteFeedReq 删除动态请求(路径参数)
|
||||
* @return DeleteFeedResp 删除动态响应
|
||||
*/
|
||||
public DeleteFeed(req: DeleteFeedReq) : Promise<DeleteFeedResp>;
|
||||
|
||||
/**
|
||||
* 点赞
|
||||
*
|
||||
@@ -4927,6 +5155,22 @@ export default class HaveADrink {
|
||||
*/
|
||||
public CreateEvent(req: CreateEventReq) : Promise<CreateEventResp>;
|
||||
|
||||
/**
|
||||
* 修改酒局
|
||||
*
|
||||
* @param req UpdateEventReq 修改酒局请求
|
||||
* @return UpdateEventResp 修改酒局响应
|
||||
*/
|
||||
public UpdateEvent(req: UpdateEventReq) : Promise<UpdateEventResp>;
|
||||
|
||||
/**
|
||||
* 删除酒局
|
||||
*
|
||||
* @param req DeleteEventReq 删除酒局请求
|
||||
* @return DeleteEventResp 删除酒局响应
|
||||
*/
|
||||
public DeleteEvent(req: DeleteEventReq) : Promise<DeleteEventResp>;
|
||||
|
||||
/**
|
||||
* 报名酒局
|
||||
*
|
||||
@@ -4989,6 +5233,6 @@ export default class HaveADrink {
|
||||
* @param req ChatWebSocket
|
||||
* @return ChatWebSocketConn
|
||||
*/
|
||||
public ChatWebSocket() : ChatWebSocketConn;
|
||||
public ChatWebSocket(input: ChatWebSocketReq) : ChatWebSocketConn;
|
||||
|
||||
}
|
||||
|
||||
+250
-12
@@ -13,6 +13,8 @@
|
||||
* 6. 社交模块 - 朋友圈动态、点赞
|
||||
*/
|
||||
|
||||
let websocket = WebSocket;
|
||||
|
||||
export class Enum {
|
||||
constructor(value) {
|
||||
this.v = value;
|
||||
@@ -2051,6 +2053,38 @@ export class PublishFeedResp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态请求(路径参数)
|
||||
*/
|
||||
export class DeleteFeedReq {
|
||||
/**
|
||||
* @param id: string|number 动态ID
|
||||
*/
|
||||
constructor(id,) {
|
||||
this.id = id;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new DeleteFeedReq(o.id,);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态响应
|
||||
*/
|
||||
export class DeleteFeedResp {
|
||||
/**
|
||||
* @param ok: boolean 是否成功
|
||||
*/
|
||||
constructor(ok,) {
|
||||
this.ok = ok;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new DeleteFeedResp(o.ok,);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞/取消点赞请求(路径参数)
|
||||
*/
|
||||
@@ -2248,12 +2282,14 @@ export class Friend {
|
||||
*/
|
||||
export class GetFriendRequestsReq {
|
||||
/**
|
||||
* @param keyword: string 搜索关键词
|
||||
*/
|
||||
constructor() {
|
||||
constructor(keyword,) {
|
||||
this.keyword = keyword;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new GetFriendRequestsReq();
|
||||
return new GetFriendRequestsReq(o.keyword,);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2336,16 +2372,14 @@ export class FriendRequestListData {
|
||||
*/
|
||||
export class SendFriendRequestReq {
|
||||
/**
|
||||
* @param userId: string|number 酒友ID
|
||||
* @param message: string 消息
|
||||
*/
|
||||
constructor(userId,message,) {
|
||||
this.userId = userId;
|
||||
constructor(message,) {
|
||||
this.message = message;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new SendFriendRequestReq(o.userId,o.message,);
|
||||
return new SendFriendRequestReq(o.message,);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2354,12 +2388,14 @@ export class SendFriendRequestReq {
|
||||
*/
|
||||
export class SendFriendRequestResp {
|
||||
/**
|
||||
* @param inviteCode: string|number 好友请求ID
|
||||
*/
|
||||
constructor() {
|
||||
constructor(inviteCode,) {
|
||||
this.inviteCode = inviteCode;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new SendFriendRequestResp();
|
||||
return new SendFriendRequestResp(o.inviteCode,);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2569,6 +2605,82 @@ export class CreateEventResp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改酒局请求
|
||||
*/
|
||||
export class UpdateEventReq {
|
||||
/**
|
||||
* @param id: string|number 酒局ID
|
||||
* @param title: string 酒局标题
|
||||
* @param time: string 酒局时间
|
||||
* @param location: string 酒局地点
|
||||
* @param maxPeople: number 最大人数
|
||||
* @param geo: GeoPoint 坐标信息
|
||||
* @param note: string 酒局备注
|
||||
*/
|
||||
constructor(id,title,time,location,maxPeople,geo,note,) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.time = time;
|
||||
this.location = location;
|
||||
this.maxPeople = maxPeople;
|
||||
this.geo = geo;
|
||||
this.note = note;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new UpdateEventReq(o.id,o.title,o.time,o.location,o.maxPeople,o.geo,o.note,);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改酒局响应
|
||||
*/
|
||||
export class UpdateEventResp {
|
||||
/**
|
||||
* @param ok: boolean 是否成功
|
||||
*/
|
||||
constructor(ok,) {
|
||||
this.ok = ok;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new UpdateEventResp(o.ok,);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒局请求
|
||||
*/
|
||||
export class DeleteEventReq {
|
||||
/**
|
||||
* @param id: string|number 酒局ID
|
||||
*/
|
||||
constructor(id,) {
|
||||
this.id = id;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new DeleteEventReq(o.id,);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒局响应
|
||||
*/
|
||||
export class DeleteEventResp {
|
||||
/**
|
||||
* @param ok: boolean 是否成功
|
||||
*/
|
||||
constructor(ok,) {
|
||||
this.ok = ok;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new DeleteEventResp(o.ok,);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 报名/取消/签到请求(路径参数)
|
||||
*/
|
||||
@@ -3087,19 +3199,36 @@ export class ChatWebSocketResp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export class ChatWebSocketReq {
|
||||
/**
|
||||
* @param token: string 连接 token
|
||||
*/
|
||||
constructor(token,) {
|
||||
this.token = token;
|
||||
|
||||
}
|
||||
static fromObject(o) {
|
||||
return new ChatWebSocketReq(o.token,);
|
||||
}
|
||||
}
|
||||
|
||||
export class ChatWebSocketConn {
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param host string 主机名
|
||||
*/
|
||||
constructor(host) {
|
||||
constructor(host, query) {
|
||||
this.host = host;
|
||||
this.reconnect = true;
|
||||
this.reconnectDelay = 1000;
|
||||
this.maxReconnectDelay = 5000;
|
||||
this.randomizationFactor = 0.5;
|
||||
this.attempt = 0;
|
||||
this.query = query;
|
||||
this.connect();
|
||||
}
|
||||
backoff(attempt) {
|
||||
@@ -3115,7 +3244,7 @@ export class ChatWebSocketConn {
|
||||
return delayWithJitter;
|
||||
}
|
||||
connect() {
|
||||
let socket = new WebSocket(`ws://${this.host}/api/have_a_drink/v1/chat/chat`);
|
||||
let socket = new websocket(`${this.host}/api/have_a_drink/v1/chat/chat?${this.query}`);
|
||||
socket.onopen = (event) => {
|
||||
this.onopen(event);
|
||||
};
|
||||
@@ -3281,6 +3410,12 @@ export class ChatWebSocketConn {
|
||||
}
|
||||
}
|
||||
|
||||
export class Config {
|
||||
host = "";
|
||||
http_request = (url, params) => {};
|
||||
upload = (url, params) => {};
|
||||
websocket = undefined;
|
||||
}
|
||||
/**
|
||||
* * 喝酒了么 - 后端接口 API
|
||||
* 小程序:喝酒了么(uni-app 微信小程序)
|
||||
@@ -3296,6 +3431,9 @@ export class ChatWebSocketConn {
|
||||
*/
|
||||
export default class HaveADrink {
|
||||
constructor(conf) {
|
||||
if (conf.websocket) {
|
||||
websocket = conf.websocket;
|
||||
}
|
||||
this.host = conf.host;
|
||||
this.http_request = conf.http_request;
|
||||
this.upload = conf.upload;
|
||||
@@ -3945,6 +4083,38 @@ export default class HaveADrink {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态
|
||||
*/
|
||||
DeleteFeed(req) {
|
||||
return new Promise((reslove, reject)=>{
|
||||
let data = req;
|
||||
let url = `${this.host}/api/have_a_drink/v1/moments/feeds`;
|
||||
|
||||
|
||||
this.http_request(url, {
|
||||
uri: '/api/have_a_drink/v1/moments/feeds',
|
||||
method: 'DELETE',
|
||||
data: data,
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then((data)=>{
|
||||
if (data.hasOwnProperty("fail")) {
|
||||
if (data.fail) {
|
||||
reject(data.msg);
|
||||
} else {
|
||||
reslove(data.data);
|
||||
}
|
||||
} else {
|
||||
reslove(data);
|
||||
}
|
||||
}).catch((err)=>reject(err));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞
|
||||
*/
|
||||
@@ -4329,6 +4499,70 @@ export default class HaveADrink {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改酒局
|
||||
*/
|
||||
UpdateEvent(req) {
|
||||
return new Promise((reslove, reject)=>{
|
||||
let data = req;
|
||||
let url = `${this.host}/api/have_a_drink/v1/events/events/update`;
|
||||
|
||||
|
||||
this.http_request(url, {
|
||||
uri: '/api/have_a_drink/v1/events/events/update',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then((data)=>{
|
||||
if (data.hasOwnProperty("fail")) {
|
||||
if (data.fail) {
|
||||
reject(data.msg);
|
||||
} else {
|
||||
reslove(data.data);
|
||||
}
|
||||
} else {
|
||||
reslove(data);
|
||||
}
|
||||
}).catch((err)=>reject(err));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒局
|
||||
*/
|
||||
DeleteEvent(req) {
|
||||
return new Promise((reslove, reject)=>{
|
||||
let data = req;
|
||||
let url = `${this.host}/api/have_a_drink/v1/events/events/delete`;
|
||||
|
||||
|
||||
this.http_request(url, {
|
||||
uri: '/api/have_a_drink/v1/events/events/delete',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then((data)=>{
|
||||
if (data.hasOwnProperty("fail")) {
|
||||
if (data.fail) {
|
||||
reject(data.msg);
|
||||
} else {
|
||||
reslove(data.data);
|
||||
}
|
||||
} else {
|
||||
reslove(data);
|
||||
}
|
||||
}).catch((err)=>reject(err));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 报名酒局
|
||||
*/
|
||||
@@ -4556,9 +4790,13 @@ export default class HaveADrink {
|
||||
/**
|
||||
* 注意:连接建立后,服务端会先验证 token,然后推送 connected 事件
|
||||
*/
|
||||
ChatWebSocket() {
|
||||
ChatWebSocket(input) {
|
||||
const url = new URL(this.host);
|
||||
return new ChatWebSocketConn(url.host);
|
||||
let host = "ws://" + url.host;
|
||||
if (url.protocol == 'https:') {
|
||||
host = "wss://" + url.host;
|
||||
}
|
||||
return new ChatWebSocketConn(host, new URLSearchParams(Object.fromEntries(Object.entries(input).filter(([_, v]) => v !== '' && v !== null && v !== undefined))).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "HaveADrink",
|
||||
"type": "module",
|
||||
"version": "v1.0.8",
|
||||
"version": "v1.0.12",
|
||||
"description": "喝酒了么 API 服务",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user