文件
yjyf/yjyf-app/pages/user/bills.vue
MiAn 0370cb9bd6 feat: 新增师傅入驻审核与接单状态联动功能
- 新增师傅资质审核模块及权限
- 未审核通过的师傅默认禁用接单状态
- 新增售后退款申诉功能与相关界面
- 新增用户钱包管理及充值功能
- 更新服务定价矩阵相关数据库结构
- 修复微信支付证书验证问题
2026-11-17 10:28:01 +08:00

659 行
14 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="bills-page">
<!-- 1. 统一标准白底导航栏(带返回键,右侧避让胶囊) -->
<YjyfNavBar theme="white" title="收支明细" :border="true" :fixed="true" :placeholder="true" />
<!-- 2. 吸顶分类 Tabs 栏(置于普通流,紧跟导航栏下方,杜绝穿模) -->
<view class="tabs-header">
<view
class="tab-item clickable-hover"
:class="{ active: currentTab === 'all' }"
@tap="switchTab('all')"
>
<text class="tab-label">全部</text>
<view class="tab-indicator" v-if="currentTab === 'all'"></view>
</view>
<view
class="tab-item clickable-hover"
:class="{ active: currentTab === 'recharge' }"
@tap="switchTab('recharge')"
>
<text class="tab-label">充值</text>
<view class="tab-indicator" v-if="currentTab === 'recharge'"></view>
</view>
<view
class="tab-item clickable-hover"
:class="{ active: currentTab === 'consume' }"
@tap="switchTab('consume')"
>
<text class="tab-label">消费</text>
<view class="tab-indicator" v-if="currentTab === 'consume'"></view>
</view>
<view
class="tab-item clickable-hover"
:class="{ active: currentTab === 'refund' }"
@tap="switchTab('refund')"
>
<text class="tab-label">退款</text>
<view class="tab-indicator" v-if="currentTab === 'refund'"></view>
</view>
</view>
<!-- 3. 统计计数栏(轻量清爽,真实数据) -->
<view class="count-bar" v-if="totalCount > 0">
<text class="count-text">共 {{ totalCount }} 笔收支明细</text>
</view>
<!-- 4. 独立流水列表滚动视口(flex: 1 严格约束在下方,绝对不发生顶栏穿透) -->
<scroll-view
class="bills-scroll"
scroll-y
:refresher-enabled="true"
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh"
@scrolltolower="loadMore"
>
<!-- 连贯典雅的整块白底流水列表(告别药片式割裂卡片堆叠) -->
<view class="list-panel" v-if="logs.length > 0">
<view
class="bill-row clickable-hover"
v-for="item in logs"
:key="item.id"
@tap="openDetail(item)"
>
<view class="row-left">
<image class="row-icon" :src="getItemIcon(item.type)" mode="aspectFit" />
<view class="row-info">
<text class="info-title">{{ getItemTitle(item) }}</text>
<text class="info-time">{{ item.created_at }}</text>
</view>
</view>
<view class="row-right">
<text
class="row-amount"
:class="{
plus: Number(item.amount) > 0,
minus: Number(item.amount) <= 0
}"
>
{{ Number(item.amount) > 0 ? '+' : '' }}{{ formatMoney(item.amount) }}
</text>
<text class="row-balance">余额 ¥{{ formatMoney(item.balance) }}</text>
</view>
</view>
<!-- 底部加载提示 -->
<view class="list-end-tip">
<text v-if="loadingMore">正在加载更多明细...</text>
<text v-else-if="!hasMore">已加载全部收支明细</text>
</view>
</view>
<!-- 真实空状态 -->
<view class="empty-wrap" v-else-if="!loading">
<image class="empty-img" src="/static/icons/empty-wallet.svg" mode="aspectFit" />
<text class="empty-title">暂无收支明细记录</text>
<text class="empty-desc">该分类下暂无账单流水,所有真实交易将在此记录展示</text>
</view>
</scroll-view>
<!-- 5. 流水凭证详情抽屉 -->
<view class="modal-mask" :class="{ show: showDetailModal }" @tap="closeDetail" @touchmove.stop.prevent>
<view class="detail-sheet" :class="{ show: showDetailModal }" @tap.stop>
<view class="sheet-head">
<text class="sheet-title">收支详情凭证</text>
<view class="sheet-close clickable-hover" @tap="closeDetail">
<image class="close-icon" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
<view class="detail-body" v-if="activeLog">
<view class="detail-hero">
<text class="dh-title">{{ activeLog.type_label }}</text>
<text
class="dh-amount"
:class="{
plus: Number(activeLog.amount) > 0,
minus: Number(activeLog.amount) <= 0
}"
>
{{ Number(activeLog.amount) > 0 ? '+' : '' }}{{ formatMoney(activeLog.amount) }}
</text>
<text class="dh-balance">变动后账户余额:¥{{ formatMoney(activeLog.balance) }}</text>
</view>
<view class="detail-table">
<view class="dt-row">
<text class="dt-label">流水单号</text>
<view class="dt-val-box">
<text class="dt-value">#WL{{ activeLog.id }}</text>
</view>
</view>
<view class="dt-row" v-if="activeLog.order_no">
<text class="dt-label">关联工单</text>
<view class="dt-val-box clickable-hover" @tap="copyOrderNo(activeLog.order_no)">
<text class="dt-value highlight">{{ activeLog.order_no }}</text>
<text class="dt-copy-btn">复制</text>
</view>
</view>
<view class="dt-row" v-if="activeLog.service_name">
<text class="dt-label">服务品类</text>
<view class="dt-val-box">
<text class="dt-value">{{ activeLog.service_name }}</text>
</view>
</view>
<view class="dt-row">
<text class="dt-label">交易说明</text>
<view class="dt-val-box">
<text class="dt-value">{{ activeLog.remark || activeLog.type_label }}</text>
</view>
</view>
<view class="dt-row">
<text class="dt-label">记账时间</text>
<view class="dt-val-box">
<text class="dt-value">{{ activeLog.created_at }}</text>
</view>
</view>
</view>
<view class="detail-btn-wrap" v-if="activeLog.order_id > 0">
<button class="detail-cta clickable-hover" @tap="goToOrder(activeLog.order_id)">
查看关联工单详情
</button>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
// 页面状态
const currentTab = ref('all');
const logs = ref([]);
const page = ref(1);
const limit = ref(20);
const totalCount = ref(0);
const hasMore = ref(false);
const loading = ref(false);
const refreshing = ref(false);
const loadingMore = ref(false);
// 详情凭证抽屉
const showDetailModal = ref(false);
const activeLog = ref(null);
onLoad((options) => {
if (options && options.type) {
currentTab.value = options.type;
}
});
// 金额格式化
function formatMoney(val) {
const num = Number(val || 0);
return isNaN(num) ? '0.00' : num.toFixed(2);
}
// 真实接口加载流水明细
async function fetchLogs(isReset = true) {
if (isReset) {
page.value = 1;
loading.value = true;
} else {
loadingMore.value = true;
}
try {
const res = await api.userWalletLogs({
type: currentTab.value,
page: page.value,
limit: limit.value
});
const list = (res && res.list) || [];
if (isReset) {
logs.value = list;
} else {
logs.value = logs.value.concat(list);
}
totalCount.value = (res && res.total) || 0;
hasMore.value = (res && res.has_more) || false;
} catch (e) {
console.error('加载收支明细失败', e);
} finally {
loading.value = false;
refreshing.value = false;
loadingMore.value = false;
}
}
// 下拉刷新
async function onRefresh() {
refreshing.value = true;
await fetchLogs(true);
}
// 触底加载更多
function loadMore() {
if (!hasMore.value || loadingMore.value || loading.value) return;
page.value += 1;
fetchLogs(false);
}
// 切换 Tab 分类
function switchTab(type) {
if (currentTab.value === type) return;
currentTab.value = type;
fetchLogs(true);
}
// 图标匹配
function getItemIcon(type) {
if (type === 'recharge') return '/static/icons/wallet-recharge.svg';
if (type === 'refund') return '/static/icons/wallet-refund.svg';
return '/static/icons/wallet-consume.svg';
}
// 标题处理
function getItemTitle(item) {
if (item.service_name) {
return item.service_name;
}
if (item.order_no) {
return `工单扣减 · ${item.order_no}`;
}
return item.remark || item.type_label || '资金变动';
}
// 打开详情抽屉
function openDetail(item) {
activeLog.value = item;
showDetailModal.value = true;
}
// 关闭详情抽屉
function closeDetail() {
showDetailModal.value = false;
}
// 复制单号
function copyOrderNo(no) {
if (!no) return;
uni.setClipboardData({
data: String(no),
success: () => uni.showToast({ title: '单号已复制', icon: 'none' })
});
}
// 跳转关联工单
function goToOrder(orderId) {
closeDetail();
uni.navigateTo({
url: `/pages/order/detail?id=${orderId}`
});
}
onMounted(() => {
fetchLogs(true);
});
</script>
<style lang="scss" scoped>
.bills-page {
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
background-color: $yjyf-bg-page;
box-sizing: border-box;
}
/* 2. 吸顶分类 Tabs 栏(文档流自上而下,绝不脱离文档流产生穿透) */
.tabs-header {
display: flex;
align-items: center;
height: 88rpx;
background-color: #ffffff;
border-bottom: 1rpx solid $yjyf-border-color;
padding: 0 16rpx;
flex-shrink: 0;
z-index: 20;
}
.tab-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
position: relative;
.tab-label {
font-size: 28rpx;
color: $yjyf-text-secondary;
font-weight: 500;
transition: all 0.2s ease;
}
&.active .tab-label {
color: $yjyf-primary;
font-weight: 700;
}
.tab-indicator {
position: absolute;
bottom: 8rpx;
width: 44rpx;
height: 4rpx;
background: $yjyf-gradient-primary;
border-radius: 4rpx;
}
}
/* 3. 统计小条 */
.count-bar {
padding: 14rpx 32rpx;
background-color: #fafbfc;
border-bottom: 1rpx solid #f0f2f5;
flex-shrink: 0;
.count-text {
font-size: 22rpx;
color: $yjyf-text-muted;
}
}
/* 4. 流水滚动视口(flex: 1 严密锁在下方,滚动完全封闭) */
.bills-scroll {
flex: 1;
height: 0;
width: 100%;
box-sizing: border-box;
}
/* 连贯纯白面板(告别药片式卡片堆叠) */
.list-panel {
margin: 20rpx 32rpx 48rpx;
background: #ffffff;
border-radius: 24rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.03);
overflow: hidden;
}
.bill-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 28rpx;
border-bottom: 1rpx solid $yjyf-border-color;
transition: background-color 0.15s ease;
&:last-child {
border-bottom: none;
}
&:active {
background-color: #fcfcfd;
}
}
.row-left {
display: flex;
align-items: center;
gap: 20rpx;
flex: 1;
min-width: 0;
.row-icon {
width: 68rpx;
height: 68rpx;
flex-shrink: 0;
}
.row-info {
display: flex;
flex-direction: column;
gap: 8rpx;
min-width: 0;
.info-title {
font-size: 28rpx;
color: $yjyf-text-main;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.info-time {
font-size: 22rpx;
color: $yjyf-text-muted;
}
}
}
.row-right {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8rpx;
flex-shrink: 0;
margin-left: 20rpx;
.row-amount {
font-size: 32rpx;
font-weight: 700;
font-variant-numeric: tabular-nums;
&.plus {
color: $yjyf-success;
}
&.minus {
color: $yjyf-text-main;
}
}
.row-balance {
font-size: 22rpx;
color: $yjyf-text-muted;
}
}
.list-end-tip {
text-align: center;
padding: 36rpx 0;
font-size: 24rpx;
color: $yjyf-text-muted;
}
/* 空状态 */
.empty-wrap {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 160rpx 48rpx;
.empty-img {
width: 200rpx;
height: 200rpx;
margin-bottom: 24rpx;
}
.empty-title {
font-size: 30rpx;
color: $yjyf-text-regular;
font-weight: 600;
margin-bottom: 12rpx;
}
.empty-desc {
font-size: 24rpx;
color: $yjyf-text-muted;
text-align: center;
line-height: 1.5;
}
}
/* 详情凭证抽屉 */
.modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.55);
backdrop-filter: blur(4px);
z-index: 1000;
visibility: hidden;
opacity: 0;
transition: all 0.25s ease;
&.show {
visibility: visible;
opacity: 1;
}
}
.detail-sheet {
position: absolute;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
border-radius: 36rpx 36rpx 0 0;
padding: 36rpx 36rpx calc(40rpx + env(safe-area-inset-bottom));
transform: translateY(100%);
transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
&.show {
transform: translateY(0);
}
}
.sheet-head {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 24rpx;
border-bottom: 1rpx solid $yjyf-border-color;
.sheet-title {
font-size: 32rpx;
font-weight: 700;
color: $yjyf-text-main;
}
.sheet-close {
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
.close-icon {
width: 32rpx;
height: 32rpx;
}
}
}
.detail-hero {
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx 0 32rpx;
.dh-title {
font-size: 26rpx;
color: $yjyf-text-secondary;
margin-bottom: 12rpx;
}
.dh-amount {
font-size: 56rpx;
font-weight: 800;
color: $yjyf-text-main;
margin-bottom: 12rpx;
&.plus {
color: $yjyf-success;
}
}
.dh-balance {
font-size: 24rpx;
color: $yjyf-text-muted;
}
}
.detail-table {
background-color: #f9fafb;
border-radius: 20rpx;
padding: 24rpx 28rpx;
display: flex;
flex-direction: column;
gap: 20rpx;
}
.dt-row {
display: flex;
align-items: center;
justify-content: space-between;
.dt-label {
font-size: 26rpx;
color: $yjyf-text-secondary;
}
.dt-val-box {
display: flex;
align-items: center;
gap: 12rpx;
.dt-value {
font-size: 26rpx;
color: $yjyf-text-main;
font-weight: 500;
&.highlight {
color: $yjyf-primary;
}
}
.dt-copy-btn {
font-size: 20rpx;
color: $yjyf-primary;
background: $yjyf-primary-bg;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
}
}
.detail-btn-wrap {
margin-top: 40rpx;
.detail-cta {
width: 100%;
height: 84rpx;
line-height: 84rpx;
text-align: center;
background: #ffffff;
border: 1rpx solid $yjyf-border-color;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 600;
color: $yjyf-text-regular;
}
}
</style>