文件
xionggeshop/xgsc.gynhc.com_wx/pages/user/wallet/index.vue
2026-09-14 17:24:53 +08:00

435 行
9.9 KiB
Vue

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

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

<!-- 我的钱包 -->
<template>
<view class="wallet-wrap brand-page">
<!-- 钱包卡片 -->
<view class="head_box">
<view class="card-box">
<view class="card-head u-flex u-col-center">
<view class="card-title">可提现金额(元)</view>
<view @tap="showMoney = !showMoney" class="u-iconfont eye-icon"
:class="showMoney ? 'uicon-eye' : 'uicon-eye-off'"></view>
</view>
<view class="money-num font-OPPOSANS">{{ showMoney ? userInfo.money || '0.00' : '*****' }}</view>
<view class="card-actions u-flex">
<button v-if="initRecharge.enable === '1'" class="u-reset-button topup-btn"
@tap="$Router.push('/pages/user/wallet/top-up')">充值</button>
<button class="u-reset-button withdraw-btn"
@tap="$Router.push('/pages/user/wallet/withdraw')">提现</button>
</view>
</view>
</view>
<!-- 筛选 -->
<u-sticky offset-top="0" :enable="true">
<view class="filter-sticky">
<view class="filter-box u-flex u-row-between">
<button class="u-reset-button date-btn u-flex u-col-center" @tap="showCalendar = true">
<text class="date-btn__text">{{ selDateText }}</text>
<text class="u-iconfont uicon-arrow-down-fill date-btn__arrow"></text>
</button>
<view class="total-box">
收入<text class="total-box__income">¥{{ incomeMoney || '0.00' }}</text>
<text class="total-box__gap"> </text>
支出<text class="total-box__expend">¥{{ expendMoney || '0.00' }}</text>
</view>
</view>
<view class="u-flex nav-box">
<view class="state-item u-flex-1" v-for="state in statusList" :key="state.value"
@tap="onTab(state.value)">
<text class="state-title"
:class="{ 'title-active': stateCurrent === state.value }">{{ state.name }}</text>
<text class="underline" :class="{ 'underline-active': stateCurrent === state.value }"></text>
</view>
</view>
</view>
</u-sticky>
<!-- 钱包记录 -->
<view class="wallet-list-wrap">
<view class="wallet-list u-flex" v-for="item in walletLog" :key="item.id">
<image class="head-img u-m-r-20" :src="item.avatar" mode="aspectFill"></image>
<view class="list-content">
<view class="title-box u-flex u-row-between">
<text class="title u-ellipsis-1">{{ item.type_name }}{{ item.title ? '-' + item.title : '' }}</text>
<view class="money">
<text v-if="item.wallet >= 0" class="add font-OPPOSANS">+{{ item.wallet }}</text>
<text v-else class="minus font-OPPOSANS">{{ item.wallet }}</text>
</view>
</view>
<text class="time">{{ $u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM') }}</text>
</view>
</view>
</view>
<shopro-empty v-if="isEmpty" marginTop="120rpx" :image="$IMG_URL + '/imgs/empty/empty_goods_null.png'" tipText="暂无数据~">
</shopro-empty>
<u-loadmore v-if="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
<u-calendar v-model="showCalendar" ref="uCalendar" safeAreaInsetBottom mode="range" start-text="开始"
end-text="结束" active-bg-color="#1677FF" active-color="#fff"
range-bg-color="rgba(22, 119, 255, 0.18)" range-color="#1677FF"
:customStyle="{ background: 'linear-gradient(90deg, #1677FF, #4096FF)', boxShadow: '0 7rpx 11rpx 2rpx rgba(22, 119, 255, 0.28)' }"
@change="selDate"></u-calendar>
</view>
</template>
<script>
import {
mapState,
mapActions,
mapGetters
} from 'vuex';
export default {
components: {},
data() {
return {
isEmpty: false,
stateCurrent: 'all', //默认
statusList: [{
name: '全部',
value: 'all'
},
{
name: '收入',
value: 'add'
},
{
name: '支出',
value: 'reduce'
}
],
showMoney: true,
//日期选择
showCalendar: false,
selDateText: '',
walletLog: [], //钱包记录
propsDate: '', //日期参数
incomeMoney: '', //收入
expendMoney: '', //支出
loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
currentPage: 1,
lastPage: 1
};
},
computed: {
...mapGetters(['isLogin', 'userInfo', 'initRecharge'])
},
onShow() {
this.isLogin && this.getUserInfo();
this.getToday();
this.currentPage = 1;
this.lastPage = 1;
this.walletLog = [];
this.getWalletLog();
},
// 触底加载更多
onReachBottom() {
if (this.currentPage < this.lastPage) {
this.currentPage += 1;
this.getWalletLog();
}
},
methods: {
...mapActions(['getUserInfo']),
// 今日
getToday() {
let now = new Date();
let dateText = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}`;
this.selDateText = `${now.getFullYear()}.${now.getMonth() + 1}.${now.getDate()}`;
this.propsDate = `${dateText}-${dateText}`;
},
// tab切换
onTab(state) {
if (this.stateCurrent !== state) {
this.stateCurrent = state;
this.currentPage = 1;
this.lastPage = 1;
this.walletLog = [];
this.getWalletLog();
}
},
// 日期选择
selDate(e) {
this.walletLog = [];
this.currentPage = 1;
this.lastPage = 1;
this.selDateText = `${e.startYear}.${e.startMonth}.${e.startDay}-${e.endYear}.${e.endMonth}.${e.endDay}`;
let dateText = `${e.startYear}/${e.startMonth}/${e.startDay}-${e.endYear}/${e.endMonth}/${e.endDay}`;
this.propsDate = dateText;
this.getWalletLog();
this.$refs.uCalendar.init();
},
// 钱包明细
getWalletLog() {
let that = this;
that.loadStatus = 'loading';
that.$http('money.walletLog', {
wallet_type: 'money',
status: that.stateCurrent,
date: that.propsDate,
page: that.currentPage
}).then(res => {
if (res.code === 1) {
that.walletLog = [...that.walletLog, ...res.data.wallet_logs.data];
that.incomeMoney = res.data.income;
that.expendMoney = Math.abs(res.data.expend);
that.isEmpty = !that.walletLog.length;
that.lastPage = res.data.wallet_logs.last_page;
that.loadStatus = that.currentPage < res.data.wallet_logs.last_page ? 'loadmore' :
'nomore';
}
});
}
}
};
</script>
<style lang="scss">
.wallet-wrap {
min-height: 100vh;
background: $brand-page-bg;
padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
}
// 余额卡片
.head_box {
padding: $brand-page-gutter;
padding-bottom: 8rpx;
.card-box {
@include brand-card;
width: 100%;
min-height: 280rpx;
padding: 40rpx 36rpx 36rpx;
background: $brand-gold-gradient;
border-radius: 20rpx;
box-shadow: 0 8rpx 32rpx rgba(22, 119, 255, 0.28);
position: relative;
overflow: hidden;
&::after {
content: '';
position: absolute;
right: -40rpx;
top: -40rpx;
width: 200rpx;
height: 200rpx;
border-radius: 50%;
background: rgba(255, 255, 255, 0.08);
}
.card-head {
position: relative;
z-index: 1;
}
.card-title {
font-size: 28rpx;
font-weight: 500;
color: rgba(255, 255, 255, 0.92);
margin-right: 16rpx;
}
.eye-icon {
color: rgba(255, 255, 255, 0.85);
font-size: 40rpx;
}
.money-num {
position: relative;
z-index: 1;
margin-top: 28rpx;
font-size: 72rpx;
line-height: 1;
font-weight: 600;
color: #ffffff;
letter-spacing: 1rpx;
}
.card-actions {
position: absolute;
right: 36rpx;
top: 36rpx;
z-index: 1;
gap: 16rpx;
}
.withdraw-btn {
min-width: 120rpx;
height: 56rpx;
line-height: 56rpx;
padding: 0 28rpx;
background: #ffffff;
border-radius: 28rpx;
font-size: 24rpx;
font-weight: 600;
color: $brand-gold;
}
.topup-btn {
min-width: 120rpx;
height: 56rpx;
line-height: 56rpx;
padding: 0 28rpx;
border-radius: 28rpx;
font-size: 24rpx;
font-weight: 500;
color: #fff;
border: 1rpx solid rgba(255, 255, 255, 0.65);
background: rgba(255, 255, 255, 0.12);
}
}
}
// 筛选 + Tab
.filter-sticky {
background: $brand-page-bg;
}
.filter-box {
height: 96rpx;
padding: 0 $brand-page-gutter;
align-items: center;
.date-btn {
@include brand-card;
line-height: 1;
border-radius: 28rpx;
padding: 14rpx 24rpx;
font-size: 24rpx;
font-weight: 500;
color: $brand-text;
box-shadow: none;
border: 1rpx solid $brand-border;
&__text {
max-width: 280rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__arrow {
margin-left: 12rpx;
font-size: 20rpx;
color: $brand-text-muted;
}
}
.total-box {
font-size: 24rpx;
color: $brand-text-muted;
&__income {
color: $brand-price;
font-weight: 600;
}
&__expend {
color: $brand-text;
font-weight: 600;
}
&__gap {
margin: 0 8rpx;
}
}
}
.nav-box {
background: #fff;
border-bottom: 1rpx solid $brand-border;
}
.state-item {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.state-title {
color: $brand-text-muted;
font-weight: 500;
font-size: 28rpx;
line-height: 88rpx;
transition: color 0.2s;
}
.title-active {
color: $brand-gold;
font-weight: 600;
}
.underline {
display: block;
width: 48rpx;
height: 4rpx;
background: transparent;
border-radius: 2rpx;
margin-top: -12rpx;
margin-bottom: 8rpx;
}
.underline-active {
background: $brand-gold;
}
}
// 钱包记录
.wallet-list-wrap {
margin: $brand-section-gap $brand-page-gutter 0;
@include brand-card;
overflow: hidden;
}
.wallet-list {
padding: 28rpx 24rpx;
border-bottom: 1rpx solid $brand-border;
&:last-child {
border-bottom: none;
}
.head-img {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background: $brand-gold-light;
flex-shrink: 0;
}
.list-content {
flex: 1;
min-width: 0;
.title {
font-size: 28rpx;
color: $brand-text;
flex: 1;
margin-right: 16rpx;
}
.time {
display: block;
margin-top: 8rpx;
color: $brand-text-muted;
font-size: 22rpx;
}
}
.money {
font-size: 30rpx;
font-weight: 600;
flex-shrink: 0;
.add {
color: $brand-price;
}
.minus {
color: $brand-text;
}
}
}
</style>