index.vue
4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
<view class="min-h-screen bg-[#F9FAFB] pb-[200rpx] flex flex-col items-center">
<!-- Header -->
<NavHeader title="我的收藏" />
<!-- Tabs Section -->
<!-- Background image from design -->
<view
class="w-[706rpx] h-[144rpx] mt-[40rpx] bg-[url('https://lanhu-oss-2537-2.lanhuapp.com/SketchPnga29210f2f5f94a789a5a08d5b75affd2f68da6108c1cf5328ce44da4ad92ee40')] bg-[length:100%_100%] bg-no-repeat flex items-center px-[32rpx]">
<div class="flex overflow-x-auto no-scrollbar space-x-[24rpx] w-full items-center">
<div v-for="(tab, index) in tabs" :key="index"
class="px-[32rpx] py-[16rpx] rounded-full text-[28rpx] whitespace-nowrap transition-colors"
:class="activeTab === tab.key ? 'bg-[#007AFF] text-white' : 'bg-transparent text-[#6B7280]'"
@click="activeTab = tab.key">
{{ tab.title }}
</div>
</div>
</view>
<!-- List Section -->
<view class="w-[706rpx] mt-[32rpx] flex flex-col gap-[24rpx]">
<view v-for="(item, index) in filteredList" :key="index"
class="bg-white rounded-[24rpx] p-[32rpx] shadow-sm flex items-center justify-between" @tap="onView(item)">
<view class="flex items-center flex-1 mr-[24rpx]">
<!-- Icon (Text Type Icons as requested) -->
<view class="w-[80rpx] h-[80rpx] rounded-[16rpx] flex items-center justify-center mr-[24rpx]"
:class="item.iconBgClass">
<IconFont :name="item.icon" size="24" :color="item.iconColor" />
</view>
<!-- Text Content -->
<view class="flex flex-col flex-1">
<view class="text-[32rpx] text-[#1F2937] font-bold mb-[8rpx] line-clamp-1">{{ item.title }}</view>
<view class="flex flex-col items-start gap-[8rpx]">
<view class="bg-gray-100 px-[12rpx] py-[4rpx] rounded-[8rpx] text-[24rpx] text-[#9CA3AF] mt-1">{{ item.category
}}</view>
<view class="text-[24rpx] text-gray-400 mt-2">{{ item.date }}</view>
</view>
</view>
</view>
<!-- Delete Button -->
<view class="p-[10rpx]" @tap.stop="onDelete(item)">
<IconFont name="Del" size="18" color="#999" />
</view>
</view>
<!-- Empty State -->
<view v-if="filteredList.length === 0"
class="flex flex-col items-center justify-center py-[100rpx] text-gray-400">
<IconFont name="Star" size="48" class="mb-[24rpx] opacity-50" />
<text class="text-[28rpx]">暂无收藏内容</text>
</view>
</view>
<!-- TabBar -->
<TabBar current="me" />
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { useGo } from '@/hooks/useGo'
import IconFont from '@/components/IconFont.vue'
import TabBar from '@/components/TabBar.vue'
import NavHeader from '@/components/NavHeader.vue'
import Taro from '@tarojs/taro'
const go = useGo()
const activeTab = ref('all')
const tabs = [
{ title: '全部', key: 'all' },
{ title: '入职培训', key: 'onboarding' },
{ title: '签单相关', key: 'signing' },
{ title: '产品知识', key: 'product' }
]
const list = ref([
{
id: 1,
title: '新员工入职培训手册.pdf',
category: '入职培训',
date: '2024-01-15',
type: 'onboarding',
icon: 'Order', // Represents a document
iconColor: '#EF4444', // Red for PDF
iconBgClass: 'bg-red-50'
},
{
id: 2,
title: '保险产品销售话术.docx',
category: '签单相关',
date: '2024-01-14',
type: 'signing',
icon: 'Order', // Represents a document
iconColor: '#2563EB', // Blue for Word
iconBgClass: 'bg-blue-50'
},
{
id: 3,
title: '重疾险产品知识详解.pptx',
category: '产品知识',
date: '2024-01-13',
type: 'product',
icon: 'Order', // Represents a document
iconColor: '#F59E0B', // Orange for PPT
iconBgClass: 'bg-orange-50'
},
{
id: 4,
title: '2024年最新保险政策解读.txt',
category: '政策解读',
date: '2024-01-12',
type: 'other',
icon: 'Edit', // Represents text
iconColor: '#10B981', // Green for TXT
iconBgClass: 'bg-green-50'
}
])
const filteredList = computed(() => {
if (activeTab.value === 'all') return list.value
return list.value.filter(item => item.type === activeTab.value)
})
const onView = (item) => {
Taro.showToast({ title: `打开: ${item.title}`, icon: 'none' })
}
const onDelete = (item) => {
Taro.showModal({
title: '提示',
content: '确定要删除该收藏吗?',
success: (res) => {
if (res.confirm) {
list.value = list.value.filter(i => i.id !== item.id)
Taro.showToast({ title: '已删除', icon: 'success' })
}
}
})
}
</script>
<style lang="less">
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}
</style>