button 组件跳转抖音号个人页

更新时间 2024-07-24 02:58:49
收藏
我的收藏
基础库 2.92.0 开始支持本能力。支持小程序跳转抖音号个人页,需要将 button 组件 open-type 的值设置为 openAwemeUserProfile。​
使用该功能前开发者需要至开发者后台-设置-关联设置-抖音号管理为对应的抖音号申请 跳转抖音号个人页能力,具体信息请参考关注抖音号
button 组件常规属性请参考button 按钮。​

属性说明​

属性名
类型
默认值
必填
说明
最低支持版本
open-type
string
用于调用开放能力,此场景下需要设置为 "openAwemeUserProfile"
2.92.0
data-aweme-id
string
跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号
2.92.0
bindopenawemeuserprofile
EventHandle
监听跳转抖音号个人页的回调,open-type=openAwemeUserProfile时有效
2.92.0

bindopenawemeuserprofile 事件对象的 detail​

object 类型,属性如下:​
属性名
类型
说明
最低支持版本
errMsg
string
错误描述
2.92.0
errNo
number
错误码
2.92.0
回调成功
Object 类型,属性如下:​
参数
参数类型
说明
errMsg
string
跳转成功信息,恒为'openAwemeUserProfile:ok'
errNo
number
恒为0
hasFollowed
boolean
是否关注
回调失败
Object 类型, 属性如下:​
参数
参数类型
说明
errMsg
string
跳转失败信息,以'openAwemeUserProfile:fail'开头​
errNo
number
错误代码
错误说明:​
errNo
errMsg
说明
最低支持版本
21100
openAwemeUserProfile:fail openAwemeUserProfile:%s
打开个人抖音号主页失败
2.92.0
10301
openAwemeUserProfile:fail feature is not supported in app
宿主未实现
2.92.0
10601
openAwemeUserProfile:fail not login
没有登录
2.92.0
21101
openAwemeUserProfile:fail aweme uid is null
没有绑定想要跳转的抖音号
2.92.0
21102​
openAwemeUserProfile:fail awemeId not exist​
抖音号不存在​
2.92.0
21103​
openAwemeUserProfile:fail awemeId not support​
只支持小程序绑定的品牌号、员工号、合作号​
2.92.0

扫码体验​

代码示例​

html
复制
<button
open-type="openAwemeUserProfile"
bindopenawemeuserprofile="eventHandler"
data-aweme-id="{{awemeId}}"
>
跳转抖音号个人页
</button>
js
复制
Page({
data: {
awemeId: "需要跳转的抖音号",
},
eventHandler(e) {
if (e.detail.errNo) {
console.log("跳转抖音号个人页失败", e.detail);
} else {
console.log("跳转抖音号个人页成功");
}
},
});

Bug & Tip​

    Tip:使用该功能前开发者需要去开发者后台-设置-关联设置-抖音号管理为对应的抖音号申请跳转抖音号个人页能力。