index.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  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 active" @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" @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 v-if="unreadCount >= 1" class="tabbar-badge">{{ unreadCount }}</view>
  240. </view> -->
  241. <view class="tabbar-item" @click="switchTab('mine')">
  242. <text class="tabbar-icon">👤</text>
  243. <text class="tabbar-text">我的</text>
  244. </view>
  245. </view>
  246. </view>
  247. </template>
  248. <script>
  249. import api from '@/utils/api.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(){ this.ensureAreaData(); this.$refs.filterPopup.open('bottom') },
  522. closeFilter(){ this.$refs.filterPopup.close() },
  523. applyFilter(){
  524. this.$refs.filterPopup.close();
  525. // 应用筛选时,清空已显示列表,重新开始
  526. this.shownUserIds = [];
  527. this.refresh(false);
  528. },
  529. hasFilter(){
  530. const q=this.query
  531. 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)
  532. },
  533. onEduChange(e){
  534. const item = this.educationOptions[e.detail.value];
  535. this.query.educationMin = item.value;
  536. this.currentEduText = item.label;
  537. },
  538. onSalaryChange(e){
  539. const item = this.salaryOptions[e.detail.value];
  540. this.query.salaryMin = item.value;
  541. this.currentSalaryText = item.label;
  542. },
  543. onStarChange(e){
  544. const item = this.starOptions[e.detail.value];
  545. this.query.star = item.value || null;
  546. this.currentStarText = item.label;
  547. },
  548. onAnimalChange(e){
  549. const item = this.animalOptions[e.detail.value];
  550. this.query.animal = item.value || null;
  551. this.currentAnimalText = item.label;
  552. },
  553. buildQueryPayload(){
  554. const q = { ...this.query };
  555. if (this.hobbyInput) {
  556. q.hobbyTags = this.hobbyInput.split(',').map(s=>s.trim()).filter(Boolean)
  557. } else {
  558. delete q.hobbyTags
  559. }
  560. // 清理空值/空字符串/NaN,避免后端收到无效条件
  561. Object.keys(q).forEach(k => {
  562. const v = q[k];
  563. if (v === null || v === undefined || v === '' || (typeof v === 'number' && Number.isNaN(v))) {
  564. delete q[k]
  565. }
  566. })
  567. return q
  568. },
  569. resetFilter(){
  570. 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};
  571. this.hobbyInput=''; this.currentStarText=''; this.currentAnimalText='';
  572. this.areaDisplayText='';
  573. this.multiAreaIndex=[0, 0, 0];
  574. this.cityList=[]; this.areaList=[]
  575. // 重置多列选择器数据,保留省份列表
  576. if(this.provinceList.length > 0){
  577. this.multiAreaData[0] = this.provinceList
  578. this.multiAreaData[1] = []
  579. this.multiAreaData[2] = []
  580. }
  581. },
  582. async ensureAreaData(){
  583. // 加载省份列表
  584. if(!this.provinceList.length){
  585. try{
  586. this.provinceList = await api.area.getProvinces()
  587. // 初始化多列选择器的省份数据
  588. this.multiAreaData[0] = this.provinceList
  589. // 如果有省份,加载第一个省份的城市
  590. if(this.provinceList.length > 0){
  591. await this.loadCitiesForProvince(0)
  592. }
  593. }catch(e){
  594. console.error('加载省份失败:', e)
  595. }
  596. }
  597. },
  598. // 加载指定省份的城市
  599. async loadCitiesForProvince(provinceIndex){
  600. if(provinceIndex < 0 || provinceIndex >= this.provinceList.length) return
  601. const province = this.provinceList[provinceIndex]
  602. if(!province || !province.id) return
  603. try{
  604. const cities = await api.area.getCities(province.id)
  605. this.multiAreaData[1] = cities || []
  606. this.cityList = cities || []
  607. // 重置区域
  608. this.multiAreaData[2] = []
  609. this.areaList = []
  610. this.multiAreaIndex[1] = 0
  611. this.multiAreaIndex[2] = 0
  612. // 如果有城市,加载第一个城市的区域
  613. if(cities && cities.length > 0){
  614. await this.loadAreasForCity(0, cities)
  615. }
  616. }catch(err){
  617. console.error('加载城市失败:', err)
  618. this.multiAreaData[1] = []
  619. this.cityList = []
  620. this.multiAreaData[2] = []
  621. this.areaList = []
  622. }
  623. },
  624. // 加载指定城市的区域
  625. async loadAreasForCity(cityIndex, cities = null){
  626. const cityList = cities || this.cityList
  627. if(cityIndex < 0 || cityIndex >= cityList.length) return
  628. const city = cityList[cityIndex]
  629. if(!city || !city.id) return
  630. try{
  631. const areas = await api.area.getAreas(city.id)
  632. this.multiAreaData[2] = areas || []
  633. this.areaList = areas || []
  634. this.multiAreaIndex[2] = 0
  635. }catch(err){
  636. console.error('加载区域失败:', err)
  637. this.multiAreaData[2] = []
  638. this.areaList = []
  639. }
  640. },
  641. // 多列选择器列变化事件(滑动某一列时触发)
  642. async onMultiAreaColumnChange(e){
  643. const column = e.detail.column // 改变的列索引:0-省份,1-城市,2-区域
  644. const row = e.detail.value // 新选中的行索引
  645. if(column === 0){
  646. // 选择了省份,需要加载该省份的城市
  647. this.multiAreaIndex[0] = row
  648. await this.loadCitiesForProvince(row)
  649. }else if(column === 1){
  650. // 选择了城市,需要加载该城市的区域
  651. this.multiAreaIndex[1] = row
  652. await this.loadAreasForCity(row)
  653. }else if(column === 2){
  654. // 选择了区域
  655. this.multiAreaIndex[2] = row
  656. }
  657. },
  658. // 多列选择器确认选择事件
  659. onMultiAreaChange(e){
  660. const values = e.detail.value // [省份索引, 城市索引, 区域索引]
  661. this.multiAreaIndex = values
  662. // 从 multiAreaData 中获取选中的数据
  663. const provinceIndex = values[0]
  664. const cityIndex = values[1]
  665. const areaIndex = values[2]
  666. const province = this.multiAreaData[0] && this.multiAreaData[0][provinceIndex]
  667. const city = this.multiAreaData[1] && this.multiAreaData[1][cityIndex]
  668. const area = this.multiAreaData[2] && this.multiAreaData[2][areaIndex]
  669. // 更新查询参数
  670. this.query.provinceId = province?.id || null
  671. this.query.cityId = city?.id || null
  672. this.query.areaId = area?.id || null
  673. // 同步到单独的列表(用于兼容)
  674. if(province) {
  675. const pIdx = this.provinceList.findIndex(p => p.id === province.id)
  676. if(pIdx >= 0) {
  677. this.cityList = this.multiAreaData[1] || []
  678. if(city) {
  679. const cIdx = this.cityList.findIndex(c => c.id === city.id)
  680. if(cIdx >= 0) {
  681. this.areaList = this.multiAreaData[2] || []
  682. }
  683. }
  684. }
  685. }
  686. // 更新显示文本
  687. const parts = []
  688. if(province) parts.push(province.name)
  689. if(city) parts.push(city.name)
  690. if(area) parts.push(area.name)
  691. this.areaDisplayText = parts.length > 0 ? parts.join(' ') : '选择省市区'
  692. },
  693. getSafeAvatar(url){
  694. if(!url) return 'http://115.190.125.125:9001/static-images/close.png'
  695. const u = String(url)
  696. if(u.includes('example.com')) return 'http://115.190.125.125:9001/static-images/close.png'
  697. return u
  698. },
  699. fmtScore(s){ return s ? Number(s).toFixed(1) : '0.0' },
  700. fmtGender(g){ return g===1?'男':g===2?'女':'-' },
  701. fmtEdu(v){ const map={1:'高中',2:'大专',3:'本科',4:'硕士',5:'博士'}; return map[v]||'-' },
  702. fmtSalary(v){ const map={1:'<5k',2:'5-10k',3:'10-20k',4:'20-50k',5:'50k+'}; return map[v]||'-' },
  703. parseHobby(h){ try{ const arr = typeof h === 'string' ? JSON.parse(h) : h; return Array.isArray(arr)?arr.slice(0,6):[] }catch{return []} },
  704. async toggleLike(i){
  705. const u=this.list[i];
  706. if(!u) return;
  707. const uid = parseInt(uni.getStorageSync('userId')||1);
  708. // 切换喜欢状态
  709. const newType = u.liked ? 'dislike' : 'like';
  710. // 调用 API 记录反馈
  711. if(u.userId){
  712. try {
  713. await api.recommend.feedback({ userId: uid, targetUserId: u.userId, type: newType });
  714. // 更新本地状态
  715. this.$set(this.list[i], 'liked', !u.liked);
  716. // 显示成功提示
  717. uni.showToast({ title: newType === 'like' ? '已喜欢' : '已取消喜欢', icon: 'success' });
  718. } catch(e) {
  719. console.error('反馈失败', e);
  720. }
  721. }
  722. },
  723. async openChat(user) {
  724. // 验证必要参数
  725. if (!user || !user.userId) {
  726. uni.showToast({
  727. title: '用户信息错误',
  728. icon: 'none'
  729. });
  730. return;
  731. }
  732. const targetUserId = parseInt(user.userId);
  733. const targetUserName = user.nickname || '用户';
  734. const targetUserAvatar = user.avatarUrl || 'http://115.190.125.125:9001/static-images/close.png';
  735. // 先导入用户到腾讯云IM(防止消息发送失败)
  736. uni.showLoading({ title: '准备中...' });
  737. try {
  738. // 获取当前用户ID
  739. const currentUserId = uni.getStorageSync('userId');
  740. // 导入当前用户
  741. await uni.request({
  742. url: 'https://api.zhongruanke.cn/api/im/importUser',
  743. method: 'POST',
  744. data: {
  745. userId: String(currentUserId),
  746. nickname: '用户' + currentUserId
  747. },
  748. header: {
  749. 'Content-Type': 'application/json'
  750. }
  751. });
  752. // 导入目标用户
  753. await uni.request({
  754. url: 'https://api.zhongruanke.cn/api/im/importUser',
  755. method: 'POST',
  756. data: {
  757. userId: String(targetUserId),
  758. nickname: targetUserName
  759. },
  760. header: {
  761. 'Content-Type': 'application/json'
  762. }
  763. });
  764. // 等待一小段时间确保导入生效
  765. await new Promise(resolve => setTimeout(resolve, 500));
  766. uni.hideLoading();
  767. // 跳转到聊天页面
  768. uni.navigateTo({
  769. url: `/subpkg-message/chat/chat?targetUserId=${targetUserId}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}`
  770. });
  771. } catch (error) {
  772. console.error('❌ 导入用户失败:', error);
  773. uni.hideLoading();
  774. // 即使导入失败也尝试打开聊天(用户可能已存在)
  775. uni.navigateTo({
  776. url: `/pages/message/chat?targetUserId=${targetUserId}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}`
  777. });
  778. }
  779. },
  780. dislike(i){
  781. const u=this.list[i];
  782. if(!u) return;
  783. this.list.splice(i,1);
  784. uni.showToast({ title:'已隐藏', icon:'none' });
  785. const uid = parseInt(uni.getStorageSync('userId')||1);
  786. if(u.userId){
  787. api.recommend.feedback({ userId: uid, targetUserId: u.userId, type: 'dislike' })
  788. }
  789. },
  790. onImgErr(idx){
  791. this.$set(this.list[idx], 'avatarUrl', 'http://115.190.125.125:9001/static-images/close.png')
  792. },
  793. // 通过索引显示用户详情(跳转到新页面)
  794. showUserDetailByIndex(index) {
  795. if (index < 0 || index >= this.list.length) {
  796. uni.showToast({
  797. title: '用户索引无效',
  798. icon: 'none'
  799. })
  800. return
  801. }
  802. const user = this.list[index]
  803. if (!user || !user.userId) {
  804. uni.showToast({
  805. title: '用户信息不存在',
  806. icon: 'none'
  807. })
  808. return
  809. }
  810. // 跳转到用户详情页面
  811. const score = user.compatibilityScore ? user.compatibilityScore : ''
  812. uni.navigateTo({
  813. url: `/pages/recommend/user-detail?userId=${user.userId}&score=${score}`
  814. })
  815. },
  816. // 显示用户详情
  817. async showUserDetail(user) {
  818. if (!user || !user.userId) {
  819. console.error('用户信息无效:', user)
  820. uni.showToast({
  821. title: '用户信息错误',
  822. icon: 'none'
  823. })
  824. return
  825. }
  826. // 确保userId是数字类型
  827. const userId = parseInt(user.userId)
  828. if (!userId || isNaN(userId)) {
  829. uni.showToast({
  830. title: '用户ID无效',
  831. icon: 'none'
  832. })
  833. return
  834. }
  835. // 先打开弹窗
  836. this.userDetail = null
  837. try {
  838. if (this.$refs.userDetailPopup) {
  839. this.$refs.userDetailPopup.open('center')
  840. } else {
  841. console.error('弹窗组件引用不存在')
  842. uni.showToast({
  843. title: '弹窗初始化失败',
  844. icon: 'none'
  845. })
  846. return
  847. }
  848. } catch (err) {
  849. console.error('打开弹窗失败:', err)
  850. uni.showToast({
  851. title: '打开弹窗失败',
  852. icon: 'none'
  853. })
  854. return
  855. }
  856. // 加载用户详情
  857. try {
  858. uni.showLoading({ title: '加载中...' })
  859. const detail = await api.user.getDetailInfo(userId)
  860. if (detail) {
  861. // 确保photos是数组,如果没有photos但有avatar,使用avatar
  862. if (!detail.photos || !Array.isArray(detail.photos)) {
  863. detail.photos = []
  864. if (detail.avatar) {
  865. detail.photos.push(detail.avatar)
  866. }
  867. }
  868. // 确保所有字段都有默认值,避免显示undefined
  869. if (!detail.nickname) detail.nickname = '未设置'
  870. this.userDetail = detail
  871. } else {
  872. uni.showToast({
  873. title: '用户信息为空',
  874. icon: 'none'
  875. })
  876. if (this.$refs.userDetailPopup) {
  877. this.$refs.userDetailPopup.close()
  878. }
  879. }
  880. } catch (e) {
  881. console.error('获取用户详情失败:', e)
  882. const errorMsg = e && e.message ? e.message : '获取用户信息失败'
  883. uni.showToast({
  884. title: errorMsg,
  885. icon: 'none',
  886. duration: 2000
  887. })
  888. // 如果加载失败,关闭弹窗
  889. if (this.$refs.userDetailPopup) {
  890. this.$refs.userDetailPopup.close()
  891. }
  892. } finally {
  893. uni.hideLoading()
  894. }
  895. },
  896. // 关闭用户详情
  897. closeUserDetail() {
  898. try {
  899. if (this.$refs.userDetailPopup) {
  900. this.$refs.userDetailPopup.close()
  901. }
  902. } catch (e) {
  903. console.error('关闭弹窗失败:', e)
  904. }
  905. this.userDetail = null
  906. },
  907. // 预览照片
  908. previewPhoto(index) {
  909. if (!this.userDetail || !this.userDetail.photos || !Array.isArray(this.userDetail.photos) || this.userDetail.photos.length === 0) {
  910. return
  911. }
  912. uni.previewImage({
  913. urls: this.userDetail.photos,
  914. current: index
  915. })
  916. },
  917. // 照片加载错误处理
  918. onPhotoError(e) {
  919. console.error('照片加载失败:', e)
  920. }
  921. }
  922. }
  923. </script>
  924. <style lang="scss" scoped>
  925. /* 扁平化设计风格 */
  926. .recommend-page {
  927. min-height: 100vh;
  928. background-color: #F5F5F5;
  929. padding-bottom: 120rpx;
  930. }
  931. .toolbar{
  932. display: flex;
  933. justify-content: space-between;
  934. align-items: center;
  935. padding: 16rpx 20rpx;
  936. background: #FFFFFF;
  937. border-bottom: 2rpx solid #E0E0E0;
  938. }
  939. /* 选项卡样式 - 扁平化 */
  940. .tab-container {
  941. display: flex;
  942. margin: 20rpx;
  943. background: #FFFFFF;
  944. border-radius: 8rpx;
  945. border: 2rpx solid #E0E0E0;
  946. overflow: hidden;
  947. }
  948. .tab-item {
  949. flex: 1;
  950. display: flex;
  951. align-items: center;
  952. justify-content: center;
  953. padding: 18rpx 20rpx;
  954. transition: all 0.2s ease;
  955. border-right: 2rpx solid #E0E0E0;
  956. &:last-child {
  957. border-right: none;
  958. }
  959. .tab-icon {
  960. font-size: 28rpx;
  961. margin-right: 8rpx;
  962. }
  963. .tab-text {
  964. font-size: 28rpx;
  965. font-weight: 500;
  966. }
  967. &.active {
  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. .first-icon{
  1176. width: 25px;
  1177. height: 25px;
  1178. margin-bottom: 5px;
  1179. margin-top: 5px;
  1180. }
  1181. .tabbar-text {
  1182. font-size: 22rpx;
  1183. color: #666666;
  1184. }
  1185. &.active {
  1186. .tabbar-text {
  1187. color: #E91E63;
  1188. font-weight: bold;
  1189. }
  1190. }
  1191. }
  1192. }
  1193. .tabbar-item {
  1194. flex: 1;
  1195. display: flex;
  1196. flex-direction: column;
  1197. align-items: center;
  1198. justify-content: center;
  1199. padding: 18rpx 0;
  1200. transition: all 0.2s ease;
  1201. &:active {
  1202. background: #F5F5F5;
  1203. }
  1204. }
  1205. .tabbar-icon {
  1206. font-size: 46rpx;
  1207. margin-bottom: 8rpx;
  1208. }
  1209. .tabbar-text {
  1210. font-size: 22rpx;
  1211. color: #666666;
  1212. font-weight: 500;
  1213. }
  1214. .tabbar-item.active {
  1215. .tabbar-text {
  1216. color: #E91E63;
  1217. font-weight: 700;
  1218. }
  1219. }
  1220. /* 筛选抽屉 - 扁平化 */
  1221. .filter-sheet{
  1222. background: #FFFFFF;
  1223. border-top-left-radius: 16rpx;
  1224. border-top-right-radius: 16rpx;
  1225. padding-bottom: env(safe-area-inset-bottom);
  1226. border-top: 2rpx solid #E0E0E0;
  1227. }
  1228. .sheet-handle{
  1229. width: 120rpx;
  1230. height: 8rpx;
  1231. background: #E0E0E0;
  1232. border-radius: 4rpx;
  1233. margin: 16rpx auto;
  1234. }
  1235. .sheet-title{
  1236. text-align: center;
  1237. font-size: 32rpx;
  1238. font-weight: 600;
  1239. color: #333;
  1240. margin-bottom: 10rpx;
  1241. padding: 0 28rpx;
  1242. border-bottom: 2rpx solid #E0E0E0;
  1243. padding-bottom: 16rpx;
  1244. }
  1245. .sheet-body{
  1246. padding: 20rpx 28rpx;
  1247. max-height: 60vh;
  1248. overflow: auto;
  1249. }
  1250. .field{
  1251. margin: 18rpx 0;
  1252. }
  1253. .field.two{
  1254. display: flex;
  1255. align-items: center;
  1256. }
  1257. .field-label{
  1258. width: 160rpx;
  1259. color: #666;
  1260. font-size: 26rpx;
  1261. font-weight: 500;
  1262. }
  1263. .ipt{
  1264. flex: 1;
  1265. height: 70rpx;
  1266. line-height: 70rpx;
  1267. background: #F5F5F5;
  1268. border-radius: 8rpx;
  1269. padding: 0 20rpx;
  1270. margin-right: 12rpx;
  1271. font-size: 26rpx;
  1272. display: flex;
  1273. align-items: center;
  1274. border: 2rpx solid #E0E0E0;
  1275. }
  1276. .ipt.full{
  1277. width: 100%;
  1278. margin-right: 0;
  1279. }
  1280. .dash{
  1281. color: #999;
  1282. margin-right: 12rpx;
  1283. }
  1284. .seg{
  1285. display: flex;
  1286. gap: 14rpx;
  1287. }
  1288. .seg-item{
  1289. flex: 1;
  1290. text-align: center;
  1291. padding: 14rpx 0;
  1292. border-radius: 8rpx;
  1293. background: #F5F5F5;
  1294. color: #666;
  1295. font-size: 26rpx;
  1296. border: 2rpx solid #E0E0E0;
  1297. transition: all 0.2s ease;
  1298. }
  1299. .seg-item.active{
  1300. background: #FFE5F1;
  1301. color: #E91E63;
  1302. font-weight: 600;
  1303. border-color: #E91E63;
  1304. }
  1305. .sheet-actions{
  1306. display: flex;
  1307. gap: 16rpx;
  1308. padding: 16rpx 28rpx 28rpx;
  1309. border-top: 2rpx solid #E0E0E0;
  1310. }
  1311. .btn{
  1312. flex: 1;
  1313. height: 80rpx;
  1314. border-radius: 8rpx;
  1315. display: flex;
  1316. align-items: center;
  1317. justify-content: center;
  1318. font-size: 28rpx;
  1319. font-weight: 600;
  1320. transition: all 0.2s ease;
  1321. &:active {
  1322. opacity: 0.8;
  1323. }
  1324. }
  1325. .btn.ghost{
  1326. background: #F5F5F5;
  1327. color: #666;
  1328. border: 2rpx solid #E0E0E0;
  1329. }
  1330. .btn.primary{
  1331. background: #E91E63;
  1332. color: #FFFFFF;
  1333. border: none;
  1334. }
  1335. /* 用户详情弹窗样式 */
  1336. .user-detail-popup {
  1337. width: 600rpx;
  1338. max-height: 70vh;
  1339. background: #FFFFFF;
  1340. border-radius: 16rpx;
  1341. overflow: hidden;
  1342. display: flex;
  1343. flex-direction: column;
  1344. }
  1345. .popup-header {
  1346. display: flex;
  1347. align-items: center;
  1348. justify-content: space-between;
  1349. padding: 20rpx 24rpx;
  1350. border-bottom: 2rpx solid #E0E0E0;
  1351. background: #FFFFFF;
  1352. }
  1353. .popup-title {
  1354. font-size: 32rpx;
  1355. font-weight: 600;
  1356. color: #333;
  1357. }
  1358. .popup-close {
  1359. font-size: 40rpx;
  1360. color: #999;
  1361. width: 60rpx;
  1362. height: 60rpx;
  1363. display: flex;
  1364. align-items: center;
  1365. justify-content: center;
  1366. border-radius: 50%;
  1367. transition: all 0.2s ease;
  1368. }
  1369. .popup-close:active {
  1370. background: #F5F5F5;
  1371. }
  1372. .popup-content {
  1373. flex: 1;
  1374. padding: 20rpx 24rpx;
  1375. max-height: calc(70vh - 120rpx);
  1376. }
  1377. .popup-loading {
  1378. padding: 60rpx 20rpx;
  1379. text-align: center;
  1380. color: #999;
  1381. font-size: 26rpx;
  1382. }
  1383. .detail-section {
  1384. margin-bottom: 32rpx;
  1385. }
  1386. .section-title {
  1387. font-size: 28rpx;
  1388. font-weight: 600;
  1389. color: #333;
  1390. margin-bottom: 16rpx;
  1391. padding-bottom: 12rpx;
  1392. border-bottom: 2rpx solid #F0F0F0;
  1393. }
  1394. /* 照片区域 */
  1395. .photos-section {
  1396. margin-bottom: 32rpx;
  1397. }
  1398. .photos-grid {
  1399. display: grid;
  1400. grid-template-columns: repeat(3, 1fr);
  1401. gap: 12rpx;
  1402. }
  1403. .photo-item {
  1404. width: 100%;
  1405. height: 200rpx;
  1406. border-radius: 8rpx;
  1407. background: #F5F5F5;
  1408. border: 2rpx solid #E0E0E0;
  1409. }
  1410. /* 信息网格 */
  1411. .detail-info-grid {
  1412. display: grid;
  1413. grid-template-columns: repeat(2, 1fr);
  1414. gap: 16rpx;
  1415. }
  1416. .info-item {
  1417. display: flex;
  1418. flex-direction: column;
  1419. padding: 16rpx;
  1420. background: #F8F9FA;
  1421. border-radius: 8rpx;
  1422. border: 1rpx solid #E0E0E0;
  1423. }
  1424. .info-label {
  1425. font-size: 22rpx;
  1426. color: #999;
  1427. margin-bottom: 8rpx;
  1428. }
  1429. .info-value {
  1430. font-size: 26rpx;
  1431. color: #333;
  1432. font-weight: 500;
  1433. }
  1434. /* 兴趣爱好标签 */
  1435. .hobby-tags {
  1436. display: flex;
  1437. flex-wrap: wrap;
  1438. gap: 12rpx;
  1439. }
  1440. .hobby-tag {
  1441. background: #FFE5F1;
  1442. color: #E91E63;
  1443. padding: 10rpx 18rpx;
  1444. border-radius: 20rpx;
  1445. font-size: 24rpx;
  1446. border: 1rpx solid #FFD0DC;
  1447. }
  1448. /* 自我简介 */
  1449. .introduction-content {
  1450. background: #F8F9FA;
  1451. padding: 20rpx;
  1452. border-radius: 8rpx;
  1453. border-left: 4rpx solid #E91E63;
  1454. line-height: 1.8;
  1455. }
  1456. .introduction-content text {
  1457. font-size: 26rpx;
  1458. color: #666;
  1459. line-height: 1.8;
  1460. }
  1461. .tabbar-badge {
  1462. position: absolute;
  1463. top: 8rpx;
  1464. right: 50%;
  1465. margin-right: -40rpx;
  1466. min-width: 32rpx;
  1467. height: 32rpx;
  1468. line-height: 32rpx;
  1469. padding: 0 6rpx;
  1470. background-color: #FA5151;
  1471. border-radius: 16rpx;
  1472. font-size: 20rpx;
  1473. color: #FFFFFF;
  1474. text-align: center;
  1475. }
  1476. </style>