index.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660
  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">暂无推荐</view>
  219. </view>
  220. </scroll-view>
  221. <!-- 底部导航栏 -->
  222. <view class="tabbar">
  223. <view class="tabbar-item" @click="switchTab('index')">
  224. <text class="tabbar-icon">🏠</text>
  225. <text class="tabbar-text">首页</text>
  226. </view>
  227. <view class="tabbar-item" @click="switchTab('plaza')">
  228. <text class="tabbar-icon">💕</text>
  229. <text class="tabbar-text">动态</text>
  230. </view>
  231. <view class="tabbar-item active" @click="switchTab('recommend')">
  232. <text class="tabbar-icon">👍</text>
  233. <text class="tabbar-text">推荐</text>
  234. </view>
  235. <!-- <view class="tabbar-item" @click="switchTab('message')">
  236. <text class="tabbar-icon">💬</text>
  237. <text class="tabbar-text">消息</text>
  238. <view v-if="unreadCount >= 1" class="tabbar-badge">{{ unreadCount }}</view>
  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 userStatusCheck from '@/utils/userStatusCheck.js'
  250. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
  251. export default {
  252. components: { uniPopup },
  253. data() {
  254. return {
  255. currentTab: 'recommend', // 当前选中的选项卡
  256. list: [],
  257. loading: false,
  258. oppoOnly: 1,
  259. currentUserId: null, // 当前登录用户ID
  260. currentUserGender: null, // 当前登录用户性别
  261. userDetail: null, // 用户详细信息
  262. shownUserIds: [], // 已显示过的用户ID列表(用于换一批功能)
  263. 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 },
  264. hobbyInput: '',
  265. educationOptions: [
  266. {label:'不限', value:null},{label:'高中及以下', value:1},{label:'大专', value:2},{label:'本科', value:3},{label:'硕士', value:4},{label:'博士', value:5}
  267. ],
  268. salaryOptions: [
  269. {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}
  270. ],
  271. starOptions: [
  272. {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:'双鱼座'}
  273. ],
  274. animalOptions: [
  275. {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:'猪'}
  276. ],
  277. currentEduText: '', currentSalaryText: '', currentStarText: '', currentAnimalText: '',
  278. provinceList: [], cityList: [], areaList: [],
  279. multiAreaData: [[], [], []], // 多列选择器数据:[省份列表, 城市列表, 区域列表]
  280. multiAreaIndex: [0, 0, 0], // 多列选择器当前选中的索引
  281. areaDisplayText: '选择省市区' // 显示的省市区文本
  282. }
  283. },
  284. computed: {
  285. unreadCount() {
  286. return this.$store.getters.getTotalUnread || 0;
  287. },
  288. // 过滤后的推荐列表:排除当前用户和未完善性别信息的用户
  289. filteredList() {
  290. return this.list.filter(user => {
  291. // 排除当前用户本身
  292. if (user.userId && this.currentUserId && user.userId === this.currentUserId) {
  293. return false;
  294. }
  295. // 排除未完善性别信息的用户(gender为null或0)
  296. if (!user.gender || user.gender === 0) {
  297. return false;
  298. }
  299. // 如果当前用户性别已设置,只显示异性
  300. if (this.currentUserGender && this.currentUserGender !== 0) {
  301. if (user.gender === this.currentUserGender) {
  302. return false; // 排除同性
  303. }
  304. }
  305. return true;
  306. });
  307. }
  308. },
  309. async onLoad() {
  310. await this.loadCurrentUserInfo();
  311. this.refresh();
  312. },
  313. // 页面显示时重新加载用户信息和推荐列表
  314. async onShow() {
  315. const genderChanged = await this.loadCurrentUserInfo();
  316. // 如果性别发生变化,或者列表为空,则刷新推荐列表
  317. if (genderChanged || this.list.length === 0) {
  318. if (genderChanged) {
  319. this.shownUserIds = [];
  320. }
  321. this.refresh(false);
  322. } else {
  323. // 列表已存在,只更新喜欢状态
  324. await this.updateLikedStatus();
  325. }
  326. },
  327. methods: {
  328. // 加载当前用户信息
  329. async loadCurrentUserInfo() {
  330. try {
  331. const storedUserId = uni.getStorageSync('userId');
  332. if (storedUserId) {
  333. this.currentUserId = parseInt(storedUserId);
  334. // 优先从storage中获取用户信息(包括性别)
  335. const storedUserInfo = uni.getStorageSync('userInfo');
  336. const oldGender = this.currentUserGender;
  337. if (storedUserInfo && storedUserInfo.gender !== undefined && storedUserInfo.gender !== null) {
  338. this.currentUserGender = parseInt(storedUserInfo.gender);
  339. }
  340. // 总是从API获取最新的用户信息,确保性别信息是最新的
  341. try {
  342. const userInfo = await api.user.getDetailInfo(this.currentUserId);
  343. if (userInfo && userInfo.gender !== undefined && userInfo.gender !== null) {
  344. const newGender = parseInt(userInfo.gender);
  345. if (newGender !== this.currentUserGender) {
  346. this.currentUserGender = newGender;
  347. // 更新storage中的用户信息
  348. if (storedUserInfo) {
  349. storedUserInfo.gender = this.currentUserGender;
  350. uni.setStorageSync('userInfo', storedUserInfo);
  351. }
  352. } else {
  353. this.currentUserGender = newGender;
  354. }
  355. }
  356. } catch (e) {
  357. console.error('获取当前用户信息失败:', e);
  358. // API失败时,如果storage中有性别信息,使用storage中的
  359. if (!this.currentUserGender && storedUserInfo && storedUserInfo.gender !== undefined && storedUserInfo.gender !== null) {
  360. this.currentUserGender = parseInt(storedUserInfo.gender);
  361. }
  362. }
  363. return oldGender !== this.currentUserGender;
  364. }
  365. return false;
  366. } catch (e) {
  367. console.error('加载当前用户信息失败:', e);
  368. return false;
  369. }
  370. },
  371. // 切换选项卡
  372. switchToTab(tab) {
  373. this.currentTab = tab
  374. if (tab === 'recommend') {
  375. // 保持在当前推荐页面,刷新推荐列表
  376. this.refresh(false)
  377. } else if (tab === 'match') {
  378. // 跳转到匹配页面
  379. uni.navigateTo({
  380. url: '/pages/match/index',
  381. fail: () => {
  382. uni.showToast({
  383. title: '在线匹配功能开发中...',
  384. icon: 'none'
  385. })
  386. }
  387. })
  388. }
  389. },
  390. switchTab(tab) {
  391. if (tab === 'recommend') return
  392. const tabPages = {
  393. index: '/pages/index/index',
  394. plaza: '/pages/plaza/index',
  395. message: '/subpkg-message/index/index',
  396. mine: '/pages/mine/index'
  397. }
  398. if (tabPages[tab]) {
  399. uni.redirectTo({ url: tabPages[tab] })
  400. }
  401. },
  402. async refresh(isChangeBatch = false) {
  403. this.loading = true
  404. try {
  405. // 确保已加载当前用户信息
  406. if (!this.currentUserId || this.currentUserGender === null || this.currentUserGender === undefined) {
  407. await this.loadCurrentUserInfo();
  408. }
  409. const userId = this.currentUserId || parseInt(uni.getStorageSync('userId') || '1');
  410. // 如果没有筛选,走默认接口;有筛选,调用 search
  411. if (!this.hasFilter()) {
  412. // 如果是换一批,传递已显示的用户ID列表
  413. let excludeIdsParam = '';
  414. if (isChangeBatch && this.shownUserIds.length > 0) {
  415. excludeIdsParam = this.shownUserIds.join(',');
  416. }
  417. // 每页显示10个推荐用户
  418. const params = { userId, oppoOnly: 1, limit: 10 };
  419. if (excludeIdsParam) {
  420. params.excludeIds = excludeIdsParam;
  421. }
  422. const data = await api.recommend.getUsers(params);
  423. // 如果换一批时返回的数据为空或很少,说明所有用户都显示过了,重新开始
  424. if (isChangeBatch && (!data || data.length === 0)) {
  425. this.shownUserIds = []; // 清空已显示列表
  426. // 重新获取,不排除任何用户
  427. const newData = await api.recommend.getUsers({ userId, oppoOnly: 1, limit: 10 });
  428. if (newData && newData.length > 0) {
  429. this.processRecommendData(newData, userId);
  430. return;
  431. }
  432. }
  433. if (data && data.length > 0) {
  434. this.processRecommendData(data, userId);
  435. } else {
  436. this.list = [];
  437. if (isChangeBatch) {
  438. uni.showToast({ title: '暂无更多推荐', icon: 'none' });
  439. }
  440. }
  441. } else {
  442. this.query.userId = userId; this.query.limit = 10; this.query.offset = 0
  443. // 不设置query.gender,让后端根据当前用户性别自动推荐异性
  444. const payload = this.buildQueryPayload()
  445. const data = await api.recommend.search(payload)
  446. const arr = Array.isArray(data) ? data : []
  447. // 再次过滤:排除当前用户和未完善性别信息的用户
  448. this.list = arr
  449. .filter(it => {
  450. // 排除当前用户本身
  451. if (!it.userId || it.userId === userId) return false;
  452. // 排除未完善性别信息的用户
  453. if (!it.gender || it.gender === 0) return false;
  454. // 如果当前用户性别已设置,只保留异性
  455. if (this.currentUserGender && this.currentUserGender !== 0) {
  456. if (it.gender === this.currentUserGender) return false; // 排除同性
  457. }
  458. return true;
  459. })
  460. .map(it=>({ ...it, avatarUrl: this.getSafeAvatar(it.avatarUrl) }))
  461. }
  462. } catch (e) {
  463. const msg = (e && (e.message || e.msg)) ? String(e.message || e.msg) : '获取推荐失败'
  464. console.error('recommend/search error:', e)
  465. uni.showToast({ title: msg, icon: 'none' })
  466. } finally { this.loading = false }
  467. },
  468. // 更新喜欢状态:从后端获取当前用户喜欢的用户列表,更新本地liked状态
  469. async updateLikedStatus() {
  470. try {
  471. const uid = parseInt(uni.getStorageSync('userId') || 1);
  472. // 调用API获取用户喜欢的列表
  473. const likedUsers = await api.recommend.getLikedUsers(uid);
  474. if (likedUsers && likedUsers.length > 0) {
  475. // 提取喜欢的用户ID集合
  476. const likedUserIds = new Set(likedUsers.map(user => user.userId));
  477. // 更新本地liked状态
  478. for (let i = 0; i < this.list.length; i++) {
  479. const u = this.list[i];
  480. if (u.userId) {
  481. this.$set(this.list[i], 'liked', likedUserIds.has(u.userId));
  482. }
  483. }
  484. }
  485. } catch (e) {
  486. console.error('获取喜欢状态失败', e);
  487. }
  488. },
  489. // 处理推荐数据:过滤并记录已显示的用户ID
  490. processRecommendData(data, userId) {
  491. const seen = new Set();
  492. const merged = [];
  493. for (const it of (data || [])) {
  494. // 过滤:排除当前用户和未完善性别信息的用户
  495. if (!it.userId || it.userId === userId || !it.gender || it.gender === 0) {
  496. continue;
  497. }
  498. // 如果当前用户性别已设置,只保留异性
  499. if (this.currentUserGender && this.currentUserGender !== 0) {
  500. if (it.gender === this.currentUserGender) {
  501. continue; // 排除同性
  502. }
  503. }
  504. if (!seen.has(it.userId)) {
  505. seen.add(it.userId);
  506. merged.push(it);
  507. // 记录已显示的用户ID
  508. if (!this.shownUserIds.includes(it.userId)) {
  509. this.shownUserIds.push(it.userId);
  510. }
  511. }
  512. }
  513. this.list = merged.map(it=>({ ...it, avatarUrl: this.getSafeAvatar(it.avatarUrl), liked: false }));
  514. // 更新喜欢状态
  515. this.updateLikedStatus();
  516. },
  517. // 换一批功能
  518. changeBatch() {
  519. this.refresh(true);
  520. },
  521. openFilter(){
  522. // 筛选功能需要检查用户状态
  523. userStatusCheck.checkAndTip().then(canOperate => {
  524. if (canOperate) {
  525. this.ensureAreaData();
  526. this.$refs.filterPopup.open('bottom')
  527. }
  528. })
  529. },
  530. closeFilter(){ this.$refs.filterPopup.close() },
  531. async applyFilter(){
  532. // 检查用户是否被禁用
  533. const canOperate = await userStatusCheck.checkAndTip()
  534. if (!canOperate) {
  535. this.$refs.filterPopup.close()
  536. return
  537. }
  538. this.$refs.filterPopup.close();
  539. // 应用筛选时,清空已显示列表,重新开始
  540. this.shownUserIds = [];
  541. this.refresh(false);
  542. },
  543. hasFilter(){
  544. const q=this.query
  545. 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)
  546. },
  547. onEduChange(e){
  548. const item = this.educationOptions[e.detail.value];
  549. this.query.educationMin = item.value;
  550. this.currentEduText = item.label;
  551. },
  552. onSalaryChange(e){
  553. const item = this.salaryOptions[e.detail.value];
  554. this.query.salaryMin = item.value;
  555. this.currentSalaryText = item.label;
  556. },
  557. onStarChange(e){
  558. const item = this.starOptions[e.detail.value];
  559. this.query.star = item.value || null;
  560. this.currentStarText = item.label;
  561. },
  562. onAnimalChange(e){
  563. const item = this.animalOptions[e.detail.value];
  564. this.query.animal = item.value || null;
  565. this.currentAnimalText = item.label;
  566. },
  567. buildQueryPayload(){
  568. const q = { ...this.query };
  569. if (this.hobbyInput) {
  570. q.hobbyTags = this.hobbyInput.split(',').map(s=>s.trim()).filter(Boolean)
  571. } else {
  572. delete q.hobbyTags
  573. }
  574. // 清理空值/空字符串/NaN,避免后端收到无效条件
  575. Object.keys(q).forEach(k => {
  576. const v = q[k];
  577. if (v === null || v === undefined || v === '' || (typeof v === 'number' && Number.isNaN(v))) {
  578. delete q[k]
  579. }
  580. })
  581. return q
  582. },
  583. resetFilter(){
  584. 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};
  585. this.hobbyInput=''; this.currentStarText=''; this.currentAnimalText='';
  586. this.areaDisplayText='';
  587. this.multiAreaIndex=[0, 0, 0];
  588. this.cityList=[]; this.areaList=[]
  589. // 重置多列选择器数据,保留省份列表
  590. if(this.provinceList.length > 0){
  591. this.multiAreaData[0] = this.provinceList
  592. this.multiAreaData[1] = []
  593. this.multiAreaData[2] = []
  594. }
  595. },
  596. async ensureAreaData(){
  597. // 加载省份列表
  598. if(!this.provinceList.length){
  599. try{
  600. this.provinceList = await api.area.getProvinces()
  601. // 初始化多列选择器的省份数据
  602. this.multiAreaData[0] = this.provinceList
  603. // 如果有省份,加载第一个省份的城市
  604. if(this.provinceList.length > 0){
  605. await this.loadCitiesForProvince(0)
  606. }
  607. }catch(e){
  608. console.error('加载省份失败:', e)
  609. }
  610. }
  611. },
  612. // 加载指定省份的城市
  613. async loadCitiesForProvince(provinceIndex){
  614. if(provinceIndex < 0 || provinceIndex >= this.provinceList.length) return
  615. const province = this.provinceList[provinceIndex]
  616. if(!province || !province.id) return
  617. try{
  618. const cities = await api.area.getCities(province.id)
  619. this.multiAreaData[1] = cities || []
  620. this.cityList = cities || []
  621. // 重置区域
  622. this.multiAreaData[2] = []
  623. this.areaList = []
  624. this.multiAreaIndex[1] = 0
  625. this.multiAreaIndex[2] = 0
  626. // 如果有城市,加载第一个城市的区域
  627. if(cities && cities.length > 0){
  628. await this.loadAreasForCity(0, cities)
  629. }
  630. }catch(err){
  631. console.error('加载城市失败:', err)
  632. this.multiAreaData[1] = []
  633. this.cityList = []
  634. this.multiAreaData[2] = []
  635. this.areaList = []
  636. }
  637. },
  638. // 加载指定城市的区域
  639. async loadAreasForCity(cityIndex, cities = null){
  640. const cityList = cities || this.cityList
  641. if(cityIndex < 0 || cityIndex >= cityList.length) return
  642. const city = cityList[cityIndex]
  643. if(!city || !city.id) return
  644. try{
  645. const areas = await api.area.getAreas(city.id)
  646. this.multiAreaData[2] = areas || []
  647. this.areaList = areas || []
  648. this.multiAreaIndex[2] = 0
  649. }catch(err){
  650. console.error('加载区域失败:', err)
  651. this.multiAreaData[2] = []
  652. this.areaList = []
  653. }
  654. },
  655. // 多列选择器列变化事件(滑动某一列时触发)
  656. async onMultiAreaColumnChange(e){
  657. const column = e.detail.column // 改变的列索引:0-省份,1-城市,2-区域
  658. const row = e.detail.value // 新选中的行索引
  659. if(column === 0){
  660. // 选择了省份,需要加载该省份的城市
  661. this.multiAreaIndex[0] = row
  662. await this.loadCitiesForProvince(row)
  663. }else if(column === 1){
  664. // 选择了城市,需要加载该城市的区域
  665. this.multiAreaIndex[1] = row
  666. await this.loadAreasForCity(row)
  667. }else if(column === 2){
  668. // 选择了区域
  669. this.multiAreaIndex[2] = row
  670. }
  671. },
  672. // 多列选择器确认选择事件
  673. onMultiAreaChange(e){
  674. const values = e.detail.value // [省份索引, 城市索引, 区域索引]
  675. this.multiAreaIndex = values
  676. // 从 multiAreaData 中获取选中的数据
  677. const provinceIndex = values[0]
  678. const cityIndex = values[1]
  679. const areaIndex = values[2]
  680. const province = this.multiAreaData[0] && this.multiAreaData[0][provinceIndex]
  681. const city = this.multiAreaData[1] && this.multiAreaData[1][cityIndex]
  682. const area = this.multiAreaData[2] && this.multiAreaData[2][areaIndex]
  683. // 更新查询参数
  684. this.query.provinceId = province?.id || null
  685. this.query.cityId = city?.id || null
  686. this.query.areaId = area?.id || null
  687. // 同步到单独的列表(用于兼容)
  688. if(province) {
  689. const pIdx = this.provinceList.findIndex(p => p.id === province.id)
  690. if(pIdx >= 0) {
  691. this.cityList = this.multiAreaData[1] || []
  692. if(city) {
  693. const cIdx = this.cityList.findIndex(c => c.id === city.id)
  694. if(cIdx >= 0) {
  695. this.areaList = this.multiAreaData[2] || []
  696. }
  697. }
  698. }
  699. }
  700. // 更新显示文本
  701. const parts = []
  702. if(province) parts.push(province.name)
  703. if(city) parts.push(city.name)
  704. if(area) parts.push(area.name)
  705. this.areaDisplayText = parts.length > 0 ? parts.join(' ') : '选择省市区'
  706. },
  707. getSafeAvatar(url){
  708. if(!url) return 'http://115.190.125.125:9001/static-images/close.png'
  709. const u = String(url)
  710. if(u.includes('example.com')) return 'http://115.190.125.125:9001/static-images/close.png'
  711. return u
  712. },
  713. fmtScore(s){ return s ? Number(s).toFixed(1) : '0.0' },
  714. fmtGender(g){ return g===1?'男':g===2?'女':'-' },
  715. fmtEdu(v){ const map={1:'高中',2:'大专',3:'本科',4:'硕士',5:'博士'}; return map[v]||'-' },
  716. fmtSalary(v){ const map={1:'<5k',2:'5-10k',3:'10-20k',4:'20-50k',5:'50k+'}; return map[v]||'-' },
  717. parseHobby(h){ try{ const arr = typeof h === 'string' ? JSON.parse(h) : h; return Array.isArray(arr)?arr.slice(0,6):[] }catch{return []} },
  718. async toggleLike(i){
  719. // 检查用户是否被禁用
  720. const canOperate = await userStatusCheck.checkAndTip()
  721. if (!canOperate) return
  722. const u=this.list[i];
  723. if(!u) return;
  724. const uid = parseInt(uni.getStorageSync('userId')||1);
  725. // 切换喜欢状态
  726. const newType = u.liked ? 'dislike' : 'like';
  727. // 调用 API 记录反馈
  728. if(u.userId){
  729. try {
  730. await api.recommend.feedback({ userId: uid, targetUserId: u.userId, type: newType });
  731. // 更新本地状态
  732. this.$set(this.list[i], 'liked', !u.liked);
  733. // 显示成功提示
  734. uni.showToast({ title: newType === 'like' ? '已喜欢' : '已取消喜欢', icon: 'success' });
  735. } catch(e) {
  736. console.error('反馈失败', e);
  737. }
  738. }
  739. },
  740. async openChat(user) {
  741. // 验证必要参数
  742. if (!user || !user.userId) {
  743. uni.showToast({
  744. title: '用户信息错误',
  745. icon: 'none'
  746. });
  747. return;
  748. }
  749. const targetUserId = parseInt(user.userId);
  750. const targetUserName = user.nickname || '用户';
  751. const targetUserAvatar = user.avatarUrl || 'http://115.190.125.125:9001/static-images/close.png';
  752. // 先导入用户到腾讯云IM(防止消息发送失败)
  753. uni.showLoading({ title: '准备中...' });
  754. try {
  755. // 获取当前用户ID
  756. const currentUserId = uni.getStorageSync('userId');
  757. // 导入当前用户
  758. await uni.request({
  759. url: 'https://api.zhongruanke.cn/api/im/importUser',
  760. method: 'POST',
  761. data: {
  762. userId: String(currentUserId),
  763. nickname: '用户' + currentUserId
  764. },
  765. header: {
  766. 'Content-Type': 'application/json'
  767. }
  768. });
  769. // 导入目标用户
  770. await uni.request({
  771. url: 'https://api.zhongruanke.cn/api/im/importUser',
  772. method: 'POST',
  773. data: {
  774. userId: String(targetUserId),
  775. nickname: targetUserName
  776. },
  777. header: {
  778. 'Content-Type': 'application/json'
  779. }
  780. });
  781. // 等待一小段时间确保导入生效
  782. await new Promise(resolve => setTimeout(resolve, 500));
  783. uni.hideLoading();
  784. // 跳转到聊天页面
  785. uni.navigateTo({
  786. url: `/subpkg-message/chat/chat?targetUserId=${targetUserId}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}`
  787. });
  788. } catch (error) {
  789. console.error('❌ 导入用户失败:', error);
  790. uni.hideLoading();
  791. // 即使导入失败也尝试打开聊天(用户可能已存在)
  792. uni.navigateTo({
  793. url: `/pages/message/chat?targetUserId=${targetUserId}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}`
  794. });
  795. }
  796. },
  797. dislike(i){
  798. const u=this.list[i];
  799. if(!u) return;
  800. this.list.splice(i,1);
  801. uni.showToast({ title:'已隐藏', icon:'none' });
  802. const uid = parseInt(uni.getStorageSync('userId')||1);
  803. if(u.userId){
  804. api.recommend.feedback({ userId: uid, targetUserId: u.userId, type: 'dislike' })
  805. }
  806. },
  807. onImgErr(idx){
  808. this.$set(this.list[idx], 'avatarUrl', 'http://115.190.125.125:9001/static-images/close.png')
  809. },
  810. // 通过索引显示用户详情(跳转到新页面)
  811. showUserDetailByIndex(index) {
  812. if (index < 0 || index >= this.list.length) {
  813. uni.showToast({
  814. title: '用户索引无效',
  815. icon: 'none'
  816. })
  817. return
  818. }
  819. const user = this.list[index]
  820. if (!user || !user.userId) {
  821. uni.showToast({
  822. title: '用户信息不存在',
  823. icon: 'none'
  824. })
  825. return
  826. }
  827. // 跳转到用户详情页面
  828. const score = user.compatibilityScore ? user.compatibilityScore : ''
  829. uni.navigateTo({
  830. url: `/pages/recommend/user-detail?userId=${user.userId}&score=${score}`
  831. })
  832. },
  833. // 显示用户详情
  834. async showUserDetail(user) {
  835. if (!user || !user.userId) {
  836. console.error('用户信息无效:', user)
  837. uni.showToast({
  838. title: '用户信息错误',
  839. icon: 'none'
  840. })
  841. return
  842. }
  843. // 确保userId是数字类型
  844. const userId = parseInt(user.userId)
  845. if (!userId || isNaN(userId)) {
  846. uni.showToast({
  847. title: '用户ID无效',
  848. icon: 'none'
  849. })
  850. return
  851. }
  852. // 先打开弹窗
  853. this.userDetail = null
  854. try {
  855. if (this.$refs.userDetailPopup) {
  856. this.$refs.userDetailPopup.open('center')
  857. } else {
  858. console.error('弹窗组件引用不存在')
  859. uni.showToast({
  860. title: '弹窗初始化失败',
  861. icon: 'none'
  862. })
  863. return
  864. }
  865. } catch (err) {
  866. console.error('打开弹窗失败:', err)
  867. uni.showToast({
  868. title: '打开弹窗失败',
  869. icon: 'none'
  870. })
  871. return
  872. }
  873. // 加载用户详情
  874. try {
  875. uni.showLoading({ title: '加载中...' })
  876. const detail = await api.user.getDetailInfo(userId)
  877. if (detail) {
  878. // 确保photos是数组,如果没有photos但有avatar,使用avatar
  879. if (!detail.photos || !Array.isArray(detail.photos)) {
  880. detail.photos = []
  881. if (detail.avatar) {
  882. detail.photos.push(detail.avatar)
  883. }
  884. }
  885. // 确保所有字段都有默认值,避免显示undefined
  886. if (!detail.nickname) detail.nickname = '未设置'
  887. this.userDetail = detail
  888. } else {
  889. uni.showToast({
  890. title: '用户信息为空',
  891. icon: 'none'
  892. })
  893. if (this.$refs.userDetailPopup) {
  894. this.$refs.userDetailPopup.close()
  895. }
  896. }
  897. } catch (e) {
  898. console.error('获取用户详情失败:', e)
  899. const errorMsg = e && e.message ? e.message : '获取用户信息失败'
  900. uni.showToast({
  901. title: errorMsg,
  902. icon: 'none',
  903. duration: 2000
  904. })
  905. // 如果加载失败,关闭弹窗
  906. if (this.$refs.userDetailPopup) {
  907. this.$refs.userDetailPopup.close()
  908. }
  909. } finally {
  910. uni.hideLoading()
  911. }
  912. },
  913. // 关闭用户详情
  914. closeUserDetail() {
  915. try {
  916. if (this.$refs.userDetailPopup) {
  917. this.$refs.userDetailPopup.close()
  918. }
  919. } catch (e) {
  920. console.error('关闭弹窗失败:', e)
  921. }
  922. this.userDetail = null
  923. },
  924. // 预览照片
  925. previewPhoto(index) {
  926. if (!this.userDetail || !this.userDetail.photos || !Array.isArray(this.userDetail.photos) || this.userDetail.photos.length === 0) {
  927. return
  928. }
  929. uni.previewImage({
  930. urls: this.userDetail.photos,
  931. current: index
  932. })
  933. },
  934. // 照片加载错误处理
  935. onPhotoError(e) {
  936. console.error('照片加载失败:', e)
  937. }
  938. }
  939. }
  940. </script>
  941. <style lang="scss" scoped>
  942. /* 扁平化设计风格 */
  943. .recommend-page {
  944. min-height: 100vh;
  945. background-color: #F5F5F5;
  946. padding-bottom: 120rpx;
  947. }
  948. .toolbar{
  949. display: flex;
  950. justify-content: space-between;
  951. align-items: center;
  952. padding: 16rpx 20rpx;
  953. background: #FFFFFF;
  954. border-bottom: 2rpx solid #E0E0E0;
  955. }
  956. /* 选项卡样式 - 扁平化 */
  957. .tab-container {
  958. display: flex;
  959. margin: 20rpx;
  960. background: #FFFFFF;
  961. border-radius: 8rpx;
  962. border: 2rpx solid #E0E0E0;
  963. overflow: hidden;
  964. }
  965. .tab-item {
  966. flex: 1;
  967. display: flex;
  968. align-items: center;
  969. justify-content: center;
  970. padding: 18rpx 20rpx;
  971. transition: all 0.2s ease;
  972. border-right: 2rpx solid #E0E0E0;
  973. &:last-child {
  974. border-right: none;
  975. }
  976. .tab-icon {
  977. font-size: 28rpx;
  978. margin-right: 8rpx;
  979. }
  980. .tab-text {
  981. font-size: 28rpx;
  982. font-weight: 500;
  983. }
  984. &.active {
  985. .tab-icon {
  986. color: #E91E63;
  987. }
  988. .tab-text {
  989. color: #E91E63;
  990. font-weight: 600;
  991. }
  992. }
  993. &:not(.active) {
  994. background: #FFFFFF;
  995. .tab-icon {
  996. color: #999;
  997. }
  998. .tab-text {
  999. color: #666;
  1000. }
  1001. }
  1002. }
  1003. .tool-text{
  1004. font-size: 26rpx;
  1005. color: #666;
  1006. }
  1007. .tool-btn{
  1008. height: 64rpx;
  1009. padding: 0 24rpx;
  1010. border-radius: 8rpx;
  1011. display: flex;
  1012. align-items: center;
  1013. gap: 10rpx;
  1014. font-size: 26rpx;
  1015. background: #FFFFFF;
  1016. border: 2rpx solid #E0E0E0;
  1017. color: #333;
  1018. transition: all 0.2s ease;
  1019. &:active {
  1020. opacity: 0.8;
  1021. }
  1022. }
  1023. .tool-btn .icon{
  1024. font-size: 28rpx;
  1025. }
  1026. .refresh-btn{
  1027. background: #FFE5F1;
  1028. border-color: #E91E63;
  1029. color: #E91E63;
  1030. }
  1031. .filter-btn{
  1032. background: #FFFFFF;
  1033. border-color: #E0E0E0;
  1034. color: #333;
  1035. }
  1036. .list{
  1037. height: calc(100vh - 260rpx);
  1038. padding: 0 20rpx;
  1039. }
  1040. .skeleton{
  1041. padding: 40rpx;
  1042. text-align: center;
  1043. color: #999;
  1044. }
  1045. .empty{
  1046. padding: 60rpx 20rpx;
  1047. text-align: center;
  1048. color: #999;
  1049. font-size: 26rpx;
  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>