客户端魔法值 API
以下魔法值能力尽在字节系的客户端内执行方可生效,在外部使用会直接忽略。
转化信息($bytedAdInfo)
你可以使用魔法值$bytedAdInfo
异步获取客户端广告的部分转化信息。
注意:仅当页面在字节域内的客户端打开且域名符合 JSB 白名单才可获得正确信息,否则返回值为空对象
例子:
<div aip-state="{ adInfo: null }" aip-init="$bytedAdInfo().then(res => adInfo = res)">
<div>{{ adInfo }}</div>
</div>
1
2
3
2
3
详细接口:
$bytedAdInfo = () => Promise<{
aid?: string;
cid?: string;
click_id?: string;
ad_type?: number;
req_id?: string;
}>
1
2
3
4
5
6
7
2
3
4
5
6
7
跳转抖音私信($openChat)
TIP
仅在抖音客户端生效
你可以使用魔法值$openChat
跳转到具体的抖音私信页面进行聊天
例子:
<div aip-state="{showDialog: false}">
<aip-button
width="375"
height="100"
content="跳转私信"
(click)="$openChat('123345')"
></aip-button>
</div>
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
详细接口:
$openChat(
id: string, // 目标聊天对象的uid,如:企业号id
)
1
2
3
2
3
抖音关注($followDouyin)
TIP
仅在抖音客户端生效
你可以使用魔法值$followDouyin
在抖音客户端内将目标用户添加到当前用户的关注列表
例子:
<head>
<meta name="followDouyin" content="['123','234']" /><!-- 必填,待关注 uid -->
</head>
<div
aip-state="{ followStatus: null, uid: '123' }">
<aip-button
(click)="$followDouyin(uid).then(res => followStatus = res.followStatus)"
>
点击关注
</aip-button>
</div>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
使用细则
uid 声明:
首先需要在<head>
标签内写入 <meta name="followDouyin" content="['${uid}']" />
。 content 内容是关注目标的 uid,每个 uid 以字符串形式,放在数组中写入。后续使用将按meta
声明的 uid 进行校验。
魔法值定义:
$followDouyin = (uid: string) => Promise<{followStatus: number}>
1
- uid 为关注的用户 ID,比如企业号 ID;
- followStatus 枚举值:
- 1 表示关注成功
- 0 表示接口返回的关注失败
- -1 表示未登录
- -2 表示接口异常
- -1000 平台错误
- -1001 uid 未出现在 meta 声明中
一键获号
TIP
仅在抖音客户端生效,在不支持的客户端为普通号码输入框。
aip-input
组件内可通过enable-auth-fill
字段开启电话字段的一键获号能力。
用户在点击该输入框时会通过底部卡片提醒用户授权使用当前客户端登录账号所绑定的手机号,用户确认后相应号码才会被填入输入框内。
例子:
<aip-form>
输入电话号码:
<aip-input
[(value)]="formModel.num1"
type="tel"
name="num1"
required
enable-auth-fill
></aip-input>
</aip-form>
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
使用细则
仅当 aip-input 组件的 type
为'tel'
且 enable-auth-fill
为真值时,触发 Focus 事件后在所支持的客户端段原生渲染场景会弹出一键获号组件,其余客户端以及 H5 渲染为普通号码输入框行为。