| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <scroll-view class="container" scroll-y>
- <!-- 邀请码区域 -->
- <view class="invite-card">
- <view class="code-section">
- <text class="code-label">我的邀请码</text>
- <view class="code-value" @click="copyCode">
- <text class="code-text">{{ referralCode || '加载中...' }}</text>
- <text class="copy-icon">⎘</text>
- </view>
- <text class="code-hint">点击复制邀请码,分享给好友</text>
- </view>
- <button class="share-btn" @click="shareCard">分享邀请卡</button>
- </view>
- <!-- 收益概览 -->
- <view class="earnings-card">
- <view class="earnings-header">
- <text class="earnings-title">收益总览</text>
- </view>
- <view class="earnings-body">
- <view class="earning-item">
- <text class="earning-label">累计佣金</text>
- <text class="earning-value orange" v-if="summary">{{ formatPriceWithSymbol(summary.totalCommission) }}</text>
- <text class="earning-value orange" v-else>{{ formatPriceWithSymbol(0) }}</text>
- </view>
- <view class="earning-divider"></view>
- <view class="earning-item">
- <text class="earning-label">可提现</text>
- <text class="earning-value blue" v-if="summary">{{ formatPriceWithSymbol(summary.availableAmount) }}</text>
- <text class="earning-value blue" v-else>{{ formatPriceWithSymbol(0) }}</text>
- </view>
- <view class="earning-divider"></view>
- <view class="earning-item">
- <text class="earning-label">待结算</text>
- <text class="earning-value green" v-if="summary">{{ formatPriceWithSymbol(summary.pendingAmount) }}</text>
- <text class="earning-value green" v-else>{{ formatPriceWithSymbol(0) }}</text>
- </view>
- </view>
- </view>
- <!-- 功能入口 -->
- <view class="menu-grid">
- <view class="menu-item" @click="goCommission">
- <view class="menu-icon-wrap icon-commission">
- <text class="menu-icon-text">📋</text>
- </view>
- <text class="menu-text">佣金明细</text>
- </view>
- <view class="menu-item" @click="goWithdraw">
- <view class="menu-icon-wrap icon-withdraw">
- <text class="menu-icon-text">💰</text>
- </view>
- <text class="menu-text">立即提现</text>
- </view>
- <view class="menu-item" @click="goInvite">
- <view class="menu-icon-wrap icon-invite">
- <text class="menu-icon-text">👥</text>
- </view>
- <text class="menu-text">邀请好友</text>
- </view>
- <view class="menu-item" @click="goTeam">
- <view class="menu-icon-wrap icon-team">
- <text class="menu-icon-text">🤝</text>
- </view>
- <text class="menu-text">推广团队</text>
- </view>
- </view>
- </scroll-view>
- </template>
- <script>
- import { getReferralCode, getReferralSummary, getCommissionSummary } from '../../utils/api.js'
- export default {
- data() {
- return {
- referralCode: '',
- totalEarnings: '0.00',
- availableAmount: '0.00',
- summary: null
- }
- },
- computed: {
- isLoggedIn() {
- return !!uni.getStorageSync('token')
- }
- },
- onLoad() {
- this.loadData()
- },
- methods: {
- async loadData() {
- try {
- const codeRes = await getReferralCode()
- if (codeRes.data) {
- this.referralCode = codeRes.data.referralCode || codeRes.data.code || ''
- }
- } catch (e) {
- console.error('获取邀请码失败', e)
- }
- try {
- const summaryRes = await getReferralSummary()
- if (summaryRes.data) {
- this.totalEarnings = summaryRes.data.totalEarnings || '0.00'
- }
- } catch (e) {
- console.error('获取邀请统计失败', e)
- }
- try {
- const comRes = await getCommissionSummary()
- if (comRes.data) {
- this.summary = comRes.data
- this.availableAmount = comRes.data.availableAmount || '0.00'
- }
- } catch (e) {
- console.error('获取佣金总览失败', e)
- }
- },
- copyCode() {
- if (!this.referralCode) return
- uni.setClipboardData({
- data: this.referralCode,
- success: function() {
- uni.showToast({ title: '邀请码已复制', icon: 'success' })
- }
- })
- },
- shareCard() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- },
- goCommission() {
- uni.navigateTo({ url: '/pages/promotion/commission' })
- },
- goWithdraw() {
- uni.navigateTo({ url: '/pages/promotion/withdraw' })
- },
- goInvite() {
- uni.navigateTo({ url: '/pages/promotion/invite' })
- },
- goTeam() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 30rpx;
- min-height: 100vh;
- background: #FFF7ED;
- }
- .invite-card {
- background: linear-gradient(135deg, #F97316, #EA580C);
- border-radius: 20rpx;
- padding: 40rpx;
- color: #fff;
- margin-bottom: 30rpx;
- }
- .code-section {
- margin-bottom: 30rpx;
- }
- .code-label {
- font-size: 24rpx;
- opacity: 0.85;
- }
- .code-value {
- display: flex;
- align-items: center;
- margin-top: 12rpx;
- }
- .code-text {
- font-size: 44rpx;
- font-weight: bold;
- letter-spacing: 6rpx;
- }
- .copy-icon {
- font-size: 36rpx;
- margin-left: 16rpx;
- opacity: 0.9;
- }
- .code-hint {
- font-size: 22rpx;
- opacity: 0.7;
- margin-top: 8rpx;
- display: block;
- }
- .share-btn {
- background: rgba(255,255,255,0.2);
- color: #fff;
- font-size: 28rpx;
- border-radius: 40rpx;
- height: 72rpx;
- line-height: 72rpx;
- border: 1rpx solid rgba(255,255,255,0.3);
- }
- .share-btn::after { border: none; }
- .share-btn:active { opacity: 0.8; }
- /* ===== 收益总览 ===== */
- .earnings-card {
- background: #fff;
- border-radius: 20rpx;
- margin-bottom: 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
- overflow: hidden;
- }
- .earnings-header {
- padding: 24rpx 32rpx 0;
- }
- .earnings-title {
- font-size: 28rpx;
- font-weight: 600;
- color: #1E293B;
- }
- .earnings-body {
- display: flex;
- align-items: center;
- padding: 24rpx 32rpx 32rpx;
- }
- .earning-item {
- flex: 1;
- text-align: center;
- }
- .earning-label {
- font-size: 22rpx;
- color: #94A3B8;
- display: block;
- margin-bottom: 8rpx;
- }
- .earning-value {
- font-size: 36rpx;
- font-weight: bold;
- }
- .earning-value.orange { color: #F97316; }
- .earning-value.blue { color: #0EA5E9; }
- .earning-value.green { color: #10B981; }
- .earning-divider {
- width: 1rpx;
- height: 64rpx;
- background: #FED7AA;
- }
- /* ===== 功能入口 ===== */
- .menu-grid {
- display: flex;
- flex-wrap: wrap;
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx 0;
- box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
- }
- .menu-item {
- width: 50%;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 24rpx 0;
- box-sizing: border-box;
- }
- .menu-icon-wrap {
- width: 80rpx;
- height: 80rpx;
- border-radius: 40rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 12rpx;
- }
- .icon-commission { background: #FEF3C7; }
- .icon-withdraw { background: #DBEAFE; }
- .icon-invite { background: #D1FAE5; }
- .icon-team { background: #FCE7F3; }
- .menu-icon-text {
- font-size: 36rpx;
- }
- .menu-text {
- font-size: 26rpx;
- color: #1E293B;
- font-weight: 500;
- }
- </style>
|