Files
RentWeAppFront/pages-biz/contract/contract.vue

368 lines
8.3 KiB
Vue
Raw Normal View History

2025-11-14 11:39:33 +08:00
<template>
2025-12-25 08:26:09 +08:00
<view class="contract-page">
<!-- 顶部导航栏 -->
2026-05-14 14:42:51 +08:00
<customNavbar title="我的合同" :showHome="true"/>
2025-12-25 08:26:09 +08:00
<!-- Tabs -->
<view class="tab-wrapper">
2026-07-24 10:46:00 +08:00
<u-tabs :list="tabList" :current="currentTab" @change="onTabChange" lineColor="#0088FE" activeColor="#0088FE"
itemStyle="padding: 0 30rpx;"></u-tabs>
2025-12-25 08:26:09 +08:00
</view>
<DateFilter :start="startDate" :end="endDate" @update:start="startDate = $event" @update:end="endDate = $event"
@change="onDateFilterChange" />
2025-12-25 08:26:09 +08:00
<!-- 合同列表 -->
<scroll-view scroll-y class="scroll-content" @scrolltolower="loadMore" :refresher-enabled="true"
:refresher-triggered="isRefreshing" @refresherrefresh="refresh">
<view v-if="contracts.length > 0" class="contract-list">
2026-07-24 10:46:00 +08:00
<view :class="['contract-card', { 'is-expired': item.signStatus === 'expired' }]" v-for="item in contracts" :key="item.contractNo" @click="goDetail(item)">
<view class="card-header">
<text class="contract-name">{{ $ellipsis(item.contractName, 12) }}</text>
2026-01-15 17:18:24 +08:00
<view :class="['status-tag', item.signStatus]">
{{ getStatusText(item.signStatus) }}
2025-12-25 08:26:09 +08:00
</view>
</view>
2026-07-24 10:46:00 +08:00
<view class="card-divider"></view>
<view class="card-body">
<view class="info-row">
<view class="info-item">
<text class="info-label">合同类型</text>
<text class="info-value">电子合同</text>
</view>
<view class="info-item">
<text class="info-label">租金</text>
<text class="info-value">{{ item.contractNo }}</text>
</view>
</view>
<view class="info-row">
<view class="info-item">
<text class="info-label">开始日期</text>
<text class="info-value">{{ item.startDate }}</text>
</view>
<view class="info-item">
<text class="info-label">结束日期</text>
<text class="info-value">{{ item.endDate }}</text>
</view>
</view>
</view>
2025-12-25 08:26:09 +08:00
</view>
2025-12-25 08:26:09 +08:00
<u-loadmore :status="loadStatus" />
</view>
2025-12-25 08:26:09 +08:00
<view v-else class="empty">
<u-empty mode="list" text="暂无合同记录" />
</view>
</scroll-view>
</view>
2025-11-14 11:39:33 +08:00
</template>
<script>
import DateFilter from '../../components/DatePicker/DateFilter.vue';
export default {
components: { DateFilter },
data() {
return {
2026-05-14 14:42:51 +08:00
tabList: [
{ name: "全部", value: "all" },
{ name: "待签署", value: "pending" },
{ name: "已签署", value: "signed" },
{ name: "已过期", value: "expired" },
],
currentTab: 0,
statusFilter: "all",
startDate: "",
endDate: "",
minDate: "2000-01-01",
2026-05-14 14:42:51 +08:00
maxDate: "2199-12-31",
contracts: [],
pageNo: 1,
pageSize: 10,
total: 0,
2026-05-14 14:42:51 +08:00
loadStatus: "more", // ✅ 修复为官方正确值
isRefreshing: false,
2026-05-14 14:42:51 +08:00
defaultCover: "/public/static/index/assets.jpg",
};
},
2026-01-15 17:18:24 +08:00
onLoad(options) {
2026-06-03 16:02:11 +08:00
// loadContracts 移到 onShow 中,等 token 校验通过后再加载
2026-01-15 17:18:24 +08:00
},
2026-06-03 16:02:11 +08:00
async onShow() {
try {
2026-07-24 10:46:00 +08:00
// await this.$checkToken(this.$getToken())
2026-06-03 16:02:11 +08:00
// token 有效,继续执行
2026-07-24 10:46:00 +08:00
// this.checkOaAuth()
2026-06-03 16:02:11 +08:00
this.loadContracts()
} catch (e) {
// token 无效,$checkToken 内部已处理跳转登录页
return
}
2026-05-14 14:42:51 +08:00
},
// ✅ 删除和 scroll-view 冲突的 onReachBottom
2026-01-15 17:18:24 +08:00
computed: {
2026-05-14 14:42:51 +08:00
staticHost() {
return this.$config.staticUrl
}
},
methods: {
2026-06-02 16:23:56 +08:00
checkOaAuth() {
const token = this.$getToken()
if (!token) return
2026-06-02 16:23:56 +08:00
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo || !userInfo.oaAuth) {
uni.showModal({
title: '提示',
content: '您还未实名认证,请先完成实名认证',
showCancel: false,
confirmText: '去认证',
success: () => {
uni.redirectTo({ url: '/pages-biz/profile/profile' })
}
})
}
},
onTabChange(index) {
this.currentTab = index;
this.statusFilter = this.tabList[index].value;
this.resetAndLoad();
},
onDateFilterChange({ start, end }) {
this.resetAndLoad();
},
formatDate(time) {
const d = new Date(time);
const m = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
return `${d.getFullYear()}-${m}-${day}`;
},
resetAndLoad() {
this.pageNo = 1;
this.contracts = [];
2026-05-14 14:42:51 +08:00
this.loadStatus = "more"; // ✅ 修复
2026-01-15 17:18:24 +08:00
this.loadContracts();
},
2026-01-15 17:18:24 +08:00
loadContracts() {
2026-05-14 14:42:51 +08:00
if (this.loadStatus !== 'more') return;
this.loadStatus = 'loading';
2026-07-24 10:46:00 +08:00
// TODO: 接口联调时取消注释,删除 mock 数据
// this.$u.post('/contract/queryPage', {
// pageNo: this.pageNo,
// pageSize: this.pageSize,
// startDate: this.startDate,
// endDate: this.endDate,
// signStatus: this.statusFilter
// }, {
// WT: this.$getToken()
// }).then(result => {
// const rows = result.data.result || [];
// if (this.pageNo === 1 && rows.length === 0) {
// this.contracts = [];
// this.loadStatus = 'nomore';
// return;
// }
// this.contracts = this.contracts.concat(rows);
// if (rows.length < this.pageSize) {
// this.loadStatus = 'nomore';
// } else {
// this.pageNo++;
// this.loadStatus = 'more';
// }
// }).catch(err => {
// console.log("获取合同信息失败:", err);
// this.loadStatus = 'more';
// }).finally(() => {
// this.isRefreshing = false;
// });
2026-05-14 14:42:51 +08:00
2026-07-24 10:46:00 +08:00
// Mock 静态数据
const mockData = [
{
contractNo: 'HT-2026-001',
contractName: '东山大道435-2-1-104号房屋租赁合同',
startDate: '2026-01-01',
endDate: '2026-12-31',
signStatus: 'signed'
},
{
contractNo: 'HT-2026-002',
contractName: '夷陵大道418号房屋租赁合同',
startDate: '2026-03-01',
endDate: '2027-02-28',
signStatus: 'pending'
},
{
contractNo: 'HT-2025-003',
contractName: '解放路88-1-502号房屋租赁合同',
startDate: '2025-01-01',
endDate: '2025-12-31',
signStatus: 'expired'
2026-05-14 14:42:51 +08:00
}
2026-07-24 10:46:00 +08:00
];
2026-05-14 14:42:51 +08:00
2026-07-24 10:46:00 +08:00
if (this.pageNo === 1) this.contracts = [];
this.contracts = this.contracts.concat(mockData);
this.loadStatus = 'nomore';
this.isRefreshing = false;
},
refresh() {
this.isRefreshing = true;
this.resetAndLoad();
},
loadMore() {
2026-05-14 14:42:51 +08:00
if (this.loadStatus !== "more") return; // ✅ 修复
this.loadContracts();
},
goDetail(item) {
uni.navigateTo({
2026-01-15 17:18:24 +08:00
url: `/pages-biz/contract/contractDetail?contractNo=${item.contractNo}`,
});
},
getStatusText(status) {
switch (status) {
2026-05-14 14:42:51 +08:00
case "pending": return "待签署";
case "signed": return "已签署";
case "expired": return "已过期";
default: return "未知";
}
},
},
};
</script>
2025-12-25 08:26:09 +08:00
<style lang="scss" scoped>
.contract-page {
background-color: #f8f8f8;
2026-01-15 17:18:24 +08:00
padding-top: 170rpx;
min-height: 100vh;
2026-05-14 14:42:51 +08:00
box-sizing: border-box;
}
2026-05-14 14:42:51 +08:00
/* ✅ 核心修复:正确的滚动高度 */
.scroll-content {
2026-05-14 14:42:51 +08:00
height: calc(100vh - 170rpx - 100rpx);
box-sizing: border-box;
}
.contract-list {
padding: 20rpx;
}
2026-07-24 10:46:00 +08:00
.card-info {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
2026-07-24 10:46:00 +08:00
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
}
.card-divider {
height: 1rpx;
background-color: #f0f0f0;
}
.contract-card {
background: #fff;
border-radius: 16rpx;
margin-bottom: 24rpx;
2026-07-24 10:46:00 +08:00
padding: 24rpx;
box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
}
2026-07-24 10:46:00 +08:00
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
2026-07-24 10:46:00 +08:00
padding-bottom: 20rpx;
}
2026-07-24 10:46:00 +08:00
.contract-name {
font-size: 30rpx;
font-weight: 600;
color: #333;
flex: 1;
}
.status-tag {
2026-07-24 10:46:00 +08:00
font-size: 24rpx;
padding: 6rpx 16rpx;
border-radius: 8rpx;
flex-shrink: 0;
&.pending {
2026-07-24 10:46:00 +08:00
background: #FF8D1A;
color: #fff;
2025-12-25 08:26:09 +08:00
}
&.signed {
2026-07-24 10:46:00 +08:00
background: #0088FE;
color: #fff;
2025-12-25 08:26:09 +08:00
}
&.expired {
2026-07-24 10:46:00 +08:00
background: #A6A6A6;
color: #fff;
}
}
.card-divider {
height: 1rpx;
background-color: #f0f0f0;
}
.card-body {
padding-top: 20rpx;
}
.info-row {
display: flex;
margin-bottom: 16rpx;
padding: 20rpx 0;
&:last-child {
margin-bottom: 0;
}
}
.info-item {
flex: 1;
display: flex;
}
.info-label {
font-size: 24rpx;
color: #999;
margin-right: 8rpx;
flex-shrink: 0;
}
.info-value {
font-size: 24rpx;
color: #333;
}
.is-expired {
.contract-name,
.info-label,
.info-value {
color: #A6A6A6 !important;
2025-12-25 08:26:09 +08:00
}
}
.empty {
margin-top: 200rpx;
}
.tab-wrapper {
background-color: #ffffff;
padding: 10rpx 0;
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.06);
position: sticky;
top: 0;
z-index: 10;
}
2025-12-25 08:26:09 +08:00
</style>