HomeLease/pages/index/index.vue
2025-08-13 09:58:47 +08:00

591 lines
12 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>
<view class="home-container">
<!-- 头部信息 -->
<view class="header">
<view class="location-info">
<image class="location" :src="commonEnum.LOCATION"></image>
<text class="company-name">福鼎创特物联科技有限公司</text>
<text class="arrow">></text>
</view>
</view>
<!-- 公告栏 -->
<view class="announcement-bar">
<image class="announcementIcon" :src="commonEnum.ANNOUNCEMENT_ICON"></image>
<view class="announcement-box">
<text class="announcement-text">暂无更多公告! 暂无更多公告! 暂无更多公告!</text>
</view>
</view>
<!-- 轮播图 -->
<view class="banner-section">
<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
:duration="duration">
<swiper-item>
<image :src="commonEnum.TEMP1"></image>
</swiper-item>
<swiper-item>
<image :src="commonEnum.TEMP1"></image>
</swiper-item>
<swiper-item>
<image :src="commonEnum.TEMP1"></image>
</swiper-item>
<swiper-item>
<image :src="commonEnum.TEMP1"></image>
</swiper-item>
</swiper>
</view>
<!-- 设备列表 -->
<view class="equipment-section">
<view class="section-title">我的租赁设备</view>
<view class="equipment-list">
<view
v-for="equipment in equipmentList"
:key="equipment.id"
class="equipment-item"
@click="onEquipmentClick(equipment)"
>
<image class="equipment-image" :src="equipment.image" mode="aspectFit"></image>
<view class="equipment-info">
<view class="equipment-header">
<text class="equipment-name">{{equipment.name}}</text>
<text class="status-badge" :class="equipment.status">{{equipment.status === 'normal' ? '正常' : '异常'}}</text>
</view>
<view class="equipment-details">
<view class="detail-item-row">
<text class="detail-item-time">租赁时间:</text>
<text class="detail-item">{{equipment.startTime}}</text>
</view>
<view class="detail-item-row">
<text class="detail-item-time">到期时间:</text>
<text class="detail-item">{{equipment.endTime}}</text>
</view>
</view>
<button class="renew-btn" @click.stop="onRenew(equipment)">去续费</button>
</view>
</view>
</view>
</view>
<!-- 底部导航 -->
<view class="bottom-nav">
<view
v-for="(nav, index) in ['首页', '申请租赁', '个人中心']"
:key="index"
class="nav-item"
:class="{ active: index === 0 }"
@click="onNavClick(index)"
>
<image
class="nav-icon"
:src="getNavIcon(index)"
mode="aspectFit"
></image>
<text class="nav-text">{{nav}}</text>
</view>
</view>
</view>
</template>
<script>
import commonEnum from "../../enum/commonEnum";
export default {
data() {
return {
background: ['color1', 'color2', 'color3'],
indicatorDots: true,
autoplay: true,
interval: 2000,
duration: 500,
commonEnum : commonEnum,
title: '设备租赁',
currentBannerIndex: 0,
bannerList: [
{
id: 1,
name: '渝锦汇',
desc: '商用节能灶燃烧器',
features: '商用节能灶燃烧器,高效节能,安全可靠,适用于各类餐饮场所。采用先进燃烧技术,热效率高,节能环保。',
image: '/static/stove.svg'
},
{
id: 2,
name: '节能燃烧器',
desc: '高效节能设备',
features: '新一代节能燃烧器热效率提升30%,节能环保,安全可靠。',
image: '/static/burner.svg'
},
{
id: 3,
name: '商用炉具',
desc: '专业厨房设备',
features: '专业商用炉具,采用不锈钢材质,耐高温,易清洁,适合大型餐饮场所使用。',
image: '/static/stove.svg'
},
{
id: 4,
name: '燃气灶具',
desc: '高效燃气设备',
features: '高效燃气灶具,燃烧充分,热效率高,节能环保,安全可靠。',
image: '/static/burner.svg'
},
{
id: 5,
name: '厨房设备',
desc: '一体化解决方案',
features: '提供完整的厨房设备解决方案,从设计到安装,一站式服务。',
image: '/static/stove.svg'
}
],
equipmentList: [
{
id: 1,
name: '商用节能灶',
status: 'normal',
startTime: '2025-07-25 13:23:59',
endTime: '2026-07-25 13:23:59',
image: commonEnum.TEMP2
},
{
id: 2,
name: '节能燃烧器',
status: 'normal',
startTime: '2025-07-25 13:23:59',
endTime: '2026-07-25 13:23:59',
image: commonEnum.TEMP3
}
]
}
},
onLoad() {
// 页面加载时的逻辑
this.startBannerAutoPlay();
},
methods: {
// 轮播图自动播放
startBannerAutoPlay() {
setInterval(() => {
this.currentBannerIndex = (this.currentBannerIndex + 1) % this.bannerList.length;
}, 3000);
},
// 点击轮播指示器
onDotClick(index) {
this.currentBannerIndex = index;
},
// 点击轮播图
onBannerClick(index) {
this.currentBannerIndex = index;
},
// 去续费
onRenew(equipment) {
uni.showToast({
title: `正在处理${equipment.name}的续费`,
icon: 'none'
});
},
// 点击设备项
onEquipmentClick(equipment) {
uni.showToast({
title: `查看${equipment.name}详情`,
icon: 'none'
});
},
// 点击底部导航
onNavClick(index) {
const navItems = ['首页', '申请租赁', '个人中心'];
uni.showToast({
title: `切换到${navItems[index]}`,
icon: 'none'
});
},
// 获取导航图标
getNavIcon(index) {
const isActive = index === 0; // 当前首页是激活状态
switch(index) {
case 0: // 首页
return isActive ? this.commonEnum.HOME_ACTIVE : this.commonEnum.HOME;
case 1: // 申请租赁
return isActive ? this.commonEnum.RENT_ACTIVE : this.commonEnum.RENT;
case 2: // 个人中心
return isActive ? this.commonEnum.PERSONAL_CENTER_ACTIVE : this.commonEnum.PERSONAL_CENTER;
default:
return this.commonEnum.HOME;
}
}
}
}
</script>
<style lang="scss" scoped >
.swiper {
height: 300rpx;
.swiper-item {
display: block;
height: 300rpx;
line-height: 300rpx;
text-align: center;
}
}
.home-container {
background: linear-gradient(
to bottom,
#FFDDCA 0px,
#FFDDCA 450rpx,
#f5f5f5 450rpx,
#f5f5f5 100%
);
min-height: 100vh;
padding-bottom: 120rpx; /* 为底部导航留出空间 */
max-width: 750rpx;
margin: 0 auto;
z-index: -2;
}
/* 头部信息 */
.header {
padding: 106rpx 30rpx 20rpx 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
background: #FFDDCA;
z-index: 999;
.location-info {
display: flex;
align-items: center;
gap: 10rpx;
flex: 1;
.location{
width: 27rpx;
height: 31rpx;
}
.company-name {
color: #3D3D3D;
font-size: 16px;
font-weight: 500;
}
.arrow {
font-size: 24rpx;
color: #666;
}
}
}
/* 公告栏 */
.announcement-bar {
background: white;
opacity: 0.5;
margin: 34rpx 19rpx 0 19rpx;
padding: 15rpx 30rpx;
display: flex;
align-items: center;
gap: 15rpx;
overflow: hidden;
height: 34rpx;
border-radius: 100rpx;
//border: #4cd964 solid 1px;
.announcementIcon {
height: 32rpx;
width: 32rpx;
flex-shrink: 0;
}
.announcement-box{
flex: 1;
overflow: hidden;
position: relative;
.announcement-text {
font-size: 13px;
opacity: 1;
color: black;
white-space: nowrap;
animation: scroll-text 10s linear infinite;
//border: #4cd964 solid 1px;
display: inline-block;
padding-left: 100%;
}
@keyframes scroll-text {
0% { transform: translateX(0); }
100% { transform: translateX(-100%); }
}
}
}
/* 轮播图 */
.banner-section {
padding: 30rpx;
}
.banner-container {
position: relative;
height: 400rpx;
overflow: hidden;
border-radius: 20rpx;
}
.banner-card {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
display: flex;
gap: 30rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
opacity: 0;
transform: scale(0.8);
transition: all 0.5s ease;
cursor: pointer;
}
.banner-card.active {
opacity: 1;
transform: scale(1);
}
.banner-left {
display: flex;
flex-direction: column;
gap: 20rpx;
flex: 1;
}
.product-info {
display: flex;
align-items: center;
gap: 10rpx;
}
.flame-icon {
font-size: 24rpx;
color: #ff4757;
}
.product-name {
font-size: 28rpx;
font-weight: bold;
color: #333;
}
.product-desc {
font-size: 24rpx;
color: #666;
}
.product-image {
width: 200rpx;
height: 150rpx;
border-radius: 10rpx;
background-color: #f8f9fa;
}
.banner-right {
flex: 1;
}
.product-features {
font-size: 24rpx;
color: #666;
line-height: 1.6;
}
.banner-dots {
display: flex;
justify-content: center;
gap: 15rpx;
margin-top: 30rpx;
}
.dot {
width: 20rpx;
height: 20rpx;
border-radius: 50%;
background-color: #ddd;
transition: all 0.3s ease;
cursor: pointer;
}
.dot.active {
background-color: #ff9a9e;
transform: scale(1.2);
}
/* 设备列表 */
.equipment-section {
padding: 0 30rpx;
}
.section-title {
width: 180rpx;
height: 33rpx;
background: #FFFFFF;
font-size: 14px;
font-weight: 400;
color: #3D3D3D;
margin-bottom: 20rpx;
padding: 14rpx 20rpx;
border-radius: 4px;
}
.equipment-list {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.equipment-item {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
display: flex;
gap: 30rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
justify-content: center;
align-items: center;
.equipment-image {
width: 160rpx;
height: 106rpx;
border-radius: 10rpx;
background-color: #f8f9fa;
flex-shrink: 0;
}
}
.equipment-item:active {
transform: scale(0.98);
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.15);
}
.equipment-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.equipment-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15rpx;
}
.equipment-name {
font-size: 16px;
font-weight: 500;
color: #3D3D3D;
}
.status-badge {
padding: 4rpx 26rpx;
border-radius: 5rpx;
font-size: 24rpx;
color: #40C186;
}
.status-badge.normal {
background-color: #EBFFF6;
}
.status-badge.warning {
background-color: #faad14;
}
.status-badge.error {
background-color: #ff4d4f;
}
.equipment-details {
display: flex;
flex-direction: column;
gap: 8rpx;
margin-bottom: 15rpx;
}
.detail-item-row{
display: flex;
justify-content: space-between;
.detail-item-time{
color: #817F7F;
font-size: 26rpx;
}
.detail-item {
font-size: 24rpx;
color: #666;
}
}
.renew-btn {
margin-right: 0;
background: #F15A04;
color: #fff;
border-radius: 5px;
padding: 0 57rpx;
font-size: 32rpx;
font-weight: 500;
margin-top: 10rpx;
}
/* 底部导航 */
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #fff;
display: flex;
justify-content: space-around;
align-items: center;
padding: 20rpx 0;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1);
z-index: 1000;
}
.nav-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
padding: 10rpx;
transition: all 0.3s ease;
}
.nav-item:active {
transform: scale(0.95);
}
.nav-icon {
width: 48rpx;
height: 48rpx;
}
.nav-text {
font-size: 20rpx;
color: #999;
}
.nav-item.active .nav-text {
color: #ff9a9e;
}
</style>