Initial commit

This commit is contained in:
Dev
2026-09-17 16:25:31 +08:00
commit 382a3069b9
1268 changed files with 266342 additions and 0 deletions
@@ -0,0 +1,174 @@
// pages/usercenter/balance/index.js
import { fetchAccountInfo, fetchAccountLogs, accountApplyWithdraw } from '../../../services/usercenter/fetchBalance';
Page({
/**
* 页面的初始数据
*/
data: {
totalAmount: 0,
accountInfo: null,
tab: 'all',
list: [],
page: 1,
pageSize: 10,
loadMoreStatus: 0,
showWithdrawDialog: false,
withdrawAmount: '',
withdrawName: '',
cancelBtnStyle: 'color: #ff0000; border-color: #ff0000; background-color: #fff;',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.loadAccountInfo();
this.loadList();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
if (this.data.loadMoreStatus === 0) {
this.setData({ loadMoreStatus: 1 });
this.loadList();
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
// Tab切换
onTabChange(e) {
const value = e.currentTarget.dataset.value;
if (value === this.data.tab) return;
this.setData({
tab: value,
list: [],
page: 1,
loadMoreStatus: 'more'
}, () => {
this.loadList();
});
},
loadAccountInfo() {
fetchAccountInfo().then((res) => {
console.log(res)
let accountInfo = res.data;
this.setData({
accountInfo,
totalAmount: (parseFloat(accountInfo.amount) + parseFloat(accountInfo.freeze)).toFixed(2)
});
});
},
// 加载明细数据(模拟)
loadList() {
let { page, pageSize, list, tab } = this.data;
let params = {
tab: tab,
page: page,
accountType: 'amount',
pageSize: pageSize,
};
fetchAccountLogs(params).then((res) => {
console.log(res)
let newList = res.data.data;
let hasMore = res.data.current_page < res.data.last_page;
this.setData({
list: list.concat(newList),
page: page + 1,
loadMoreStatus: hasMore ? 0 : 2
});
});
},
// 提现弹窗
onWithdraw() {
this.setData({ showWithdrawDialog: true });
},
onWithdrawAmountInput(e) {
this.setData({ withdrawAmount: e.detail.value });
},
onWithdrawNameInput(e) {
this.setData({ withdrawName: e.detail.value });
},
onConfirmWithdraw() {
const { withdrawName, withdrawAmount } = this.data;
let params = {
'name': withdrawName,
'amount': withdrawAmount,
};
accountApplyWithdraw(params).then((res) => {
console.log(res)
if (res.code == 1) {
this.setData({
showWithdrawDialog: false,
withdrawAmount: '',
withdrawName: ''
});
wx.showModal({
title: '提示',
showCancel: false,
content: res.msg,
success: (re) => {
if (re.confirm) {
//提现之后,刷新数据
this.loadAccountInfo();
this.loadList();
console.log('用户点击确定');
}
}
});
} else {
wx.showToast({ title: res.msg, icon: 'none' });
}
});
},
onCancelWithdraw() {
this.setData({ showWithdrawDialog: false });
}
})
@@ -0,0 +1,10 @@
{
"usingComponents": {
"t-button": "tdesign-miniprogram/button/button",
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-input": "tdesign-miniprogram/input/input",
"t-empty": "tdesign-miniprogram/empty/empty",
"t-load-more": "/components/load-more/index",
"t-cell": "tdesign-miniprogram/cell/cell"
}
}
@@ -0,0 +1,60 @@
<!--pages/usercenter/balance/index.wxml-->
<t-navbar title="我的余额" />
<view class="balance-card">
<view class="balance-total">
<text class="total-amount">{{totalAmount}}</text>
<text class="total-label">总金额(元)</text>
</view>
<view class="balance-info">
<view class="balance-info-item">
<text class="label">可提现余额(元)</text>
<view class="value-wrap">
<text class="value">{{accountInfo.amount}}</text>
</view>
</view>
<view class="balance-info-item">
<text class="label">冻结中余额(元)</text>
<view class="value-wrap">
<text class="value">{{accountInfo.freeze}}</text>
</view>
</view>
</view>
<t-button block theme="primary" class="withdraw-btn" style="width:320rpx;margin:0 auto;" bindtap="onWithdraw">提现</t-button>
</view>
<view class="balance-detail">
<view class="detail-title">余额明细</view>
<view class="tab-bar">
<view class="tab-item {{tab==='all'?'active':''}}" bindtap="onTabChange" data-value="all">全部</view>
<view class="tab-item {{tab==='income'?'active':''}}" bindtap="onTabChange" data-value="income">收入</view>
<view class="tab-item {{tab==='expense'?'active':''}}" bindtap="onTabChange" data-value="expense">支出</view>
</view>
<view>
<block wx:for="{{list}}" wx:key="id">
<t-cell class="{{(index === list.length - 1) ? 'no-border' : ''}}">
<view slot="title">
<view class="item-title">{{item.log}}</view>
<view class="item-time">{{item.createtime}}</view>
</view>
<view slot="note">
<view class="item-amount {{item.inc_or_exp == 1 ? 'plus' : 'minus'}}">
{{item.inc_or_exp == 1 ? '+' : '-'}}{{item.amount}}
</view>
</view>
</t-cell>
</block>
<view class="empty-container" wx:if="{{list.length <= 0}}">
<t-empty icon="file" description="暂无记录" />
</view>
<t-load-more status="{{loadMoreStatus}}" />
</view>
</view>
<!-- 提现弹窗 -->
<t-dialog visible="{{showWithdrawDialog}}" title="提现" confirmBtn="确认" cancelBtn="取消" cancel-style="{{ cancelBtnStyle }}" bind:confirm="onConfirmWithdraw" bind:cancel="onCancelWithdraw" content="请填写该微信账号的真实姓名,用于安全校验">
<view class="dialog-content" slot="content">
<t-input label="真实姓名" placeholder="请输入姓名" value="{{withdrawName}}" bindchange="onWithdrawNameInput" />
<t-input label="提现金额" placeholder="请输入提现金额" type="number" value="{{withdrawAmount}}" bindchange="onWithdrawAmountInput" />
</view>
</t-dialog>
@@ -0,0 +1,178 @@
/* pages/usercenter/balance/index.wxss */
.t-button--default {
color: var(--brand) !important;
}
/* 余额主卡:品牌渐变视觉焦点 */
.balance-card {
margin: 24rpx;
padding: 48rpx 32rpx 40rpx;
background: var(--brand-gradient);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-brand);
text-align: center;
color: var(--text-inverse);
}
.balance-total .total-amount {
font-size: 64rpx;
font-weight: 700;
color: var(--text-inverse);
font-family: 'DIN Alternate', -apple-system, sans-serif;
line-height: 80rpx;
}
.balance-total .total-label {
display: block;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
margin-top: 8rpx;
}
.balance-info {
display: flex;
justify-content: space-between;
margin: 40rpx 0 8rpx 0;
}
.balance-info-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.balance-info-item .label {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.75);
}
.value-wrap {
display: flex;
align-items: center;
justify-content: center;
height: 48rpx;
margin-top: 8rpx;
}
.balance-info-item .value {
font-size: 32rpx;
color: var(--text-inverse);
font-weight: 600;
font-family: 'DIN Alternate', -apple-system, sans-serif;
}
/* 提现按钮:白底品牌橙字,与橙色渐变卡片形成清晰对比 */
.withdraw-btn {
margin-top: 24rpx;
--td-button-primary-bg-color: #ffffff;
--td-button-primary-color: var(--brand);
--td-button-primary-border-color: #ffffff;
--td-button-primary-active-bg-color: #fff5ef;
--td-button-primary-active-border-color: #fff5ef;
}
.withdraw-btn .t-button {
background-color: #ffffff;
border-color: #ffffff;
color: var(--brand);
font-weight: 600;
}
.withdraw-btn .t-button::after {
border-color: #ffffff;
}
.balance-detail {
margin: 24rpx;
background: var(--bg-card);
border-radius: var(--radius-lg);
padding: 0 0 24rpx 0;
box-shadow: var(--shadow-card);
overflow: hidden;
}
.item-title {
font-size: 28rpx;
color: var(--text-primary);
}
.item-time {
font-size: 22rpx;
color: var(--text-placeholder);
margin-top: 4rpx;
}
.item-amount {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
font-size: 32rpx;
font-weight: bold;
font-family: 'DIN Alternate', -apple-system, sans-serif;
}
.item-amount.plus {
color: var(--success);
}
.item-amount.minus {
color: var(--error);
}
/* tab bar 样式 */
.tab-bar {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
background: var(--bg-grey);
border-radius: var(--radius-md);
margin: 24rpx 24rpx 0 24rpx;
padding: 8rpx 0;
}
.tab-item {
flex: 1;
text-align: center;
font-size: 28rpx;
color: var(--text-tertiary);
padding: 16rpx 0;
border-radius: var(--radius-sm);
transition: background 0.2s;
}
.tab-item.active {
color: var(--brand);
background: var(--bg-card);
font-weight: 600;
box-shadow: 0 2rpx 8rpx rgba(255, 95, 21, 0.1);
}
/* t-dialog 取消按钮 */
.t-dialog__footer .t-button--outline {
color: var(--text-secondary) !important;
border-color: var(--border-level-2) !important;
background: var(--bg-card) !important;
}
/* t-cell分割线 */
t-cell,
.t-cell {
border-bottom: 1px solid var(--border-level-1);
}
.t-cell.no-border {
border-bottom: none !important;
}
.empty-container {
min-height: 50vh;
padding-top: 30%;
}
.safe-bottom {
min-height: 100rpx;
width: 100%;
}