index.vue 43 KB

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