| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <template>
- <view class="container">
- <!-- 可提现余额 -->
- <view class="balance-card">
- <text class="balance-label">可提现金额</text>
- <text class="balance-value" v-if="availableAmount">{{ '¥' + availableAmount }}</text>
- <text class="balance-value" v-else>¥0.00</text>
- <text class="balance-sub">累计佣金 ¥{{ totalCommission || '0.00' }}</text>
- </view>
- <!-- 快捷金额 -->
- <view class="quick-amounts">
- <view class="quick-item" :class="amount === '100' ? 'quick-active' : ''" @click="amount = '100'">
- <text>¥100</text>
- </view>
- <view class="quick-item" :class="amount === '200' ? 'quick-active' : ''" @click="amount = '200'">
- <text>¥200</text>
- </view>
- <view class="quick-item" :class="amount === '500' ? 'quick-active' : ''" @click="amount = '500'">
- <text>¥500</text>
- </view>
- <view class="quick-item quick-all" @click="setAllAmount">
- <text>全部提现</text>
- </view>
- </view>
- <!-- 提现表单 -->
- <view class="form-card">
- <view class="form-item">
- <text class="form-label">提现金额</text>
- <view class="input-row">
- <input v-model="amount" type="digit" placeholder="输入提现金额" class="form-input" />
- <text class="unit">元</text>
- </view>
- </view>
- <view class="form-item">
- <text class="form-label">支付宝账号</text>
- <input v-model="accountInfo" type="text" placeholder="请输入支付宝账号" class="form-input" />
- </view>
- <view class="form-tip">最低提现金额:1元</view>
- <button class="submit-btn" @click="submitWithdraw">提交申请</button>
- </view>
- <!-- 提现历史 -->
- <view class="history-section" v-if="history.length > 0">
- <text class="section-title">提现记录</text>
- <view class="history-item" v-for="item in history" :key="item.id">
- <view class="history-left">
- <text class="history-amount">¥{{ item.amount }}</text>
- <text class="history-time">{{ formatTime(item.createdAt) }}</text>
- </view>
- <text :class="['history-status', statusClass(item.status)]">{{ statusText(item.status) }}</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getCommissionSummary, applyWithdrawal, getWithdrawalHistory } from '../../utils/api.js'
- export default {
- data() {
- return {
- availableAmount: '0.00',
- totalCommission: '0.00',
- amount: '',
- accountInfo: '',
- history: [],
- historyPage: 1
- }
- },
- onLoad() {
- this.loadBalance()
- this.loadHistory()
- },
- methods: {
- async loadBalance() {
- try {
- const res = await getCommissionSummary()
- if (res.data) {
- this.availableAmount = res.data.availableAmount || '0.00'
- this.totalCommission = res.data.totalCommission || '0.00'
- }
- } catch (e) {
- console.error('获取佣金总览失败', e)
- }
- },
- async loadHistory() {
- try {
- const res = await getWithdrawalHistory(this.historyPage)
- if (res.data && res.data.records) {
- this.history = res.data.records
- }
- } catch (e) {
- console.error('获取提现记录失败', e)
- }
- },
- setAllAmount() {
- this.amount = String(parseFloat(this.availableAmount))
- },
- submitWithdraw() {
- var amountNum = parseFloat(this.amount)
- if (!this.amount || isNaN(amountNum) || amountNum < 1) {
- uni.showToast({ title: '提现金额不能少于1元', icon: 'none' })
- return
- }
- if (amountNum > parseFloat(this.availableAmount)) {
- uni.showToast({ title: '提现金额超过可提现余额', icon: 'none' })
- return
- }
- if (!this.accountInfo) {
- uni.showToast({ title: '请输入支付宝账号', icon: 'none' })
- return
- }
- uni.showModal({
- title: '确认提现',
- content: '确认提现 ¥' + amountNum.toFixed(2) + ' 到 ' + this.accountInfo + ' ?',
- success: function(res) {
- if (res.confirm) {
- this.doWithdraw(amountNum)
- }
- }.bind(this)
- })
- },
- async doWithdraw(amountNum) {
- try {
- await applyWithdrawal(amountNum, this.accountInfo)
- uni.showToast({ title: '提现申请已提交', icon: 'success' })
- this.amount = ''
- this.accountInfo = ''
- this.loadBalance()
- this.loadHistory()
- } catch (e) {
- uni.showToast({ title: e.message || '提现失败', icon: 'none' })
- }
- },
- statusText(status) {
- var map = { pending: '待审核', approved: '已通过', rejected: '已拒绝' }
- return map[status] || status
- },
- statusClass(status) {
- if (status === 'approved') return 'text-success'
- if (status === 'rejected') return 'text-danger'
- return 'text-warning'
- },
- formatTime(time) {
- if (!time) return ''
- var t = new Date(time)
- return t.getFullYear() + '-' + String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0')
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 30rpx;
- min-height: 100vh;
- background: #FFF7ED;
- }
- .balance-card {
- background: linear-gradient(135deg, #F97316, #EA580C);
- border-radius: 20rpx;
- padding: 40rpx;
- text-align: center;
- color: #fff;
- margin-bottom: 24rpx;
- }
- .balance-label {
- font-size: 26rpx;
- opacity: 0.9;
- }
- .balance-value {
- font-size: 60rpx;
- font-weight: bold;
- margin-top: 12rpx;
- }
- .balance-sub {
- font-size: 22rpx;
- opacity: 0.7;
- margin-top: 8rpx;
- display: block;
- }
- /* ===== 快捷金额 ===== */
- .quick-amounts {
- display: flex;
- gap: 16rpx;
- margin-bottom: 24rpx;
- }
- .quick-item {
- flex: 1;
- height: 72rpx;
- line-height: 72rpx;
- text-align: center;
- background: #fff;
- border: 1rpx solid #FED7AA;
- border-radius: 12rpx;
- font-size: 26rpx;
- color: #F97316;
- font-weight: 500;
- }
- .quick-item:active {
- opacity: 0.8;
- }
- .quick-active {
- background: #F97316;
- border-color: #F97316;
- color: #fff;
- }
- .quick-all {
- color: #64748B;
- border-color: #CBD5E1;
- font-size: 22rpx;
- }
- .form-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 40rpx;
- margin-bottom: 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
- }
- .form-item {
- margin-bottom: 30rpx;
- }
- .form-label {
- font-size: 28rpx;
- color: #1E293B;
- display: block;
- margin-bottom: 16rpx;
- font-weight: 500;
- }
- .input-row {
- display: flex;
- align-items: center;
- border: 1rpx solid #CBD5E1;
- border-radius: 12rpx;
- padding: 20rpx;
- }
- .form-input {
- flex: 1;
- font-size: 28rpx;
- }
- .unit {
- font-size: 28rpx;
- color: #94A3B8;
- margin: 0 16rpx;
- }
- .form-tip {
- font-size: 22rpx;
- color: #94A3B8;
- margin-bottom: 24rpx;
- }
- .submit-btn {
- background: linear-gradient(135deg, #F97316, #EA580C);
- color: #fff;
- font-size: 30rpx;
- border-radius: 40rpx;
- height: 80rpx;
- line-height: 80rpx;
- font-weight: 600;
- border: none;
- }
- .submit-btn::after { border: none; }
- .submit-btn:active { opacity: 0.9; }
- .history-section {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
- }
- .section-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #1E293B;
- display: block;
- margin-bottom: 20rpx;
- }
- .history-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #FED7AA;
- }
- .history-item:last-child { border-bottom: none; }
- .history-left {
- flex: 1;
- }
- .history-amount {
- font-size: 28rpx;
- font-weight: bold;
- display: block;
- color: #1E293B;
- }
- .history-time {
- font-size: 22rpx;
- color: #94A3B8;
- margin-top: 4rpx;
- }
- .history-status {
- font-size: 24rpx;
- }
- .text-success { color: #10B981; }
- .text-warning { color: #D97706; }
- .text-danger { color: #EF4444; }
- </style>
|