| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <template>
- <view class="container">
- <!-- 邀请码区域 -->
- <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>
- </view>
- <button class="share-btn" @click="shareCard">📤 分享邀请卡</button>
- </view>
- <!-- 收益概览 -->
- <view class="earnings-card">
- <view class="earning-item">
- <text class="earning-label">累计收益</text>
- <text class="earning-value orange">¥{{ totalEarnings || '0.00' }}</text>
- </view>
- <view class="earning-divider"></view>
- <view class="earning-item">
- <text class="earning-label">可提现</text>
- <text class="earning-value blue">¥{{ availableAmount || '0.00' }}</text>
- </view>
- </view>
- <!-- 功能入口 -->
- <view class="menu-grid">
- <view class="menu-item" @click="goCommission">
- <text class="menu-icon">📋</text>
- <text class="menu-text">佣金明细</text>
- </view>
- <view class="menu-item" @click="goWithdraw">
- <text class="menu-icon">💰</text>
- <text class="menu-text">立即提现</text>
- </view>
- <view class="menu-item" @click="goInvite">
- <text class="menu-icon">👥</text>
- <text class="menu-text">邀请记录</text>
- </view>
- <view class="menu-item" @click="showTutorial">
- <text class="menu-icon">📖</text>
- <text class="menu-text">推广教程</text>
- </view>
- </view>
- <bottom-nav v-if="!isLoggedIn" current="promotion" />
- </view>
- </template>
- <script>
- import { getReferralCode, getReferralSummary } from '../../utils/api.js'
- export default {
- data() {
- return {
- referralCode: '',
- totalEarnings: '0.00',
- availableAmount: '0.00'
- }
- },
- 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 { getCommissionSummary } = require('../../utils/api.js')
- const comRes = await getCommissionSummary()
- if (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: () => {
- 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' })
- },
- showTutorial() {
- uni.showToast({ title: '即将上线', icon: 'none' })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 30rpx;
- min-height: 100vh;
- background: #f5f7fa;
- }
- .invite-card {
- background: linear-gradient(135deg, #5B9BD5, #3A7CC4);
- border-radius: 20rpx;
- padding: 40rpx;
- color: #fff;
- margin-bottom: 30rpx;
- }
- .code-section {
- margin-bottom: 30rpx;
- }
- .code-label {
- font-size: 26rpx;
- opacity: 0.9;
- }
- .code-value {
- display: flex;
- align-items: center;
- margin-top: 16rpx;
- }
- .code-text {
- font-size: 40rpx;
- font-weight: bold;
- letter-spacing: 4rpx;
- }
- .copy-icon {
- font-size: 32rpx;
- margin-left: 16rpx;
- }
- .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; }
- .earnings-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 40rpx;
- display: flex;
- align-items: center;
- margin-bottom: 30rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.05);
- }
- .earning-item {
- flex: 1;
- text-align: center;
- }
- .earning-label {
- font-size: 26rpx;
- color: #999;
- display: block;
- margin-bottom: 12rpx;
- }
- .earning-value {
- font-size: 44rpx;
- font-weight: bold;
- }
- .earning-value.orange { color: #F97316; }
- .earning-value.blue { color: #3A7CC4; }
- .earning-divider {
- width: 1rpx;
- height: 80rpx;
- background: #eee;
- }
- .menu-grid {
- display: flex;
- flex-wrap: wrap;
- background: #fff;
- border-radius: 20rpx;
- padding: 20rpx 0;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.05);
- }
- .menu-item {
- width: 50%;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 30rpx 0;
- box-sizing: border-box;
- }
- .menu-icon {
- font-size: 48rpx;
- margin-bottom: 12rpx;
- }
- .menu-text {
- font-size: 28rpx;
- color: #333;
- }
- </style>
|