index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <template>
  2. <view class="today-recommend-page">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-navbar">
  5. <view class="navbar-left" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <view class="navbar-title">💕 今日推荐</view>
  9. <view class="navbar-right"></view>
  10. </view>
  11. <!-- 页面内容 -->
  12. <view class="page-content">
  13. <!-- 推荐用户卡片 -->
  14. <view class="recommend-list">
  15. <view class="recommend-card" v-for="(user, index) in recommendUsers" :key="index">
  16. <view class="card-header">
  17. <image class="user-avatar" :src="user.avatar" mode="aspectFill"></image>
  18. <view class="user-basic-info">
  19. <view class="user-name-row">
  20. <text class="user-name">{{ user.nickname }}</text>
  21. <view class="vip-badge" v-if="user.isVip">VIP</view>
  22. </view>
  23. <view class="user-details">
  24. <text class="user-detail">{{ user.age }}岁</text>
  25. <text class="user-detail">{{ user.height }}cm</text>
  26. <text class="user-detail">{{ user.location }}</text>
  27. </view>
  28. </view>
  29. <view class="online-status" :class="{ online: user.isOnline }">
  30. <text class="status-dot"></text>
  31. <text class="status-text">{{ user.isOnline ? '在线' : '离线' }}</text>
  32. </view>
  33. </view>
  34. <view class="card-content">
  35. <view class="user-info-grid">
  36. <view class="info-item">
  37. <text class="info-label">职业</text>
  38. <text class="info-value">{{ user.job }}</text>
  39. </view>
  40. <view class="info-item">
  41. <text class="info-label">学历</text>
  42. <text class="info-value">{{ user.education }}</text>
  43. </view>
  44. <view class="info-item">
  45. <text class="info-label">星座</text>
  46. <text class="info-value">{{ user.constellation }}</text>
  47. </view>
  48. <view class="info-item">
  49. <text class="info-label">月收入</text>
  50. <text class="info-value">{{ user.salary }}</text>
  51. </view>
  52. </view>
  53. <view class="user-tags">
  54. <text class="tag" v-for="(tag, tagIndex) in user.hobbies" :key="tagIndex">{{ tag }}</text>
  55. </view>
  56. <view class="personal-intro" v-if="user.introduction">
  57. <text class="intro-label">个人简介:</text>
  58. <text class="intro-text">{{ user.introduction }}</text>
  59. </view>
  60. </view>
  61. <view class="card-actions">
  62. <view class="action-btn pass-btn" @click="handlePass(user, index)">
  63. <text class="action-icon">👎</text>
  64. <text class="action-text">不感兴趣</text>
  65. </view>
  66. <view class="action-btn like-btn" @click="handleLike(user, index)">
  67. <text class="action-icon">❤️</text>
  68. <text class="action-text">喜欢</text>
  69. </view>
  70. <view class="action-btn chat-btn" @click="handleChat(user)">
  71. <text class="action-icon">💬</text>
  72. <text class="action-text">打招呼</text>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- 暂无推荐 -->
  78. <view class="no-recommend" v-if="recommendUsers.length === 0">
  79. <text class="no-recommend-icon">💭</text>
  80. <text class="no-recommend-title">今日暂无新推荐</text>
  81. <text class="no-recommend-tip">明天再来看看吧~</text>
  82. <view class="complete-profile-btn" @click="goToProfile">
  83. <text class="btn-text">完善资料获得更多推荐</text>
  84. </view>
  85. </view>
  86. <!-- 底部占位 -->
  87. <view class="bottom-placeholder"></view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import userAuth from '@/utils/userAuth.js'
  93. export default {
  94. data() {
  95. return {
  96. currentUserId: null,
  97. // 推荐用户数据
  98. recommendUsers: [
  99. {
  100. id: 2,
  101. nickname: '小红',
  102. age: 25,
  103. height: 165,
  104. location: '杭州市',
  105. job: '设计师',
  106. education: '本科',
  107. constellation: '水瓶座',
  108. salary: '10-20K',
  109. avatar: 'https://via.placeholder.com/200x200/FFB6C1/FFFFFF?text=小红',
  110. isVip: true,
  111. isOnline: true,
  112. hobbies: ['旅游', '美食', '电影', '摄影'],
  113. introduction: '热爱生活,喜欢旅游和美食。希望找到一个有趣的灵魂,一起探索世界的美好。'
  114. },
  115. {
  116. id: 3,
  117. nickname: '小李',
  118. age: 28,
  119. height: 175,
  120. location: '上海市',
  121. job: '软件工程师',
  122. education: '硕士',
  123. constellation: '天秤座',
  124. salary: '20-30K',
  125. avatar: 'https://via.placeholder.com/200x200/87CEEB/FFFFFF?text=小李',
  126. isVip: false,
  127. isOnline: false,
  128. hobbies: ['运动', '阅读', '音乐'],
  129. introduction: '喜欢安静,热爱阅读和音乐。希望找到一个能够理解我的人,一起度过美好的时光。'
  130. },
  131. {
  132. id: 4,
  133. nickname: '小王',
  134. age: 26,
  135. height: 170,
  136. location: '深圳市',
  137. job: '市场经理',
  138. education: '本科',
  139. constellation: '狮子座',
  140. salary: '15-25K',
  141. avatar: 'https://via.placeholder.com/200x200/DDA0DD/FFFFFF?text=小王',
  142. isVip: true,
  143. isOnline: true,
  144. hobbies: ['健身', '烘焙', '瑜伽', '旅游'],
  145. introduction: '积极向上的生活态度,喜欢健身和烘焙。希望找到一个同样热爱生活的伴侣。'
  146. }
  147. ]
  148. }
  149. },
  150. onLoad() {
  151. console.log('今日推荐页面加载')
  152. this.currentUserId = userAuth.getUserId()
  153. console.log('当前用户ID:', this.currentUserId)
  154. // 模拟加载推荐数据
  155. this.loadTodayRecommend()
  156. },
  157. methods: {
  158. // 加载今日推荐
  159. loadTodayRecommend() {
  160. uni.showLoading({
  161. title: '加载推荐中...'
  162. })
  163. // 模拟API调用延迟
  164. setTimeout(() => {
  165. uni.hideLoading()
  166. if (this.recommendUsers.length > 0) {
  167. uni.showToast({
  168. title: `为您推荐了${this.recommendUsers.length}位会员`,
  169. icon: 'success'
  170. })
  171. }
  172. }, 1000)
  173. },
  174. // 处理不感兴趣
  175. handlePass(user, index) {
  176. uni.showModal({
  177. title: '确认操作',
  178. content: `确定对${user.nickname}不感兴趣吗?`,
  179. success: (res) => {
  180. if (res.confirm) {
  181. console.log('不感兴趣:', user.nickname)
  182. uni.showToast({
  183. title: '已记录您的偏好',
  184. icon: 'success'
  185. })
  186. // 从列表中移除
  187. this.recommendUsers.splice(index, 1)
  188. }
  189. }
  190. })
  191. },
  192. // 处理喜欢
  193. handleLike(user, index) {
  194. console.log('喜欢:', user.nickname)
  195. // 动画效果
  196. uni.showToast({
  197. title: `已喜欢${user.nickname} ❤️`,
  198. icon: 'success'
  199. })
  200. // 从列表中移除
  201. setTimeout(() => {
  202. this.recommendUsers.splice(index, 1)
  203. // 检查是否匹配成功(模拟)
  204. const isMatch = Math.random() > 0.7 // 30%几率匹配成功
  205. if (isMatch) {
  206. setTimeout(() => {
  207. uni.showModal({
  208. title: '🎉 匹配成功!',
  209. content: `恭喜您与${user.nickname}互相喜欢,现在可以开始聊天了!`,
  210. showCancel: false,
  211. confirmText: '开始聊天',
  212. success: (modalRes) => {
  213. if (modalRes.confirm) {
  214. // TODO: 跳转到聊天页面
  215. uni.showToast({
  216. title: '聊天功能开发中',
  217. icon: 'none'
  218. })
  219. }
  220. }
  221. })
  222. }, 1000)
  223. }
  224. }, 800)
  225. },
  226. // 处理打招呼
  227. handleChat(user) {
  228. console.log('打招呼:', user.nickname)
  229. const greetings = [
  230. '你好,很高兴认识你!',
  231. 'Hi,看了你的资料很不错呢~',
  232. '你好,我们聊聊天吧!',
  233. 'Hello,可以交个朋友吗?'
  234. ]
  235. const randomGreeting = greetings[Math.floor(Math.random() * greetings.length)]
  236. uni.showModal({
  237. title: `向${user.nickname}打招呼`,
  238. content: `发送消息:"${randomGreeting}"`,
  239. showCancel: true,
  240. cancelText: '自定义',
  241. confirmText: '发送',
  242. success: (res) => {
  243. if (res.confirm) {
  244. uni.showToast({
  245. title: '招呼已发送!',
  246. icon: 'success'
  247. })
  248. // TODO: 调用发送消息API
  249. } else {
  250. // 自定义消息
  251. uni.navigateTo({
  252. url: `/pages/message/chat?userId=${user.id}&nickname=${user.nickname}`
  253. }).catch(() => {
  254. uni.showToast({
  255. title: '聊天功能开发中',
  256. icon: 'none'
  257. })
  258. })
  259. }
  260. }
  261. })
  262. },
  263. // 跳转到个人资料
  264. goToProfile() {
  265. uni.navigateTo({
  266. url: '/pages/profile/index'
  267. })
  268. },
  269. // 返回
  270. goBack() {
  271. uni.navigateBack({
  272. fail: () => {
  273. // 返回失败时跳转首页
  274. uni.navigateTo({
  275. url: '/pages/index/index'
  276. })
  277. }
  278. })
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. .today-recommend-page {
  285. min-height: 100vh;
  286. background: linear-gradient(180deg, #FFE5EE 0%, #FFF9F9 100%);
  287. padding-top: 90rpx;
  288. padding-bottom: 40rpx;
  289. }
  290. /* 自定义导航栏 */
  291. .custom-navbar {
  292. position: fixed;
  293. top: 0;
  294. left: 0;
  295. right: 0;
  296. height: 90rpx;
  297. display: flex;
  298. align-items: center;
  299. justify-content: space-between;
  300. padding: 0 20rpx;
  301. background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
  302. z-index: 999;
  303. .navbar-left,
  304. .navbar-right {
  305. width: 80rpx;
  306. }
  307. .back-icon {
  308. font-size: 40rpx;
  309. color: #FFFFFF;
  310. font-weight: bold;
  311. }
  312. .navbar-title {
  313. flex: 1;
  314. text-align: center;
  315. font-size: 32rpx;
  316. font-weight: bold;
  317. color: #FFFFFF;
  318. }
  319. }
  320. /* 页面内容 */
  321. .page-content {
  322. padding: 20rpx 30rpx;
  323. }
  324. /* 推荐列表 */
  325. .recommend-list {
  326. .recommend-card {
  327. background: #FFFFFF;
  328. border-radius: 25rpx;
  329. margin-bottom: 30rpx;
  330. overflow: hidden;
  331. box-shadow: 0 8rpx 25rpx rgba(255, 107, 157, 0.15);
  332. border: 2rpx solid rgba(255, 107, 157, 0.1);
  333. .card-header {
  334. padding: 30rpx;
  335. display: flex;
  336. align-items: center;
  337. position: relative;
  338. background: linear-gradient(135deg, #FFF9FC 0%, #FFFFFF 100%);
  339. .user-avatar {
  340. width: 120rpx;
  341. height: 120rpx;
  342. border-radius: 60rpx;
  343. margin-right: 25rpx;
  344. border: 4rpx solid #FFE5EE;
  345. box-shadow: 0 4rpx 12rpx rgba(255, 107, 157, 0.2);
  346. }
  347. .user-basic-info {
  348. flex: 1;
  349. .user-name-row {
  350. display: flex;
  351. align-items: center;
  352. margin-bottom: 15rpx;
  353. .user-name {
  354. font-size: 34rpx;
  355. font-weight: bold;
  356. color: #333333;
  357. margin-right: 15rpx;
  358. }
  359. .vip-badge {
  360. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  361. color: #FFFFFF;
  362. font-size: 20rpx;
  363. font-weight: bold;
  364. padding: 6rpx 15rpx;
  365. border-radius: 20rpx;
  366. box-shadow: 0 2rpx 8rpx rgba(255, 165, 0, 0.3);
  367. }
  368. }
  369. .user-details {
  370. display: flex;
  371. gap: 20rpx;
  372. .user-detail {
  373. font-size: 26rpx;
  374. color: #666666;
  375. background: rgba(255, 107, 157, 0.1);
  376. padding: 8rpx 16rpx;
  377. border-radius: 15rpx;
  378. }
  379. }
  380. }
  381. .online-status {
  382. position: absolute;
  383. top: 20rpx;
  384. right: 20rpx;
  385. display: flex;
  386. align-items: center;
  387. gap: 8rpx;
  388. .status-dot {
  389. width: 16rpx;
  390. height: 16rpx;
  391. border-radius: 50%;
  392. background: #CCCCCC;
  393. }
  394. .status-text {
  395. font-size: 22rpx;
  396. color: #999999;
  397. }
  398. &.online {
  399. .status-dot {
  400. background: #4CAF50;
  401. animation: blink 2s infinite;
  402. }
  403. .status-text {
  404. color: #4CAF50;
  405. }
  406. }
  407. }
  408. }
  409. .card-content {
  410. padding: 0 30rpx 20rpx;
  411. .user-info-grid {
  412. display: grid;
  413. grid-template-columns: 1fr 1fr;
  414. gap: 20rpx;
  415. margin-bottom: 25rpx;
  416. .info-item {
  417. background: #F8F9FA;
  418. padding: 20rpx;
  419. border-radius: 15rpx;
  420. .info-label {
  421. font-size: 22rpx;
  422. color: #999999;
  423. display: block;
  424. margin-bottom: 8rpx;
  425. }
  426. .info-value {
  427. font-size: 26rpx;
  428. color: #333333;
  429. font-weight: 500;
  430. }
  431. }
  432. }
  433. .user-tags {
  434. display: flex;
  435. flex-wrap: wrap;
  436. gap: 12rpx;
  437. margin-bottom: 25rpx;
  438. .tag {
  439. background: linear-gradient(135deg, #FFE5EE 0%, #FFD0DC 100%);
  440. color: #FF6B8A;
  441. font-size: 22rpx;
  442. padding: 10rpx 18rpx;
  443. border-radius: 20rpx;
  444. font-weight: 500;
  445. }
  446. }
  447. .personal-intro {
  448. background: rgba(255, 107, 157, 0.05);
  449. padding: 20rpx;
  450. border-radius: 15rpx;
  451. border-left: 4rpx solid #FF6B9D;
  452. .intro-label {
  453. font-size: 24rpx;
  454. color: #FF6B9D;
  455. font-weight: bold;
  456. display: block;
  457. margin-bottom: 10rpx;
  458. }
  459. .intro-text {
  460. font-size: 26rpx;
  461. color: #666666;
  462. line-height: 1.6;
  463. }
  464. }
  465. }
  466. .card-actions {
  467. display: flex;
  468. padding: 25rpx 30rpx 30rpx;
  469. gap: 15rpx;
  470. background: linear-gradient(135deg, #FAFAFA 0%, #F5F5F5 100%);
  471. .action-btn {
  472. flex: 1;
  473. display: flex;
  474. flex-direction: column;
  475. align-items: center;
  476. justify-content: center;
  477. padding: 25rpx 0;
  478. border-radius: 20rpx;
  479. font-weight: 500;
  480. transition: all 0.3s;
  481. .action-icon {
  482. font-size: 36rpx;
  483. margin-bottom: 8rpx;
  484. }
  485. .action-text {
  486. font-size: 24rpx;
  487. }
  488. &.pass-btn {
  489. background: #FFFFFF;
  490. color: #666666;
  491. border: 2rpx solid #E9ECEF;
  492. &:active {
  493. background: #F8F9FA;
  494. transform: scale(0.95);
  495. }
  496. }
  497. &.like-btn {
  498. background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
  499. color: #FFFFFF;
  500. box-shadow: 0 6rpx 20rpx rgba(255, 107, 157, 0.3);
  501. &:active {
  502. transform: scale(0.95);
  503. }
  504. }
  505. &.chat-btn {
  506. background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  507. color: #FFFFFF;
  508. box-shadow: 0 6rpx 20rpx rgba(76, 175, 80, 0.3);
  509. &:active {
  510. transform: scale(0.95);
  511. }
  512. }
  513. }
  514. }
  515. }
  516. }
  517. @keyframes blink {
  518. 0%, 100% { opacity: 1; }
  519. 50% { opacity: 0.5; }
  520. }
  521. /* 暂无推荐 */
  522. .no-recommend {
  523. text-align: center;
  524. padding: 100rpx 40rpx;
  525. .no-recommend-icon {
  526. font-size: 120rpx;
  527. display: block;
  528. margin-bottom: 30rpx;
  529. }
  530. .no-recommend-title {
  531. font-size: 36rpx;
  532. color: #333333;
  533. font-weight: bold;
  534. display: block;
  535. margin-bottom: 15rpx;
  536. }
  537. .no-recommend-tip {
  538. font-size: 28rpx;
  539. color: #666666;
  540. display: block;
  541. margin-bottom: 50rpx;
  542. }
  543. .complete-profile-btn {
  544. background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
  545. color: #FFFFFF;
  546. padding: 25rpx 45rpx;
  547. border-radius: 35rpx;
  548. box-shadow: 0 8rpx 20rpx rgba(255, 107, 157, 0.3);
  549. display: inline-block;
  550. .btn-text {
  551. font-size: 28rpx;
  552. font-weight: bold;
  553. }
  554. &:active {
  555. transform: scale(0.95);
  556. }
  557. }
  558. }
  559. .bottom-placeholder {
  560. height: 60rpx;
  561. }
  562. </style>