index.vue 45 KB

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