index.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663
  1. <template>
  2. <view class="recommend-page">
  3. <view class="toolbar">
  4. <button size="mini" class="tool-btn refresh-btn" @click="changeBatch"><text class="icon">⟳</text><text>换一批</text></button>
  5. <button size="mini" class="tool-btn filter-btn" @click="openFilter"><text class="icon">🔍</text><text>筛选</text></button>
  6. </view>
  7. <!-- 推荐/匹配选项卡 -->
  8. <view class="tab-container">
  9. <view :class="['tab-item', currentTab === 'recommend' ? 'active' : '']" @click="switchToTab('recommend')">
  10. <text class="tab-icon">💕</text>
  11. <text class="tab-text">推荐</text>
  12. </view>
  13. <view :class="['tab-item', currentTab === 'match' ? 'active' : '']" @click="switchToTab('match')">
  14. <text class="tab-icon">⚡</text>
  15. <text class="tab-text">匹配</text>
  16. </view>
  17. </view>
  18. <uni-popup ref="filterPopup" type="bottom" :mask-click="true">
  19. <view class="filter-sheet">
  20. <view class="sheet-handle"></view>
  21. <view class="sheet-title">精确筛选</view>
  22. <view class="sheet-body">
  23. <view class="field two">
  24. <text class="field-label">年龄</text>
  25. <input class="ipt" type="number" v-model.number="query.ageMin" placeholder="最小" />
  26. <text class="dash">-</text>
  27. <input class="ipt" type="number" v-model.number="query.ageMax" placeholder="最大" />
  28. </view>
  29. <view class="field two">
  30. <text class="field-label">身高(cm)</text>
  31. <input class="ipt" type="number" v-model.number="query.heightMin" placeholder="最小" />
  32. <text class="dash">-</text>
  33. <input class="ipt" type="number" v-model.number="query.heightMax" placeholder="最大" />
  34. </view>
  35. <view class="field">
  36. <text class="field-label">地区</text>
  37. <picker
  38. mode="multiSelector"
  39. :range="multiAreaData"
  40. range-key="name"
  41. :value="multiAreaIndex"
  42. @change="onMultiAreaChange"
  43. @columnchange="onMultiAreaColumnChange">
  44. <view class="ipt full picker">{{ areaDisplayText || '选择省市区' }}</view>
  45. </picker>
  46. </view>
  47. <view class="field two">
  48. <text class="field-label">学历/收入</text>
  49. <picker mode="selector" :range="educationOptions" range-key="label" @change="onEduChange">
  50. <view class="ipt picker">{{ currentEduText || '不限学历' }}</view>
  51. </picker>
  52. <picker mode="selector" :range="salaryOptions" range-key="label" @change="onSalaryChange">
  53. <view class="ipt picker">{{ currentSalaryText || '不限收入' }}</view>
  54. </picker>
  55. </view>
  56. <view class="field two">
  57. <text class="field-label">星座/生肖</text>
  58. <picker mode="selector" :range="starOptions" range-key="label" @change="onStarChange">
  59. <view class="ipt picker">{{ currentStarText || '不限星座' }}</view>
  60. </picker>
  61. <picker mode="selector" :range="animalOptions" range-key="label" @change="onAnimalChange">
  62. <view class="ipt picker">{{ currentAnimalText || '不限生肖' }}</view>
  63. </picker>
  64. </view>
  65. <view class="field">
  66. <text class="field-label">兴趣</text>
  67. <input class="ipt full" v-model="hobbyInput" placeholder="用逗号分隔,如:旅行,音乐" />
  68. </view>
  69. </view>
  70. <view class="sheet-actions">
  71. <button class="btn ghost" @click="resetFilter">重置</button>
  72. <button class="btn primary" @click="applyFilter">确定</button>
  73. </view>
  74. </view>
  75. </uni-popup>
  76. <!-- 用户详情弹窗 -->
  77. <uni-popup ref="userDetailPopup" type="center" :isMaskClick="true">
  78. <view class="user-detail-popup">
  79. <view class="popup-header">
  80. <text class="popup-title">用户详情</text>
  81. <text class="popup-close" @click="closeUserDetail">✕</text>
  82. </view>
  83. <scroll-view scroll-y class="popup-content" v-if="userDetail">
  84. <!-- 用户照片 -->
  85. <view class="detail-section photos-section" v-if="userDetail.photos && Array.isArray(userDetail.photos) && userDetail.photos.length > 0">
  86. <view class="section-title">📷 照片</view>
  87. <view class="photos-grid">
  88. <image
  89. v-for="(photo, pIdx) in userDetail.photos"
  90. :key="pIdx"
  91. :src="photo || 'http://115.190.125.125:9001/static-images/close.png'"
  92. class="photo-item"
  93. mode="aspectFill"
  94. @click="previewPhoto(pIdx)"
  95. @error="onPhotoError"
  96. />
  97. </view>
  98. </view>
  99. <!-- 基本信息 -->
  100. <view class="detail-section">
  101. <view class="section-title">基本信息</view>
  102. <view class="detail-info-grid">
  103. <view class="info-item" v-if="userDetail.nickname">
  104. <text class="info-label">昵称</text>
  105. <text class="info-value">{{ userDetail.nickname }}</text>
  106. </view>
  107. <view class="info-item" v-if="userDetail.genderText">
  108. <text class="info-label">性别</text>
  109. <text class="info-value">{{ userDetail.genderText }}</text>
  110. </view>
  111. <view class="info-item" v-if="userDetail.age">
  112. <text class="info-label">年龄</text>
  113. <text class="info-value">{{ userDetail.age }}岁</text>
  114. </view>
  115. <view class="info-item" v-if="userDetail.height">
  116. <text class="info-label">身高</text>
  117. <text class="info-value">{{ userDetail.height }}cm</text>
  118. </view>
  119. <view class="info-item" v-if="userDetail.weight">
  120. <text class="info-label">体重</text>
  121. <text class="info-value">{{ userDetail.weight }}kg</text>
  122. </view>
  123. <view class="info-item" v-if="userDetail.educationText">
  124. <text class="info-label">学历</text>
  125. <text class="info-value">{{ userDetail.educationText }}</text>
  126. </view>
  127. <view class="info-item" v-if="userDetail.salaryText">
  128. <text class="info-label">收入</text>
  129. <text class="info-value">{{ userDetail.salaryText }}</text>
  130. </view>
  131. <view class="info-item" v-if="userDetail.star">
  132. <text class="info-label">星座</text>
  133. <text class="info-value">{{ userDetail.star }}</text>
  134. </view>
  135. <view class="info-item" v-if="userDetail.animal">
  136. <text class="info-label">生肖</text>
  137. <text class="info-value">{{ userDetail.animal }}</text>
  138. </view>
  139. <view class="info-item" v-if="userDetail.jobTitle">
  140. <text class="info-label">职业</text>
  141. <text class="info-value">{{ userDetail.jobTitle }}</text>
  142. </view>
  143. <view class="info-item" v-if="userDetail.schoolName">
  144. <text class="info-label">毕业院校</text>
  145. <text class="info-value">{{ userDetail.schoolName }}</text>
  146. </view>
  147. <view class="info-item" v-if="userDetail.company">
  148. <text class="info-label">工作单位</text>
  149. <text class="info-value">{{ userDetail.company }}</text>
  150. </view>
  151. <view class="info-item" v-if="userDetail.maritalText">
  152. <text class="info-label">婚姻状况</text>
  153. <text class="info-value">{{ userDetail.maritalText }}</text>
  154. </view>
  155. <view class="info-item" v-if="userDetail.houseText">
  156. <text class="info-label">房产</text>
  157. <text class="info-value">{{ userDetail.houseText }}</text>
  158. </view>
  159. <view class="info-item" v-if="userDetail.carText">
  160. <text class="info-label">车产</text>
  161. <text class="info-value">{{ userDetail.carText }}</text>
  162. </view>
  163. </view>
  164. </view>
  165. <!-- 兴趣爱好 -->
  166. <view class="detail-section" v-if="userDetail.hobby">
  167. <view class="section-title">兴趣爱好</view>
  168. <view class="hobby-tags">
  169. <text
  170. v-for="(h, hIdx) in parseHobby(userDetail.hobby)"
  171. :key="hIdx"
  172. class="hobby-tag"
  173. >{{ h }}</text>
  174. </view>
  175. </view>
  176. <!-- 自我简介 -->
  177. <view class="detail-section" v-if="userDetail.introduction">
  178. <view class="section-title">自我简介</view>
  179. <view class="introduction-content">
  180. <text>{{ userDetail.introduction }}</text>
  181. </view>
  182. </view>
  183. </scroll-view>
  184. <view class="popup-loading" v-else>
  185. <text>加载中...</text>
  186. </view>
  187. </view>
  188. </uni-popup>
  189. <scroll-view scroll-y class="list">
  190. <view v-if="loading" class="skeleton">加载中...</view>
  191. <view v-else>
  192. <view v-for="(u, idx) in filteredList" :key="u.userId || idx" class="card">
  193. <image :src="u.avatarUrl || 'http://115.190.125.125:9001/static-images/close.png'" class="avatar" mode="aspectFill" @error="onImgErr(idx)"/>
  194. <view class="main" @click="showUserDetailByIndex(idx)">
  195. <view class="row">
  196. <text class="name">{{ u.nickname || '-' }}</text>
  197. </view>
  198. <view class="meta">
  199. <text>{{ fmtGender(u.gender) }}</text>
  200. <text v-if="u.height">{{ u.height }}cm</text>
  201. <text v-if="u.educationLevel">{{ fmtEdu(u.educationLevel) }}</text>
  202. <text v-if="u.salaryRange">{{ fmtSalary(u.salaryRange) }}</text>
  203. </view>
  204. <view class="tags">
  205. <text v-if="u.star" class="tag">{{ u.star }}</text>
  206. <text v-if="u.animal" class="tag">{{ u.animal }}</text>
  207. <text v-if="u.jobTitle" class="tag">{{ u.jobTitle }}</text>
  208. <text v-for="(t, tIdx) in parseHobby(u.hobby)" :key="`hobby-${u.userId}-${tIdx}`" class="tag">{{ t }}</text>
  209. </view>
  210. </view>
  211. <view class="actions">
  212. <!-- <button size="mini" class="act-btn ghost" @click.stop="dislike(idx)">不喜欢</button> -->
  213. <button size="mini" :class="['act-btn', u.liked ? 'liked' : 'primary']" @click.stop="toggleLike(idx)">
  214. {{ u.liked ? '我的喜欢' : '喜欢' }}
  215. </button>
  216. </view>
  217. </view>
  218. <view v-if="!list.length" class="empty-container">
  219. <view class="empty" @click="goLogin">前往登录,解锁功能</view>
  220. </view>
  221. </view>
  222. </scroll-view>
  223. <!-- 底部导航栏 -->
  224. <common-tabbar current="recommend" client-type="user" :badge-data="badgeData" />
  225. </view>
  226. </template>
  227. <script>
  228. import api from '@/utils/api.js'
  229. import userStatusCheck from '@/utils/userStatusCheck.js'
  230. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
  231. import CommonTabbar from '@/components/common-tabbar/common-tabbar.vue'
  232. export default {
  233. components: { uniPopup, CommonTabbar },
  234. data() {
  235. return {
  236. currentTab: 'recommend', // 当前选中的选项卡
  237. badgeData: { unreadCount: 0 }, // 角标数据
  238. list: [],
  239. loading: false,
  240. oppoOnly: 1,
  241. currentUserId: null, // 当前登录用户ID
  242. currentUserGender: null, // 当前登录用户性别
  243. userDetail: null, // 用户详细信息
  244. shownUserIds: [], // 已显示过的用户ID列表(用于换一批功能)
  245. query: { userId: null, ageMin: null, ageMax: null, heightMin: null, heightMax: null, provinceId: null, cityId: null, areaId: null, educationMin: null, salaryMin: null, star: null, animal: null, hobbyTags: [], limit: 10, offset: 0 },
  246. hobbyInput: '',
  247. educationOptions: [
  248. {label:'不限', value:null},{label:'高中及以下', value:1},{label:'大专', value:2},{label:'本科', value:3},{label:'硕士', value:4},{label:'博士', value:5}
  249. ],
  250. salaryOptions: [
  251. {label:'不限', value:null},{label:'<5k', value:1},{label:'5-10k', value:2},{label:'10-20k', value:3},{label:'20-50k', value:4},{label:'50k+', value:5}
  252. ],
  253. starOptions: [
  254. {label:'不限', value:null},{label:'白羊座', value:'白羊座'},{label:'金牛座', value:'金牛座'},{label:'双子座', value:'双子座'},{label:'巨蟹座', value:'巨蟹座'},{label:'狮子座', value:'狮子座'},{label:'处女座', value:'处女座'},{label:'天秤座', value:'天秤座'},{label:'天蝎座', value:'天蝎座'},{label:'射手座', value:'射手座'},{label:'摩羯座', value:'摩羯座'},{label:'水瓶座', value:'水瓶座'},{label:'双鱼座', value:'双鱼座'}
  255. ],
  256. animalOptions: [
  257. {label:'不限', value:null},{label:'鼠', value:'鼠'},{label:'牛', value:'牛'},{label:'虎', value:'虎'},{label:'兔', value:'兔'},{label:'龙', value:'龙'},{label:'蛇', value:'蛇'},{label:'马', value:'马'},{label:'羊', value:'羊'},{label:'猴', value:'猴'},{label:'鸡', value:'鸡'},{label:'狗', value:'狗'},{label:'猪', value:'猪'}
  258. ],
  259. currentEduText: '', currentSalaryText: '', currentStarText: '', currentAnimalText: '',
  260. provinceList: [], cityList: [], areaList: [],
  261. multiAreaData: [[], [], []], // 多列选择器数据:[省份列表, 城市列表, 区域列表]
  262. multiAreaIndex: [0, 0, 0], // 多列选择器当前选中的索引
  263. areaDisplayText: '选择省市区' // 显示的省市区文本
  264. }
  265. },
  266. computed: {
  267. unreadCount() {
  268. return this.$store.getters.getTotalUnread || 0;
  269. },
  270. // 过滤后的推荐列表:排除当前用户和未完善性别信息的用户
  271. filteredList() {
  272. return this.list.filter(user => {
  273. // 排除当前用户本身
  274. if (user.userId && this.currentUserId && user.userId === this.currentUserId) {
  275. return false;
  276. }
  277. // 排除未完善性别信息的用户(gender为null或0)
  278. if (!user.gender || user.gender === 0) {
  279. return false;
  280. }
  281. // 如果当前用户性别已设置,只显示异性
  282. if (this.currentUserGender && this.currentUserGender !== 0) {
  283. if (user.gender === this.currentUserGender) {
  284. return false; // 排除同性
  285. }
  286. }
  287. return true;
  288. });
  289. }
  290. },
  291. async onLoad() {
  292. await this.loadCurrentUserInfo();
  293. this.refresh();
  294. },
  295. // 页面显示时重新加载用户信息和推荐列表
  296. async onShow() {
  297. const genderChanged = await this.loadCurrentUserInfo();
  298. // 如果性别发生变化,或者列表为空,则刷新推荐列表
  299. if (genderChanged || this.list.length === 0) {
  300. if (genderChanged) {
  301. this.shownUserIds = [];
  302. }
  303. this.refresh(false);
  304. } else {
  305. // 列表已存在,只更新喜欢状态
  306. await this.updateLikedStatus();
  307. }
  308. },
  309. methods: {
  310. // 加载当前用户信息
  311. async loadCurrentUserInfo() {
  312. try {
  313. const storedUserId = uni.getStorageSync('userId');
  314. if (storedUserId) {
  315. this.currentUserId = parseInt(storedUserId);
  316. // 优先从storage中获取用户信息(包括性别)
  317. const storedUserInfo = uni.getStorageSync('userInfo');
  318. const oldGender = this.currentUserGender;
  319. if (storedUserInfo && storedUserInfo.gender !== undefined && storedUserInfo.gender !== null) {
  320. this.currentUserGender = parseInt(storedUserInfo.gender);
  321. }
  322. // 总是从API获取最新的用户信息,确保性别信息是最新的
  323. try {
  324. const userInfo = await api.user.getDetailInfo(this.currentUserId);
  325. if (userInfo && userInfo.gender !== undefined && userInfo.gender !== null) {
  326. const newGender = parseInt(userInfo.gender);
  327. if (newGender !== this.currentUserGender) {
  328. this.currentUserGender = newGender;
  329. // 更新storage中的用户信息
  330. if (storedUserInfo) {
  331. storedUserInfo.gender = this.currentUserGender;
  332. uni.setStorageSync('userInfo', storedUserInfo);
  333. }
  334. } else {
  335. this.currentUserGender = newGender;
  336. }
  337. }
  338. } catch (e) {
  339. console.error('获取当前用户信息失败:', e);
  340. // API失败时,如果storage中有性别信息,使用storage中的
  341. if (!this.currentUserGender && storedUserInfo && storedUserInfo.gender !== undefined && storedUserInfo.gender !== null) {
  342. this.currentUserGender = parseInt(storedUserInfo.gender);
  343. }
  344. }
  345. return oldGender !== this.currentUserGender;
  346. }
  347. return false;
  348. } catch (e) {
  349. console.error('加载当前用户信息失败:', e);
  350. return false;
  351. }
  352. },
  353. // 切换选项卡
  354. switchToTab(tab) {
  355. this.currentTab = tab
  356. if (tab === 'recommend') {
  357. // 保持在当前推荐页面,刷新推荐列表
  358. this.refresh(false)
  359. } else if (tab === 'match') {
  360. // 跳转到匹配页面
  361. uni.navigateTo({
  362. url: '/pages/match/index',
  363. fail: () => {
  364. uni.showToast({
  365. title: '在线匹配功能开发中...',
  366. icon: 'none'
  367. })
  368. }
  369. })
  370. }
  371. },
  372. switchTab(tab) {
  373. if (tab === 'recommend') return
  374. const tabPages = {
  375. index: '/pages/index/index',
  376. plaza: '/pages/plaza/index',
  377. message: '/subpkg-message/index/index',
  378. mine: '/pages/mine/index'
  379. }
  380. if (tabPages[tab]) {
  381. uni.redirectTo({ url: tabPages[tab] })
  382. }
  383. },
  384. async refresh(isChangeBatch = false) {
  385. this.loading = true
  386. try {
  387. // 确保已加载当前用户信息
  388. if (!this.currentUserId || this.currentUserGender === null || this.currentUserGender === undefined) {
  389. await this.loadCurrentUserInfo();
  390. }
  391. const userId = this.currentUserId || parseInt(uni.getStorageSync('userId') || '1');
  392. // 如果没有筛选,走默认接口;有筛选,调用 search
  393. if (!this.hasFilter()) {
  394. // 如果是换一批,传递已显示的用户ID列表
  395. let excludeIdsParam = '';
  396. if (isChangeBatch && this.shownUserIds.length > 0) {
  397. excludeIdsParam = this.shownUserIds.join(',');
  398. }
  399. // 每页显示10个推荐用户
  400. const params = { userId, oppoOnly: 1, limit: 10 };
  401. if (excludeIdsParam) {
  402. params.excludeIds = excludeIdsParam;
  403. }
  404. const data = await api.recommend.getUsers(params);
  405. // 如果换一批时返回的数据为空或很少,说明所有用户都显示过了,重新开始
  406. if (isChangeBatch && (!data || data.length === 0)) {
  407. this.shownUserIds = []; // 清空已显示列表
  408. // 重新获取,不排除任何用户
  409. const newData = await api.recommend.getUsers({ userId, oppoOnly: 1, limit: 10 });
  410. if (newData && newData.length > 0) {
  411. this.processRecommendData(newData, userId);
  412. return;
  413. }
  414. }
  415. if (data && data.length > 0) {
  416. this.processRecommendData(data, userId);
  417. } else {
  418. this.list = [];
  419. if (isChangeBatch) {
  420. uni.showToast({ title: '暂无更多推荐', icon: 'none' });
  421. }
  422. }
  423. } else {
  424. this.query.userId = userId; this.query.limit = 10; this.query.offset = 0
  425. // 不设置query.gender,让后端根据当前用户性别自动推荐异性
  426. const payload = this.buildQueryPayload()
  427. const data = await api.recommend.search(payload)
  428. const arr = Array.isArray(data) ? data : []
  429. // 再次过滤:排除当前用户和未完善性别信息的用户
  430. this.list = arr
  431. .filter(it => {
  432. // 排除当前用户本身
  433. if (!it.userId || it.userId === userId) return false;
  434. // 排除未完善性别信息的用户
  435. if (!it.gender || it.gender === 0) return false;
  436. // 如果当前用户性别已设置,只保留异性
  437. if (this.currentUserGender && this.currentUserGender !== 0) {
  438. if (it.gender === this.currentUserGender) return false; // 排除同性
  439. }
  440. return true;
  441. })
  442. .map(it=>({ ...it, avatarUrl: this.getSafeAvatar(it.avatarUrl) }))
  443. }
  444. } catch (e) {
  445. const msg = (e && (e.message || e.msg)) ? String(e.message || e.msg) : '获取推荐失败'
  446. console.error('recommend/search error:', e)
  447. uni.showToast({ title: msg, icon: 'none' })
  448. } finally { this.loading = false }
  449. },
  450. // 更新喜欢状态:从后端获取当前用户喜欢的用户列表,更新本地liked状态
  451. async updateLikedStatus() {
  452. try {
  453. const uid = parseInt(uni.getStorageSync('userId') || 1);
  454. // 调用API获取用户喜欢的列表
  455. const likedUsers = await api.recommend.getLikedUsers(uid);
  456. if (likedUsers && likedUsers.length > 0) {
  457. // 提取喜欢的用户ID集合
  458. const likedUserIds = new Set(likedUsers.map(user => user.userId));
  459. // 更新本地liked状态
  460. for (let i = 0; i < this.list.length; i++) {
  461. const u = this.list[i];
  462. if (u.userId) {
  463. this.$set(this.list[i], 'liked', likedUserIds.has(u.userId));
  464. }
  465. }
  466. }
  467. } catch (e) {
  468. console.error('获取喜欢状态失败', e);
  469. }
  470. },
  471. // 处理推荐数据:过滤并记录已显示的用户ID
  472. processRecommendData(data, userId) {
  473. const seen = new Set();
  474. const merged = [];
  475. for (const it of (data || [])) {
  476. // 过滤:排除当前用户和未完善性别信息的用户
  477. if (!it.userId || it.userId === userId || !it.gender || it.gender === 0) {
  478. continue;
  479. }
  480. // 如果当前用户性别已设置,只保留异性
  481. if (this.currentUserGender && this.currentUserGender !== 0) {
  482. if (it.gender === this.currentUserGender) {
  483. continue; // 排除同性
  484. }
  485. }
  486. if (!seen.has(it.userId)) {
  487. seen.add(it.userId);
  488. merged.push(it);
  489. // 记录已显示的用户ID
  490. if (!this.shownUserIds.includes(it.userId)) {
  491. this.shownUserIds.push(it.userId);
  492. }
  493. }
  494. }
  495. this.list = merged.map(it=>({ ...it, avatarUrl: this.getSafeAvatar(it.avatarUrl), liked: false }));
  496. // 更新喜欢状态
  497. this.updateLikedStatus();
  498. },
  499. // 换一批功能
  500. changeBatch() {
  501. this.refresh(true);
  502. },
  503. openFilter(){
  504. // 筛选功能需要检查用户状态
  505. userStatusCheck.checkAndTip().then(canOperate => {
  506. if (canOperate) {
  507. this.ensureAreaData();
  508. this.$refs.filterPopup.open('bottom')
  509. }
  510. })
  511. },
  512. closeFilter(){ this.$refs.filterPopup.close() },
  513. async applyFilter(){
  514. // 检查用户是否被禁用
  515. const canOperate = await userStatusCheck.checkAndTip()
  516. if (!canOperate) {
  517. this.$refs.filterPopup.close()
  518. return
  519. }
  520. this.$refs.filterPopup.close();
  521. // 应用筛选时,清空已显示列表,重新开始
  522. this.shownUserIds = [];
  523. this.refresh(false);
  524. },
  525. hasFilter(){
  526. const q=this.query
  527. return !!(q.ageMin||q.ageMax||q.heightMin||q.heightMax||q.provinceId||q.cityId||q.areaId||q.educationMin||q.salaryMin||q.star||q.animal||this.hobbyInput)
  528. },
  529. onEduChange(e){
  530. const item = this.educationOptions[e.detail.value];
  531. this.query.educationMin = item.value;
  532. this.currentEduText = item.label;
  533. },
  534. onSalaryChange(e){
  535. const item = this.salaryOptions[e.detail.value];
  536. this.query.salaryMin = item.value;
  537. this.currentSalaryText = item.label;
  538. },
  539. onStarChange(e){
  540. const item = this.starOptions[e.detail.value];
  541. this.query.star = item.value || null;
  542. this.currentStarText = item.label;
  543. },
  544. onAnimalChange(e){
  545. const item = this.animalOptions[e.detail.value];
  546. this.query.animal = item.value || null;
  547. this.currentAnimalText = item.label;
  548. },
  549. buildQueryPayload(){
  550. const q = { ...this.query };
  551. if (this.hobbyInput) {
  552. q.hobbyTags = this.hobbyInput.split(',').map(s=>s.trim()).filter(Boolean)
  553. } else {
  554. delete q.hobbyTags
  555. }
  556. // 清理空值/空字符串/NaN,避免后端收到无效条件
  557. Object.keys(q).forEach(k => {
  558. const v = q[k];
  559. if (v === null || v === undefined || v === '' || (typeof v === 'number' && Number.isNaN(v))) {
  560. delete q[k]
  561. }
  562. })
  563. return q
  564. },
  565. resetFilter(){
  566. this.query={...this.query, ageMin:null, ageMax:null, heightMin:null, heightMax:null, provinceId:null, cityId:null, areaId:null, educationMin:null, salaryMin:null, star:null, animal:null};
  567. this.hobbyInput=''; this.currentStarText=''; this.currentAnimalText='';
  568. this.areaDisplayText='';
  569. this.multiAreaIndex=[0, 0, 0];
  570. this.cityList=[]; this.areaList=[]
  571. // 重置多列选择器数据,保留省份列表
  572. if(this.provinceList.length > 0){
  573. this.multiAreaData[0] = this.provinceList
  574. this.multiAreaData[1] = []
  575. this.multiAreaData[2] = []
  576. }
  577. },
  578. async ensureAreaData(){
  579. // 加载省份列表
  580. if(!this.provinceList.length){
  581. try{
  582. this.provinceList = await api.area.getProvinces()
  583. // 初始化多列选择器的省份数据
  584. this.multiAreaData[0] = this.provinceList
  585. // 如果有省份,加载第一个省份的城市
  586. if(this.provinceList.length > 0){
  587. await this.loadCitiesForProvince(0)
  588. }
  589. }catch(e){
  590. console.error('加载省份失败:', e)
  591. }
  592. }
  593. },
  594. // 加载指定省份的城市
  595. async loadCitiesForProvince(provinceIndex){
  596. if(provinceIndex < 0 || provinceIndex >= this.provinceList.length) return
  597. const province = this.provinceList[provinceIndex]
  598. if(!province || !province.id) return
  599. try{
  600. const cities = await api.area.getCities(province.id)
  601. this.multiAreaData[1] = cities || []
  602. this.cityList = cities || []
  603. // 重置区域
  604. this.multiAreaData[2] = []
  605. this.areaList = []
  606. this.multiAreaIndex[1] = 0
  607. this.multiAreaIndex[2] = 0
  608. // 如果有城市,加载第一个城市的区域
  609. if(cities && cities.length > 0){
  610. await this.loadAreasForCity(0, cities)
  611. }
  612. }catch(err){
  613. console.error('加载城市失败:', err)
  614. this.multiAreaData[1] = []
  615. this.cityList = []
  616. this.multiAreaData[2] = []
  617. this.areaList = []
  618. }
  619. },
  620. // 加载指定城市的区域
  621. async loadAreasForCity(cityIndex, cities = null){
  622. const cityList = cities || this.cityList
  623. if(cityIndex < 0 || cityIndex >= cityList.length) return
  624. const city = cityList[cityIndex]
  625. if(!city || !city.id) return
  626. try{
  627. const areas = await api.area.getAreas(city.id)
  628. this.multiAreaData[2] = areas || []
  629. this.areaList = areas || []
  630. this.multiAreaIndex[2] = 0
  631. }catch(err){
  632. console.error('加载区域失败:', err)
  633. this.multiAreaData[2] = []
  634. this.areaList = []
  635. }
  636. },
  637. // 多列选择器列变化事件(滑动某一列时触发)
  638. async onMultiAreaColumnChange(e){
  639. const column = e.detail.column // 改变的列索引:0-省份,1-城市,2-区域
  640. const row = e.detail.value // 新选中的行索引
  641. if(column === 0){
  642. // 选择了省份,需要加载该省份的城市
  643. this.multiAreaIndex[0] = row
  644. await this.loadCitiesForProvince(row)
  645. }else if(column === 1){
  646. // 选择了城市,需要加载该城市的区域
  647. this.multiAreaIndex[1] = row
  648. await this.loadAreasForCity(row)
  649. }else if(column === 2){
  650. // 选择了区域
  651. this.multiAreaIndex[2] = row
  652. }
  653. },
  654. // 多列选择器确认选择事件
  655. onMultiAreaChange(e){
  656. const values = e.detail.value // [省份索引, 城市索引, 区域索引]
  657. this.multiAreaIndex = values
  658. // 从 multiAreaData 中获取选中的数据
  659. const provinceIndex = values[0]
  660. const cityIndex = values[1]
  661. const areaIndex = values[2]
  662. const province = this.multiAreaData[0] && this.multiAreaData[0][provinceIndex]
  663. const city = this.multiAreaData[1] && this.multiAreaData[1][cityIndex]
  664. const area = this.multiAreaData[2] && this.multiAreaData[2][areaIndex]
  665. // 更新查询参数
  666. this.query.provinceId = province?.id || null
  667. this.query.cityId = city?.id || null
  668. this.query.areaId = area?.id || null
  669. // 同步到单独的列表(用于兼容)
  670. if(province) {
  671. const pIdx = this.provinceList.findIndex(p => p.id === province.id)
  672. if(pIdx >= 0) {
  673. this.cityList = this.multiAreaData[1] || []
  674. if(city) {
  675. const cIdx = this.cityList.findIndex(c => c.id === city.id)
  676. if(cIdx >= 0) {
  677. this.areaList = this.multiAreaData[2] || []
  678. }
  679. }
  680. }
  681. }
  682. // 更新显示文本
  683. const parts = []
  684. if(province) parts.push(province.name)
  685. if(city) parts.push(city.name)
  686. if(area) parts.push(area.name)
  687. this.areaDisplayText = parts.length > 0 ? parts.join(' ') : '选择省市区'
  688. },
  689. getSafeAvatar(url){
  690. if(!url) return 'http://115.190.125.125:9001/static-images/close.png'
  691. const u = String(url)
  692. if(u.includes('example.com')) return 'http://115.190.125.125:9001/static-images/close.png'
  693. return u
  694. },
  695. fmtScore(s){ return s ? Number(s).toFixed(1) : '0.0' },
  696. fmtGender(g){ return g===1?'男':g===2?'女':'-' },
  697. fmtEdu(v){ const map={1:'高中',2:'大专',3:'本科',4:'硕士',5:'博士'}; return map[v]||'-' },
  698. fmtSalary(v){ const map={1:'<5k',2:'5-10k',3:'10-20k',4:'20-50k',5:'50k+'}; return map[v]||'-' },
  699. parseHobby(h){ try{ const arr = typeof h === 'string' ? JSON.parse(h) : h; return Array.isArray(arr)?arr.slice(0,6):[] }catch{return []} },
  700. async toggleLike(i){
  701. // 检查用户是否被禁用
  702. const canOperate = await userStatusCheck.checkAndTip()
  703. if (!canOperate) return
  704. const u=this.list[i];
  705. if(!u) return;
  706. const uid = parseInt(uni.getStorageSync('userId')||1);
  707. // 切换喜欢状态
  708. const newType = u.liked ? 'dislike' : 'like';
  709. // 调用 API 记录反馈
  710. if(u.userId){
  711. try {
  712. await api.recommend.feedback({ userId: uid, targetUserId: u.userId, type: newType });
  713. // 更新本地状态
  714. this.$set(this.list[i], 'liked', !u.liked);
  715. // 显示成功提示
  716. uni.showToast({ title: newType === 'like' ? '已喜欢' : '已取消喜欢', icon: 'success' });
  717. } catch(e) {
  718. console.error('反馈失败', e);
  719. }
  720. }
  721. },
  722. async openChat(user) {
  723. // 验证必要参数
  724. if (!user || !user.userId) {
  725. uni.showToast({
  726. title: '用户信息错误',
  727. icon: 'none'
  728. });
  729. return;
  730. }
  731. const targetUserId = parseInt(user.userId);
  732. const targetUserName = user.nickname || '用户';
  733. const targetUserAvatar = user.avatarUrl || 'http://115.190.125.125:9001/static-images/close.png';
  734. // 先导入用户到腾讯云IM(防止消息发送失败)
  735. uni.showLoading({ title: '准备中...' });
  736. try {
  737. // 获取当前用户ID
  738. const currentUserId = uni.getStorageSync('userId');
  739. // 导入当前用户
  740. await uni.request({
  741. url: 'https://api.zhongruanke.cn/api/im/importUser',
  742. method: 'POST',
  743. data: {
  744. userId: String(currentUserId),
  745. nickname: '用户' + currentUserId
  746. },
  747. header: {
  748. 'Content-Type': 'application/json'
  749. }
  750. });
  751. // 导入目标用户
  752. await uni.request({
  753. url: 'https://api.zhongruanke.cn/api/im/importUser',
  754. method: 'POST',
  755. data: {
  756. userId: String(targetUserId),
  757. nickname: targetUserName
  758. },
  759. header: {
  760. 'Content-Type': 'application/json'
  761. }
  762. });
  763. // 等待一小段时间确保导入生效
  764. await new Promise(resolve => setTimeout(resolve, 500));
  765. uni.hideLoading();
  766. // 跳转到聊天页面
  767. uni.navigateTo({
  768. url: `/subpkg-message/chat/chat?targetUserId=${targetUserId}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}`
  769. });
  770. } catch (error) {
  771. console.error('❌ 导入用户失败:', error);
  772. uni.hideLoading();
  773. // 即使导入失败也尝试打开聊天(用户可能已存在)
  774. uni.navigateTo({
  775. url: `/pages/message/chat?targetUserId=${targetUserId}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}`
  776. });
  777. }
  778. },
  779. dislike(i){
  780. const u=this.list[i];
  781. if(!u) return;
  782. this.list.splice(i,1);
  783. uni.showToast({ title:'已隐藏', icon:'none' });
  784. const uid = parseInt(uni.getStorageSync('userId')||1);
  785. if(u.userId){
  786. api.recommend.feedback({ userId: uid, targetUserId: u.userId, type: 'dislike' })
  787. }
  788. },
  789. onImgErr(idx){
  790. this.$set(this.list[idx], 'avatarUrl', 'http://115.190.125.125:9001/static-images/close.png')
  791. },
  792. // 通过索引显示用户详情(跳转到新页面)
  793. showUserDetailByIndex(index) {
  794. if (index < 0 || index >= this.list.length) {
  795. uni.showToast({
  796. title: '用户索引无效',
  797. icon: 'none'
  798. })
  799. return
  800. }
  801. const user = this.list[index]
  802. if (!user || !user.userId) {
  803. uni.showToast({
  804. title: '用户信息不存在',
  805. icon: 'none'
  806. })
  807. return
  808. }
  809. // 跳转到用户详情页面
  810. const score = user.compatibilityScore ? user.compatibilityScore : ''
  811. uni.navigateTo({
  812. url: `/pages/recommend/user-detail?userId=${user.userId}&score=${score}`
  813. })
  814. },
  815. // 显示用户详情
  816. async showUserDetail(user) {
  817. if (!user || !user.userId) {
  818. console.error('用户信息无效:', user)
  819. uni.showToast({
  820. title: '用户信息错误',
  821. icon: 'none'
  822. })
  823. return
  824. }
  825. // 确保userId是数字类型
  826. const userId = parseInt(user.userId)
  827. if (!userId || isNaN(userId)) {
  828. uni.showToast({
  829. title: '用户ID无效',
  830. icon: 'none'
  831. })
  832. return
  833. }
  834. // 先打开弹窗
  835. this.userDetail = null
  836. try {
  837. if (this.$refs.userDetailPopup) {
  838. this.$refs.userDetailPopup.open('center')
  839. } else {
  840. console.error('弹窗组件引用不存在')
  841. uni.showToast({
  842. title: '弹窗初始化失败',
  843. icon: 'none'
  844. })
  845. return
  846. }
  847. } catch (err) {
  848. console.error('打开弹窗失败:', err)
  849. uni.showToast({
  850. title: '打开弹窗失败',
  851. icon: 'none'
  852. })
  853. return
  854. }
  855. // 加载用户详情
  856. try {
  857. uni.showLoading({ title: '加载中...' })
  858. const detail = await api.user.getDetailInfo(userId)
  859. if (detail) {
  860. // 确保photos是数组,如果没有photos但有avatar,使用avatar
  861. if (!detail.photos || !Array.isArray(detail.photos)) {
  862. detail.photos = []
  863. if (detail.avatar) {
  864. detail.photos.push(detail.avatar)
  865. }
  866. }
  867. // 确保所有字段都有默认值,避免显示undefined
  868. if (!detail.nickname) detail.nickname = '未设置'
  869. this.userDetail = detail
  870. } else {
  871. uni.showToast({
  872. title: '用户信息为空',
  873. icon: 'none'
  874. })
  875. if (this.$refs.userDetailPopup) {
  876. this.$refs.userDetailPopup.close()
  877. }
  878. }
  879. } catch (e) {
  880. console.error('获取用户详情失败:', e)
  881. const errorMsg = e && e.message ? e.message : '获取用户信息失败'
  882. uni.showToast({
  883. title: errorMsg,
  884. icon: 'none',
  885. duration: 2000
  886. })
  887. // 如果加载失败,关闭弹窗
  888. if (this.$refs.userDetailPopup) {
  889. this.$refs.userDetailPopup.close()
  890. }
  891. } finally {
  892. uni.hideLoading()
  893. }
  894. },
  895. // 关闭用户详情
  896. closeUserDetail() {
  897. try {
  898. if (this.$refs.userDetailPopup) {
  899. this.$refs.userDetailPopup.close()
  900. }
  901. } catch (e) {
  902. console.error('关闭弹窗失败:', e)
  903. }
  904. this.userDetail = null
  905. },
  906. // 预览照片
  907. previewPhoto(index) {
  908. if (!this.userDetail || !this.userDetail.photos || !Array.isArray(this.userDetail.photos) || this.userDetail.photos.length === 0) {
  909. return
  910. }
  911. uni.previewImage({
  912. urls: this.userDetail.photos,
  913. current: index
  914. })
  915. },
  916. // 照片加载错误处理
  917. onPhotoError(e) {
  918. console.error('照片加载失败:', e)
  919. },
  920. // 跳转到登录页面
  921. goLogin() {
  922. uni.navigateTo({
  923. url: '/pages/page3/page3?redirect=' + encodeURIComponent('/pages/recommend/index')
  924. })
  925. }
  926. }
  927. }
  928. </script>
  929. <style lang="scss" scoped>
  930. /* 扁平化设计风格 */
  931. .recommend-page {
  932. min-height: 100vh;
  933. background-color: #F5F5F5;
  934. padding-bottom: 120rpx;
  935. }
  936. .toolbar{
  937. display: flex;
  938. justify-content: space-between;
  939. align-items: center;
  940. padding: 16rpx 20rpx;
  941. background: #FFFFFF;
  942. border-bottom: 2rpx solid #E0E0E0;
  943. }
  944. /* 选项卡样式 - 扁平化 */
  945. .tab-container {
  946. display: flex;
  947. margin: 20rpx;
  948. background: #FFFFFF;
  949. border-radius: 8rpx;
  950. border: 2rpx solid #E0E0E0;
  951. overflow: hidden;
  952. }
  953. .tab-item {
  954. flex: 1;
  955. display: flex;
  956. align-items: center;
  957. justify-content: center;
  958. padding: 18rpx 20rpx;
  959. transition: all 0.2s ease;
  960. border-right: 2rpx solid #E0E0E0;
  961. &:last-child {
  962. border-right: none;
  963. }
  964. .tab-icon {
  965. font-size: 28rpx;
  966. margin-right: 8rpx;
  967. }
  968. .tab-text {
  969. font-size: 28rpx;
  970. font-weight: 500;
  971. }
  972. &.active {
  973. .tab-icon {
  974. color: #E91E63;
  975. }
  976. .tab-text {
  977. color: #E91E63;
  978. font-weight: 600;
  979. }
  980. }
  981. &:not(.active) {
  982. background: #FFFFFF;
  983. .tab-icon {
  984. color: #999;
  985. }
  986. .tab-text {
  987. color: #666;
  988. }
  989. }
  990. }
  991. .tool-text{
  992. font-size: 26rpx;
  993. color: #666;
  994. }
  995. .tool-btn{
  996. height: 64rpx;
  997. padding: 0 24rpx;
  998. border-radius: 8rpx;
  999. display: flex;
  1000. align-items: center;
  1001. gap: 10rpx;
  1002. font-size: 26rpx;
  1003. background: #FFFFFF;
  1004. border: 2rpx solid #E0E0E0;
  1005. color: #333;
  1006. transition: all 0.2s ease;
  1007. &:active {
  1008. opacity: 0.8;
  1009. }
  1010. }
  1011. .tool-btn .icon{
  1012. font-size: 28rpx;
  1013. }
  1014. .refresh-btn{
  1015. background: #FFE5F1;
  1016. border-color: #E91E63;
  1017. color: #E91E63;
  1018. }
  1019. .filter-btn{
  1020. background: #FFFFFF;
  1021. border-color: #E0E0E0;
  1022. color: #333;
  1023. }
  1024. .list{
  1025. height: calc(100vh - 260rpx);
  1026. padding: 0 20rpx;
  1027. }
  1028. .skeleton{
  1029. padding: 40rpx;
  1030. text-align: center;
  1031. color: #999;
  1032. }
  1033. .empty-container{
  1034. width: 100%;
  1035. height: 500rpx;
  1036. display: flex;
  1037. justify-content: center;
  1038. align-items: center;
  1039. }
  1040. .empty{
  1041. padding: 20rpx 40rpx;
  1042. text-align: center;
  1043. color: #E91E63;
  1044. font-size: 28rpx;
  1045. font-weight: 600;
  1046. transition: all 0.2s ease;
  1047. &:active {
  1048. opacity: 0.8;
  1049. }
  1050. }
  1051. /* 用户卡片 - 扁平化 */
  1052. .card{
  1053. display: flex;
  1054. background: #FFFFFF;
  1055. border-radius: 12rpx;
  1056. padding: 20rpx;
  1057. margin: 16rpx 0;
  1058. border: 2rpx solid #E0E0E0;
  1059. transition: all 0.2s ease;
  1060. &:active {
  1061. background: #F5F5F5;
  1062. }
  1063. }
  1064. .avatar{
  1065. width: 140rpx;
  1066. height: 140rpx;
  1067. border-radius: 12rpx;
  1068. background: #F5F5F5;
  1069. border: 2rpx solid #E0E0E0;
  1070. }
  1071. .main{
  1072. flex: 1;
  1073. padding: 0 16rpx;
  1074. }
  1075. .row{
  1076. display: flex;
  1077. align-items: center;
  1078. justify-content: space-between;
  1079. }
  1080. .name{
  1081. font-size: 32rpx;
  1082. font-weight: 600;
  1083. color: #333;
  1084. }
  1085. .score{
  1086. font-size: 28rpx;
  1087. color: #E91E63;
  1088. }
  1089. .score-badge{
  1090. min-width: 80rpx;
  1091. text-align: center;
  1092. padding: 6rpx 16rpx;
  1093. border-radius: 8rpx;
  1094. background: #FFE5F1;
  1095. color: #E91E63;
  1096. font-size: 26rpx;
  1097. font-weight: 600;
  1098. }
  1099. .meta{
  1100. display: flex;
  1101. gap: 16rpx;
  1102. font-size: 24rpx;
  1103. color: #666;
  1104. margin-top: 8rpx;
  1105. }
  1106. .tags{
  1107. display: flex;
  1108. flex-wrap: wrap;
  1109. gap: 10rpx;
  1110. margin-top: 10rpx;
  1111. }
  1112. .tag{
  1113. background: #F5F5F5;
  1114. color: #666;
  1115. padding: 6rpx 12rpx;
  1116. border-radius: 6rpx;
  1117. font-size: 22rpx;
  1118. border: 1rpx solid #E0E0E0;
  1119. }
  1120. .actions{
  1121. display: flex;
  1122. flex-direction: column;
  1123. gap: 10rpx;
  1124. justify-content: center;
  1125. }
  1126. .act-btn{
  1127. border-radius: 8rpx;
  1128. padding: 0 20rpx;
  1129. height: 56rpx;
  1130. line-height: 56rpx;
  1131. font-size: 24rpx;
  1132. transition: all 0.2s ease;
  1133. &:active {
  1134. opacity: 0.8;
  1135. }
  1136. }
  1137. .tabbar-badge {
  1138. position: absolute;
  1139. top: 8rpx;
  1140. right: 25%;
  1141. min-width: 36rpx;
  1142. height: 36rpx;
  1143. line-height: 36rpx;
  1144. padding: 0 8rpx;
  1145. background: #FF6B6B;
  1146. color: #FFFFFF;
  1147. font-size: 20rpx;
  1148. font-weight: bold;
  1149. border-radius: 18rpx;
  1150. text-align: center;
  1151. }
  1152. .act-btn.ghost{
  1153. background: #F5F5F5;
  1154. color: #666;
  1155. border: 2rpx solid #E0E0E0;
  1156. }
  1157. .act-btn.primary{
  1158. background: #E91E63;
  1159. color: #FFFFFF;
  1160. border: none;
  1161. }
  1162. .act-btn.liked{
  1163. background: #FFB3C6;
  1164. color: #E91E63;
  1165. border: 2rpx solid #E91E63;
  1166. }
  1167. /* 底部导航栏 - 扁平化 */
  1168. .tabbar {
  1169. position: fixed;
  1170. bottom: 0;
  1171. left: 0;
  1172. right: 0;
  1173. display: flex;
  1174. background-color: #FFFFFF;
  1175. border-top: 1rpx solid #F0F0F0;
  1176. padding-bottom: constant(safe-area-inset-bottom);
  1177. padding-bottom: env(safe-area-inset-bottom);
  1178. z-index: 999;
  1179. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  1180. .tabbar-item {
  1181. flex: 1;
  1182. display: flex;
  1183. flex-direction: column;
  1184. align-items: center;
  1185. justify-content: center;
  1186. padding: 15rpx 0;
  1187. position: relative;
  1188. .tabbar-icon {
  1189. font-size: 44rpx;
  1190. margin-bottom: 5rpx;
  1191. }
  1192. .first-icon{
  1193. width: 25px;
  1194. height: 25px;
  1195. margin-bottom: 5px;
  1196. margin-top: 5px;
  1197. }
  1198. .tabbar-text {
  1199. font-size: 22rpx;
  1200. color: #666666;
  1201. }
  1202. &.active {
  1203. .tabbar-text {
  1204. color: #E91E63;
  1205. font-weight: bold;
  1206. }
  1207. }
  1208. }
  1209. }
  1210. .tabbar-item {
  1211. flex: 1;
  1212. display: flex;
  1213. flex-direction: column;
  1214. align-items: center;
  1215. justify-content: center;
  1216. padding: 18rpx 0;
  1217. transition: all 0.2s ease;
  1218. &:active {
  1219. background: #F5F5F5;
  1220. }
  1221. }
  1222. .tabbar-icon {
  1223. font-size: 46rpx;
  1224. margin-bottom: 8rpx;
  1225. }
  1226. .tabbar-text {
  1227. font-size: 22rpx;
  1228. color: #666666;
  1229. font-weight: 500;
  1230. }
  1231. .tabbar-item.active {
  1232. .tabbar-text {
  1233. color: #E91E63;
  1234. font-weight: 700;
  1235. }
  1236. }
  1237. /* 筛选抽屉 - 扁平化 */
  1238. .filter-sheet{
  1239. background: #FFFFFF;
  1240. border-top-left-radius: 16rpx;
  1241. border-top-right-radius: 16rpx;
  1242. padding-bottom: env(safe-area-inset-bottom);
  1243. border-top: 2rpx solid #E0E0E0;
  1244. height: 75vh !important;
  1245. display: flex;
  1246. flex-direction: column;
  1247. }
  1248. .sheet-handle{
  1249. width: 120rpx;
  1250. height: 8rpx;
  1251. background: #E0E0E0;
  1252. border-radius: 4rpx;
  1253. margin: 16rpx auto;
  1254. }
  1255. .sheet-title{
  1256. text-align: center;
  1257. font-size: 32rpx;
  1258. font-weight: 600;
  1259. color: #333;
  1260. margin-bottom: 10rpx;
  1261. padding: 0 28rpx;
  1262. border-bottom: 2rpx solid #E0E0E0;
  1263. padding-bottom: 16rpx;
  1264. }
  1265. .sheet-body{
  1266. padding: 20rpx 28rpx;
  1267. max-height: calc(75vh - 240rpx);
  1268. overflow-y: auto;
  1269. }
  1270. .field{
  1271. margin: 18rpx 0;
  1272. }
  1273. .field.two{
  1274. display: flex;
  1275. align-items: center;
  1276. }
  1277. .field-label{
  1278. width: 160rpx;
  1279. color: #666;
  1280. font-size: 26rpx;
  1281. font-weight: 500;
  1282. }
  1283. .ipt{
  1284. flex: 1;
  1285. height: 70rpx;
  1286. line-height: 70rpx;
  1287. background: #F5F5F5;
  1288. border-radius: 8rpx;
  1289. padding: 0 20rpx;
  1290. margin-right: 12rpx;
  1291. font-size: 26rpx;
  1292. display: flex;
  1293. align-items: center;
  1294. border: 2rpx solid #E0E0E0;
  1295. }
  1296. .ipt.full{
  1297. width: 100%;
  1298. margin-right: 0;
  1299. }
  1300. .dash{
  1301. color: #999;
  1302. margin-right: 12rpx;
  1303. }
  1304. .seg{
  1305. display: flex;
  1306. gap: 14rpx;
  1307. }
  1308. .seg-item{
  1309. flex: 1;
  1310. text-align: center;
  1311. padding: 14rpx 0;
  1312. border-radius: 8rpx;
  1313. background: #F5F5F5;
  1314. color: #666;
  1315. font-size: 26rpx;
  1316. border: 2rpx solid #E0E0E0;
  1317. transition: all 0.2s ease;
  1318. }
  1319. .seg-item.active{
  1320. background: #FFE5F1;
  1321. color: #E91E63;
  1322. font-weight: 600;
  1323. border-color: #E91E63;
  1324. }
  1325. .sheet-actions{
  1326. display: flex;
  1327. gap: 16rpx;
  1328. padding: 24rpx 28rpx 32rpx;
  1329. border-top: 2rpx solid #E0E0E0;
  1330. margin-top: 16rpx;
  1331. }
  1332. .btn{
  1333. flex: 1;
  1334. height: 80rpx;
  1335. border-radius: 8rpx;
  1336. display: flex;
  1337. align-items: center;
  1338. justify-content: center;
  1339. font-size: 28rpx;
  1340. font-weight: 600;
  1341. transition: all 0.2s ease;
  1342. &:active {
  1343. opacity: 0.8;
  1344. }
  1345. }
  1346. .btn.ghost{
  1347. background: #F5F5F5;
  1348. color: #666;
  1349. border: 2rpx solid #E0E0E0;
  1350. }
  1351. .btn.primary{
  1352. background: #E91E63;
  1353. color: #FFFFFF;
  1354. border: none;
  1355. }
  1356. /* 用户详情弹窗样式 */
  1357. .user-detail-popup {
  1358. width: 600rpx;
  1359. max-height: 70vh;
  1360. background: #FFFFFF;
  1361. border-radius: 16rpx;
  1362. overflow: hidden;
  1363. display: flex;
  1364. flex-direction: column;
  1365. }
  1366. .popup-header {
  1367. display: flex;
  1368. align-items: center;
  1369. justify-content: space-between;
  1370. padding: 20rpx 24rpx;
  1371. border-bottom: 2rpx solid #E0E0E0;
  1372. background: #FFFFFF;
  1373. }
  1374. .popup-title {
  1375. font-size: 32rpx;
  1376. font-weight: 600;
  1377. color: #333;
  1378. }
  1379. .popup-close {
  1380. font-size: 40rpx;
  1381. color: #999;
  1382. width: 60rpx;
  1383. height: 60rpx;
  1384. display: flex;
  1385. align-items: center;
  1386. justify-content: center;
  1387. border-radius: 50%;
  1388. transition: all 0.2s ease;
  1389. }
  1390. .popup-close:active {
  1391. background: #F5F5F5;
  1392. }
  1393. .popup-content {
  1394. flex: 1;
  1395. padding: 20rpx 24rpx;
  1396. max-height: calc(70vh - 120rpx);
  1397. }
  1398. .popup-loading {
  1399. padding: 60rpx 20rpx;
  1400. text-align: center;
  1401. color: #999;
  1402. font-size: 26rpx;
  1403. }
  1404. .detail-section {
  1405. margin-bottom: 32rpx;
  1406. }
  1407. .section-title {
  1408. font-size: 28rpx;
  1409. font-weight: 600;
  1410. color: #333;
  1411. margin-bottom: 16rpx;
  1412. padding-bottom: 12rpx;
  1413. border-bottom: 2rpx solid #F0F0F0;
  1414. }
  1415. /* 照片区域 */
  1416. .photos-section {
  1417. margin-bottom: 32rpx;
  1418. }
  1419. .photos-grid {
  1420. display: grid;
  1421. grid-template-columns: repeat(3, 1fr);
  1422. gap: 12rpx;
  1423. }
  1424. .photo-item {
  1425. width: 100%;
  1426. height: 200rpx;
  1427. border-radius: 8rpx;
  1428. background: #F5F5F5;
  1429. border: 2rpx solid #E0E0E0;
  1430. }
  1431. /* 信息网格 */
  1432. .detail-info-grid {
  1433. display: grid;
  1434. grid-template-columns: repeat(2, 1fr);
  1435. gap: 16rpx;
  1436. }
  1437. .info-item {
  1438. display: flex;
  1439. flex-direction: column;
  1440. padding: 16rpx;
  1441. background: #F8F9FA;
  1442. border-radius: 8rpx;
  1443. border: 1rpx solid #E0E0E0;
  1444. }
  1445. .info-label {
  1446. font-size: 22rpx;
  1447. color: #999;
  1448. margin-bottom: 8rpx;
  1449. }
  1450. .info-value {
  1451. font-size: 26rpx;
  1452. color: #333;
  1453. font-weight: 500;
  1454. }
  1455. /* 兴趣爱好标签 */
  1456. .hobby-tags {
  1457. display: flex;
  1458. flex-wrap: wrap;
  1459. gap: 12rpx;
  1460. }
  1461. .hobby-tag {
  1462. background: #FFE5F1;
  1463. color: #E91E63;
  1464. padding: 10rpx 18rpx;
  1465. border-radius: 20rpx;
  1466. font-size: 24rpx;
  1467. border: 1rpx solid #FFD0DC;
  1468. }
  1469. /* 自我简介 */
  1470. .introduction-content {
  1471. background: #F8F9FA;
  1472. padding: 20rpx;
  1473. border-radius: 8rpx;
  1474. border-left: 4rpx solid #E91E63;
  1475. line-height: 1.8;
  1476. }
  1477. .introduction-content text {
  1478. font-size: 26rpx;
  1479. color: #666;
  1480. line-height: 1.8;
  1481. }
  1482. .tabbar-badge {
  1483. position: absolute;
  1484. top: 8rpx;
  1485. right: 50%;
  1486. margin-right: -40rpx;
  1487. min-width: 32rpx;
  1488. height: 32rpx;
  1489. line-height: 32rpx;
  1490. padding: 0 6rpx;
  1491. background-color: #FA5151;
  1492. border-radius: 16rpx;
  1493. font-size: 20rpx;
  1494. color: #FFFFFF;
  1495. text-align: center;
  1496. }
  1497. </style>