Ai_GirlFriend/xuniYou/pages/mine/invite.vue

233 lines
6.4 KiB
Vue
Raw Normal View History

2026-01-31 19:15:41 +08:00
<template>
<view>
<view class="body">
2026-02-01 13:59:38 +08:00
<view class="invite-info">
<view class="invite-code-box">
<text class="label">我的邀请码</text>
<text class="code">{{ inviteCode }}</text>
<view class="copy-btn" @click="copyInviteCode">复制</view>
2026-01-31 19:15:41 +08:00
</view>
2026-02-01 13:59:38 +08:00
<view class="invite-stats">
<view class="stat-item">
<text class="stat-value">{{ inviteCount }}</text>
<text class="stat-label">邀请人数</text>
</view>
<view class="stat-item">
<text class="stat-value">{{ inviteReward }}</text>
<text class="stat-label">累计奖励</text>
</view>
</view>
</view>
<!-- 二维码显示 -->
<view class="qrcode-container">
<view class="qrcode-title">扫描二维码获取邀请码</view>
<image
class="qrcode-image"
:src="qrCodeUrl"
mode="aspectFit"
@longpress="saveQRCode">
</image>
<view class="qrcode-tip">长按保存二维码分享给好友</view>
</view>
<view class="invite-rule">
<text class="rule-title">邀请规则</text>
<text class="rule-item"> 分享邀请码或二维码给好友</text>
<text class="rule-item"> 好友扫码或输入邀请码注册</text>
<text class="rule-item"> 您获得10金币好友获得5金币</text>
<text class="rule-item"> 金币可用于购买会员音色等</text>
2026-01-31 19:15:41 +08:00
</view>
</view>
</view>
</template>
<script>
import { baseURLPy } from '@/utils/request.js'
2026-01-31 19:15:41 +08:00
export default {
data() {
return {
2026-02-01 13:59:38 +08:00
inviteCode: '',
inviteCount: 0,
inviteReward: 0,
qrCodeUrl: '',
baseURLPy: baseURLPy,
2026-01-31 19:15:41 +08:00
}
},
onLoad() {
2026-02-01 13:59:38 +08:00
this.getInviteInfo();
2026-01-31 19:15:41 +08:00
},
methods: {
2026-02-01 13:59:38 +08:00
getInviteInfo() {
uni.request({
url: this.baseURLPy + '/config/invite/info',
method: 'GET',
header: {
'token': uni.getStorageSync("token") || "",
},
success: (res) => {
if (res.data.code === 1) {
const data = res.data.data;
this.inviteCode = data.invite_code;
this.inviteCount = data.invite_count;
this.inviteReward = data.invite_reward_total;
// 生成二维码 URL
this.qrCodeUrl = `https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=${encodeURIComponent(this.inviteCode)}`;
}
2026-02-01 13:59:38 +08:00
},
fail: (err) => {
console.error('获取邀请信息失败:', err);
}
2026-01-31 19:15:41 +08:00
});
},
2026-02-01 13:59:38 +08:00
copyInviteCode() {
uni.setClipboardData({
data: this.inviteCode,
success: () => {
uni.showToast({
title: '邀请码已复制',
icon: 'success'
});
}
2026-01-31 19:15:41 +08:00
});
},
2026-02-01 13:59:38 +08:00
saveQRCode() {
uni.showModal({
title: '提示',
content: '长按二维码可保存到相册',
showCancel: false
2026-01-31 19:15:41 +08:00
});
}
}
}
</script>
<style>
page {
2026-02-01 13:59:38 +08:00
background: #F6F8FA;
2026-01-31 19:15:41 +08:00
}
2026-02-01 13:59:38 +08:00
2026-01-31 19:15:41 +08:00
.body {
position: relative;
2026-02-01 13:59:38 +08:00
padding: 20rpx;
2026-01-31 19:15:41 +08:00
}
2026-02-01 13:59:38 +08:00
/* 邀请信息卡片 */
.invite-info {
background: linear-gradient(135deg, #9F47FF 0%, #0053FA 100%);
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 30rpx;
}
.invite-code-box {
display: flex;
align-items: center;
justify-content: space-between;
background: rgba(255, 255, 255, 0.2);
border-radius: 12rpx;
padding: 20rpx 30rpx;
margin-bottom: 30rpx;
}
.invite-code-box .label {
color: #FFFFFF;
font-size: 28rpx;
}
.invite-code-box .code {
color: #FFFFFF;
font-size: 36rpx;
font-weight: bold;
letter-spacing: 4rpx;
}
.copy-btn {
background: #FFFFFF;
color: #9F47FF;
padding: 10rpx 30rpx;
border-radius: 30rpx;
font-size: 26rpx;
}
.invite-stats {
display: flex;
justify-content: space-around;
}
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
}
.stat-value {
color: #FFFFFF;
font-size: 40rpx;
font-weight: bold;
margin-bottom: 10rpx;
}
.stat-label {
color: rgba(255, 255, 255, 0.8);
font-size: 24rpx;
2026-01-31 19:15:41 +08:00
}
2026-02-01 13:59:38 +08:00
/* 二维码容器 */
.qrcode-container {
background: #FFFFFF;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 30rpx;
2026-01-31 19:15:41 +08:00
display: flex;
flex-direction: column;
align-items: center;
2026-02-01 13:59:38 +08:00
}
.qrcode-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
2026-01-31 19:15:41 +08:00
margin-bottom: 30rpx;
}
2026-02-01 13:59:38 +08:00
.qrcode-image {
width: 400rpx;
height: 400rpx;
border: 2rpx solid #E0E0E0;
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.qrcode-tip {
font-size: 24rpx;
color: #999;
2026-01-31 19:15:41 +08:00
}
2026-02-01 13:59:38 +08:00
/* 邀请规则 */
.invite-rule {
background: #FFFFFF;
border-radius: 20rpx;
padding: 30rpx;
}
.rule-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
display: block;
margin-bottom: 20rpx;
}
.rule-item {
font-size: 28rpx;
color: #666;
line-height: 50rpx;
display: block;
}
</style>