<template>
|
|
<view class="container">
|
|
<!-- 搜索栏 -->
|
|
<view class="search-box">
|
|
<input
|
|
v-model="searchKey"
|
|
placeholder="请输入客户姓名/客户手机号"
|
|
class="search-input"
|
|
/>
|
|
<button @tap="handleSearch" class="search-btn">搜索</button>
|
|
</view>
|
|
|
|
<!-- 订单状态筛选 -->
|
|
<view class="filter-tabs">
|
|
<text
|
|
v-for="tab in tabs"
|
|
:key="tab"
|
|
:class="['tab-item', activeTab === tab ? 'active' : '']"
|
|
@tap="activeTab = tab"
|
|
>
|
|
{{ tab }}
|
|
</text>
|
|
</view>
|
|
|
|
<!-- 订单列表 -->
|
|
<scroll-view scroll-y class="order-list">
|
|
<view
|
|
v-for="(order, index) in filteredOrders"
|
|
:key="index"
|
|
class="order-item"
|
|
>
|
|
<view class="order-header">
|
|
<text class="order-no">{{ order.orderNo }}</text>
|
|
<text class="copy-btn" @tap="copyOrderNo(order.orderNo)">复制</text>
|
|
</view>
|
|
|
|
<view class="order-info">
|
|
<text>客户姓名:{{ order.customerName }}</text>
|
|
<text>联系方式:{{ order.phone }}</text>
|
|
<text>服务名称:{{ order.serviceName }}</text>
|
|
<text>订单时间:{{ order.orderTime }}</text>
|
|
<text>销售人员:{{ order.salesman }}</text>
|
|
<text>门店名称:{{ order.store }}</text>
|
|
</view>
|
|
|
|
<button class="download-btn" @tap="downloadPDF(order)">PDF下载</button>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
searchKey: '', // 搜索关键词
|
|
activeTab: '全部', // 当前激活的标签
|
|
tabs: ['全部', '已生效', '已失效'],
|
|
orders: [/* 从接口获取的数据 */]
|
|
}
|
|
},
|
|
computed: {
|
|
// 过滤后的订单列表
|
|
filteredOrders() {
|
|
return this.orders.filter(order => {
|
|
const matchStatus = this.activeTab === '全部' ||
|
|
order.status === this.activeTab
|
|
const matchSearch = order.customerName.includes(this.searchKey) ||
|
|
order.phone.includes(this.searchKey)
|
|
return matchStatus && matchSearch
|
|
})
|
|
}
|
|
},
|
|
methods: {
|
|
// 搜索处理
|
|
handleSearch() {
|
|
// 实际调用接口获取数据
|
|
console.log('搜索关键词:', this.searchKey)
|
|
},
|
|
|
|
// 复制订单号
|
|
copyOrderNo(orderNo) {
|
|
uni.setClipboardData({
|
|
data: orderNo,
|
|
success: () => {
|
|
uni.showToast({ title: '复制成功' })
|
|
}
|
|
})
|
|
},
|
|
|
|
// PDF下载
|
|
async downloadPDF(order) {
|
|
uni.showLoading({ title: '下载中...' })
|
|
|
|
try {
|
|
// 1. 调用下载接口
|
|
const { tempFilePath } = await uni.downloadFile({
|
|
url: 'https://your-api.com/download',
|
|
header: { 'order-id': order.id }
|
|
})
|
|
|
|
// 2. 保存到本地
|
|
await uni.saveFile({
|
|
tempFilePath,
|
|
success: (res) => {
|
|
uni.showToast({ title: '下载成功' })
|
|
console.log('文件路径:', res.savedFilePath)
|
|
}
|
|
})
|
|
|
|
// 3. 打开文档(可选)
|
|
uni.openDocument({
|
|
filePath: tempFilePath,
|
|
showMenu: true
|
|
})
|
|
} catch (err) {
|
|
uni.showToast({ title: '下载失败', icon: 'none' })
|
|
} finally {
|
|
uni.hideLoading()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.container {
|
|
padding: 20rpx;
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.search-box {
|
|
display: flex;
|
|
margin-bottom: 30rpx;
|
|
.search-input {
|
|
flex: 1;
|
|
background: #fff;
|
|
padding: 20rpx;
|
|
border-radius: 8rpx;
|
|
}
|
|
.search-btn {
|
|
width: 140rpx;
|
|
margin-left: 20rpx;
|
|
background: #007AFF;
|
|
color: white;
|
|
}
|
|
}
|
|
|
|
.filter-tabs {
|
|
display: flex;
|
|
margin-bottom: 30rpx;
|
|
.tab-item {
|
|
flex: 1;
|
|
text-align: center;
|
|
padding: 20rpx;
|
|
color: #666;
|
|
border-bottom: 4rpx solid transparent;
|
|
&.active {
|
|
color: #007AFF;
|
|
border-bottom-color: #007AFF;
|
|
}
|
|
}
|
|
}
|
|
|
|
.order-list {
|
|
width: 100%;
|
|
height: 40%;
|
|
height: calc(100vh - 300rpx);
|
|
}
|
|
|
|
.order-item {
|
|
background: white;
|
|
border-radius: 12rpx;
|
|
margin-bottom: 20rpx;
|
|
padding: 20rpx;
|
|
|
|
.order-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding-bottom: 20rpx;
|
|
border-bottom: 1rpx solid #eee;
|
|
|
|
.order-no {
|
|
color: #333;
|
|
font-size: 28rpx;
|
|
}
|
|
.copy-btn {
|
|
color: #007AFF;
|
|
font-size: 24rpx;
|
|
}
|
|
}
|
|
|
|
.order-info {
|
|
padding: 20rpx 0;
|
|
text {
|
|
display: block;
|
|
color: #666;
|
|
font-size: 24rpx;
|
|
line-height: 1.8;
|
|
}
|
|
}
|
|
|
|
.download-btn {
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: red;
|
|
color: #333;
|
|
font-size: 26rpx;
|
|
margin-top: 20rpx;
|
|
}
|
|
}
|
|
</style>
|