index.vue 45 KB

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