chore(电子名片): 支持点击视频号视频,非嵌入模式可以播放了

This commit is contained in:
2026-01-13 11:17:14 +08:00
parent 8ceeca33b4
commit e20968aee2
3 changed files with 31 additions and 54 deletions

View File

@@ -19,13 +19,13 @@
<view class="video-info">
<!-- 视频标题支持多行显示控制 -->
<view class="video-title" :style="{ '--title-line-clamp': titleLineClamp }">{{ value.videoTitle }}</view>
<!-- 视频统计信息非列表模式下显示 -->
<view class="video-stats" v-if="value.showViewCount && !listMode">{{ value.viewCount }}次观看</view>
<!-- 视频统计信息 -->
<view class="video-stats" v-if="value.showViewCount">{{ value.viewCount }}次观看</view>
</view>
</view>
<!-- 跳转式视频播放 -->
<view v-else @tap.stop="playVideo" @click.stop="playVideo" class="video-container">
<view v-else @click.stop="playVideo" class="video-container">
<view class="video-cover-wrap" :style="coverStyle">
<image class="video-cover" :src="$util.img(value.coverUrl)" mode="aspectFill"></image>
<view class="channel-play-btn" v-if="showPlayBtn" :style="playBtnStyle">
@@ -143,7 +143,11 @@ export default {
*/
canUseEmbedMode() {
// #ifdef MP-WEIXIN
return this.value?.embedMode && wechatChannelUtil.isEmbedModeSupported();
const enableEmbedMode = Boolean(this.value?.embedMode)
&& Boolean(this.value?.feedToken)
&& wechatChannelUtil.isEmbedModeSupported();
console.log('enableEmbedMode', enableEmbedMode);
return enableEmbedMode;
// #endif
return false
},
@@ -156,17 +160,7 @@ export default {
return wechatChannelConfig.icon.playIcon
// #endif
return ''
},
/**
* 视频号用户名,适用于微信视频号
* 优先使用 finderUserName其次使用 channelName
* @returns {string}
*/
finderUserName() {
return this.value?.finderUserName || this.value?.channelName || ''
},
}
},
methods: {
/**
@@ -174,18 +168,7 @@ export default {
* 触发 video-play 事件,由父组件处理具体播放逻辑
*/
async playVideo() {
// #ifdef MP-WEIXIN
const playload = {
...this.value,
finderUserName: this.finderUserName
}
console.log('playload', playload);
this.$emit('video-play', playload);
// #endif
// #ifdef H5
this.$emit('video-play', this.value);
// #endif
this.$emit('video-play', this.value);
}
}
};

View File

@@ -17,7 +17,7 @@ export const wechatChannelConfig = {
maxHeight: 500, // 最大视频高度rpx
defaultCoverUrl: 'addon/personnel/shop/view/enterprise/default-video-cover.png', // 默认视频封面
},
// 播放按钮配置
playButton: {
size: 80, // 标准尺寸rpx
@@ -26,21 +26,21 @@ export const wechatChannelConfig = {
smallIconSize: 30, // 小图标尺寸rpx
background: 'rgba(0, 0, 0, 0.4)', // 背景颜色
},
// 布局配置
layout: {
borderRadius: 12, // 圆角rpx
padding: 16, // 内边距rpx
margin: 10, // 外边距rpx
},
// 字体配置
font: {
channelNameSize: 28, // 频道名称字体大小rpx
videoTitleSize: 28, // 视频标题字体大小rpx
statsSize: 24, // 统计信息字体大小rpx
},
// 颜色配置
color: {
channelName: '#333', // 频道名称颜色
@@ -48,13 +48,13 @@ export const wechatChannelConfig = {
stats: '#999', // 统计信息颜色
border: '#f0f0f0', // 边框颜色
},
// 微信相关配置
wechat: {
minSdkVersion: '2.19.2', // 最小微信基础库版本
embedComponent: 'component.channel-video', // 嵌入式视频组件名称
embedComponent: 'channel-video', // 嵌入式视频组件名称
},
// 错误提示配置
error: {
notWechat: '当前环境不是微信小程序',
@@ -68,14 +68,14 @@ export const wechatChannelConfig = {
export const getwechatChannelConfig = (key, defaultValue = null) => {
const keys = key.split('.');
let config = wechatChannelConfig;
for (const k of keys) {
if (config[k] === undefined) {
return defaultValue;
}
config = config[k];
}
return config;
};
@@ -164,24 +164,14 @@ export const wechatChannelUtil = {
handleError(err, item) {
console.error('微信视频号错误:', err);
let errorMsg = err.errMsg || '视频播放失败';
// 可以添加错误上报或用户提示逻辑
switch (err.errCode) {
case 40001:
errorMsg = '错误40001检查主体要求或嵌入式打开的关联关系';
break;
case 40002:
errorMsg = '错误40002参数错误检查 feedId 和 finderUserName';
break;
default:
break;
let errorMsg = err.errMsg || '微信视频播放失败';
const showErrorToast = (otherMsgs = []) => {
uni.showToast({
title: [errorMsg, ...otherMsgs].join('\n'),
icon: 'none',
duration: 5000
});
}
uni.showToast({
title: [errorMsg, 'feedId: ' + item.feedId, 'finderUserName: ' + item.finderUserName, 'feedToken: ' + item.feedToken].join('\n'),
icon: 'none',
duration: 5000
});
showErrorToast();
}
};