| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- <template>
- <view class="invite-link-page">
- <view class="container">
- <view class="header">
- <view class="title">邀请好友</view>
- <view class="desc">通过微信分享邀请好友,直接打开小程序</view>
- </view>
- <view class="main-card">
- <!-- <view class="invite-info">
- <view class="info-row">
- <text class="label">邀请人ID</text>
- <text class="value">{{ userId }}</text>
- </view>
- <view class="info-row">
- <text class="label">邀请参数</text>
- <text class="value link-text">inviteUserId={{ userId }}</text>
- </view>
- </view> -->
- <view class="invite-info">
- <view class="info-row">
- <text class="label">邀请人ID</text>
- <text class="value">{{ userId }}</text>
- </view>
- <view class="info-row">
- <text class="label">邀请人</text>
- <text class="value">{{ userInfo.nickname }}</text>
- </view>
- </view>
- <view class="share-btn primary">
- <button open-type="share" class="share-button">
- <text class="share-icon"></text>
- <text>分享给微信好友</text>
- </button>
- </view>
- </view>
- <view class="tips-section">
- <view class="tip-title">邀请说明</view>
- <view class="tip-list">
- <view class="tip-item">
- <text class="tip-number">1</text>
- <text class="tip-text">点击分享按钮,选择要邀请的好友</text>
- </view>
- <view class="tip-item">
- <text class="tip-number">2</text>
- <text class="tip-text">好友点击分享卡片将直接打开小程序登录页</text>
- </view>
- <view class="tip-item">
- <text class="tip-number">3</text>
- <text class="tip-text">好友登录后自动绑定邀请关系</text>
- </view>
- </view>
- </view>
- <view class="note-section">
- <text class="note-title">温馨提示</text>
- <text class="note-content">微信小程序的可复制链接需要通过微信官方API生成,如需此功能请联系后端开发配置。当前推荐使用分享按钮邀请好友。</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "InviteFriend",
- data() {
- return {
- userId: '',
- invitePath: '',
- userInfo: JSON.parse(uni.getStorageSync('userInfo')) || {}
- };
- },
- mounted() {
- this.initData();
- },
- onShareAppMessage() {
- return {
- title: '邀请你加入健康商城',
- path: `/pages/home/index?inviteUserId=${this.userId}`,
- imageUrl: '/static/logo.jpg',
- success(res) {
- uni.showToast({
- title: '分享成功',
- icon: 'success'
- });
- },
- fail(err) {
- uni.showToast({
- title: '分享失败',
- icon: 'none'
- });
- }
- };
- },
- methods: {
- initData() {
- if (this.userInfo) {
- this.userId = this.userInfo.userId;
- } else {
- uni.showToast({
- title: '请先登录',
- icon: 'none'
- });
- return;
- }
- this.invitePath = `/pages/home/index?inviteUserId=${this.userInfo.userId}`;
- this.invitePath = `/pages/auth/login?inviteUserId=${this.userInfo.userId}`;
- },
- handleShare() {
- uni.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage']
- });
- // uni.showToast({
- // title: '请点击右上角分享',
- // icon: 'none',
- // duration: 2000
- // });
- }
- }
- };
- </script>
- <style lang="less">
- .invite-link-page {
- min-height: 100vh;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- }
- .container {
- padding: 60rpx 40rpx;
- }
- .header {
- text-align: center;
- margin-bottom: 60rpx;
- .title {
- font-size: 48rpx;
- font-weight: bold;
- color: #fff;
- margin-bottom: 20rpx;
- }
- .desc {
- font-size: 28rpx;
- color: rgba(255, 255, 255, 0.8);
- }
- }
- .main-card {
- background: #fff;
- border-radius: 24rpx;
- padding: 40rpx;
- box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
- .invite-info {
- margin-bottom: 30rpx;
- .info-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #f0f0f0;
- &:last-child {
- border-bottom: none;
- }
- .label {
- font-size: 28rpx;
- color: #999;
- }
- .value {
- font-size: 28rpx;
- color: #333;
- font-weight: 500;
- &.link-text {
- color: #4C49E9;
- word-break: break-all;
- }
- }
- }
- }
- .share-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 96rpx;
- border-radius: 48rpx;
- font-size: 32rpx;
- margin-bottom: 20rpx;
- .share-icon {
- font-family: iconfont;
- margin-right: 12rpx;
- font-size: 36rpx;
- }
- &.primary {
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- }
- &.secondary {
- background: #f5f5f5;
- color: #666;
- }
- }
- .share-button {
- width: 100%;
- height: 100%;
- background: transparent;
- border: none;
- padding: 0;
- margin: 0;
- font-size: inherit;
- color: inherit;
- line-height: inherit;
- display: flex;
- align-items: center;
- justify-content: center;
- &::after {
- display: none;
- }
- }
- }
- .tips-section {
- margin-top: 40rpx;
- background: rgba(255, 255, 255, 0.1);
- border-radius: 24rpx;
- padding: 30rpx;
- .tip-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #fff;
- margin-bottom: 24rpx;
- }
- .tip-list {
- .tip-item {
- display: flex;
- align-items: flex-start;
- margin-bottom: 20rpx;
- &:last-child {
- margin-bottom: 0;
- }
- .tip-number {
- width: 40rpx;
- height: 40rpx;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.2);
- color: #fff;
- font-size: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- flex-shrink: 0;
- }
- .tip-text {
- font-size: 26rpx;
- color: rgba(255, 255, 255, 0.9);
- line-height: 1.6;
- }
- }
- }
- }
- .note-section {
- margin-top: 30rpx;
- background: rgba(255, 255, 255, 0.08);
- border-radius: 16rpx;
- padding: 24rpx;
- .note-title {
- font-size: 26rpx;
- font-weight: bold;
- color: rgba(255, 255, 255, 0.9);
- display: block;
- margin-bottom: 12rpx;
- }
- .note-content {
- font-size: 24rpx;
- color: rgba(255, 255, 255, 0.7);
- line-height: 1.6;
- }
- }
- </style>on-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 24rpx;
- }
- }
- .rewards-list {
- .reward-item {
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- &:last-child {
- border-bottom: none;
- }
- .reward-icon {
- width: 48rpx;
- height: 48rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- font-size: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- }
- .reward-info {
- flex: 1;
- .reward-title {
- font-size: 28rpx;
- color: #333;
- margin-bottom: 6rpx;
- }
- .reward-desc {
- font-size: 24rpx;
- color: #999;
- }
- }
- .reward-value {
- font-size: 28rpx;
- font-weight: bold;
- color: #4C49E9;
- }
- }
- }
- .share-list {
- display: flex;
- justify-content: space-around;
- .share-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- .share-icon {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 16rpx;
- .iconfont {
- font-size: 48rpx;
- }
- }
- .wechat-icon {
- background: linear-gradient(135deg, #07c160 0%, #10b981 100%);
- color: #fff;
- }
- .moments-icon {
- background: linear-gradient(135deg, #e6d5b8 0%, #d4a373 100%);
- color: #fff;
- }
- .qq-icon {
- background: linear-gradient(135deg, #1677ff 0%, #096dd9 100%);
- color: #fff;
- }
- .link-icon {
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- }
- .share-name {
- font-size: 24rpx;
- color: #666;
- }
- }
- }
- .invited-section {
- .invited-count {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 30rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- .count-num {
- font-size: 56rpx;
- font-weight: bold;
- color: #4C49E9;
- }
- .count-desc {
- font-size: 26rpx;
- color: #999;
- margin-top: 8rpx;
- }
- }
- .invited-list {
- padding-top: 20rpx;
- .invited-item {
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- &:last-child {
- border-bottom: none;
- }
- .avatar {
- width: 72rpx;
- height: 72rpx;
- border-radius: 50%;
- overflow: hidden;
- margin-right: 20rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- flex: 1;
- .name {
- font-size: 28rpx;
- color: #333;
- margin-bottom: 6rpx;
- }
- .time {
- font-size: 24rpx;
- color: #999;
- }
- }
- .status {
- font-size: 22rpx;
- color: #999;
- padding: 6rpx 16rpx;
- border-radius: 20rpx;
- background: #f5f5f5;
- &.active {
- color: #4C49E9;
- background: rgba(76, 73, 233, 0.1);
- }
- }
- }
- }
- .empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 40rpx 0;
- .empty-icon {
- width: 120rpx;
- height: 120rpx;
- margin-bottom: 20rpx;
- }
- .empty-text {
- font-size: 28rpx;
- color: #999;
- margin-bottom: 24rpx;
- }
- .empty-btn {
- padding: 16rpx 48rpx;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- font-size: 28rpx;
- border-radius: 30rpx;
- }
- }
- }
- .bottom-btn {
- position: fixed;
- left: 30rpx;
- right: 30rpx;
- bottom: 30rpx;
- height: 96rpx;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- font-size: 32rpx;
- font-weight: bold;
- border-radius: 48rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.4);
- }
- </style>
|