使用微信小程序原生头部导航
This commit is contained in:
@@ -709,7 +709,31 @@ const handleServiceClick = (serviceType) => {
|
||||
|
||||
// 处理直播按钮点击
|
||||
const handleLiveClick = () => {
|
||||
$api.msg('该功能正在开发中');
|
||||
// #ifdef MP-WEIXIN
|
||||
const feedId = "sphKH1AEeLfTJJE";
|
||||
|
||||
// 使用微信原生 API 打开视频号主页
|
||||
if (typeof wx !== "undefined" && wx.openChannelsUserProfile) {
|
||||
wx.openChannelsUserProfile({
|
||||
finderUserName: feedId,
|
||||
success: (res) => {
|
||||
console.log("打开视频号成功", res);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("打开视频号失败", err);
|
||||
$api.msg(err.errMsg || "无法打开直播,请稍后重试");
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// 如果 API 不存在,提示用户更新微信版本
|
||||
$api.msg("请更新微信版本以使用该功能");
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
// 非微信小程序环境提示
|
||||
$api.msg("该功能仅在微信小程序中可用");
|
||||
// #endif
|
||||
};
|
||||
|
||||
// 跳转到测试页面
|
||||
|
||||
Reference in New Issue
Block a user