diff --git a/components-diy/diy-channel-video.vue b/components-diy/diy-channel-video.vue index 00183c6..39dcd98 100644 --- a/components-diy/diy-channel-video.vue +++ b/components-diy/diy-channel-video.vue @@ -19,13 +19,13 @@ {{ value.videoTitle }} - - {{ value.viewCount }}次观看 + + {{ value.viewCount }}次观看 - + @@ -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); } } }; diff --git a/components-diy/js/wechat-channel.js b/components-diy/js/wechat-channel.js index e5adca1..baf9f23 100644 --- a/components-diy/js/wechat-channel.js +++ b/components-diy/js/wechat-channel.js @@ -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(); } }; \ No newline at end of file diff --git a/pages_tool/contact/contact.vue b/pages_tool/contact/contact.vue index 6a6a86a..71daa9f 100644 --- a/pages_tool/contact/contact.vue +++ b/pages_tool/contact/contact.vue @@ -260,6 +260,10 @@ export default { if (item.avatarImageType === 'upload') { item.avatarUrl = this.$util.img(item.avatarUrl); } + // #ifdef MP-WEIXIN + // item.embedMode = Boolean(item.feedToken); + item.finderUserName = item.channelName; + // #endif return item; }); // 视频号