| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638 |
- <template>
- <view class="today-recommend-page">
- <!-- 自定义导航栏 -->
- <view class="custom-navbar">
- <view class="navbar-left" @click="goBack">
- <text class="back-icon">←</text>
- </view>
- <view class="navbar-title">💕 今日推荐</view>
- <view class="navbar-right"></view>
- </view>
- <!-- 页面内容 -->
- <view class="page-content">
- <!-- 推荐用户卡片 -->
- <view class="recommend-list">
- <view class="recommend-card" v-for="(user, index) in recommendUsers" :key="index">
- <view class="card-header">
- <image class="user-avatar" :src="user.avatar" mode="aspectFill"></image>
- <view class="user-basic-info">
- <view class="user-name-row">
- <text class="user-name">{{ user.nickname }}</text>
- <view class="vip-badge" v-if="user.isVip">VIP</view>
- </view>
- <view class="user-details">
- <text class="user-detail">{{ user.age }}岁</text>
- <text class="user-detail">{{ user.height }}cm</text>
- <text class="user-detail">{{ user.location }}</text>
- </view>
- </view>
- <view class="online-status" :class="{ online: user.isOnline }">
- <text class="status-dot"></text>
- <text class="status-text">{{ user.isOnline ? '在线' : '离线' }}</text>
- </view>
- </view>
- <view class="card-content">
- <view class="user-info-grid">
- <view class="info-item">
- <text class="info-label">职业</text>
- <text class="info-value">{{ user.job }}</text>
- </view>
- <view class="info-item">
- <text class="info-label">学历</text>
- <text class="info-value">{{ user.education }}</text>
- </view>
- <view class="info-item">
- <text class="info-label">星座</text>
- <text class="info-value">{{ user.constellation }}</text>
- </view>
- <view class="info-item">
- <text class="info-label">月收入</text>
- <text class="info-value">{{ user.salary }}</text>
- </view>
- </view>
- <view class="user-tags">
- <text class="tag" v-for="(tag, tagIndex) in user.hobbies" :key="tagIndex">{{ tag }}</text>
- </view>
- <view class="personal-intro" v-if="user.introduction">
- <text class="intro-label">个人简介:</text>
- <text class="intro-text">{{ user.introduction }}</text>
- </view>
- </view>
- <view class="card-actions">
- <view class="action-btn pass-btn" @click="handlePass(user, index)">
- <text class="action-icon">👎</text>
- <text class="action-text">不感兴趣</text>
- </view>
- <view class="action-btn like-btn" @click="handleLike(user, index)">
- <text class="action-icon">❤️</text>
- <text class="action-text">喜欢</text>
- </view>
- <view class="action-btn chat-btn" @click="handleChat(user)">
- <text class="action-icon">💬</text>
- <text class="action-text">打招呼</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 暂无推荐 -->
- <view class="no-recommend" v-if="recommendUsers.length === 0">
- <text class="no-recommend-icon">💭</text>
- <text class="no-recommend-title">今日暂无新推荐</text>
- <text class="no-recommend-tip">明天再来看看吧~</text>
- <view class="complete-profile-btn" @click="goToProfile">
- <text class="btn-text">完善资料获得更多推荐</text>
- </view>
- </view>
- <!-- 底部占位 -->
- <view class="bottom-placeholder"></view>
- </view>
- </view>
- </template>
- <script>
- import userAuth from '@/utils/userAuth.js'
- export default {
- data() {
- return {
- currentUserId: null,
-
- // 推荐用户数据
- recommendUsers: [
- {
- id: 2,
- nickname: '小红',
- age: 25,
- height: 165,
- location: '杭州市',
- job: '设计师',
- education: '本科',
- constellation: '水瓶座',
- salary: '10-20K',
- avatar: 'https://via.placeholder.com/200x200/FFB6C1/FFFFFF?text=小红',
- isVip: true,
- isOnline: true,
- hobbies: ['旅游', '美食', '电影', '摄影'],
- introduction: '热爱生活,喜欢旅游和美食。希望找到一个有趣的灵魂,一起探索世界的美好。'
- },
- {
- id: 3,
- nickname: '小李',
- age: 28,
- height: 175,
- location: '上海市',
- job: '软件工程师',
- education: '硕士',
- constellation: '天秤座',
- salary: '20-30K',
- avatar: 'https://via.placeholder.com/200x200/87CEEB/FFFFFF?text=小李',
- isVip: false,
- isOnline: false,
- hobbies: ['运动', '阅读', '音乐'],
- introduction: '喜欢安静,热爱阅读和音乐。希望找到一个能够理解我的人,一起度过美好的时光。'
- },
- {
- id: 4,
- nickname: '小王',
- age: 26,
- height: 170,
- location: '深圳市',
- job: '市场经理',
- education: '本科',
- constellation: '狮子座',
- salary: '15-25K',
- avatar: 'https://via.placeholder.com/200x200/DDA0DD/FFFFFF?text=小王',
- isVip: true,
- isOnline: true,
- hobbies: ['健身', '烘焙', '瑜伽', '旅游'],
- introduction: '积极向上的生活态度,喜欢健身和烘焙。希望找到一个同样热爱生活的伴侣。'
- }
- ]
- }
- },
- onLoad() {
- console.log('今日推荐页面加载')
- this.currentUserId = userAuth.getUserId()
- console.log('当前用户ID:', this.currentUserId)
-
- // 模拟加载推荐数据
- this.loadTodayRecommend()
- },
- methods: {
- // 加载今日推荐
- loadTodayRecommend() {
- uni.showLoading({
- title: '加载推荐中...'
- })
-
- // 模拟API调用延迟
- setTimeout(() => {
- uni.hideLoading()
-
- if (this.recommendUsers.length > 0) {
- uni.showToast({
- title: `为您推荐了${this.recommendUsers.length}位会员`,
- icon: 'success'
- })
- }
- }, 1000)
- },
- // 处理不感兴趣
- handlePass(user, index) {
- uni.showModal({
- title: '确认操作',
- content: `确定对${user.nickname}不感兴趣吗?`,
- success: (res) => {
- if (res.confirm) {
- console.log('不感兴趣:', user.nickname)
- uni.showToast({
- title: '已记录您的偏好',
- icon: 'success'
- })
-
- // 从列表中移除
- this.recommendUsers.splice(index, 1)
- }
- }
- })
- },
- // 处理喜欢
- handleLike(user, index) {
- console.log('喜欢:', user.nickname)
-
- // 动画效果
- uni.showToast({
- title: `已喜欢${user.nickname} ❤️`,
- icon: 'success'
- })
-
- // 从列表中移除
- setTimeout(() => {
- this.recommendUsers.splice(index, 1)
-
- // 检查是否匹配成功(模拟)
- const isMatch = Math.random() > 0.7 // 30%几率匹配成功
- if (isMatch) {
- setTimeout(() => {
- uni.showModal({
- title: '🎉 匹配成功!',
- content: `恭喜您与${user.nickname}互相喜欢,现在可以开始聊天了!`,
- showCancel: false,
- confirmText: '开始聊天',
- success: (modalRes) => {
- if (modalRes.confirm) {
- // TODO: 跳转到聊天页面
- uni.showToast({
- title: '聊天功能开发中',
- icon: 'none'
- })
- }
- }
- })
- }, 1000)
- }
- }, 800)
- },
- // 处理打招呼
- handleChat(user) {
- console.log('打招呼:', user.nickname)
-
- const greetings = [
- '你好,很高兴认识你!',
- 'Hi,看了你的资料很不错呢~',
- '你好,我们聊聊天吧!',
- 'Hello,可以交个朋友吗?'
- ]
-
- const randomGreeting = greetings[Math.floor(Math.random() * greetings.length)]
-
- uni.showModal({
- title: `向${user.nickname}打招呼`,
- content: `发送消息:"${randomGreeting}"`,
- showCancel: true,
- cancelText: '自定义',
- confirmText: '发送',
- success: (res) => {
- if (res.confirm) {
- uni.showToast({
- title: '招呼已发送!',
- icon: 'success'
- })
- // TODO: 调用发送消息API
- } else {
- // 自定义消息
- uni.navigateTo({
- url: `/pages/message/chat?userId=${user.id}&nickname=${user.nickname}`
- }).catch(() => {
- uni.showToast({
- title: '聊天功能开发中',
- icon: 'none'
- })
- })
- }
- }
- })
- },
- // 跳转到个人资料
- goToProfile() {
- uni.navigateTo({
- url: '/pages/profile/index'
- })
- },
- // 返回
- goBack() {
- uni.navigateBack({
- fail: () => {
- // 返回失败时跳转首页
- uni.navigateTo({
- url: '/pages/index/index'
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .today-recommend-page {
- min-height: 100vh;
- background: linear-gradient(180deg, #FFE5EE 0%, #FFF9F9 100%);
- padding-top: 90rpx;
- padding-bottom: 40rpx;
- }
- /* 自定义导航栏 */
- .custom-navbar {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- height: 90rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 20rpx;
- background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
- z-index: 999;
- .navbar-left,
- .navbar-right {
- width: 80rpx;
- }
- .back-icon {
- font-size: 40rpx;
- color: #FFFFFF;
- font-weight: bold;
- }
- .navbar-title {
- flex: 1;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #FFFFFF;
- }
- }
- /* 页面内容 */
- .page-content {
- padding: 20rpx 30rpx;
- }
- /* 推荐列表 */
- .recommend-list {
- .recommend-card {
- background: #FFFFFF;
- border-radius: 25rpx;
- margin-bottom: 30rpx;
- overflow: hidden;
- box-shadow: 0 8rpx 25rpx rgba(255, 107, 157, 0.15);
- border: 2rpx solid rgba(255, 107, 157, 0.1);
- .card-header {
- padding: 30rpx;
- display: flex;
- align-items: center;
- position: relative;
- background: linear-gradient(135deg, #FFF9FC 0%, #FFFFFF 100%);
- .user-avatar {
- width: 120rpx;
- height: 120rpx;
- border-radius: 60rpx;
- margin-right: 25rpx;
- border: 4rpx solid #FFE5EE;
- box-shadow: 0 4rpx 12rpx rgba(255, 107, 157, 0.2);
- }
- .user-basic-info {
- flex: 1;
- .user-name-row {
- display: flex;
- align-items: center;
- margin-bottom: 15rpx;
- .user-name {
- font-size: 34rpx;
- font-weight: bold;
- color: #333333;
- margin-right: 15rpx;
- }
- .vip-badge {
- background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
- color: #FFFFFF;
- font-size: 20rpx;
- font-weight: bold;
- padding: 6rpx 15rpx;
- border-radius: 20rpx;
- box-shadow: 0 2rpx 8rpx rgba(255, 165, 0, 0.3);
- }
- }
- .user-details {
- display: flex;
- gap: 20rpx;
- .user-detail {
- font-size: 26rpx;
- color: #666666;
- background: rgba(255, 107, 157, 0.1);
- padding: 8rpx 16rpx;
- border-radius: 15rpx;
- }
- }
- }
- .online-status {
- position: absolute;
- top: 20rpx;
- right: 20rpx;
- display: flex;
- align-items: center;
- gap: 8rpx;
- .status-dot {
- width: 16rpx;
- height: 16rpx;
- border-radius: 50%;
- background: #CCCCCC;
- }
- .status-text {
- font-size: 22rpx;
- color: #999999;
- }
- &.online {
- .status-dot {
- background: #4CAF50;
- animation: blink 2s infinite;
- }
- .status-text {
- color: #4CAF50;
- }
- }
- }
- }
- .card-content {
- padding: 0 30rpx 20rpx;
- .user-info-grid {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 20rpx;
- margin-bottom: 25rpx;
- .info-item {
- background: #F8F9FA;
- padding: 20rpx;
- border-radius: 15rpx;
- .info-label {
- font-size: 22rpx;
- color: #999999;
- display: block;
- margin-bottom: 8rpx;
- }
- .info-value {
- font-size: 26rpx;
- color: #333333;
- font-weight: 500;
- }
- }
- }
- .user-tags {
- display: flex;
- flex-wrap: wrap;
- gap: 12rpx;
- margin-bottom: 25rpx;
- .tag {
- background: linear-gradient(135deg, #FFE5EE 0%, #FFD0DC 100%);
- color: #FF6B8A;
- font-size: 22rpx;
- padding: 10rpx 18rpx;
- border-radius: 20rpx;
- font-weight: 500;
- }
- }
- .personal-intro {
- background: rgba(255, 107, 157, 0.05);
- padding: 20rpx;
- border-radius: 15rpx;
- border-left: 4rpx solid #FF6B9D;
- .intro-label {
- font-size: 24rpx;
- color: #FF6B9D;
- font-weight: bold;
- display: block;
- margin-bottom: 10rpx;
- }
- .intro-text {
- font-size: 26rpx;
- color: #666666;
- line-height: 1.6;
- }
- }
- }
- .card-actions {
- display: flex;
- padding: 25rpx 30rpx 30rpx;
- gap: 15rpx;
- background: linear-gradient(135deg, #FAFAFA 0%, #F5F5F5 100%);
- .action-btn {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 25rpx 0;
- border-radius: 20rpx;
- font-weight: 500;
- transition: all 0.3s;
- .action-icon {
- font-size: 36rpx;
- margin-bottom: 8rpx;
- }
- .action-text {
- font-size: 24rpx;
- }
- &.pass-btn {
- background: #FFFFFF;
- color: #666666;
- border: 2rpx solid #E9ECEF;
- &:active {
- background: #F8F9FA;
- transform: scale(0.95);
- }
- }
- &.like-btn {
- background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
- color: #FFFFFF;
- box-shadow: 0 6rpx 20rpx rgba(255, 107, 157, 0.3);
- &:active {
- transform: scale(0.95);
- }
- }
- &.chat-btn {
- background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
- color: #FFFFFF;
- box-shadow: 0 6rpx 20rpx rgba(76, 175, 80, 0.3);
- &:active {
- transform: scale(0.95);
- }
- }
- }
- }
- }
- }
- @keyframes blink {
- 0%, 100% { opacity: 1; }
- 50% { opacity: 0.5; }
- }
- /* 暂无推荐 */
- .no-recommend {
- text-align: center;
- padding: 100rpx 40rpx;
- .no-recommend-icon {
- font-size: 120rpx;
- display: block;
- margin-bottom: 30rpx;
- }
- .no-recommend-title {
- font-size: 36rpx;
- color: #333333;
- font-weight: bold;
- display: block;
- margin-bottom: 15rpx;
- }
- .no-recommend-tip {
- font-size: 28rpx;
- color: #666666;
- display: block;
- margin-bottom: 50rpx;
- }
- .complete-profile-btn {
- background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
- color: #FFFFFF;
- padding: 25rpx 45rpx;
- border-radius: 35rpx;
- box-shadow: 0 8rpx 20rpx rgba(255, 107, 157, 0.3);
- display: inline-block;
- .btn-text {
- font-size: 28rpx;
- font-weight: bold;
- }
- &:active {
- transform: scale(0.95);
- }
- }
- }
- .bottom-placeholder {
- height: 60rpx;
- }
- </style>
|