index.vue 44 KB

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