index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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. },
  101. onLoad() {
  102. console.log('今日推荐页面加载')
  103. this.currentUserId = userAuth.getUserId()
  104. console.log('当前用户ID:', this.currentUserId)
  105. // 模拟加载推荐数据
  106. this.loadTodayRecommend()
  107. },
  108. methods: {
  109. // 加载今日推荐
  110. loadTodayRecommend() {
  111. uni.showLoading({
  112. title: '加载推荐中...'
  113. })
  114. // 模拟API调用延迟
  115. setTimeout(() => {
  116. uni.hideLoading()
  117. if (this.recommendUsers.length > 0) {
  118. uni.showToast({
  119. title: `为您推荐了${this.recommendUsers.length}位会员`,
  120. icon: 'success'
  121. })
  122. }
  123. }, 1000)
  124. },
  125. // 处理不感兴趣
  126. handlePass(user, index) {
  127. uni.showModal({
  128. title: '确认操作',
  129. content: `确定对${user.nickname}不感兴趣吗?`,
  130. success: (res) => {
  131. if (res.confirm) {
  132. console.log('不感兴趣:', user.nickname)
  133. uni.showToast({
  134. title: '已记录您的偏好',
  135. icon: 'success'
  136. })
  137. // 从列表中移除
  138. this.recommendUsers.splice(index, 1)
  139. }
  140. }
  141. })
  142. },
  143. // 处理喜欢
  144. handleLike(user, index) {
  145. console.log('喜欢:', user.nickname)
  146. // 动画效果
  147. uni.showToast({
  148. title: `已喜欢${user.nickname} ❤️`,
  149. icon: 'success'
  150. })
  151. // 从列表中移除
  152. setTimeout(() => {
  153. this.recommendUsers.splice(index, 1)
  154. // 检查是否匹配成功(模拟)
  155. const isMatch = Math.random() > 0.7 // 30%几率匹配成功
  156. if (isMatch) {
  157. setTimeout(() => {
  158. uni.showModal({
  159. title: '🎉 匹配成功!',
  160. content: `恭喜您与${user.nickname}互相喜欢,现在可以开始聊天了!`,
  161. showCancel: false,
  162. confirmText: '开始聊天',
  163. success: (modalRes) => {
  164. if (modalRes.confirm) {
  165. // TODO: 跳转到聊天页面
  166. uni.showToast({
  167. title: '聊天功能开发中',
  168. icon: 'none'
  169. })
  170. }
  171. }
  172. })
  173. }, 1000)
  174. }
  175. }, 800)
  176. },
  177. // 处理打招呼
  178. handleChat(user) {
  179. console.log('打招呼:', user.nickname)
  180. const greetings = [
  181. '你好,很高兴认识你!',
  182. 'Hi,看了你的资料很不错呢~',
  183. '你好,我们聊聊天吧!',
  184. 'Hello,可以交个朋友吗?'
  185. ]
  186. const randomGreeting = greetings[Math.floor(Math.random() * greetings.length)]
  187. uni.showModal({
  188. title: `向${user.nickname}打招呼`,
  189. content: `发送消息:"${randomGreeting}"`,
  190. showCancel: true,
  191. cancelText: '自定义',
  192. confirmText: '发送',
  193. success: (res) => {
  194. if (res.confirm) {
  195. uni.showToast({
  196. title: '招呼已发送!',
  197. icon: 'success'
  198. })
  199. // TODO: 调用发送消息API
  200. } else {
  201. // 自定义消息
  202. uni.navigateTo({
  203. url: `/pages/message/chat?userId=${user.id}&nickname=${user.nickname}`
  204. }).catch(() => {
  205. uni.showToast({
  206. title: '聊天功能开发中',
  207. icon: 'none'
  208. })
  209. })
  210. }
  211. }
  212. })
  213. },
  214. // 跳转到个人资料
  215. goToProfile() {
  216. uni.navigateTo({
  217. url: '/pages/profile/index'
  218. })
  219. },
  220. // 返回
  221. goBack() {
  222. uni.navigateBack({
  223. fail: () => {
  224. // 返回失败时跳转首页
  225. uni.navigateTo({
  226. url: '/pages/index/index'
  227. })
  228. }
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .today-recommend-page {
  236. min-height: 100vh;
  237. background: linear-gradient(180deg, #FFE5EE 0%, #FFF9F9 100%);
  238. padding-top: 90rpx;
  239. padding-bottom: 40rpx;
  240. }
  241. /* 自定义导航栏 */
  242. .custom-navbar {
  243. position: fixed;
  244. top: 0;
  245. left: 0;
  246. right: 0;
  247. height: 90rpx;
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. padding: 0 20rpx;
  252. background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
  253. z-index: 999;
  254. .navbar-left,
  255. .navbar-right {
  256. width: 80rpx;
  257. }
  258. .back-icon {
  259. font-size: 40rpx;
  260. color: #FFFFFF;
  261. font-weight: bold;
  262. }
  263. .navbar-title {
  264. flex: 1;
  265. text-align: center;
  266. font-size: 32rpx;
  267. font-weight: bold;
  268. color: #FFFFFF;
  269. }
  270. }
  271. /* 页面内容 */
  272. .page-content {
  273. padding: 20rpx 30rpx;
  274. }
  275. /* 推荐列表 */
  276. .recommend-list {
  277. .recommend-card {
  278. background: #FFFFFF;
  279. border-radius: 25rpx;
  280. margin-bottom: 30rpx;
  281. overflow: hidden;
  282. box-shadow: 0 8rpx 25rpx rgba(255, 107, 157, 0.15);
  283. border: 2rpx solid rgba(255, 107, 157, 0.1);
  284. .card-header {
  285. padding: 30rpx;
  286. display: flex;
  287. align-items: center;
  288. position: relative;
  289. background: linear-gradient(135deg, #FFF9FC 0%, #FFFFFF 100%);
  290. .user-avatar {
  291. width: 120rpx;
  292. height: 120rpx;
  293. border-radius: 60rpx;
  294. margin-right: 25rpx;
  295. border: 4rpx solid #FFE5EE;
  296. box-shadow: 0 4rpx 12rpx rgba(255, 107, 157, 0.2);
  297. }
  298. .user-basic-info {
  299. flex: 1;
  300. .user-name-row {
  301. display: flex;
  302. align-items: center;
  303. margin-bottom: 15rpx;
  304. .user-name {
  305. font-size: 34rpx;
  306. font-weight: bold;
  307. color: #333333;
  308. margin-right: 15rpx;
  309. }
  310. .vip-badge {
  311. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  312. color: #FFFFFF;
  313. font-size: 20rpx;
  314. font-weight: bold;
  315. padding: 6rpx 15rpx;
  316. border-radius: 20rpx;
  317. box-shadow: 0 2rpx 8rpx rgba(255, 165, 0, 0.3);
  318. }
  319. }
  320. .user-details {
  321. display: flex;
  322. gap: 20rpx;
  323. .user-detail {
  324. font-size: 26rpx;
  325. color: #666666;
  326. background: rgba(255, 107, 157, 0.1);
  327. padding: 8rpx 16rpx;
  328. border-radius: 15rpx;
  329. }
  330. }
  331. }
  332. .online-status {
  333. position: absolute;
  334. top: 20rpx;
  335. right: 20rpx;
  336. display: flex;
  337. align-items: center;
  338. gap: 8rpx;
  339. .status-dot {
  340. width: 16rpx;
  341. height: 16rpx;
  342. border-radius: 50%;
  343. background: #CCCCCC;
  344. }
  345. .status-text {
  346. font-size: 22rpx;
  347. color: #999999;
  348. }
  349. &.online {
  350. .status-dot {
  351. background: #4CAF50;
  352. animation: blink 2s infinite;
  353. }
  354. .status-text {
  355. color: #4CAF50;
  356. }
  357. }
  358. }
  359. }
  360. .card-content {
  361. padding: 0 30rpx 20rpx;
  362. .user-info-grid {
  363. display: grid;
  364. grid-template-columns: 1fr 1fr;
  365. gap: 20rpx;
  366. margin-bottom: 25rpx;
  367. .info-item {
  368. background: #F8F9FA;
  369. padding: 20rpx;
  370. border-radius: 15rpx;
  371. .info-label {
  372. font-size: 22rpx;
  373. color: #999999;
  374. display: block;
  375. margin-bottom: 8rpx;
  376. }
  377. .info-value {
  378. font-size: 26rpx;
  379. color: #333333;
  380. font-weight: 500;
  381. }
  382. }
  383. }
  384. .user-tags {
  385. display: flex;
  386. flex-wrap: wrap;
  387. gap: 12rpx;
  388. margin-bottom: 25rpx;
  389. .tag {
  390. background: linear-gradient(135deg, #FFE5EE 0%, #FFD0DC 100%);
  391. color: #FF6B8A;
  392. font-size: 22rpx;
  393. padding: 10rpx 18rpx;
  394. border-radius: 20rpx;
  395. font-weight: 500;
  396. }
  397. }
  398. .personal-intro {
  399. background: rgba(255, 107, 157, 0.05);
  400. padding: 20rpx;
  401. border-radius: 15rpx;
  402. border-left: 4rpx solid #FF6B9D;
  403. .intro-label {
  404. font-size: 24rpx;
  405. color: #FF6B9D;
  406. font-weight: bold;
  407. display: block;
  408. margin-bottom: 10rpx;
  409. }
  410. .intro-text {
  411. font-size: 26rpx;
  412. color: #666666;
  413. line-height: 1.6;
  414. }
  415. }
  416. }
  417. .card-actions {
  418. display: flex;
  419. padding: 25rpx 30rpx 30rpx;
  420. gap: 15rpx;
  421. background: linear-gradient(135deg, #FAFAFA 0%, #F5F5F5 100%);
  422. .action-btn {
  423. flex: 1;
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. justify-content: center;
  428. padding: 25rpx 0;
  429. border-radius: 20rpx;
  430. font-weight: 500;
  431. transition: all 0.3s;
  432. .action-icon {
  433. font-size: 36rpx;
  434. margin-bottom: 8rpx;
  435. }
  436. .action-text {
  437. font-size: 24rpx;
  438. }
  439. &.pass-btn {
  440. background: #FFFFFF;
  441. color: #666666;
  442. border: 2rpx solid #E9ECEF;
  443. &:active {
  444. background: #F8F9FA;
  445. transform: scale(0.95);
  446. }
  447. }
  448. &.like-btn {
  449. background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
  450. color: #FFFFFF;
  451. box-shadow: 0 6rpx 20rpx rgba(255, 107, 157, 0.3);
  452. &:active {
  453. transform: scale(0.95);
  454. }
  455. }
  456. &.chat-btn {
  457. background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  458. color: #FFFFFF;
  459. box-shadow: 0 6rpx 20rpx rgba(76, 175, 80, 0.3);
  460. &:active {
  461. transform: scale(0.95);
  462. }
  463. }
  464. }
  465. }
  466. }
  467. }
  468. @keyframes blink {
  469. 0%, 100% { opacity: 1; }
  470. 50% { opacity: 0.5; }
  471. }
  472. /* 暂无推荐 */
  473. .no-recommend {
  474. text-align: center;
  475. padding: 100rpx 40rpx;
  476. .no-recommend-icon {
  477. font-size: 120rpx;
  478. display: block;
  479. margin-bottom: 30rpx;
  480. }
  481. .no-recommend-title {
  482. font-size: 36rpx;
  483. color: #333333;
  484. font-weight: bold;
  485. display: block;
  486. margin-bottom: 15rpx;
  487. }
  488. .no-recommend-tip {
  489. font-size: 28rpx;
  490. color: #666666;
  491. display: block;
  492. margin-bottom: 50rpx;
  493. }
  494. .complete-profile-btn {
  495. background: linear-gradient(135deg, #FF6B9D 0%, #FF8FAB 100%);
  496. color: #FFFFFF;
  497. padding: 25rpx 45rpx;
  498. border-radius: 35rpx;
  499. box-shadow: 0 8rpx 20rpx rgba(255, 107, 157, 0.3);
  500. display: inline-block;
  501. .btn-text {
  502. font-size: 28rpx;
  503. font-weight: bold;
  504. }
  505. &:active {
  506. transform: scale(0.95);
  507. }
  508. }
  509. }
  510. .bottom-placeholder {
  511. height: 60rpx;
  512. }
  513. </style>