Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

更新 API #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/api/open/getAuthUserInfo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ declare namespace my {

/**
* 客户端获取会员信息。
* @deprecated 对于 2019 年 5 月 25 日及以后创建的小程序,已不再支持使用此接口。建议查看升级后的 my.getOpenUserInfo 接口文档。
*/
function getAuthUserInfo(options: IGetAuthUserInfoOptions): void;
}
36 changes: 36 additions & 0 deletions types/api/open/userinfo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare namespace my {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名要不改成 getOpenUserInfo 吧。

interface IGetOpenUserInfoSuccessResult {
/**
* 获取用户信息后,应使用 `let userInfo = JSON.parse(res.response).response` 解析数据
*
* 成功返回 res.response 报文格式示例如下:
* ```
* `{"response": {"code": "10000","msg": "Success","countryCode": "CN","gender": "f","nickName": "XXX","avatar": "https://tfs.alipayobjects.com/images/partner/XXXXXXXX","city": "南通市","province": "江苏省"}}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要不也放一个 parse 后的类型?

interface IGetOpenUserInfoSuccessParsedResult {
  response: {
    code: 1000 | xxxx;
    ...
  }
}

* ```
*
* 未接入“获取用户基础信息”的功能包,返回 res.response 报文格式示例如下:
* ```
* `{"response":{"code":"40006","msg":"Insufficient Permissions","subCode":"isv.insufficient-isv-permissions","subMsg":"ISV权限不足,建议在开发者中心检查对应功能是否已经添加"}}`
* ```
*/
response: string;
}
interface IGetOpenUserInfoOptions {
/**
* 调用成功的回调函数
*/
success?(res: IGetOpenUserInfoSuccessResult): void;
/**
* 调用失败的回调函数
*/
fail?(): void;
/**
* 调用结束的回调函数(调用成功、失败都会执行)
*/
complete?(): void;
}
/**
* 获取支付宝会员的基础信息
*/
function getOpenUserInfo(option?: IGetOpenUserInfoOptions): void;
}
5 changes: 5 additions & 0 deletions types/api/share.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ declare namespace my {
* 隐藏分享按钮。
*/
function hideShareMenu(options?: IHideShareMenuOptions): void;

/**
* 唤起分享面板。当通过 `my.showSharePanel` 唤起分享功能时,`page.onShareAppMessage` 入参中 `from` 的值为 `code`。
*/
function showSharePanel(): void;
}
8 changes: 7 additions & 1 deletion types/page.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
declare namespace tinyapp {
type OnShareAppMessageOptions = {
from: 'button';
/**
* 触发来源:
* + button:页面分享按钮触发;
* + menu:右上角分享按钮触发
* + code:执行my.showSharePanel 触发。
*/
from: 'button'|'menu'|'code';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注意空格:

'button' | 'menu' | 'code'

target: Record<string, any>;
webViewUrl?: string;
} | {
Expand Down