Files
dachui-mall-web/src/views/Rental.vue
T

423 lines
19 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.
<template>
<div class="space-y-4 sm:space-y-8 pb-16">
<!-- Rental Hero Banner -->
<section class="bg-gradient-to-r from-slate-900 via-indigo-950 to-slate-900 text-white py-6 sm:py-12 border-b border-indigo-900/40 relative overflow-hidden">
<!-- Background Ambient Glow -->
<div class="absolute -right-20 -top-20 w-96 h-96 bg-indigo-500/20 rounded-full blur-3xl pointer-events-none"></div>
<div class="absolute left-1/4 -bottom-20 w-80 h-80 bg-red-500/15 rounded-full blur-3xl pointer-events-none"></div>
<div class="max-w-site mx-auto px-3 sm:px-4 relative z-10 flex flex-col md:flex-row items-center justify-between gap-5 sm:gap-8">
<div class="space-y-2.5 sm:space-y-4 max-w-xl text-center md:text-left">
<div class="inline-flex items-center space-x-2 px-3 py-1 rounded-full bg-indigo-500/20 border border-indigo-400/30 text-indigo-300 text-[11px] sm:text-xs font-semibold backdrop-blur-sm">
<span>🛡️ 信用免押 · 随租随还 · 企个两用</span>
</div>
<h1 class="text-2xl sm:text-4xl font-extrabold tracking-tight text-white leading-tight">
💻 全品类数码设备免押租赁
</h1>
<p class="text-xs sm:text-sm text-indigo-200/80 leading-relaxed">
专业提供 <strong>苹果Mac/高性能电脑、旗舰手机、iPad平板、会展测试机、摄影器材</strong> 租赁。日租低至 <span class="text-orange-400 font-bold text-base sm:text-lg">¥2.8/天</span> 起,到期可还可买断!
</p>
<div class="flex items-center justify-center md:justify-start space-x-3 pt-1">
<a href="#rental-grid" class="px-5 sm:px-6 py-2 sm:py-2.5 bg-gradient-to-r from-red-500 to-orange-500 text-white font-bold text-xs rounded-xl shadow-lg shadow-red-500/25 transition-all">
挑选设备
</a>
<button @click="openConsult" class="px-5 sm:px-6 py-2 sm:py-2.5 bg-white/10 text-white font-semibold text-xs rounded-xl border border-white/20 backdrop-blur-sm transition-colors">
企业批量租
</button>
</div>
</div>
<!-- 4 Step Guarantee Highlights -->
<div class="grid grid-cols-2 gap-2 sm:gap-3 w-full md:w-auto">
<div class="bg-white/10 backdrop-blur-md border border-white/15 p-2.5 sm:p-4 rounded-xl sm:rounded-2xl">
<span class="text-xl sm:text-2xl">💎</span>
<h4 class="font-bold text-xs sm:text-sm mt-0.5 text-white">芝麻免押</h4>
<p class="text-[10px] sm:text-[11px] text-gray-300">信用良好 0 押金</p>
</div>
<div class="bg-white/10 backdrop-blur-md border border-white/15 p-2.5 sm:p-4 rounded-xl sm:rounded-2xl">
<span class="text-xl sm:text-2xl">⚡</span>
<h4 class="font-bold text-xs sm:text-sm mt-0.5 text-white">顺丰包邮</h4>
<p class="text-[10px] sm:text-[11px] text-gray-300">当日顺丰发出</p>
</div>
<div class="bg-white/10 backdrop-blur-md border border-white/15 p-2.5 sm:p-4 rounded-xl sm:rounded-2xl">
<span class="text-xl sm:text-2xl">🔄</span>
<h4 class="font-bold text-xs sm:text-sm mt-0.5 text-white">租完即送</h4>
<p class="text-[10px] sm:text-[11px] text-gray-300">满期可0元买断</p>
</div>
<div class="bg-white/10 backdrop-blur-md border border-white/15 p-2.5 sm:p-4 rounded-xl sm:rounded-2xl">
<span class="text-xl sm:text-2xl">🛠️</span>
<h4 class="font-bold text-xs sm:text-sm mt-0.5 text-white">全程质保</h4>
<p class="text-[10px] sm:text-[11px] text-gray-300">故障免费换新</p>
</div>
</div>
</div>
</section>
<!-- Rental Category Tabs & Filter -->
<div id="rental-grid" class="max-w-site mx-auto px-3 sm:px-4 space-y-4 sm:space-y-6">
<div class="bg-white rounded-2xl p-3.5 sm:p-6 shadow-sm border border-gray-100 space-y-3 sm:space-y-4">
<!-- Device Category Tabs (Horizontal scroll on mobile) -->
<div class="flex items-center space-x-2 sm:space-x-3 pb-3 sm:pb-4 border-b border-gray-100 overflow-x-auto no-scrollbar text-xs font-semibold">
<span class="hidden sm:inline-block text-gray-400 flex-shrink-0 w-16">设备类别:</span>
<button
v-for="cat in rentalCategories"
:key="cat.key"
@click="activeCat = cat.key"
:class="activeCat === cat.key ? 'bg-indigo-600 text-white shadow-sm' : 'bg-gray-100 text-gray-700 hover:bg-gray-200'"
class="px-3 sm:px-4 py-1.5 sm:py-2 rounded-xl transition-all flex items-center space-x-1 sm:space-x-1.5 flex-shrink-0 whitespace-nowrap"
>
<span>{{ cat.icon }}</span>
<span>{{ cat.name }}</span>
</button>
</div>
<!-- Lease Term Filter -->
<div class="flex items-center space-x-2 sm:space-x-3 text-xs font-medium overflow-x-auto no-scrollbar">
<span class="hidden sm:inline-block text-gray-400 flex-shrink-0 w-16">租赁周期:</span>
<button
v-for="term in leaseTerms"
:key="term.val"
@click="selectedTerm = term.val"
:class="selectedTerm === term.val ? 'text-indigo-600 bg-indigo-50 border-indigo-200 font-bold' : 'text-gray-600 border-gray-200 hover:border-gray-400'"
class="px-2.5 sm:px-3.5 py-1 sm:py-1.5 rounded-lg border transition-all flex-shrink-0 whitespace-nowrap text-[11px] sm:text-xs"
>
{{ term.label }}
</button>
</div>
</div>
<!-- Rental Products Grid (2 cols on mobile, 4 on desktop) -->
<div class="grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2.5 sm:gap-6">
<div
v-for="item in filteredRentalProducts"
:key="item.id"
class="bg-white rounded-xl sm:rounded-2xl border border-gray-100 overflow-hidden shadow-sm hover:shadow-xl hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group relative"
>
<!-- Badge -->
<div class="absolute top-2 left-2 sm:top-3 sm:left-3 z-10 flex gap-1">
<span class="px-1.5 sm:px-2.5 py-0.5 sm:py-1 text-[9px] sm:text-[10px] font-extrabold bg-gradient-to-r from-indigo-600 to-purple-600 text-white rounded-md sm:rounded-lg shadow-sm">
{{ item.tag || '免押租赁' }}
</span>
<span v-if="item.condition" class="hidden sm:inline-block px-2 py-1 text-[10px] font-bold bg-gray-900/80 text-white rounded-lg backdrop-blur-sm">
{{ item.condition }}
</span>
</div>
<!-- Product Image -->
<div class="aspect-square bg-gray-50 overflow-hidden relative cursor-pointer" @click="goDetail(item.id)">
<img :src="item.image" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500" />
<!-- Term hint overlay -->
<div class="absolute bottom-1.5 right-1.5 sm:bottom-2 sm:right-2 bg-black/60 text-white text-[9px] sm:text-[10px] px-1.5 sm:px-2 py-0.5 rounded backdrop-blur-sm">
{{ item.termDesc }}
</div>
</div>
<!-- Product Info -->
<div class="p-2.5 sm:p-5 flex-1 flex flex-col justify-between space-y-2.5 sm:space-y-4">
<div>
<h3 @click="goDetail(item.id)" class="text-xs sm:text-sm font-bold text-gray-900 line-clamp-2 hover:text-primary cursor-pointer leading-snug">
{{ item.title }}
</h3>
<p class="hidden sm:block text-xs text-gray-400 line-clamp-1 mt-1">{{ item.specs }}</p>
</div>
<div class="pt-2 sm:pt-3 border-t border-gray-100 space-y-2 sm:space-y-3">
<!-- Price per day / month -->
<div class="flex items-baseline justify-between">
<div>
<span class="text-[9px] sm:text-[11px] text-gray-400">低至 </span>
<span class="text-xs font-bold text-primary">¥</span>
<span class="text-lg sm:text-2xl font-black text-primary tracking-tight">{{ item.dailyPrice }}</span>
<span class="text-[10px] sm:text-xs text-primary font-semibold">/天</span>
</div>
<div class="hidden sm:block text-[11px] text-gray-400">
月租约 ¥{{ item.monthlyPrice }}
</div>
</div>
<!-- Action buttons -->
<div class="flex items-center space-x-1.5 sm:space-x-2">
<button
@click="openRentalDialog(item)"
class="flex-1 py-1.5 sm:py-2.5 bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-700 hover:to-purple-700 text-white font-bold text-[10px] sm:text-xs rounded-lg sm:rounded-xl shadow-sm transition-all"
>
立即申请免押
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Rental Application / Booking Modal -->
<el-dialog
v-model="showRentalDialog"
title="申请数码设备租赁 / 预订"
width="92%"
:align-center="true"
destroy-on-close
class="max-w-lg rounded-2xl"
>
<div v-if="currentRentalItem" class="space-y-5 text-xs">
<!-- Selected Item Brief -->
<div class="flex items-center space-x-4 p-3 bg-gray-50 rounded-xl border border-gray-100">
<img :src="currentRentalItem.image" class="w-16 h-16 rounded-lg object-cover bg-white" />
<div class="space-y-1">
<h4 class="font-bold text-gray-900 text-sm">{{ currentRentalItem.title }}</h4>
<p class="text-gray-400 text-[11px]">{{ currentRentalItem.specs }}</p>
<p class="text-primary font-bold">日租金:¥{{ currentRentalItem.dailyPrice }}/天 (月租约 ¥{{ currentRentalItem.monthlyPrice }})</p>
</div>
</div>
<!-- Rent Duration Selector -->
<div>
<label class="block font-bold text-gray-700 mb-2">选择租赁租期:</label>
<div class="grid grid-cols-4 gap-2">
<button
v-for="d in durationOptions"
:key="d.days"
@click="selectedDays = d.days"
:class="selectedDays === d.days ? 'border-primary bg-red-50 text-primary font-bold ring-2 ring-red-100' : 'border-gray-200 text-gray-700 hover:border-gray-400'"
class="p-2.5 rounded-xl border text-center transition-all"
>
<div class="text-xs font-bold">{{ d.label }}</div>
<div class="text-[10px] text-gray-400 mt-0.5">{{ d.discount }}</div>
</button>
</div>
</div>
<!-- Rent Scheme Options -->
<div class="space-y-2">
<label class="block font-bold text-gray-700">到期方案:</label>
<div class="grid grid-cols-2 gap-3">
<div
@click="rentScheme = 'return'"
:class="rentScheme === 'return' ? 'border-primary bg-red-50/50' : 'border-gray-200'"
class="p-3 rounded-xl border cursor-pointer transition-all"
>
<div class="font-bold text-gray-800">📦 到期归还 / 续租</div>
<p class="text-[11px] text-gray-500 mt-1">租期满后顺丰寄回,或随时申请续租</p>
</div>
<div
@click="rentScheme = 'buyout'"
:class="rentScheme === 'buyout' ? 'border-primary bg-red-50/50' : 'border-gray-200'"
class="p-3 rounded-xl border cursor-pointer transition-all"
>
<div class="font-bold text-gray-800">🎁 租完即送 / 补差买断</div>
<p class="text-[11px] text-gray-500 mt-1">租期满后自动归您所有,无需退还</p>
</div>
</div>
</div>
<!-- User Contact Info -->
<div class="space-y-3 pt-2">
<div>
<label class="block font-bold text-gray-700 mb-1">联系人姓名:</label>
<input v-model="rentalForm.name" type="text" placeholder="请输入真实姓名" class="w-full px-3 py-2 border border-gray-200 rounded-lg outline-none focus:border-primary" />
</div>
<div>
<label class="block font-bold text-gray-700 mb-1">联系电话:</label>
<input v-model="rentalForm.phone" type="text" placeholder="请输入手机号码" class="w-full px-3 py-2 border border-gray-200 rounded-lg outline-none focus:border-primary" />
</div>
<div>
<label class="block font-bold text-gray-700 mb-1">收货地址:</label>
<input v-model="rentalForm.address" type="text" placeholder="请输入设备寄送详细地址" class="w-full px-3 py-2 border border-gray-200 rounded-lg outline-none focus:border-primary" />
</div>
</div>
<!-- Cost Estimate -->
<div class="p-4 bg-indigo-50/70 border border-indigo-100 rounded-xl flex items-center justify-between">
<div>
<span class="text-gray-500">预估总租金({{ selectedDays }}天):</span>
<p class="text-xs text-indigo-700 mt-0.5">芝麻信用分 ≥ 650 享 ¥0 押金</p>
</div>
<span class="text-2xl font-black text-primary">¥{{ (currentRentalItem.dailyPrice * selectedDays).toFixed(2) }}</span>
</div>
</div>
<template #footer>
<div class="flex items-center justify-end space-x-3">
<button @click="showRentalDialog = false" class="px-5 py-2 text-xs text-gray-600 hover:text-gray-800">取消</button>
<button @click="submitRental" class="px-6 py-2 bg-primary hover:bg-primary-hover text-white text-xs font-bold rounded-lg shadow-sm">
提交免押租赁申请
</button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/store/user'
import { ElMessage } from 'element-plus'
import { brand } from '@/config/brands'
const router = useRouter()
const userStore = useUserStore()
const activeCat = ref('all')
const selectedTerm = ref('all')
const rentalCategories = [
{ key: 'all', name: '全部设备', icon: '⚡' },
{ key: 'computer', name: '笔记本 / 台式电脑', icon: '💻' },
{ key: 'phone', name: '智能手机', icon: '📱' },
{ key: 'pad', name: 'iPad / 平板电脑', icon: '📟' },
{ key: 'audio', name: '音响 / 会议影音', icon: '🎧' },
{ key: 'enterprise', name: '企业批量工位机', icon: '🏢' }
]
const leaseTerms = [
{ label: '全部周期', val: 'all' },
{ label: '短期体验 (7~30天)', val: 'short' },
{ label: '季度/半年租 (3~6个月)', val: 'mid' },
{ label: '长期租赁 (12个月以上)', val: 'long' }
]
// Curated rental products mapped to store products
const rentalProducts = ref([
{
id: 1,
cat: 'computer',
title: 'Apple MacBook Pro 14英寸 M3 Max 芯片 / 36G / 1TB 剪辑办公本',
specs: '设计剪辑/移动办公神器 · 官方质保 · 顺丰包邮',
dailyPrice: 18.8,
monthlyPrice: 499,
image: 'https://images.unsplash.com/photo-1517336714731-489689fd1ca8?auto=format&fit=crop&w=600&q=80',
condition: '99新',
tag: '电脑办公',
termDesc: '企业免押专享'
},
{
id: 2,
cat: 'pad',
title: 'Apple iPad Pro 13英寸 M4芯片 256G 深空黑 (双层OLED屏)',
specs: '原封/99新 · 生产力神器 · 支持二代Pencil',
dailyPrice: 8.5,
monthlyPrice: 240,
image: 'https://images.unsplash.com/photo-1544244015-0df4b3ffc6b0?auto=format&fit=crop&w=600&q=80',
condition: '全新原封',
tag: '平板旗舰',
termDesc: '支持租完即送'
},
{
id: 3,
cat: 'phone',
title: 'iPhone 15 Pro Max 256GB 原色钛金属 5G旗舰手机',
specs: 'A17 Pro芯片 · 5倍潜望光学长焦 · 钛金属机身',
dailyPrice: 6.8,
monthlyPrice: 188,
image: 'https://images.unsplash.com/photo-1695048133142-1a20484d2569?auto=format&fit=crop&w=600&q=80',
condition: '99新',
tag: '手机租借',
termDesc: '7天起租 · 随租随还'
},
{
id: 4,
cat: 'computer',
title: 'ThinkPad X1 Carbon 商务旗舰超极本 i7/32G/1TB',
specs: '仅1.09kg轻薄碳纤维 · 经典小红点 · 超长续航',
dailyPrice: 12.5,
monthlyPrice: 320,
image: 'https://images.unsplash.com/photo-1588872657578-7efd1f1555ed?auto=format&fit=crop&w=600&q=80',
condition: '95新',
tag: '商务出差',
termDesc: '支持月租/年租'
},
{
id: 5,
cat: 'audio',
title: '索尼 WH-1000XM5 无线降噪头戴式耳机 铂金银',
specs: '旗舰双芯降噪 · 商务会议降噪 · 40小时长续航',
dailyPrice: 3.5,
monthlyPrice: 90,
image: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?auto=format&fit=crop&w=600&q=80',
condition: '99新',
tag: '影音会议',
termDesc: '免押试用'
},
{
id: 6,
cat: 'audio',
title: 'Apple Watch Ultra 2 智能手表 钛金属表壳/越野表带',
specs: '3000尼特超亮屏 · 双频GPS · 户外探险运动',
dailyPrice: 4.2,
monthlyPrice: 115,
image: 'https://images.unsplash.com/photo-1523275335684-37898b6baf30?auto=format&fit=crop&w=600&q=80',
condition: '99新',
tag: '智能穿戴',
termDesc: '短期户外租'
},
{
id: 7,
cat: 'enterprise',
title: 'Dell / 联想企业级批量商务台式电脑 + 27寸4K双屏工位套装',
specs: 'i7/32G/1TB SSD + 27寸4K护眼屏 · 上门安装',
dailyPrice: 9.8,
monthlyPrice: 260,
image: 'https://images.unsplash.com/photo-1497215728101-856f4ea42174?auto=format&fit=crop&w=600&q=80',
condition: '全新批量',
tag: '企业免押',
termDesc: '企业租金按月结'
}
])
const filteredRentalProducts = computed(() => {
if (activeCat.value === 'all') return rentalProducts.value
return rentalProducts.value.filter(item => item.cat === activeCat.value)
})
const showRentalDialog = ref(false)
const currentRentalItem = ref(null)
const selectedDays = ref(30)
const rentScheme = ref('return')
const durationOptions = [
{ label: '7 天试用', days: 7, discount: '标准价' },
{ label: '30 天月租', days: 30, discount: '立减10%' },
{ label: '90 天季租', days: 90, discount: '立减20%' },
{ label: '365 天年租', days: 365, discount: '可0元买断' }
]
const rentalForm = ref({
name: '',
phone: '',
address: ''
})
const goDetail = (id) => {
router.push(`/product/${id}`)
}
const openRentalModal = (item) => {
if (!userStore.token) {
userStore.openAuthModal('login')
return
}
currentRentalItem.value = item
rentalForm.value = {
name: userStore.userInfo?.nickname || '',
phone: userStore.userInfo?.phone || '',
address: ''
}
showRentalDialog.value = true
}
const openConsult = () => {
ElMessage.success(`企业客服专线已接通:${brand.customerServicePhone},请联系在线客服了解企业批量免押授信方案`)
}
const submitRental = () => {
if (!rentalForm.value.name || !rentalForm.value.phone || !rentalForm.value.address) {
ElMessage.warning('请填写完整的收货人、电话与寄送地址')
return
}
showRentalDialog.value = false
ElMessage.success('🎉 租赁预订申请提交成功!专属客服将在 15 分钟内为您完成免押审核与发货。')
router.push('/user?tab=orders')
}
</script>