From 1d62b37060b87829f50b58c82b6413f282ac3a73 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Thu, 12 Mar 2026 15:09:27 +0800 Subject: [PATCH 01/94] =?UTF-8?q?chore=EF=BC=9A=E5=A4=B4=E5=83=8F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BB=8E=E7=9B=B8=E5=86=8C=E9=80=89=E6=8B=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=AD=A3=E5=B8=B8=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 9 ++++++--- pages_tool/ai-chat/ai-chat-message.vue | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 6a72520..c8d9866 100644 --- a/manifest.json +++ b/manifest.json @@ -71,11 +71,14 @@ "scope.userLocation" : { "desc" : "为了更好地为您提供服务" }, - "scope.writePhotosAlbum" : { - "desc" : "为了更好地为您提供服务" - }, "scope.userClipboard" : { "desc" : "为了方便您复制信息" + }, + "scope.camera" : { + "desc" : "用于拍照上传头像" + }, + "scope.writePhotosAlbum" : { + "desc" : "用于从相册选择和保存头像" } }, "requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ], diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 82866a7..2ce9d16 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -280,7 +280,7 @@ - + @@ -612,16 +612,19 @@ export default { // 从相册选择头像 chooseAvatarFromAlbum() { + console.log('选择从相册选择头像') this.selectAvatar('album') }, // 拍照上传头像 takeAvatarWithCamera() { + console.log('选择拍照上传头像') this.selectAvatar('camera') }, // 统一头像选择方法 selectAvatar(sourceType) { + console.log('开始选择头像,来源:', sourceType) uni.chooseImage({ count: 1, // 仅选择1张 sizeType: ['compressed'], // 压缩图片 From fdf85dfec76f7b9ef4d2e84bc9c952da126b8254 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Thu, 12 Mar 2026 18:25:12 +0800 Subject: [PATCH 02/94] =?UTF-8?q?chore=EF=BC=9A=E6=9B=B4=E6=8D=A2=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 79 ++++++++++++++++++++------ 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 2ce9d16..2c937c8 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -299,10 +299,6 @@ 从相册选择 - @@ -613,22 +609,66 @@ export default { // 从相册选择头像 chooseAvatarFromAlbum() { console.log('选择从相册选择头像') - this.selectAvatar('album') + this.selectAvatar() }, - // 拍照上传头像 - takeAvatarWithCamera() { - console.log('选择拍照上传头像') - this.selectAvatar('camera') - }, - - // 统一头像选择方法 - selectAvatar(sourceType) { - console.log('开始选择头像,来源:', sourceType) + // 统一头像选择方法 - 仅从相册选择 + selectAvatar() { + console.log('开始选择头像') + + // #ifdef H5 + // H5环境下的处理 - 仅从相册选择 + const input = document.createElement('input') + input.type = 'file' + input.accept = 'image/*' + input.style.display = 'none' + + // 监听文件选择 + input.onchange = (e) => { + const file = e.target.files[0] + if (file) { + // 创建临时URL + const tempFilePath = URL.createObjectURL(file) + + // 1. 本地预览更新 + this.localUserAvatar = tempFilePath + + // 2. 持久化缓存(支持页面刷新后保留) + const reader = new FileReader() + reader.onload = (e) => { + const base64 = e.target.result + uni.setStorageSync('user_avatar', base64) + } + reader.readAsDataURL(file) + + // 3. 通知父组件(可选,用于同步到服务器等场景) + this.$emit('avatar-changed', tempFilePath) + + // 4. 关闭弹窗 + this.closeAvatarSelector() + + // 5. 提示成功 + uni.showToast({ + title: '头像更换成功', + icon: 'success', + duration: 1500 + }) + } else { + // 用户取消选择 + this.closeAvatarSelector() + } + } + + // 触发点击 + input.click() + // #endif + + // #ifdef MP-WEIXIN + // 微信小程序环境下,使用uni.chooseImage - 仅从相册选择 uni.chooseImage({ count: 1, // 仅选择1张 sizeType: ['compressed'], // 压缩图片 - sourceType: [sourceType], // 来源:相册/相机 + sourceType: ['album'], // 仅从相册选择 success: (res) => { const tempFilePath = res.tempFilePaths[0] @@ -654,12 +694,14 @@ export default { fail: (error) => { console.error('选择头像失败:', error) // 权限拒绝处理 - if (error.errMsg.includes('deny')) { + if (error.errMsg && error.errMsg.includes('deny')) { uni.showToast({ - title: '请开启相册/相机权限', + title: '请开启相册权限', icon: 'none', duration: 2000 }) + } else if (error.errMsg && error.errMsg.includes('cancel')) { + // 用户取消选择,不显示错误提示 } else { uni.showToast({ title: '头像选择失败,请重试', @@ -667,8 +709,11 @@ export default { duration: 2000 }) } + // 关闭弹窗 + this.closeAvatarSelector() } }) + // #endif }, // 新增:打开昵称编辑弹窗 From 4bcf0cbd2d931c2be3eef65bbe0804f5f1396213 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Thu, 12 Mar 2026 18:29:11 +0800 Subject: [PATCH 03/94] =?UTF-8?q?chore=EF=BC=9A=E5=8F=AF=E4=BB=A5=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E6=B8=85=E7=A9=BA=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 2c937c8..6b902ee 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -1464,6 +1464,22 @@ export default { this.$emit('location-selected', locationMessage) } }) + }, + + // 清空聊天记录 + clearMessages() { + // 清空消息数组 + this.messages = [] + // 重置消息 ID + this.messageId = 0 + // 清除会话 ID + this.currentConversationId = null + aiService.clearConversationId() + this.clearConversationIdFromLocal() + // 重置历史偏移量 + this.historyOffset = 0 + // 触发清空事件 + this.$emit('messages-cleared') } } } From 7ffe4acc0f1055b79d9631ed64b5a8b7813e5760 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Fri, 13 Mar 2026 13:57:24 +0800 Subject: [PATCH 04/94] =?UTF-8?q?chore=EF=BC=9A=E9=9A=90=E8=97=8F=E4=BA=86?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=BD=95=E9=9F=B3?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 6b902ee..9b84302 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -182,10 +182,10 @@ - - From 0912b9b0311e65347ae698d1b7cb564259b5a01a Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Fri, 13 Mar 2026 16:41:00 +0800 Subject: [PATCH 05/94] =?UTF-8?q?chore=EF=BC=9A=E6=99=BA=E8=83=BD=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E5=8A=A0=E4=BA=86=E5=95=86=E5=93=81=E7=9A=84=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 316 +++++++++++++++++++++++-- 1 file changed, 300 insertions(+), 16 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 9b84302..4fd1bed 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -182,6 +182,9 @@ + @@ -279,6 +282,50 @@ + + + + + + 选择商品 + + + + + + {{ category.category_name }} + + + + + 加载商品中... + + + 该分类下暂无商品 + + + + + {{ product.goods_name }} + ¥{{ product.price }} + + + + + + + @@ -410,22 +457,28 @@ export default { // 默认头像路径 defaultAvatar: '/static/images/default-avatar.png', // 头像选择弹窗控制 - showAvatarSelector: false, - // 新增:用户昵称相关 - localUserNickname: '', // 当前用户昵称 - defaultNickname: '我', // 默认昵称 - showNicknameEditor: false, // 昵称编辑弹窗控制 - tempNickname: '', // 昵称编辑临时值 - // Dify API相关 - currentConversationId: null, - isAIServiceAvailable: true, - aiServiceError: null, - isLoadingHistory: false, // 新增:标记历史加载状态 - shouldScrollToBottom: false, - scrollTimer: null, - lastScrollTop: 0, - historyOffset: 0, - isFetchingHistory: false + showAvatarSelector: false, // 头像选择弹窗控制 + // 新增:用户昵称相关 + localUserNickname: '', // 当前用户昵称 + defaultNickname: '我', // 默认昵称 + showNicknameEditor: false, // 昵称编辑弹窗控制 + tempNickname: '', // 昵称编辑临时值 + // 商品选择相关 + showProductSelector: false, // 商品选择弹窗控制 + productCategories: [], // 商品分类列表 + selectedCategoryIndex: 0, // 当前选中的分类索引 + selectedCategoryProducts: [], // 当前分类下的商品列表 + loadingProducts: false, // 商品加载状态 + // Dify API相关 + currentConversationId: null, + isAIServiceAvailable: true, + aiServiceError: null, + isLoadingHistory: false, // 新增:标记历史加载状态 + shouldScrollToBottom: false, + scrollTimer: null, + lastScrollTop: 0, + historyOffset: 0, + isFetchingHistory: false } }, onShow() { @@ -1466,6 +1519,111 @@ export default { }) }, + // 选择商品 + selectProduct() { + this.hideToolsPanel() + this.showProductSelector = true + this.loadProductCategories() + }, + + // 关闭商品选择弹窗 + closeProductSelector() { + this.showProductSelector = false + }, + + // 加载商品分类 + loadProductCategories() { + uni.showLoading({ title: '加载商品分类中...' }) + + this.$api.sendRequest({ + url: '/api/goodscategory/tree', + data: { + level: 2 + }, + success: (res) => { + uni.hideLoading() + + if (res.code == 0 && res.data) { + this.productCategories = res.data + if (res.data.length > 0) { + this.selectCategory(0) + } + } else { + uni.showToast({ + title: '获取商品分类失败', + icon: 'none' + }) + this.closeProductSelector() + } + }, + fail: () => { + uni.hideLoading() + uni.showToast({ + title: '网络错误,请稍后重试', + icon: 'none' + }) + this.closeProductSelector() + } + }) + }, + + // 选择分类 + selectCategory(index) { + this.selectedCategoryIndex = index + const category = this.productCategories[index] + if (category) { + this.loadCategoryProducts(category.id) + } + }, + + // 加载分类商品 + loadCategoryProducts(categoryId) { + this.loadingProducts = true + this.selectedCategoryProducts = [] + + this.$api.sendRequest({ + url: '/api/goods/list', + data: { + category_id: categoryId, + page: 1, + limit: 50 + }, + success: (res) => { + this.loadingProducts = false + + if (res.code == 0 && res.data && res.data.list) { + this.selectedCategoryProducts = res.data.list + } else { + this.selectedCategoryProducts = [] + } + }, + fail: () => { + this.loadingProducts = false + this.selectedCategoryProducts = [] + } + }) + }, + + // 选择商品 + selectProductItem(product) { + // 构建商品消息 + const productMessage = { + id: ++this.messageId, + role: 'user', + type: 'text', + content: `我想了解以下商品的信息:\n商品名称:${product.goods_name}\n价格:¥${product.price}\n商品ID:${product.id}`, + timestamp: Date.now(), + product: product + } + + this.messages.push(productMessage) + this.closeProductSelector() + this.$emit('product-selected', productMessage) + + // 触发AI回复 + this.sendMessageWithContent(productMessage.content) + }, + // 清空聊天记录 clearMessages() { // 清空消息数组 @@ -2842,6 +3000,132 @@ $radius-lg: 36rpx; } } +/* 商品选择弹窗样式 */ +.product-selector-popup { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 9999; + + .product-selector-mask { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.5); + } + + .product-selector-panel { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 90%; + max-width: 800rpx; + max-height: 80vh; + background-color: #fff; + border-radius: 20rpx; + overflow: hidden; + + .product-selector-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 20rpx; + border-bottom: 1rpx solid #e8edf3; + + text { + font-size: 32rpx; + font-weight: bold; + color: #4e5969; + } + + .close-btn { + padding: 0; + background: none; + + .iconfont { + font-size: 32rpx; + color: #8492a6; + } + } + } + + .product-selector-content { + display: flex; + height: 60vh; + + .category-list { + width: 200rpx; + border-right: 1rpx solid #e8edf3; + + .category-item { + padding: 20rpx; + text-align: center; + border-bottom: 1rpx solid #e8edf3; + + &.active { + background-color: #f5f7fa; + font-weight: bold; + color: #6c8ebf; + } + } + } + + .product-list { + flex: 1; + padding: 20rpx; + + .loading { + text-align: center; + padding: 40rpx; + color: #8492a6; + } + + .empty { + text-align: center; + padding: 40rpx; + color: #8492a6; + } + + .product-item { + display: flex; + padding: 15rpx; + border-bottom: 1rpx solid #e8edf3; + + .product-image { + width: 120rpx; + height: 120rpx; + border-radius: 8rpx; + margin-right: 15rpx; + } + + .product-info { + flex: 1; + + .product-name { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + margin-bottom: 10rpx; + color: #4e5969; + } + + .product-price { + color: #f56c6c; + font-weight: bold; + } + } + } + } + } + } +} + /* 响应式适配 */ @media (max-width: 750rpx) { .ai-chat-container { From 875072bb68a149f7c94c30b17e7a1f83ab5364e1 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Sat, 14 Mar 2026 10:53:55 +0800 Subject: [PATCH 06/94] =?UTF-8?q?chore=EF=BC=9A=E5=95=86=E5=93=81=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=88=86=E4=BA=AB=E7=BB=99=E6=99=BA=E8=83=BD=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E8=BF=9B=E8=A1=8C=E8=A7=A3=E7=AD=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components-diy/diy-category-item.vue | 51 +++++++ pages_tool/ai-chat/ai-chat-message.vue | 180 +------------------------ pages_tool/ai-chat/index.vue | 28 ++++ 3 files changed, 83 insertions(+), 176 deletions(-) diff --git a/components-diy/diy-category-item.vue b/components-diy/diy-category-item.vue index f6515cb..bb8795d 100644 --- a/components-diy/diy-category-item.vue +++ b/components-diy/diy-category-item.vue @@ -120,6 +120,10 @@ {{ showMarketPrice(item) }} + + 🤖 + 更多详情 + - - - - - - - {{ message.title }} - ¥{{ message.price }} - {{ message.description }} - - - - + @@ -182,9 +169,6 @@ - @@ -282,50 +266,6 @@ - - - - - - 选择商品 - - - - - - {{ category.category_name }} - - - - - 加载商品中... - - - 该分类下暂无商品 - - - - - {{ product.goods_name }} - ¥{{ product.price }} - - - - - - - @@ -463,12 +403,7 @@ export default { defaultNickname: '我', // 默认昵称 showNicknameEditor: false, // 昵称编辑弹窗控制 tempNickname: '', // 昵称编辑临时值 - // 商品选择相关 - showProductSelector: false, // 商品选择弹窗控制 - productCategories: [], // 商品分类列表 - selectedCategoryIndex: 0, // 当前选中的分类索引 - selectedCategoryProducts: [], // 当前分类下的商品列表 - loadingProducts: false, // 商品加载状态 + // Dify API相关 currentConversationId: null, isAIServiceAvailable: true, @@ -1320,11 +1255,7 @@ export default { this.$emit('link-open', message) }, - // 查看商品 - viewProduct(message) { - this.$emit('product-view', message) - }, - + // 处理操作 handleAction(action, message) { // 处理重试操作 @@ -1519,110 +1450,7 @@ export default { }) }, - // 选择商品 - selectProduct() { - this.hideToolsPanel() - this.showProductSelector = true - this.loadProductCategories() - }, - - // 关闭商品选择弹窗 - closeProductSelector() { - this.showProductSelector = false - }, - - // 加载商品分类 - loadProductCategories() { - uni.showLoading({ title: '加载商品分类中...' }) - - this.$api.sendRequest({ - url: '/api/goodscategory/tree', - data: { - level: 2 - }, - success: (res) => { - uni.hideLoading() - - if (res.code == 0 && res.data) { - this.productCategories = res.data - if (res.data.length > 0) { - this.selectCategory(0) - } - } else { - uni.showToast({ - title: '获取商品分类失败', - icon: 'none' - }) - this.closeProductSelector() - } - }, - fail: () => { - uni.hideLoading() - uni.showToast({ - title: '网络错误,请稍后重试', - icon: 'none' - }) - this.closeProductSelector() - } - }) - }, - - // 选择分类 - selectCategory(index) { - this.selectedCategoryIndex = index - const category = this.productCategories[index] - if (category) { - this.loadCategoryProducts(category.id) - } - }, - - // 加载分类商品 - loadCategoryProducts(categoryId) { - this.loadingProducts = true - this.selectedCategoryProducts = [] - - this.$api.sendRequest({ - url: '/api/goods/list', - data: { - category_id: categoryId, - page: 1, - limit: 50 - }, - success: (res) => { - this.loadingProducts = false - - if (res.code == 0 && res.data && res.data.list) { - this.selectedCategoryProducts = res.data.list - } else { - this.selectedCategoryProducts = [] - } - }, - fail: () => { - this.loadingProducts = false - this.selectedCategoryProducts = [] - } - }) - }, - - // 选择商品 - selectProductItem(product) { - // 构建商品消息 - const productMessage = { - id: ++this.messageId, - role: 'user', - type: 'text', - content: `我想了解以下商品的信息:\n商品名称:${product.goods_name}\n价格:¥${product.price}\n商品ID:${product.id}`, - timestamp: Date.now(), - product: product - } - - this.messages.push(productMessage) - this.closeProductSelector() - this.$emit('product-selected', productMessage) - - // 触发AI回复 - this.sendMessageWithContent(productMessage.content) - }, + // 清空聊天记录 clearMessages() { diff --git a/pages_tool/ai-chat/index.vue b/pages_tool/ai-chat/index.vue index 62be17b..9002f06 100644 --- a/pages_tool/ai-chat/index.vue +++ b/pages_tool/ai-chat/index.vue @@ -257,6 +257,20 @@ export default { // ========== 初始化页面 ========== initChat() { console.log('AI聊天页面初始化'); + + // 检查是否有从商品分类传递过来的商品信息 + const selectedProduct = uni.getStorageSync('selectedProduct') + if (selectedProduct) { + console.log('检测到选择的商品:', selectedProduct) + + // 清除存储的商品信息,避免重复发送 + uni.removeStorageSync('selectedProduct') + + // 延迟发送商品信息,确保聊天组件已经初始化 + setTimeout(() => { + this.sendProductToAI(selectedProduct) + }, 500) + } }, async initNavigation() { @@ -482,6 +496,20 @@ export default { onVideoPause(message) { console.log('视频暂停:', message); }, + + sendProductToAI(product) { + if (!this.$refs.chat) { + console.error('聊天组件未初始化') + return + } + + const productContent = `我想了解以下商品的详细信息:\n商品名称:${product.goods_name}\n价格:¥${product.price}\n商品ID:${product.goods_id}` + + console.log('商品信息已发送到AI客服:', productContent) + + // 使用sendMessageWithContent方法发送商品信息 + this.$refs.chat.sendMessageWithContent(productContent) + }, onLinkOpen(message) { uni.showModal({ From d8ba7ace0f99bc20df3e41631a927831a0eae33c Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Mon, 16 Mar 2026 17:21:33 +0800 Subject: [PATCH 07/94] =?UTF-8?q?chore=EF=BC=9A=E8=B7=B3=E8=BD=AC=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E5=AE=A2=E6=9C=8D=E7=9A=84=E6=9B=B4=E5=A4=9A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8C=89=E9=92=AE=E6=94=BE=E5=88=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components-diy/diy-category-item.vue | 34 ++---------------- pages_goods/detail.vue | 52 +++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/components-diy/diy-category-item.vue b/components-diy/diy-category-item.vue index bb8795d..b5d867c 100644 --- a/components-diy/diy-category-item.vue +++ b/components-diy/diy-category-item.vue @@ -120,10 +120,7 @@ {{ showMarketPrice(item) }} - - 🤖 - 更多详情 - + + + 🤖 + + @import '@/common/css/goods_detail.scss'; - \ No newline at end of file + \ No newline at end of file diff --git a/pages_goods/detail.vue b/pages_goods/detail.vue index 942fec8..6371941 100644 --- a/pages_goods/detail.vue +++ b/pages_goods/detail.vue @@ -6,7 +6,7 @@ --> - + @@ -38,6 +62,17 @@ export default { } }, methods: { + // 获取视频URL,根据格式决定是否使用$util.img()处理 + getVideoUrl() { + if (!this.value || !this.value.videoUrl) return ''; + const videoUrl = this.value.videoUrl; + // 如果是完整的http/https链接,直接使用 + if (videoUrl.indexOf('http://') === 0 || videoUrl.indexOf('https://') === 0) { + return videoUrl; + } + // 否则使用$util.img()处理 + return this.$util.img(videoUrl); + }, async handlerClick(videoUrl) { await this.__$emitEvent({ eventName: 'video-tap', data: videoUrl, promiseCallback: (event, handler, awaitedResult) => { @@ -52,20 +87,47 @@ export default { \ No newline at end of file From 50ee885b7498008980b2ee8673e8d54085b32c82 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Wed, 25 Mar 2026 14:44:25 +0800 Subject: [PATCH 12/94] =?UTF-8?q?chore=EF=BC=9A=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=AE=9E=E7=8E=B0=E7=AB=96=E5=B1=8F=E6=98=AF?= =?UTF-8?q?=E7=AB=96=E5=B1=8F=EF=BC=8C=E6=A8=AA=E5=B1=8F=E6=98=AF=E6=A8=AA?= =?UTF-8?q?=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components-diy/diy-video-list.vue | 75 ++++++++++++++++++++++- components-diy/diy-video.vue | 84 +++++++++++++++++++++----- pages_tool/ai-chat/ai-chat-message.vue | 38 ++++++++++++ 3 files changed, 180 insertions(+), 17 deletions(-) diff --git a/components-diy/diy-video-list.vue b/components-diy/diy-video-list.vue index c60f3b1..687588a 100644 --- a/components-diy/diy-video-list.vue +++ b/components-diy/diy-video-list.vue @@ -53,9 +53,19 @@ - - + + @@ -126,12 +136,38 @@ export default { isIndicatorDots() { return this.value.carousel.type != 'hide' && 1 != Math.ceil(this.value.list.length / (this.value.pageCount * this.value.rowCount)); + }, + + // 弹窗视频容器样式 + popupVideoStyle() { + let style = 'position:fixed;width:100%;left:0;'; + + if (this.popupVideoRatio) { + // 根据视频比例设置位置 + if (this.popupVideoRatio === 'portrait') { + // 竖屏视频:居中显示,使用9/16比例 + style += 'top:50%;transform:translateY(-50%);'; + style += 'aspect-ratio: 9 / 16;'; + } else { + // 横屏视频:靠近顶部显示,使用16/9比例 + style += 'top:20%;'; + style += 'aspect-ratio: 16 / 9;'; + } + } else { + // 默认:居中显示,使用竖屏比例 + style += 'top:50%;transform:translateY(-50%);'; + style += 'aspect-ratio: 9 / 16;'; + } + + return style; } }, methods: { // 显示视频播放弹窗 showVideo(item) { this.video_url = item.videoUrl; + // 重置视频比例为null,等待新的检测结果 + this.popupVideoRatio = null; this.$refs.videoPopup.open(); }, @@ -139,6 +175,39 @@ export default { imgError(index) { // 图片加载失败的处理逻辑 console.log('图片加载失败:', index); + }, + + // 弹窗视频加载完成事件 + onPopupVideoLoaded(event) { + this.$nextTick(() => { + let width = 0; + let height = 0; + + // H5 端:获取真实视频宽高 + // #ifdef H5 + const video = this.$refs.popupVideoRef; + if (video) { + width = video.videoWidth || 0; + height = video.videoHeight || 0; + } + // #endif + + // 微信小程序端:通过事件对象获取视频宽高 + // #ifdef MP-WEIXIN + if (event && event.detail) { + width = event.detail.width || 0; + height = event.detail.height || 0; + } + // #endif + + if (width && height) { + this.popupVideoRatio = width >= height ? 'landscape' : 'portrait'; + console.log(`弹窗视频宽高比检测: ${width}x${height}, 比例: ${this.popupVideoRatio}`); + } else { + // 获取失败,默认竖屏 + this.popupVideoRatio = 'portrait'; + } + }); } } } diff --git a/components-diy/diy-video.vue b/components-diy/diy-video.vue index ecb8f61..da4d5a8 100644 --- a/components-diy/diy-video.vue +++ b/components-diy/diy-video.vue @@ -1,8 +1,9 @@