完成大体功能和样式

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

366
pages-biz/wae/wae.vue Normal file
View File

@@ -0,0 +1,366 @@
<template>
<view class="pending-bill-page">
<!-- 自定义导航栏 -->
<custom-navbar title="水电费待付" />
<scroll-view scroll-y class="scroll-content" :refresher-enabled="true" :refresher-triggered="isRefreshing"
@refresherrefresh="refresh" @scrolltolower="loadMore">
<view v-if="bills.length > 0">
<view class="bill-item" v-for="item in bills" :key="item.billNo">
<!-- 左侧勾选 + 信息 -->
<view class="bill-left">
<u-checkbox v-model="item.checked" @change="toggleCheck(item)" size="32"
active-color="#EA414A" />
<view class="bill-info">
<text class="bill-name">{{ item.billName }}</text>
<text class="bill-date">缴费截止<text class="date">{{ item.billEndDate }}</text></text>
</view>
</view>
<!-- 右侧金额 + 支付按钮 -->
<view class="bill-right">
<text class="amount">{{ formatMoney(item.billAmount) }}</text>
<button class="pay-btn" @click="goPayTest([item])">去支付
</button>
</view>
</view>
</view>
<view v-else class="empty">
<u-empty mode="list" text="暂无水电费账单" />
</view>
<u-loadmore :status="loadStatus" />
</scroll-view>
<!-- 底部批量支付栏 -->
<view v-if="selectedBills.length > 0" class="batch-pay-bar">
<view class="batch-pay-bar-left"><text>已选 {{ selectedBills.length }} </text></view>
<view class="batch-pay-bar-center">
合计<text class="sumAmount">{{ formatMoney(sumAmount) }}</text>
</view>
<view class="batch-pay-bar-right">
<button class="bottomPayBtn" color="linear-gradient(90deg, #007aff, #00aaff)" type="primary"
size="small" @click="goPayTest(selectedBills)">
批量缴费
</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
pageNo: 1,
pageSize: 10,
bills: [],
isRefreshing: false,
loadStatus: 'loadmore',
sumAmount: 0,
selectedBills: [], // 勾选的账单集合
};
},
onLoad(options) {
this.loadBills();
},
onShow() {
this.$checkToken(this.$getToken())
},
methods: {
loadBills() {
if (this.loadStatus !== 'loadmore') return;
this.loadStatus = 'loading';
const token = this.$getToken();
let url = '/bill/pageQueryWaeBill'
this.$u.post(url, {
pageNo: this.pageNo,
pageSize: this.pageSize
}, {
WT: token
}).then(
result => {
const rows = result.data.result || [];
if (this.pageNo === 1) this.bills = [];
this.bills = this.bills.concat(rows);
if (rows.length < this.pageSize) {
this.loadStatus = 'nomore';
} else {
this.pageNo++;
this.loadStatus = 'loadmore';
}
})
this.updateSelected();
},
refresh() {
this.isRefreshing = true;
setTimeout(() => {
this.loadBills();
this.isRefreshing = false;
}, 1000);
},
loadMore() {
this.loadBills()
},
formatMoney(val) {
if (val === null || val === undefined || isNaN(val)) return '—';
val = Number(val);
if (val >= 10000) {
return '¥' + (val / 10000).toFixed(2) + '万';
}
return '¥' + val.toFixed(2);
},
toggleCheck(item) {
item.checked = !item.checked;
if (item.checked && !this.selectedBills.some(b => b.id === item.id)) {
this.selectedBills.push(item);
} else {
// 取消勾选时从已选数组移除
this.selectedBills = this.selectedBills.filter(b => b.id !== item.id);
}
let sumFee = 0;
this.selectedBills.forEach(b => sumFee += b.amount);
this.sumAmount = sumFee;
},
updateSelected() {
if (!Array.isArray(this.bills)) return;
this.selectedBills = this.bills.filter(b => b.checked);
},
goPayTest(billList) {
if (!billList || billList.length === 0) return;
// 模拟后台生成订单返回
const order = {
timeStamp: String(Date.now()), // 时间戳
nonceStr: Math.random().toString(36).substr(2, 15), // 随机字符串
package: 'prepay_id=TEST1234567890', // 模拟预支付ID
signType: 'MD5',
paySign: 'TEST_SIGN', // 模拟签名
};
// 调用微信支付接口(测试)
uni.requestPayment({
...order,
success: () => {
uni.showToast({
title: '支付成功(测试)',
icon: 'success'
});
// 清空勾选状态
billList.forEach(b => b.checked = false);
this.updateSelected();
// 刷新列表(可选)
this.loadBills();
},
fail: () => {
uni.showToast({
title: '支付失败(测试)',
icon: 'none'
});
}
});
},
async goPay(billList) {
if (!billList || billList.length === 0) return;
try {
// 1. 请求后台生成订单
const res = await uni.request({
url: 'https://api.example.com/payments/create',
method: 'POST',
data: {
userId: this.userId,
bills: billList.map(b => b.id),
}
});
if (res[1].data.code !== 0) {
uni.showToast({
title: res[1].data.msg,
icon: 'none'
});
return;
}
const order = res[1].data.data; // 后台返回的支付参数
// 2. 调用微信支付
uni.requestPayment({
timeStamp: order.timeStamp,
nonceStr: order.nonceStr,
package: order.package,
signType: order.signType,
paySign: order.paySign,
success: () => {
uni.showToast({
title: '支付成功',
icon: 'success'
});
// 更新勾选状态
billList.forEach(b => b.checked = false);
this.updateSelected();
// 刷新列表
this.loadBills();
},
fail: () => {
uni.showToast({
title: '支付失败',
icon: 'none'
});
}
});
} catch (error) {
console.error('支付请求失败', error);
uni.showToast({
title: '支付请求失败',
icon: 'none'
});
}
},
}
};
</script>
<style lang="scss" scoped>
.pending-bill-page {
background: #f7f8fa;
min-height: 100vh;
padding-top: 175rpx;
/* 自定义导航栏高度 */
}
.scroll-content {
padding: 20rpx;
box-sizing: border-box;
}
.bill-item {
display: flex;
justify-content: space-between;
background: #fff;
margin-bottom: 20rpx;
border-radius: 12rpx;
padding: 20rpx;
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
}
.bill-left {
display: flex;
align-items: center;
.bill-info {
display: flex;
flex-direction: column;
.bill-name {
font-size: 30rpx;
color: #2D2B2C;
font-weight: 500;
}
.bill-date {
font-size: 24rpx;
color: #86868C;
margin-top: 6rpx;
.date {
font-size: 24rpx;
color: #2D2B2C;
}
}
}
}
.bill-right {
flex-direction: column;
align-items: flex-end;
width: 30%;
.amount {
text-align: center;
height: 28rpx;
line-height: 28rpx;
font-size: 30rpx;
color: #EF8849;
}
.pay-btn {
margin-top: 12rpx;
padding: 0 40rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 6rpx; // 圆角
font-size: 30rpx;
color: #fff;
background-color: #F34038;
text-align: center;
}
.btn-text {
padding-top: 13rpx;
}
}
.batch-pay-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 170rpx;
padding: 0 30rpx;
background-color: #fff;
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 -4rpx 10rpx rgba(0, 0, 0, 0.08);
z-index: 999;
.batch-pay-bar-left {
font-size: 28rpx;
color: #86868C;
}
.batch-pay-bar-center {
font-size: 28rpx;
color: #222222;
.sumAmount {
font-size: 28rpx;
color: #ff7f00;
}
}
.batch-pay-bar-right {
flex-direction: column;
align-items: flex-end;
.bottomPayBtn {
height: 60rpx;
line-height: 60rpx;
padding: 0 40rpx;
border-radius: 6rpx;
font-size: 30rpx;
font-weight: bold;
text-align: center;
background: #F34038;
}
}
}
.empty {
margin-top: 200rpx;
text-align: center;
}
</style>

View File

@@ -0,0 +1,195 @@
<template>
<view class="water-electric-page">
<!-- 页面标题栏 -->
<customNavbar title="水电费明细" />
<!-- 空状态 -->
<!-- 列表部分 -->
<!-- 收支记录列表 -->
<scroll-view scroll-y class="scroll-content" @scrolltolower="loadMore">
<view v-if="flowList.length > 0" class="record-list">
<view
class="record-item"
v-for="(item, index) in flowList"
:key="index"
@click="toDetail(item)"
>
<!-- <view class="record-icon">
<image src="/static/icon/水费.png" class="icon-1" v-if="item.feeType=='水费'"></image>
<image src="/static/icon/电费.png" class="icon-2" v-else></image>
</view> -->
<!-- 左侧信息 -->
<view class="record-left">
<text class="record-title">{{ item.itemName }}</text>
<text class="record-time">支付时间{{ item.payDate }}</text>
</view>
<!-- 右侧金额 + 箭头 -->
<view class="record-right">
<view class="amount">
{{ item.itemAmount.toFixed(2) }}
<u-icon name="arrow-right" size="20" color="#ccc"></u-icon>
</view>
</view>
</view>
</view>
<view v-if="records.length === 0" class="empty">
<image src="/static/empty.png" mode="aspectFit" />
<text>暂明细记录</text>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
pageNo: 1,
pageSize:10,
flowList: [],
loadStatus: 'loadmore'
};
},
onShow() {
this.$checkToken(this.$getToken())
},
onLoad() {
this.fetchDataList();
},
methods: {
fetchDataList(){
if (this.loadStatus !== 'loadmore') return;
this.loadStatus = 'loading';
let url = '/bill/pageQueryPayRecord'
this.$u.post(url, {
pageNo: this.pageNo,
pageSize: this.pageSize,
recordType:'wae'
},{
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';
})
},
loadMore() {
// 只有在 loadStatus 为 'loadmore' 时才触发
if (this.loadStatus !== 'loadmore') return;
// 调用接口获取下一页
this.fetchDataList();
},
toDetail(item) {
}
}
};
</script>
<style lang="scss" scoped>
.water-electric-page {
padding: 175rpx 20rpx 20rpx 20rpx;
.header {
background-color: #fff;
padding: 30rpx;
border-radius: 16rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
text-align: center;
.title {
font-size: 32rpx;
font-weight: 600;
}
}
.record-list {
margin-top: 20rpx;
}
.record-item {
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
padding: 24rpx 30rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
.record-icon{
display: flex;
align-items: center;
justify-content: center;
.icon-1{
width: 33rpx;
height: 47rpx;
}
.icon-2{
width: 35rpx;
height: 57rpx;
}
}
.record-left {
display: flex;
flex-direction: column;
gap: 10rpx;
.record-title {
font-size: 30rpx;
font-weight: 500;
color: #2D2B2C;
}
.record-time {
font-size: 24rpx;
color: #86868C;
}
}
.record-right {
display: flex;
align-items: center;
font-size: 30rpx;
font-weight: 400;
color: #222222;
.amount {
display: flex;
align-items: center;
gap: 8rpx;
}
}
}
.empty {
margin-top: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
font-size: 28rpx;
image {
width: 200rpx;
height: 200rpx;
margin-bottom: 20rpx;
}
}
}
</style>