微信小程序兼容修改
This commit is contained in:
@@ -701,9 +701,43 @@ const handleServiceClick = (serviceType) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 处理直播按钮点击
|
||||
// 处理直播按钮点击 - 跳转微信视频号
|
||||
const handleLiveClick = () => {
|
||||
$api.msg('该功能正在开发中');
|
||||
// #ifdef MP-WEIXIN
|
||||
const feedId = 'sphKH1AEeLfTJJE';
|
||||
|
||||
// 使用微信原生 API 打开视频号直播
|
||||
if (typeof wx !== 'undefined' && wx.openChannelsUserProfile) {
|
||||
wx.openChannelsUserProfile({
|
||||
// feedId: feedId,
|
||||
finderUserName: feedId, // 视频号 finderUserName,如果feedId足够可以留空
|
||||
success: (res) => {
|
||||
console.log('打开视频号成功', res);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('打开视频号失败', err);
|
||||
$api.msg(err.errMsg || '无法打开直播,请稍后重试');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 如果 API 不存在,尝试使用 uni API
|
||||
uni.openChannelsLive({
|
||||
feedId: feedId,
|
||||
success: (res) => {
|
||||
console.log('打开视频号成功', res);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('打开视频号失败', err);
|
||||
$api.msg('无法打开直播,请检查微信版本或稍后重试');
|
||||
}
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
// 非微信小程序环境提示
|
||||
$api.msg('该功能仅在微信小程序中可用');
|
||||
// #endif
|
||||
};
|
||||
|
||||
// 跳转到测试页面
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<AppLayout title="我的" back-gorund-color="#F4F4F4">
|
||||
<AppLayout back-gorund-color="#F4F4F4">
|
||||
<!-- 自定义tabbar -->
|
||||
<CustomTabBar :currentPage="4" />
|
||||
<!-- 企业用户信息卡片 -->
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<AppLayout title="附近" :use-scroll-view="false">
|
||||
<AppLayout :use-scroll-view="false">
|
||||
<template #headerleft>
|
||||
<view class="btnback">
|
||||
<image src="@/static/icon/back.png" @click="navBack"></image>
|
||||
@@ -19,10 +19,10 @@
|
||||
<component :is="components[index]" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<oneComponent v-show="currentIndex === 0" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<twoComponent v-show="currentIndex === 1" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<threeComponent v-show="currentIndex === 2" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<fourComponent v-show="currentIndex === 3" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<oneComponent v-if="index === 0" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<twoComponent v-if="index === 1" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<threeComponent v-if="index === 2" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<fourComponent v-if="index === 3" :ref="(el) => handelComponentsRef(el, index)" />
|
||||
<!-- #endif -->
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
Reference in New Issue
Block a user