Files
assistant-storefront/app/javascript/shared/components/OrderList.vue
Liang XJ 4bd11c0ecc
Some checks failed
Lock Threads / action (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
feat: add search_image and product_list content types with image upload
## 新增功能

### 1. 新增消息类型
- 添加 search_image (17) 和 product_list (18) content_type
- 支持图片搜索和商品列表消息展示

### 2. 图片上传功能
- 添加 ImageUploadButton 组件,支持图片上传到 Mall API
- 上传后发送 search_image 类型消息,图片 URL 存储在 content_attributes
- 支持图片文件验证(类型、大小)

### 3. Webhook 推送优化
- 修改 webhook_listener.rb,允许 search_image 类型即使 content 为空也推送 webhook
- 解决 search_image 消息不触发 webhook 的问题

### 4. 前端组件
- 新增 SearchImage.vue 组件(widget 和 dashboard)
- 新增 ProductList.vue、Logistics.vue、OrderDetail.vue、OrderList.vue 组件
- 更新 Message.vue 路由逻辑支持新的 content_type
- 更新 UserMessage.vue 支持 search_image 消息显示

### 5. API 层修改
- widget/messages_controller.rb: 允许 content_attributes 参数
- widget/base_controller.rb: 使用前端传入的 content_attributes
- widget/conversation API: 支持 contentAttributes 参数传递
- conversation actions 和 helpers: 完整的 content_attributes 数据流

### 6. Widget 测试页面优化
- 重写 /widget_tests 页面,支持游客/用户模式切换
- 登录流程:使用 reset() + setUser(),不刷新页面
- 退出流程:使用 reset() + 刷新页面
- 添加详细的日志输出和状态显示

## 技术细节

### Message Model
```ruby
enum content_type: {
  # ...existing types...
  search_image: 17,
  product_list: 18
}
```

### Webhook Listener
```ruby
# Allow search_image webhook even if content is blank
return if message.content.blank? && message.content_type != 'search_image'
```

### Widget Upload Flow
```
用户选择图片
  → 上传到 Mall API
  → 获取图片 URL
  → 发送消息: { content: '', content_type: 'search_image', content_attributes: { url: '...' } }
```

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-27 19:03:46 +08:00

233 lines
3.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script>
import { mapActions } from 'vuex';
export default {
props: {
orders: {
type: Array,
default: () => [],
},
},
methods: {
...mapActions('conversation', ['sendMessage']),
onActionClick(order, action) {
if (action && action.reply) {
this.sendMessage({ content: action.reply });
}
},
},
};
</script>
<template>
<div class="order-list-wrapper">
<div v-for="(order, index) in orders" :key="'order-' + index" class="order-card">
<!-- 头部信息订单号和时间 -->
<div class="order-header">
<span class="order-number">Order number: {{ order.orderNumber }}</span>
<span class="order-date">{{ order.date }}</span>
</div>
<!-- 状态标签 -->
<div v-if="order.status" class="status-badge">
{{ order.status }}
</div>
<!-- 商品图片列表 -->
<div class="product-list">
<div v-for="(item, itemIndex) in order.items" :key="'item-' + index + '-' + itemIndex" class="product-item">
<img :src="item.image" :alt="item.name || 'Product'" />
</div>
</div>
<!-- 底部操作按钮 -->
<div class="order-actions">
<a
v-for="(action, actionIndex) in order.actions"
:key="'action-' + index + '-' + actionIndex"
href="#"
class="action-link"
@click.prevent="onActionClick(order, action)"
>
{{ action.text }}
</a>
</div>
</div>
</div>
</template>
<style scoped>
.order-list-wrapper {
display: flex;
flex-direction: column;
gap: 12px;
width: 100%;
max-width: 100%;
}
.order-card {
border: 1px solid #e0e0e0;
border-radius: 4px;
padding: 12px;
background-color: #fff;
font-family: Arial, sans-serif;
position: relative;
max-width: 100%;
}
.dark .order-card {
background-color: #1e293b;
border-color: #374151;
}
.order-header {
margin-bottom: 8px;
color: #333;
font-size: 12px;
display: flex;
justify-content: space-between;
align-items: center;
}
.dark .order-header {
color: #f3f4f6;
}
.order-number {
font-weight: 500;
color: #333;
font-size: 12px;
}
.dark .order-number {
color: #f9fafb;
}
.order-date {
color: #666;
font-size: 11px;
}
.dark .order-date {
color: #9ca3af;
}
.status-badge {
display: inline-block;
background-color: #000000;
color: #ffffff;
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: bold;
margin-bottom: 12px;
}
.dark .status-badge {
background-color: #000000;
color: #ffffff;
}
.product-list {
display: flex;
gap: 12px;
margin-bottom: 16px;
min-height: 60px;
align-items: center;
overflow-x: auto;
scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch;
scrollbar-width: thin;
padding-bottom: 4px;
}
.product-list::-webkit-scrollbar {
height: 4px;
}
.product-list::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 2px;
}
.product-list::-webkit-scrollbar-thumb {
background: #888;
border-radius: 2px;
}
.product-list::-webkit-scrollbar-thumb:hover {
background: #555;
}
.product-item {
flex: 0 0 auto;
scroll-snap-align: start;
}
.product-item img {
height: 60px;
width: 48px;
object-fit: cover;
border-radius: 4px;
background-color: #e5e7eb;
}
.dark .product-item img {
background-color: #374151;
}
.order-actions {
display: flex;
justify-content: flex-end;
gap: 16px;
}
.action-link {
color: #333;
text-decoration: underline;
font-size: 12px;
font-weight: 500;
cursor: pointer;
}
.dark .action-link {
color: #e5e7eb;
}
.action-link:hover {
color: #000;
}
.dark .action-link:hover {
color: #fff;
}
/* 响应式设计 */
@media (max-width: 480px) {
.order-card {
padding: 10px;
}
.order-header {
font-size: 11px;
}
.product-list {
gap: 10px;
}
.product-item img {
height: 50px;
width: 40px;
}
.order-actions {
gap: 12px;
}
.action-link {
font-size: 11px;
}
}
</style>