index.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630
  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. <text class="score-badge">{{ fmtScore(u.compatibilityScore) }}</text>
  198. </view>
  199. <view class="meta">
  200. <text>{{ fmtGender(u.gender) }}</text>
  201. <text v-if="u.height">{{ u.height }}cm</text>
  202. <text v-if="u.educationLevel">{{ fmtEdu(u.educationLevel) }}</text>
  203. <text v-if="u.salaryRange">{{ fmtSalary(u.salaryRange) }}</text>
  204. </view>
  205. <view class="tags">
  206. <text v-if="u.star" class="tag">{{ u.star }}</text>
  207. <text v-if="u.animal" class="tag">{{ u.animal }}</text>
  208. <text v-if="u.jobTitle" class="tag">{{ u.jobTitle }}</text>
  209. <text v-for="(t, tIdx) in parseHobby(u.hobby)" :key="`hobby-${u.userId}-${tIdx}`" class="tag">{{ t }}</text>
  210. </view>
  211. </view>
  212. <view class="actions">
  213. <!-- <button size="mini" class="act-btn ghost" @click.stop="dislike(idx)">不喜欢</button> -->
  214. <button size="mini" :class="['act-btn', u.liked ? 'liked' : 'primary']" @click.stop="toggleLike(idx)">
  215. {{ u.liked ? '我的喜欢' : '喜欢' }}
  216. </button>
  217. </view>
  218. </view>
  219. <view v-if="!list.length" class="empty">暂无推荐</view>
  220. </view>
  221. </scroll-view>
  222. <!-- 底部导航栏 -->
  223. <view class="tabbar">
  224. <view class="tabbar-item" @click="switchTab('index')">
  225. <text class="tabbar-icon">🏠</text>
  226. <text class="tabbar-text">首页</text>
  227. </view>
  228. <view class="tabbar-item" @click="switchTab('plaza')">
  229. <text class="tabbar-icon">💕</text>
  230. <text class="tabbar-text">动态</text>
  231. </view>
  232. <view class="tabbar-item active" @click="switchTab('recommend')">
  233. <text class="tabbar-icon">👍</text>
  234. <text class="tabbar-text">推荐</text>
  235. </view>
  236. <!-- <view class="tabbar-item" @click="switchTab('message')">
  237. <text class="tabbar-icon">💬</text>
  238. <text class="tabbar-text">消息</text>
  239. </view> -->
  240. <view class="tabbar-item" @click="switchTab('mine')">
  241. <text class="tabbar-icon">👤</text>
  242. <text class="tabbar-text">我的</text>
  243. </view>
  244. </view>
  245. </view>
  246. </template>
  247. <script>
  248. import api from '@/utils/api.js'
  249. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
  250. export default {
  251. components: { uniPopup },
  252. data() {
  253. return {
  254. currentTab: 'recommend', // 当前选中的选项卡
  255. list: [],
  256. loading: false,
  257. oppoOnly: 1,
  258. currentUserId: null, // 当前登录用户ID
  259. currentUserGender: null, // 当前登录用户性别
  260. userDetail: null, // 用户详细信息
  261. shownUserIds: [], // 已显示过的用户ID列表(用于换一批功能)
  262. 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 },
  263. hobbyInput: '',
  264. educationOptions: [
  265. {label:'不限', value:null},{label:'高中及以下', value:1},{label:'大专', value:2},{label:'本科', value:3},{label:'硕士', value:4},{label:'博士', value:5}
  266. ],
  267. salaryOptions: [
  268. {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}
  269. ],
  270. starOptions: [
  271. {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:'双鱼座'}
  272. ],
  273. animalOptions: [
  274. {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:'猪'}
  275. ],
  276. currentEduText: '', currentSalaryText: '', currentStarText: '', currentAnimalText: '',
  277. provinceList: [], cityList: [], areaList: [],
  278. multiAreaData: [[], [], []], // 多列选择器数据:[省份列表, 城市列表, 区域列表]
  279. multiAreaIndex: [0, 0, 0], // 多列选择器当前选中的索引
  280. areaDisplayText: '选择省市区' // 显示的省市区文本
  281. }
  282. },
  283. computed: {
  284. unreadCount() {
  285. return this.$store.getters.getTotalUnread || 0;
  286. },
  287. // 过滤后的推荐列表:排除当前用户和未完善性别信息的用户
  288. filteredList() {
  289. return this.list.filter(user => {
  290. // 排除当前用户本身
  291. if (user.userId && this.currentUserId && user.userId === this.currentUserId) {
  292. return false;
  293. }
  294. // 排除未完善性别信息的用户(gender为null或0)
  295. if (!user.gender || user.gender === 0) {
  296. return false;
  297. }
  298. // 如果当前用户性别已设置,只显示异性
  299. if (this.currentUserGender && this.currentUserGender !== 0) {
  300. if (user.gender === this.currentUserGender) {
  301. return false; // 排除同性
  302. }
  303. }
  304. return true;
  305. });
  306. }
  307. },
  308. async onLoad() {
  309. await this.loadCurrentUserInfo();
  310. this.refresh();
  311. },
  312. // 页面显示时重新加载用户信息和推荐列表
  313. async onShow() {
  314. const genderChanged = await this.loadCurrentUserInfo();
  315. // 如果性别发生变化,或者列表为空,则刷新推荐列表
  316. if (genderChanged || this.list.length === 0) {
  317. if (genderChanged) {
  318. this.shownUserIds = [];
  319. }
  320. this.refresh(false);
  321. } else {
  322. // 列表已存在,只更新喜欢状态
  323. await this.updateLikedStatus();
  324. }
  325. },
  326. methods: {
  327. // 加载当前用户信息
  328. async loadCurrentUserInfo() {
  329. try {
  330. const storedUserId = uni.getStorageSync('userId');
  331. if (storedUserId) {
  332. this.currentUserId = parseInt(storedUserId);
  333. // 优先从storage中获取用户信息(包括性别)
  334. const storedUserInfo = uni.getStorageSync('userInfo');
  335. const oldGender = this.currentUserGender;
  336. if (storedUserInfo && storedUserInfo.gender !== undefined && storedUserInfo.gender !== null) {
  337. this.currentUserGender = parseInt(storedUserInfo.gender);
  338. }
  339. // 总是从API获取最新的用户信息,确保性别信息是最新的
  340. try {
  341. const userInfo = await api.user.getDetailInfo(this.currentUserId);
  342. if (userInfo && userInfo.gender !== undefined && userInfo.gender !== null) {
  343. const newGender = parseInt(userInfo.gender);
  344. if (newGender !== this.currentUserGender) {
  345. this.currentUserGender = newGender;
  346. // 更新storage中的用户信息
  347. if (storedUserInfo) {
  348. storedUserInfo.gender = this.currentUserGender;
  349. uni.setStorageSync('userInfo', storedUserInfo);
  350. }
  351. } else {
  352. this.currentUserGender = newGender;
  353. }
  354. }
  355. } catch (e) {
  356. console.error('获取当前用户信息失败:', e);
  357. // API失败时,如果storage中有性别信息,使用storage中的
  358. if (!this.currentUserGender && storedUserInfo && storedUserInfo.gender !== undefined && storedUserInfo.gender !== null) {
  359. this.currentUserGender = parseInt(storedUserInfo.gender);
  360. }
  361. }
  362. return oldGender !== this.currentUserGender;
  363. }
  364. return false;
  365. } catch (e) {
  366. console.error('加载当前用户信息失败:', e);
  367. return false;
  368. }
  369. },
  370. // 切换选项卡
  371. switchToTab(tab) {
  372. this.currentTab = tab
  373. if (tab === 'recommend') {
  374. // 保持在当前推荐页面,刷新推荐列表
  375. this.refresh(false)
  376. } else if (tab === 'match') {
  377. // 跳转到匹配页面
  378. uni.navigateTo({
  379. url: '/pages/match/index',
  380. fail: () => {
  381. uni.showToast({
  382. title: '在线匹配功能开发中...',
  383. icon: 'none'
  384. })
  385. }
  386. })
  387. }
  388. },
  389. switchTab(tab) {
  390. if (tab === 'recommend') return
  391. const tabPages = {
  392. index: '/pages/index/index',
  393. plaza: '/pages/plaza/index',
  394. message: '/subpkg-message/index/index',
  395. mine: '/pages/mine/index'
  396. }
  397. if (tabPages[tab]) {
  398. uni.redirectTo({ url: tabPages[tab] })
  399. }
  400. },
  401. async refresh(isChangeBatch = false) {
  402. this.loading = true
  403. try {
  404. // 确保已加载当前用户信息
  405. if (!this.currentUserId || this.currentUserGender === null || this.currentUserGender === undefined) {
  406. await this.loadCurrentUserInfo();
  407. }
  408. const userId = this.currentUserId || parseInt(uni.getStorageSync('userId') || '1');
  409. // 如果没有筛选,走默认接口;有筛选,调用 search
  410. if (!this.hasFilter()) {
  411. // 如果是换一批,传递已显示的用户ID列表
  412. let excludeIdsParam = '';
  413. if (isChangeBatch && this.shownUserIds.length > 0) {
  414. excludeIdsParam = this.shownUserIds.join(',');
  415. }
  416. // 每页显示10个推荐用户
  417. const params = { userId, oppoOnly: 1, limit: 10 };
  418. if (excludeIdsParam) {
  419. params.excludeIds = excludeIdsParam;
  420. }
  421. const data = await api.recommend.getUsers(params);
  422. // 如果换一批时返回的数据为空或很少,说明所有用户都显示过了,重新开始
  423. if (isChangeBatch && (!data || data.length === 0)) {
  424. this.shownUserIds = []; // 清空已显示列表
  425. // 重新获取,不排除任何用户
  426. const newData = await api.recommend.getUsers({ userId, oppoOnly: 1, limit: 10 });
  427. if (newData && newData.length > 0) {
  428. this.processRecommendData(newData, userId);
  429. return;
  430. }
  431. }
  432. if (data && data.length > 0) {
  433. this.processRecommendData(data, userId);
  434. } else {
  435. this.list = [];
  436. if (isChangeBatch) {
  437. uni.showToast({ title: '暂无更多推荐', icon: 'none' });
  438. }
  439. }
  440. } else {
  441. this.query.userId = userId; this.query.limit = 10; this.query.offset = 0
  442. // 不设置query.gender,让后端根据当前用户性别自动推荐异性
  443. const payload = this.buildQueryPayload()
  444. const data = await api.recommend.search(payload)
  445. const arr = Array.isArray(data) ? data : []
  446. // 再次过滤:排除当前用户和未完善性别信息的用户
  447. this.list = arr
  448. .filter(it => {
  449. // 排除当前用户本身
  450. if (!it.userId || it.userId === userId) return false;
  451. // 排除未完善性别信息的用户
  452. if (!it.gender || it.gender === 0) return false;
  453. // 如果当前用户性别已设置,只保留异性
  454. if (this.currentUserGender && this.currentUserGender !== 0) {
  455. if (it.gender === this.currentUserGender) return false; // 排除同性
  456. }
  457. return true;
  458. })
  459. .map(it=>({ ...it, avatarUrl: this.getSafeAvatar(it.avatarUrl) }))
  460. }
  461. } catch (e) {
  462. const msg = (e && (e.message || e.msg)) ? String(e.message || e.msg) : '获取推荐失败'
  463. console.error('recommend/search error:', e)
  464. uni.showToast({ title: msg, icon: 'none' })
  465. } finally { this.loading = false }
  466. },
  467. // 更新喜欢状态:从后端获取当前用户喜欢的用户列表,更新本地liked状态
  468. async updateLikedStatus() {
  469. try {
  470. const uid = parseInt(uni.getStorageSync('userId') || 1);
  471. // 调用API获取用户喜欢的列表
  472. const likedUsers = await api.recommend.getLikedUsers(uid);
  473. if (likedUsers && likedUsers.length > 0) {
  474. // 提取喜欢的用户ID集合
  475. const likedUserIds = new Set(likedUsers.map(user => user.userId));
  476. // 更新本地liked状态
  477. for (let i = 0; i < this.list.length; i++) {
  478. const u = this.list[i];
  479. if (u.userId) {
  480. this.$set(this.list[i], 'liked', likedUserIds.has(u.userId));
  481. }
  482. }
  483. }
  484. } catch (e) {
  485. console.error('获取喜欢状态失败', e);
  486. }
  487. },
  488. // 处理推荐数据:过滤并记录已显示的用户ID
  489. processRecommendData(data, userId) {
  490. const seen = new Set();
  491. const merged = [];
  492. for (const it of (data || [])) {
  493. // 过滤:排除当前用户和未完善性别信息的用户
  494. if (!it.userId || it.userId === userId || !it.gender || it.gender === 0) {
  495. continue;
  496. }
  497. // 如果当前用户性别已设置,只保留异性
  498. if (this.currentUserGender && this.currentUserGender !== 0) {
  499. if (it.gender === this.currentUserGender) {
  500. continue; // 排除同性
  501. }
  502. }
  503. if (!seen.has(it.userId)) {
  504. seen.add(it.userId);
  505. merged.push(it);
  506. // 记录已显示的用户ID
  507. if (!this.shownUserIds.includes(it.userId)) {
  508. this.shownUserIds.push(it.userId);
  509. }
  510. }
  511. }
  512. this.list = merged.map(it=>({ ...it, avatarUrl: this.getSafeAvatar(it.avatarUrl), liked: false }));
  513. // 更新喜欢状态
  514. this.updateLikedStatus();
  515. },
  516. // 换一批功能
  517. changeBatch() {
  518. this.refresh(true);
  519. },
  520. openFilter(){ this.ensureAreaData(); this.$refs.filterPopup.open('bottom') },
  521. closeFilter(){ this.$refs.filterPopup.close() },
  522. applyFilter(){
  523. this.$refs.filterPopup.close();
  524. // 应用筛选时,清空已显示列表,重新开始
  525. this.shownUserIds = [];
  526. this.refresh(false);
  527. },
  528. hasFilter(){
  529. const q=this.query
  530. 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)
  531. },
  532. onEduChange(e){
  533. const item = this.educationOptions[e.detail.value];
  534. this.query.educationMin = item.value;
  535. this.currentEduText = item.label;
  536. },
  537. onSalaryChange(e){
  538. const item = this.salaryOptions[e.detail.value];
  539. this.query.salaryMin = item.value;
  540. this.currentSalaryText = item.label;
  541. },
  542. onStarChange(e){
  543. const item = this.starOptions[e.detail.value];
  544. this.query.star = item.value || null;
  545. this.currentStarText = item.label;
  546. },
  547. onAnimalChange(e){
  548. const item = this.animalOptions[e.detail.value];
  549. this.query.animal = item.value || null;
  550. this.currentAnimalText = item.label;
  551. },
  552. buildQueryPayload(){
  553. const q = { ...this.query };
  554. if (this.hobbyInput) {
  555. q.hobbyTags = this.hobbyInput.split(',').map(s=>s.trim()).filter(Boolean)
  556. } else {
  557. delete q.hobbyTags
  558. }
  559. // 清理空值/空字符串/NaN,避免后端收到无效条件
  560. Object.keys(q).forEach(k => {
  561. const v = q[k];
  562. if (v === null || v === undefined || v === '' || (typeof v === 'number' && Number.isNaN(v))) {
  563. delete q[k]
  564. }
  565. })
  566. return q
  567. },
  568. resetFilter(){
  569. 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};
  570. this.hobbyInput=''; this.currentStarText=''; this.currentAnimalText='';
  571. this.areaDisplayText='';
  572. this.multiAreaIndex=[0, 0, 0];
  573. this.cityList=[]; this.areaList=[]
  574. // 重置多列选择器数据,保留省份列表
  575. if(this.provinceList.length > 0){
  576. this.multiAreaData[0] = this.provinceList
  577. this.multiAreaData[1] = []
  578. this.multiAreaData[2] = []
  579. }
  580. },
  581. async ensureAreaData(){
  582. // 加载省份列表
  583. if(!this.provinceList.length){
  584. try{
  585. this.provinceList = await api.area.getProvinces()
  586. // 初始化多列选择器的省份数据
  587. this.multiAreaData[0] = this.provinceList
  588. // 如果有省份,加载第一个省份的城市
  589. if(this.provinceList.length > 0){
  590. await this.loadCitiesForProvince(0)
  591. }
  592. }catch(e){
  593. console.error('加载省份失败:', e)
  594. }
  595. }
  596. },
  597. // 加载指定省份的城市
  598. async loadCitiesForProvince(provinceIndex){
  599. if(provinceIndex < 0 || provinceIndex >= this.provinceList.length) return
  600. const province = this.provinceList[provinceIndex]
  601. if(!province || !province.id) return
  602. try{
  603. const cities = await api.area.getCities(province.id)
  604. this.multiAreaData[1] = cities || []
  605. this.cityList = cities || []
  606. // 重置区域
  607. this.multiAreaData[2] = []
  608. this.areaList = []
  609. this.multiAreaIndex[1] = 0
  610. this.multiAreaIndex[2] = 0
  611. // 如果有城市,加载第一个城市的区域
  612. if(cities && cities.length > 0){
  613. await this.loadAreasForCity(0, cities)
  614. }
  615. }catch(err){
  616. console.error('加载城市失败:', err)
  617. this.multiAreaData[1] = []
  618. this.cityList = []
  619. this.multiAreaData[2] = []
  620. this.areaList = []
  621. }
  622. },
  623. // 加载指定城市的区域
  624. async loadAreasForCity(cityIndex, cities = null){
  625. const cityList = cities || this.cityList
  626. if(cityIndex < 0 || cityIndex >= cityList.length) return
  627. const city = cityList[cityIndex]
  628. if(!city || !city.id) return
  629. try{
  630. const areas = await api.area.getAreas(city.id)
  631. this.multiAreaData[2] = areas || []
  632. this.areaList = areas || []
  633. this.multiAreaIndex[2] = 0
  634. }catch(err){
  635. console.error('加载区域失败:', err)
  636. this.multiAreaData[2] = []
  637. this.areaList = []
  638. }
  639. },
  640. // 多列选择器列变化事件(滑动某一列时触发)
  641. async onMultiAreaColumnChange(e){
  642. const column = e.detail.column // 改变的列索引:0-省份,1-城市,2-区域
  643. const row = e.detail.value // 新选中的行索引
  644. if(column === 0){
  645. // 选择了省份,需要加载该省份的城市
  646. this.multiAreaIndex[0] = row
  647. await this.loadCitiesForProvince(row)
  648. }else if(column === 1){
  649. // 选择了城市,需要加载该城市的区域
  650. this.multiAreaIndex[1] = row
  651. await this.loadAreasForCity(row)
  652. }else if(column === 2){
  653. // 选择了区域
  654. this.multiAreaIndex[2] = row
  655. }
  656. },
  657. // 多列选择器确认选择事件
  658. onMultiAreaChange(e){
  659. const values = e.detail.value // [省份索引, 城市索引, 区域索引]
  660. this.multiAreaIndex = values
  661. // 从 multiAreaData 中获取选中的数据
  662. const provinceIndex = values[0]
  663. const cityIndex = values[1]
  664. const areaIndex = values[2]
  665. const province = this.multiAreaData[0] && this.multiAreaData[0][provinceIndex]
  666. const city = this.multiAreaData[1] && this.multiAreaData[1][cityIndex]
  667. const area = this.multiAreaData[2] && this.multiAreaData[2][areaIndex]
  668. // 更新查询参数
  669. this.query.provinceId = province?.id || null
  670. this.query.cityId = city?.id || null
  671. this.query.areaId = area?.id || null
  672. // 同步到单独的列表(用于兼容)
  673. if(province) {
  674. const pIdx = this.provinceList.findIndex(p => p.id === province.id)
  675. if(pIdx >= 0) {
  676. this.cityList = this.multiAreaData[1] || []
  677. if(city) {
  678. const cIdx = this.cityList.findIndex(c => c.id === city.id)
  679. if(cIdx >= 0) {
  680. this.areaList = this.multiAreaData[2] || []
  681. }
  682. }
  683. }
  684. }
  685. // 更新显示文本
  686. const parts = []
  687. if(province) parts.push(province.name)
  688. if(city) parts.push(city.name)
  689. if(area) parts.push(area.name)
  690. this.areaDisplayText = parts.length > 0 ? parts.join(' ') : '选择省市区'
  691. },
  692. getSafeAvatar(url){
  693. if(!url) return 'http://115.190.125.125:9001/static-images/close.png'
  694. const u = String(url)
  695. if(u.includes('example.com')) return 'http://115.190.125.125:9001/static-images/close.png'
  696. return u
  697. },
  698. fmtScore(s){ return s ? Number(s).toFixed(1) : '0.0' },
  699. fmtGender(g){ return g===1?'男':g===2?'女':'-' },
  700. fmtEdu(v){ const map={1:'高中',2:'大专',3:'本科',4:'硕士',5:'博士'}; return map[v]||'-' },
  701. fmtSalary(v){ const map={1:'<5k',2:'5-10k',3:'10-20k',4:'20-50k',5:'50k+'}; return map[v]||'-' },
  702. parseHobby(h){ try{ const arr = typeof h === 'string' ? JSON.parse(h) : h; return Array.isArray(arr)?arr.slice(0,6):[] }catch{return []} },
  703. async toggleLike(i){
  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. }
  922. </script>
  923. <style lang="scss" scoped>
  924. /* 扁平化设计风格 */
  925. .recommend-page {
  926. min-height: 100vh;
  927. background-color: #F5F5F5;
  928. padding-bottom: 120rpx;
  929. }
  930. .toolbar{
  931. display: flex;
  932. justify-content: space-between;
  933. align-items: center;
  934. padding: 16rpx 20rpx;
  935. background: #FFFFFF;
  936. border-bottom: 2rpx solid #E0E0E0;
  937. }
  938. /* 选项卡样式 - 扁平化 */
  939. .tab-container {
  940. display: flex;
  941. margin: 20rpx;
  942. background: #FFFFFF;
  943. border-radius: 8rpx;
  944. border: 2rpx solid #E0E0E0;
  945. overflow: hidden;
  946. }
  947. .tab-item {
  948. flex: 1;
  949. display: flex;
  950. align-items: center;
  951. justify-content: center;
  952. padding: 18rpx 20rpx;
  953. transition: all 0.2s ease;
  954. border-right: 2rpx solid #E0E0E0;
  955. &:last-child {
  956. border-right: none;
  957. }
  958. .tab-icon {
  959. font-size: 28rpx;
  960. margin-right: 8rpx;
  961. }
  962. .tab-text {
  963. font-size: 28rpx;
  964. font-weight: 500;
  965. }
  966. &.active {
  967. background: #FFE5F1;
  968. .tab-icon {
  969. color: #E91E63;
  970. }
  971. .tab-text {
  972. color: #E91E63;
  973. font-weight: 600;
  974. }
  975. }
  976. &:not(.active) {
  977. background: #FFFFFF;
  978. .tab-icon {
  979. color: #999;
  980. }
  981. .tab-text {
  982. color: #666;
  983. }
  984. }
  985. }
  986. .tool-text{
  987. font-size: 26rpx;
  988. color: #666;
  989. }
  990. .tool-btn{
  991. height: 64rpx;
  992. padding: 0 24rpx;
  993. border-radius: 8rpx;
  994. display: flex;
  995. align-items: center;
  996. gap: 10rpx;
  997. font-size: 26rpx;
  998. background: #FFFFFF;
  999. border: 2rpx solid #E0E0E0;
  1000. color: #333;
  1001. transition: all 0.2s ease;
  1002. &:active {
  1003. opacity: 0.8;
  1004. }
  1005. }
  1006. .tool-btn .icon{
  1007. font-size: 28rpx;
  1008. }
  1009. .refresh-btn{
  1010. background: #FFE5F1;
  1011. border-color: #E91E63;
  1012. color: #E91E63;
  1013. }
  1014. .filter-btn{
  1015. background: #FFFFFF;
  1016. border-color: #E0E0E0;
  1017. color: #333;
  1018. }
  1019. .list{
  1020. height: calc(100vh - 260rpx);
  1021. padding: 0 20rpx;
  1022. }
  1023. .skeleton{
  1024. padding: 40rpx;
  1025. text-align: center;
  1026. color: #999;
  1027. }
  1028. .empty{
  1029. padding: 60rpx 20rpx;
  1030. text-align: center;
  1031. color: #999;
  1032. font-size: 26rpx;
  1033. }
  1034. /* 用户卡片 - 扁平化 */
  1035. .card{
  1036. display: flex;
  1037. background: #FFFFFF;
  1038. border-radius: 12rpx;
  1039. padding: 20rpx;
  1040. margin: 16rpx 0;
  1041. border: 2rpx solid #E0E0E0;
  1042. transition: all 0.2s ease;
  1043. &:active {
  1044. background: #F5F5F5;
  1045. }
  1046. }
  1047. .avatar{
  1048. width: 140rpx;
  1049. height: 140rpx;
  1050. border-radius: 12rpx;
  1051. background: #F5F5F5;
  1052. border: 2rpx solid #E0E0E0;
  1053. }
  1054. .main{
  1055. flex: 1;
  1056. padding: 0 16rpx;
  1057. }
  1058. .row{
  1059. display: flex;
  1060. align-items: center;
  1061. justify-content: space-between;
  1062. }
  1063. .name{
  1064. font-size: 32rpx;
  1065. font-weight: 600;
  1066. color: #333;
  1067. }
  1068. .score{
  1069. font-size: 28rpx;
  1070. color: #E91E63;
  1071. }
  1072. .score-badge{
  1073. min-width: 80rpx;
  1074. text-align: center;
  1075. padding: 6rpx 16rpx;
  1076. border-radius: 8rpx;
  1077. background: #FFE5F1;
  1078. color: #E91E63;
  1079. font-size: 26rpx;
  1080. font-weight: 600;
  1081. }
  1082. .meta{
  1083. display: flex;
  1084. gap: 16rpx;
  1085. font-size: 24rpx;
  1086. color: #666;
  1087. margin-top: 8rpx;
  1088. }
  1089. .tags{
  1090. display: flex;
  1091. flex-wrap: wrap;
  1092. gap: 10rpx;
  1093. margin-top: 10rpx;
  1094. }
  1095. .tag{
  1096. background: #F5F5F5;
  1097. color: #666;
  1098. padding: 6rpx 12rpx;
  1099. border-radius: 6rpx;
  1100. font-size: 22rpx;
  1101. border: 1rpx solid #E0E0E0;
  1102. }
  1103. .actions{
  1104. display: flex;
  1105. flex-direction: column;
  1106. gap: 10rpx;
  1107. justify-content: center;
  1108. }
  1109. .act-btn{
  1110. border-radius: 8rpx;
  1111. padding: 0 20rpx;
  1112. height: 56rpx;
  1113. line-height: 56rpx;
  1114. font-size: 24rpx;
  1115. transition: all 0.2s ease;
  1116. &:active {
  1117. opacity: 0.8;
  1118. }
  1119. }
  1120. .tabbar-badge {
  1121. position: absolute;
  1122. top: 8rpx;
  1123. right: 25%;
  1124. min-width: 36rpx;
  1125. height: 36rpx;
  1126. line-height: 36rpx;
  1127. padding: 0 8rpx;
  1128. background: #FF6B6B;
  1129. color: #FFFFFF;
  1130. font-size: 20rpx;
  1131. font-weight: bold;
  1132. border-radius: 18rpx;
  1133. text-align: center;
  1134. }
  1135. .act-btn.ghost{
  1136. background: #F5F5F5;
  1137. color: #666;
  1138. border: 2rpx solid #E0E0E0;
  1139. }
  1140. .act-btn.primary{
  1141. background: #E91E63;
  1142. color: #FFFFFF;
  1143. border: none;
  1144. }
  1145. .act-btn.liked{
  1146. background: #FFB3C6;
  1147. color: #E91E63;
  1148. border: 2rpx solid #E91E63;
  1149. }
  1150. /* 底部导航栏 - 扁平化 */
  1151. .tabbar {
  1152. position: fixed;
  1153. bottom: 0;
  1154. left: 0;
  1155. right: 0;
  1156. display: flex;
  1157. background-color: #FFFFFF;
  1158. border-top: 1rpx solid #F0F0F0;
  1159. padding-bottom: constant(safe-area-inset-bottom);
  1160. padding-bottom: env(safe-area-inset-bottom);
  1161. z-index: 999;
  1162. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  1163. .tabbar-item {
  1164. flex: 1;
  1165. display: flex;
  1166. flex-direction: column;
  1167. align-items: center;
  1168. justify-content: center;
  1169. padding: 15rpx 0;
  1170. position: relative;
  1171. .tabbar-icon {
  1172. font-size: 44rpx;
  1173. margin-bottom: 5rpx;
  1174. }
  1175. .tabbar-text {
  1176. font-size: 22rpx;
  1177. color: #666666;
  1178. }
  1179. &.active {
  1180. .tabbar-text {
  1181. color: #E91E63;
  1182. font-weight: bold;
  1183. }
  1184. }
  1185. }
  1186. }
  1187. .tabbar-item {
  1188. flex: 1;
  1189. display: flex;
  1190. flex-direction: column;
  1191. align-items: center;
  1192. justify-content: center;
  1193. padding: 18rpx 0;
  1194. transition: all 0.2s ease;
  1195. &:active {
  1196. background: #F5F5F5;
  1197. }
  1198. }
  1199. .tabbar-icon {
  1200. font-size: 46rpx;
  1201. margin-bottom: 8rpx;
  1202. }
  1203. .tabbar-text {
  1204. font-size: 22rpx;
  1205. color: #666666;
  1206. font-weight: 500;
  1207. }
  1208. .tabbar-item.active {
  1209. background: #FFE5F1;
  1210. .tabbar-text {
  1211. color: #E91E63;
  1212. font-weight: 700;
  1213. }
  1214. }
  1215. /* 筛选抽屉 - 扁平化 */
  1216. .filter-sheet{
  1217. background: #FFFFFF;
  1218. border-top-left-radius: 16rpx;
  1219. border-top-right-radius: 16rpx;
  1220. padding-bottom: env(safe-area-inset-bottom);
  1221. border-top: 2rpx solid #E0E0E0;
  1222. }
  1223. .sheet-handle{
  1224. width: 120rpx;
  1225. height: 8rpx;
  1226. background: #E0E0E0;
  1227. border-radius: 4rpx;
  1228. margin: 16rpx auto;
  1229. }
  1230. .sheet-title{
  1231. text-align: center;
  1232. font-size: 32rpx;
  1233. font-weight: 600;
  1234. color: #333;
  1235. margin-bottom: 10rpx;
  1236. padding: 0 28rpx;
  1237. border-bottom: 2rpx solid #E0E0E0;
  1238. padding-bottom: 16rpx;
  1239. }
  1240. .sheet-body{
  1241. padding: 20rpx 28rpx;
  1242. max-height: 60vh;
  1243. overflow: auto;
  1244. }
  1245. .field{
  1246. margin: 18rpx 0;
  1247. }
  1248. .field.two{
  1249. display: flex;
  1250. align-items: center;
  1251. }
  1252. .field-label{
  1253. width: 160rpx;
  1254. color: #666;
  1255. font-size: 26rpx;
  1256. font-weight: 500;
  1257. }
  1258. .ipt{
  1259. flex: 1;
  1260. height: 70rpx;
  1261. line-height: 70rpx;
  1262. background: #F5F5F5;
  1263. border-radius: 8rpx;
  1264. padding: 0 20rpx;
  1265. margin-right: 12rpx;
  1266. font-size: 26rpx;
  1267. display: flex;
  1268. align-items: center;
  1269. border: 2rpx solid #E0E0E0;
  1270. }
  1271. .ipt.full{
  1272. width: 100%;
  1273. margin-right: 0;
  1274. }
  1275. .dash{
  1276. color: #999;
  1277. margin-right: 12rpx;
  1278. }
  1279. .seg{
  1280. display: flex;
  1281. gap: 14rpx;
  1282. }
  1283. .seg-item{
  1284. flex: 1;
  1285. text-align: center;
  1286. padding: 14rpx 0;
  1287. border-radius: 8rpx;
  1288. background: #F5F5F5;
  1289. color: #666;
  1290. font-size: 26rpx;
  1291. border: 2rpx solid #E0E0E0;
  1292. transition: all 0.2s ease;
  1293. }
  1294. .seg-item.active{
  1295. background: #FFE5F1;
  1296. color: #E91E63;
  1297. font-weight: 600;
  1298. border-color: #E91E63;
  1299. }
  1300. .sheet-actions{
  1301. display: flex;
  1302. gap: 16rpx;
  1303. padding: 16rpx 28rpx 28rpx;
  1304. border-top: 2rpx solid #E0E0E0;
  1305. }
  1306. .btn{
  1307. flex: 1;
  1308. height: 80rpx;
  1309. border-radius: 8rpx;
  1310. display: flex;
  1311. align-items: center;
  1312. justify-content: center;
  1313. font-size: 28rpx;
  1314. font-weight: 600;
  1315. transition: all 0.2s ease;
  1316. &:active {
  1317. opacity: 0.8;
  1318. }
  1319. }
  1320. .btn.ghost{
  1321. background: #F5F5F5;
  1322. color: #666;
  1323. border: 2rpx solid #E0E0E0;
  1324. }
  1325. .btn.primary{
  1326. background: #E91E63;
  1327. color: #FFFFFF;
  1328. border: none;
  1329. }
  1330. /* 用户详情弹窗样式 */
  1331. .user-detail-popup {
  1332. width: 600rpx;
  1333. max-height: 70vh;
  1334. background: #FFFFFF;
  1335. border-radius: 16rpx;
  1336. overflow: hidden;
  1337. display: flex;
  1338. flex-direction: column;
  1339. }
  1340. .popup-header {
  1341. display: flex;
  1342. align-items: center;
  1343. justify-content: space-between;
  1344. padding: 20rpx 24rpx;
  1345. border-bottom: 2rpx solid #E0E0E0;
  1346. background: #FFFFFF;
  1347. }
  1348. .popup-title {
  1349. font-size: 32rpx;
  1350. font-weight: 600;
  1351. color: #333;
  1352. }
  1353. .popup-close {
  1354. font-size: 40rpx;
  1355. color: #999;
  1356. width: 60rpx;
  1357. height: 60rpx;
  1358. display: flex;
  1359. align-items: center;
  1360. justify-content: center;
  1361. border-radius: 50%;
  1362. transition: all 0.2s ease;
  1363. }
  1364. .popup-close:active {
  1365. background: #F5F5F5;
  1366. }
  1367. .popup-content {
  1368. flex: 1;
  1369. padding: 20rpx 24rpx;
  1370. max-height: calc(70vh - 120rpx);
  1371. }
  1372. .popup-loading {
  1373. padding: 60rpx 20rpx;
  1374. text-align: center;
  1375. color: #999;
  1376. font-size: 26rpx;
  1377. }
  1378. .detail-section {
  1379. margin-bottom: 32rpx;
  1380. }
  1381. .section-title {
  1382. font-size: 28rpx;
  1383. font-weight: 600;
  1384. color: #333;
  1385. margin-bottom: 16rpx;
  1386. padding-bottom: 12rpx;
  1387. border-bottom: 2rpx solid #F0F0F0;
  1388. }
  1389. /* 照片区域 */
  1390. .photos-section {
  1391. margin-bottom: 32rpx;
  1392. }
  1393. .photos-grid {
  1394. display: grid;
  1395. grid-template-columns: repeat(3, 1fr);
  1396. gap: 12rpx;
  1397. }
  1398. .photo-item {
  1399. width: 100%;
  1400. height: 200rpx;
  1401. border-radius: 8rpx;
  1402. background: #F5F5F5;
  1403. border: 2rpx solid #E0E0E0;
  1404. }
  1405. /* 信息网格 */
  1406. .detail-info-grid {
  1407. display: grid;
  1408. grid-template-columns: repeat(2, 1fr);
  1409. gap: 16rpx;
  1410. }
  1411. .info-item {
  1412. display: flex;
  1413. flex-direction: column;
  1414. padding: 16rpx;
  1415. background: #F8F9FA;
  1416. border-radius: 8rpx;
  1417. border: 1rpx solid #E0E0E0;
  1418. }
  1419. .info-label {
  1420. font-size: 22rpx;
  1421. color: #999;
  1422. margin-bottom: 8rpx;
  1423. }
  1424. .info-value {
  1425. font-size: 26rpx;
  1426. color: #333;
  1427. font-weight: 500;
  1428. }
  1429. /* 兴趣爱好标签 */
  1430. .hobby-tags {
  1431. display: flex;
  1432. flex-wrap: wrap;
  1433. gap: 12rpx;
  1434. }
  1435. .hobby-tag {
  1436. background: #FFE5F1;
  1437. color: #E91E63;
  1438. padding: 10rpx 18rpx;
  1439. border-radius: 20rpx;
  1440. font-size: 24rpx;
  1441. border: 1rpx solid #FFD0DC;
  1442. }
  1443. /* 自我简介 */
  1444. .introduction-content {
  1445. background: #F8F9FA;
  1446. padding: 20rpx;
  1447. border-radius: 8rpx;
  1448. border-left: 4rpx solid #E91E63;
  1449. line-height: 1.8;
  1450. }
  1451. .introduction-content text {
  1452. font-size: 26rpx;
  1453. color: #666;
  1454. line-height: 1.8;
  1455. }
  1456. .tabbar-badge {
  1457. position: absolute;
  1458. top: 8rpx;
  1459. right: 50%;
  1460. margin-right: -40rpx;
  1461. min-width: 32rpx;
  1462. height: 32rpx;
  1463. line-height: 32rpx;
  1464. padding: 0 6rpx;
  1465. background-color: #FA5151;
  1466. border-radius: 16rpx;
  1467. font-size: 20rpx;
  1468. color: #FFFFFF;
  1469. text-align: center;
  1470. }
  1471. </style>