完成大体功能和样式

This commit is contained in:
2026-01-15 17:18:24 +08:00
parent 036eb3a206
commit 44a4b33502
211 changed files with 5480 additions and 7826 deletions

313
pages-biz/bill/bill.vue Normal file
View File

@@ -0,0 +1,313 @@
<template>
<view class="bill-list-page">
<!-- 自定义导航栏 -->
<customNavbar title="我的账单"></customNavbar>
<!-- 筛选栏 -->
<view class="filter-bar">
<!-- 年份筛选点击区域 -->
<view class="year-filter" @click="toggleYearPicker">
<text class="year-text">{{ currentYear }}</text>
<u-icon name="arrow-down" size="24" color="#666"></u-icon>
</view>
<!-- 自定义年份选择器弹窗 -->
<u-popup v-model="showYearPicker" mode="bottom" border-radius="20rpx" :closeable="true">
<view class="year-picker-popup">
<!-- 弹窗标题 -->
<view class="popup-header">
<text class="popup-title">选择年份</text>
</view>
<!-- 年份列表 -->
<view class="year-list">
<view class="year-item" v-for="year in years" :key="year"
:class="{ active: currentYear === year }" @click="selectYear(year)">
{{ year }}
</view>
</view>
</view>
</u-popup>
</view>
<!-- 账单列表 -->
<scroll-view scroll-y class="scroll-content" :scroll-top="0" :refresher-enabled="true"
:refresher-triggered="isRefreshing" @refresherrefresh="refresh" @scrolltolower="loadMore">
<view v-if="flowList.length > 0">
<view class="bill-item" v-for="item in flowList" :key="item.id" @click="goDetail(item)">
<!-- 左侧信息 -->
<view class="bill-left">
<text class="bill-name">{{ item.billName }}</text>
<text class="bill-date" v-if="item.payTime">支付时间{{ item.payTime }}</text>
<text class="bill-date" v-if="!item.payTime">账单截止日期: {{ item.billEndDate }}</text>
<text :class="['bill-status', (item.billStatus === '待缴费' ? 'unpay' : paid)]" >{{ item.billStatus }}</text>
</view>
<!-- 右侧金额 + 箭头 -->
<view class="bill-right">
<text class="amount">{{ formatMoney(item.billAmount) }}</text>
<u-icon name="arrow-right" size="28" color="#ccc" />
</view>
</view>
</view>
<view v-else class="empty">
<u-empty mode="list" text="暂无账单" />
</view>
<u-loadmore :status="loadStatus" />
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
bills: [],
flowList: [],
isRefreshing: false,
loadStatus: 'more', // u-loadmore 状态
// 年份筛选相关
currentYear: null,
years: [],
pageNo: 1,
pageSize: 10,
showYearPicker: false
};
},
onLoad(options) {
// 可以从 options 获取用户ID或合同ID
let year = new Date().getFullYear();
this.currentYear = year;
this.years = [];
for (let i = 5; i >= 1; i--) {
this.years.push(year - i);
}
this.loadBills();
},
onReachBottom() {
this.loadStatus = 'loading';
// 获取数据
this.loadBills();
},
onShow(){
this.$checkToken(this.$getToken())
},
methods: {
// 切换年份选择器显示
toggleYearPicker() {
this.showYearPicker = !this.showYearPicker;
},
// 选择年份
selectYear(year) {
this.currentYear = year;
this.showYearPicker = false;
// 重新加载账单数据
this.loadBills();
},
loadBills() {
let url = '/bill/pageQueryContractBill'
this.$u.post(url, {
pageNo: this.pageNo,
pageSize: this.pageSize,
year: this.currentYear,
billStatus: '已缴费'
},{
WT: this.$getToken()
}).then(result => {
const data = result.data.result;
this.bills = data;
for (let i = 0; i < this.bills.length; i++) {
let item = this.bills[i]
this.flowList.push(item);
}
++this.pageNo
}).catch(err => {
console.log("获取合同账单信息失败:", err)
})
},
refresh() {
this.isRefreshing = true;
setTimeout(() => {
this.loadBills();
this.isRefreshing = false;
}, 1000);
},
loadMore() {
// 可以调用接口分页加载更多数据
this.loadStatus = 'noMore';
},
formatMoney(val) {
if (!val && val !== 0) return '—';
return '¥' + Number(val).toFixed(2);
},
goDetail(item) {
uni.navigateTo({
url: `/pages-biz/bill/billDetail?id=${item.id}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.bill-list-page {
background: #f7f8fa;
min-height: 100vh;
padding-top: 160rpx;
/* 给导航栏留空间 */
}
.filter-bar {
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
padding: 24rpx 30rpx;
margin: 20rpx;
border-radius: 12rpx;
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
}
/* 年份筛选 */
.year-filter {
display: flex;
align-items: center;
gap: 8rpx;
font-size: 32rpx;
color: #333;
cursor: pointer;
}
/* 支出/收入切换 */
.tab-bar {
display: flex;
gap: 20rpx;
}
.tab-item {
padding: 12rpx 32rpx;
font-size: 28rpx;
border-radius: 24rpx;
color: #333;
background-color: #f5f5f5;
transition: all 0.2s ease;
&.active {
color: #fff;
background: #ff3b30;
}
}
/* 自定义年份选择器样式 */
.year-picker-popup {
background: #fff;
padding: 30rpx 0;
}
.popup-header {
text-align: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.popup-title {
font-size: 34rpx;
font-weight: 600;
color: #333;
}
.year-list {
padding: 20rpx;
}
.year-item {
font-size: 32rpx;
color: #666;
text-align: center;
padding: 24rpx;
border-radius: 12rpx;
margin-bottom: 16rpx;
background: #f5f5f5;
transition: all 0.2s ease;
&:last-child {
margin-bottom: 0;
}
&.active {
background: #ff3b30;
color: #fff;
}
&:hover {
background: #ff5252;
color: #fff;
}
}
.scroll-content {
margin-top: 20rpx;
padding-bottom: 20rpx;
}
.bill-item {
display: flex;
justify-content: space-between;
background: #fff;
margin: 0 20rpx 20rpx 20rpx;
border-radius: 12rpx;
padding: 20rpx;
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
}
.bill-left {
display: flex;
flex-direction: column;
.bill-name {
font-size: 28rpx;
color: #2D2B2C;
font-weight: 500;
}
.bill-status{
font-size: 30rpx;
font-weight: 800;
&.paid {
color: red;
}
&.unpay {
color: green;
}
}
.bill-date,
.bill-status {
margin-top: 18rpx;
}
}
.bill-right {
display: flex;
align-items: center;
.amount {
font-size: 28rpx;
color: #F34038;
margin-right: 10rpx;
}
}
.empty {
margin-top: 200rpx;
text-align: center;
}
</style>

View File

@@ -0,0 +1,136 @@
<template>
<view class="bill-detail-page">
<!-- 顶部自定义导航栏 -->
<custom-navbar title="账单详情" />
<scroll-view scroll-y class="scroll-content">
<!-- 基本信息 -->
<view class="section">
<view class="section-title">账单信息</view>
<view class="info-item">
<text class="label">费用名称</text>
<text class="value">{{ bill.feeName }}</text>
</view>
<view class="info-item">
<text class="label">支付时间</text>
<text class="value">{{ bill.payTime || '未支付' }}</text>
</view>
<view class="info-item">
<text class="label">支付状态</text>
<text class="value">{{ bill.status }}</text>
</view>
<view class="info-item">
<text class="label">金额</text>
<text class="value">{{ formatMoney(bill.amount) }}</text>
</view>
<view class="info-item" v-if="bill.contractId">
<text class="label">关联合同</text>
<text class="value" @click="goContractDetail(bill.contractId)" style="color:#007aff;">点击查看</text>
</view>
<view class="info-item" v-if="bill.payMethod">
<text class="label">支付方式</text>
<text class="value">{{ bill.payMethod }}</text>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
bill: {},
};
},
onLoad(options) {
const { id } = options; // 列表页传过来的账单ID
this.loadBillDetail(id);
},
onShow() {
this.$checkToken(this.$getToken())
},
methods: {
loadBillDetail(id) {
// 模拟请求接口
this.bill = {
id,
feeName: '第一期租金2024.12.01-2024.12.31',
payTime: '2024-12-05',
status: '已支付',
amount: 3000,
contractId: 'c123',
payMethod: '线上支付',
};
},
formatMoney(val) {
if (!val && val !== 0) return '—';
return '¥' + Number(val).toFixed(2);
},
goDetail(contractId) {
uni.navigateTo({
url: `/pages-biz/contract/contractDetail?id=${contractId}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.bill-detail-page {
background: #f7f8fa;
min-height: 100vh;
padding-top: 175rpx; // 自定义导航栏高度
}
.scroll-content {
padding: 20rpx;
}
.section {
background: #fff;
border-radius: 12rpx;
padding: 20rpx;
margin-bottom: 20rpx;
.section-title {
font-size: 28rpx;
font-weight: bold;
margin-bottom: 20rpx;
color: #333;
}
.info-item {
display: flex;
justify-content: space-between;
padding: 16rpx 0;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
.label {
font-size: 26rpx;
color: #666;
}
.value {
font-size: 26rpx;
color: #333;
margin-right: 16rpx; /* 增加右侧安全间距 */
max-width: 70%; /* 防止过长文字挤到箭头或屏幕边缘 */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
</style>

View File

@@ -0,0 +1,328 @@
<template>
<view class="pay-history-page">
<customNavbar title="账单" />
<!-- 筛选栏 -->
<view class="filter-bar">
<!-- 年份筛选点击区域 -->
<view class="year-filter" @click="toggleYearPicker">
<text class="year-text">{{ currentYear }}</text>
<u-icon name="arrow-down" size="24" color="#666"></u-icon>
</view>
<!-- 自定义年份选择器弹窗 -->
<u-popup v-model="showYearPicker" mode="bottom" border-radius="20rpx" :closeable="true">
<view class="year-picker-popup">
<!-- 弹窗标题 -->
<view class="popup-header">
<text class="popup-title">选择年份</text>
</view>
<!-- 年份列表 -->
<view class="year-list">
<view class="year-item" v-for="year in years" :key="year"
:class="{ active: currentYear === year }" @click="selectYear(year)">
{{ year }}
</view>
</view>
</view>
</u-popup>
<!-- 顶部tab切换 -->
<view class="tab-bar">
<view v-for="(tab, index) in tabs" :key="index"
:class="['tab-item', activeTab === tab.value ? 'active' : '']" @click="activeTab = tab.value">
{{ tab.label }}
</view>
</view>
</view>
<!-- 收支记录列表 -->
<scroll-view scroll-y class="scroll-content" @scrolltolower="loadMore">
<view v-if="flowList.length > 0" class="record-list">
<view v-for="(item, index) in flowList" :key="index" class="record-item" @click="goDetail(item)">
<!-- 左侧信息 -->
<view class="left">
<view class="title">{{ item.itemName }}</view>
<view class="sub">{{ item.payDate || item.inDate || '未知'}}</view>
</view>
<!-- 右侧金额 + 图标 -->
<view class="right">
<view class="amount" :class="item.inOutType === '收' ? 'income' : 'expense'">
{{ item.inOutType === '收' ? '+' : '-' }}{{ item.itemAmount.toFixed(2) }}
</view>
<u-icon name="arrow-right" size="32" color="#ccc"></u-icon>
</view>
</view>
</view>
<view v-else class="empty">
<u-empty mode="list" text="暂无记录" />
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
pageNo: 1,
pageSize:10,
flowList: [],
loadStatus: 'loadmore',
activeTab: 'in', // 默认显示“收”
tabs: [{
label: '收入',
value: 'in'
},
{
label: '支出',
value: 'out'
},
],
// 年份筛选相关
currentYear: null,
years: [],
showYearPicker: false
};
},
onLoad(options) {
let year = new Date().getFullYear();
this.currentYear = year;
this.years = [];
for (let i = 5; i >= 1; i--) {
this.years.push(year - i);
}
this.fetchPayRecord();
},
onShow() {
this.$checkToken(this.$getToken())
},
watch: {
activeTab(newVal, oldVal) {
if (newVal !== oldVal) {
this.resetAndLoad()
}
}
},
computed: {
},
methods: {
fetchPayRecord() {
if (this.loadStatus !== 'loadmore') return;
this.loadStatus = 'loading';
let url = '/bill/pageQueryPayRecord'
this.$u.post(url, {
pageNo: this.pageNo,
pageSize: this.pageSize,
year: this.currentYear,
leType: this.activeTab
},{
WT:this.$getToken()
}).then(res => {
const rows = res.data.result || [];
console.log(rows)
if (this.pageNo === 1) this.flowList = [];
this.flowList = this.flowList.concat(rows);
if (rows.length < this.pageSize) {
this.loadStatus = 'nomore';
} else {
this.pageNo++;
this.loadStatus = 'loadmore';
}
}).catch(err => {
console.log("获取账单记录失败:", err)
this.loadStatus = 'loadmore';
})
},
// 切换年份选择器显示
toggleYearPicker() {
this.showYearPicker = !this.showYearPicker;
},
// 选择年份
selectYear(year) {
this.currentYear = year;
this.showYearPicker = false;
this.resetAndLoad();
},
resetAndLoad(){
// 重新加载数据
this.pageNo = 1;
this.flowList = [];
this.fetchPayRecord();
},
loadMore() {
// 只有在 loadStatus 为 'loadmore' 时才触发
if (this.loadStatus !== 'loadmore') return;
// 调用接口获取下一页
this.fetchPayRecord();
},
goDetail(item) {
},
},
};
</script>
<style lang="scss" scoped>
.pay-history-page {
background: #f8f8f8;
min-height: 100vh;
padding-top: 175rpx;
.filter-bar {
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
padding: 24rpx 30rpx;
margin: 20rpx;
margin-bottom: 0;
border-radius: 12rpx;
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
}
/* 年份筛选 */
.year-filter {
display: flex;
align-items: center;
gap: 8rpx;
font-size: 32rpx;
color: #333;
cursor: pointer;
}
/* 支出/收入切换 */
.tab-bar {
display: flex;
gap: 20rpx;
}
.tab-item {
padding: 12rpx 32rpx;
font-size: 28rpx;
border-radius: 24rpx;
color: #333;
background-color: #f5f5f5;
transition: all 0.2s ease;
&.active {
color: #fff;
background: #ff3b30;
}
}
/* 自定义年份选择器样式 */
.year-picker-popup {
background: #fff;
padding: 30rpx 0;
}
.popup-header {
text-align: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.popup-title {
font-size: 34rpx;
font-weight: 600;
color: #333;
}
.year-list {
padding: 20rpx;
}
.year-item {
font-size: 32rpx;
color: #666;
text-align: center;
padding: 24rpx;
border-radius: 12rpx;
margin-bottom: 16rpx;
background: #f5f5f5;
transition: all 0.2s ease;
&:last-child {
margin-bottom: 0;
}
&.active {
background: #ff3b30;
color: #fff;
}
&:hover {
background: #ff5252;
color: #fff;
}
}
.record-list {
padding: 20rpx;
.record-item {
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
padding: 20rpx;
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.03);
.left {
flex: 1;
.title {
font-size: 28rpx;
font-weight:5600;
color: #2D2B2C;
}
.sub {
font-size: 24rpx;
color: #86868C;
margin-top: 18rpx;
}
.status {
font-size: 28rpx;
&.paid {
color: #73B936;
}
&.unpaid {
color: #F34038;
}
}
}
.right {
display: flex;
align-items: center;
.amount {
font-size: 28rpx;
font-weight: 500;
margin-right: 10rpx;
&.income {
color: #73B936;
}
&.expense {
color: #F34038;
}
}
}
}
}
.empty {
margin-top: 100rpx;
}
}
</style>