my-resources.vue 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845
  1. <template>
  2. <view class="my-resources">
  3. <view class="status-bar-placeholder" :style="{height: statusBarHeight + 'px', backgroundColor: '#FFFFFF'}"></view>
  4. <!-- 顶部导航栏 -->
  5. <view class="header">
  6. <view class="header-left" @click="goBack">
  7. <text class="back-icon">←</text>
  8. </view>
  9. <text class="header-title">我的资源</text>
  10. <view class="header-right">
  11. <text class="dropdown-arrow">▼</text>
  12. </view>
  13. </view>
  14. <!-- 搜索栏 -->
  15. <view class="search-bar">
  16. <view class="search-input-wrapper">
  17. <view class="search-icon-small"></view>
  18. <input type="text" class="search-input" placeholder="请输入姓名、手机号或标签(如:温柔)" v-model="searchKeyword" @input="handleSearch" />
  19. </view>
  20. </view>
  21. <!-- 资源/线索切换标签 -->
  22. <view class="tab-switcher">
  23. <view class="tab-item" :class="{ active: currentTab === 'resource' }" @click="switchToResource">
  24. <text class="tab-text">资源</text>
  25. <text class="tab-count">({{ registeredTotal }})</text>
  26. </view>
  27. <view class="tab-item" :class="{ active: currentTab === 'clue' }" @click="switchToClue">
  28. <text class="tab-text">线索</text>
  29. <text class="tab-count">({{ unregisteredTotal }})</text>
  30. </view>
  31. </view>
  32. <scroll-view scroll-y class="content" @scrolltolower="handleScrollToLower" :lower-threshold="50" :enable-back-to-top="true" :scroll-with-animation="true">
  33. <!-- 资源部分(已注册用户) -->
  34. <view class="resource-section" v-if="currentTab === 'resource'">
  35. <view class="section-header" v-if="registeredResources.length > 0">
  36. <text class="section-title">资源</text>
  37. <text class="section-count">({{ registeredTotal }})</text>
  38. </view>
  39. <view class="resource-list-container">
  40. <view class="resource-item" v-for="(item, index) in getRegisteredDisplayData" :key="getRegisteredItemKey(item, index)" @click="handleResourceClickSafe(item, index)">
  41. <!-- 右上角选中图标(左移) -->
  42. <view class="select-icon">✓-</view>
  43. <!-- 编辑按钮 -->
  44. <view class="edit-icon" @click.stop="handleEdit(item.id || item.resourceId || item.resource_id)">
  45. <text class="edit-text">编辑</text>
  46. </view>
  47. <view class="resource-header">
  48. <image
  49. :src="item.avatar"
  50. mode="aspectFill"
  51. class="resource-avatar"
  52. @error="handleImageErrorRegistered(index)"
  53. @load="handleImageLoadRegistered(index)"
  54. :lazy-load="true"
  55. ></image>
  56. <view class="resource-basic-info">
  57. <view class="name-gender">
  58. <text class="resource-name">{{ item.name }}</text>
  59. <text class="resource-gender gender-tag">{{ item.gender }}</text>
  60. </view>
  61. <view class="status-tag-wrapper">
  62. <text class="status-tag register-tag registered">已注册</text>
  63. <text class="status-tag match-tag" :class="{ 'matched': item.isMatch === 1, 'unmatched': item.isMatch === 0 || !item.isMatch }">
  64. {{ item.isMatch === 1 ? '已匹配' : '未匹配' }}
  65. </text>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="resource-details">
  70. <view class="labels">
  71. <text class="label" v-for="(label, idx) in item.labels" :key="idx">{{ label }}</text>
  72. </view>
  73. <view class="requirement-box">
  74. <text class="requirement-label">择偶要求:</text>
  75. <text class="requirement-content">{{ item.requirement }}</text>
  76. </view>
  77. <view class="contact-box">
  78. <text class="contact-label">联系方式:</text>
  79. <text class="contact-number">{{ item.contact }}</text>
  80. <text class="copy-btn" @click.stop="handleCopyContact(item.originalPhone || item.contact)">复制</text>
  81. </view>
  82. <view class="action-buttons">
  83. <view class="delete-btn" @click.stop="handleDelete(item.id || item.resourceId || item.resource_id)">删除</view>
  84. <view class="match-btn" @click.stop="handleMatch(item.id || item.resourceId || item.resource_id)">精准匹配</view>
  85. </view>
  86. </view>
  87. <!-- 优质资源标签 -->
  88. <view class="quality-tag" v-if="item.isQuality">
  89. <text class="quality-star">★</text>
  90. <text class="quality-text">优质资源</text>
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 加载更多提示 -->
  95. <view class="load-more-tip" v-if="registeredResources.length < registeredTotal && currentTab === 'resource'">
  96. <text class="load-more-text">下拉加载更多</text>
  97. </view>
  98. <!-- 没有更多数据提示 -->
  99. <view class="no-more-tip" v-if="registeredResources.length >= registeredTotal && registeredTotal > 0 && currentTab === 'resource'">
  100. <text class="no-more-text">已加载全部数据</text>
  101. </view>
  102. </view>
  103. <!-- 线索部分(未注册用户) -->
  104. <view class="resource-section" v-if="currentTab === 'clue'">
  105. <view class="section-header" v-if="unregisteredResources.length > 0">
  106. <text class="section-title">线索</text>
  107. <text class="section-count">({{ unregisteredTotal }})</text>
  108. </view>
  109. <view class="resource-list-container">
  110. <view class="resource-item" v-for="(item, index) in getUnregisteredDisplayData" :key="getUnregisteredItemKey(item, index)" @click="handleResourceClickSafe(item, index)">
  111. <!-- 右上角选中图标(左移) -->
  112. <view class="select-icon">✓-</view>
  113. <!-- 编辑按钮 -->
  114. <view class="edit-icon" @click.stop="handleEdit(item.id || item.resourceId || item.resource_id)">
  115. <text class="edit-text">编辑</text>
  116. </view>
  117. <view class="resource-header">
  118. <image
  119. :src="item.avatar"
  120. mode="aspectFill"
  121. class="resource-avatar"
  122. @error="handleImageErrorUnregistered(index)"
  123. @load="handleImageLoadUnregistered(index)"
  124. :lazy-load="true"
  125. ></image>
  126. <view class="resource-basic-info">
  127. <view class="name-gender">
  128. <text class="resource-name">{{ item.name }}</text>
  129. <text class="resource-gender gender-tag">{{ item.gender }}</text>
  130. </view>
  131. <view class="status-tag-wrapper">
  132. <text class="status-tag register-tag unregistered">未注册</text>
  133. <!-- 审核状态标签(仅线索列表显示) -->
  134. <text class="status-tag audit-tag" :class="{ 'audit-pending': item.status === 0 || item.status === null || item.status === undefined, 'audit-approved': item.status === 1, 'audit-rejected': item.status === 2 }">
  135. {{ item.status === 0 || item.status === null || item.status === undefined ? '待审核' : (item.status === 1 ? '审核通过' : (item.status === 2 ? '审核未通过' : '待审核')) }}
  136. </text>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="resource-details">
  141. <view class="labels">
  142. <text class="label" v-for="(label, idx) in item.labels" :key="idx">{{ label }}</text>
  143. </view>
  144. <!-- 未审核通过原因 -->
  145. <view class="reject-reason" v-if="item.status === 2 && item.rejectReason">
  146. <text class="reject-reason-text">审核未通过原因:{{ item.rejectReason }}</text>
  147. </view>
  148. <view class="requirement-box">
  149. <text class="requirement-label">择偶要求:</text>
  150. <text class="requirement-content">{{ item.requirement }}</text>
  151. </view>
  152. <view class="contact-box">
  153. <text class="contact-label">联系方式:</text>
  154. <text class="contact-number">{{ item.contact }}</text>
  155. <text class="copy-btn" @click.stop="handleCopyContact(item.originalPhone || item.contact)">复制</text>
  156. </view>
  157. <view class="action-buttons">
  158. <view class="delete-btn" @click.stop="handleDelete(item.id || item.resourceId || item.resource_id)">删除</view>
  159. <view class="match-btn" @click.stop="handleMatch(item.id || item.resourceId || item.resource_id)">精准匹配</view>
  160. </view>
  161. </view>
  162. <!-- 优质资源标签 -->
  163. <view class="quality-tag" v-if="item.isQuality">
  164. <text class="quality-star">★</text>
  165. <text class="quality-text">优质资源</text>
  166. </view>
  167. </view>
  168. </view>
  169. <!-- 加载更多提示 -->
  170. <view class="load-more-tip" v-if="unregisteredResources.length < unregisteredTotal && currentTab === 'clue'">
  171. <text class="load-more-text">下拉加载更多</text>
  172. </view>
  173. <!-- 没有更多数据提示 -->
  174. <view class="no-more-tip" v-if="unregisteredResources.length >= unregisteredTotal && unregisteredTotal > 0 && currentTab === 'clue'">
  175. <text class="no-more-text">已加载全部数据</text>
  176. </view>
  177. </view>
  178. <!-- 空状态 -->
  179. <view class="empty-state" v-if="(currentTab === 'resource' && registeredTotal === 0 && registeredResources.length === 0) || (currentTab === 'clue' && unregisteredTotal === 0 && unregisteredResources.length === 0)">
  180. <text class="empty-text">{{ currentTab === 'resource' ? '暂无资源' : '暂无线索' }}</text>
  181. </view>
  182. </scroll-view>
  183. <!-- 底部添加按钮 -->
  184. <view class="add-button" @click="handleAdd">
  185. <text class="add-button-icon">+</text>
  186. </view>
  187. <!-- 底部导航 -->
  188. <view class="tabbar">
  189. <view class="tabbar-item home" @click="navigateToWorkbench">
  190. <view class="tabbar-icon"></view>
  191. <text class="tabbar-text">工作台</text>
  192. </view>
  193. <view class="tabbar-item resources active" @click="navigateToMyResources">
  194. <view class="tabbar-icon"></view>
  195. <text class="tabbar-text">我的资源</text>
  196. </view>
  197. <view class="tabbar-item trophy" @click="navigateToRanking">
  198. <view class="tabbar-icon"></view>
  199. <text class="tabbar-text">排行榜</text>
  200. </view>
  201. <!-- <view class="tabbar-item message" @click="navigateToMessage">
  202. <view class="tabbar-icon">
  203. <view v-if="unreadCount > 0" class="badge">{{ unreadCount }}</view>
  204. </view>
  205. <text class="tabbar-text">消息</text>
  206. </view> -->
  207. <view class="tabbar-item mine" @click="navigateToMine">
  208. <view class="tabbar-icon"></view>
  209. <text class="tabbar-text">我的</text>
  210. </view>
  211. </view>
  212. </view>
  213. </template>
  214. <script>
  215. import api from '@/utils/api.js'
  216. export default {
  217. data() {
  218. return {
  219. statusBarHeight: 0,
  220. searchKeyword: '',
  221. isFirstLoad: true, // 标记是否为首次加载
  222. currentTab: 'resource', // 当前选中的标签:'resource' 或 'clue'
  223. resources: [], // 保留用于兼容
  224. registeredResources: [], // 已注册用户(资源部分)- 已加载的数据
  225. unregisteredResources: [], // 未注册用户(线索部分)- 已加载的数据
  226. allRegisteredResources: [], // 已注册用户(资源部分)- 全部数据(从后端获取)
  227. allUnregisteredResources: [], // 未注册用户(线索部分)- 全部数据(从后端获取)
  228. refreshTimer: null, // 定时刷新器
  229. // 资源分页
  230. registeredPageNum: 1, // 资源当前页码
  231. registeredPageSize: 3, // 资源每页显示数量
  232. registeredTotal: 0, // 资源总数
  233. registeredLoading: false, // 资源加载中标志
  234. // 线索分页
  235. unregisteredPageNum: 1, // 线索当前页码
  236. unregisteredPageSize: 3, // 线索每页显示数量
  237. unregisteredTotal: 0, // 线索总数
  238. unregisteredLoading: false // 线索加载中标志
  239. }
  240. },
  241. computed: {
  242. // 全局未读消息数
  243. unreadCount() {
  244. return this.$store.getters.getTotalUnread || 0
  245. },
  246. // 获取资源已加载的数据(用于显示)
  247. getRegisteredDisplayData() {
  248. const data = (this.registeredResources || []).filter(item => {
  249. const isValid = item && item.id !== undefined && item.id !== null
  250. if (!isValid) {
  251. }
  252. return isValid
  253. })
  254. return data
  255. },
  256. // 获取线索已加载的数据(用于显示)
  257. getUnregisteredDisplayData() {
  258. const data = (this.unregisteredResources || []).filter(item => {
  259. const isValid = item && item.id !== undefined && item.id !== null
  260. return isValid
  261. })
  262. return data
  263. }
  264. },
  265. onLoad() {
  266. // 加载我的资源数据
  267. this.loadMyResources()
  268. this.isFirstLoad = false
  269. // 监听刷新事件
  270. uni.$on('refreshResourceList', () => {
  271. this.loadMyResources()
  272. })
  273. // 启动定时刷新,每30秒检查一次用户注册状态变化
  274. this.startAutoRefresh()
  275. //获取状态栏高度
  276. const systemInfo = uni.getSystemInfoSync()
  277. this.statusBarHeight = systemInfo.statusBarHeight
  278. },
  279. onShow() {
  280. // 页面显示时刷新列表(从其他页面返回时,非首次加载)
  281. if (!this.isFirstLoad) {
  282. this.loadMyResources()
  283. }
  284. // 重新启动定时刷新
  285. this.startAutoRefresh()
  286. },
  287. onHide() {
  288. // 页面隐藏时停止定时刷新
  289. this.stopAutoRefresh()
  290. },
  291. onUnload() {
  292. // 页面卸载时移除事件监听和停止定时刷新
  293. uni.$off('refreshResourceList')
  294. this.stopAutoRefresh()
  295. },
  296. methods: {
  297. //返回上一页
  298. goBack() {
  299. uni.navigateBack({
  300. delta: 1 // 返回上一级页面
  301. })
  302. },
  303. // 获取审核状态文本
  304. getAuditStatusText(status) {
  305. if (status === null || status === undefined) {
  306. return '待审核'
  307. }
  308. switch (status) {
  309. case 0:
  310. return '待审核'
  311. case 1:
  312. return '审核通过'
  313. case 2:
  314. return '审核未通过'
  315. default:
  316. return '待审核'
  317. }
  318. },
  319. // 获取审核状态样式类(返回对象,用于:class绑定)
  320. getAuditStatusClass(status) {
  321. if (status === null || status === undefined) {
  322. return { 'audit-pending': true }
  323. }
  324. switch (status) {
  325. case 0:
  326. return { 'audit-pending': true }
  327. case 1:
  328. return { 'audit-approved': true }
  329. case 2:
  330. return { 'audit-rejected': true }
  331. default:
  332. return { 'audit-pending': true }
  333. }
  334. },
  335. // 获取资源项的key
  336. getRegisteredItemKey(item, index) {
  337. if (item && item.id) {
  338. return 'registered-' + item.id
  339. }
  340. return 'registered-placeholder-' + index
  341. },
  342. // 获取线索项的key
  343. getUnregisteredItemKey(item, index) {
  344. if (item && item.id) {
  345. return 'unregistered-' + item.id
  346. }
  347. return 'unregistered-placeholder-' + index
  348. },
  349. // 切换到资源标签
  350. switchToResource() {
  351. this.currentTab = 'resource'
  352. // 切换标签时重置已加载数据
  353. this.registeredPageNum = 1
  354. this.loadRegisteredPage(1)
  355. },
  356. // 切换到线索标签
  357. switchToClue() {
  358. this.currentTab = 'clue'
  359. // 切换标签时重置已加载数据
  360. this.unregisteredPageNum = 1
  361. this.loadUnregisteredPage(1)
  362. },
  363. // 滚动到底部触发加载更多
  364. handleScrollToLower(e) {
  365. if (this.currentTab === 'resource') {
  366. // 资源列表加载更多
  367. if (!this.registeredLoading) {
  368. // 如果已加载数量小于总数,继续加载
  369. if (this.registeredTotal > 0 && this.registeredResources.length < this.registeredTotal) {
  370. this.loadMoreRegistered()
  371. } else if (this.registeredTotal === 0) {
  372. this.loadMoreRegistered()
  373. }
  374. }
  375. } else {
  376. if (!this.unregisteredLoading) {
  377. // 如果已加载数量小于总数,继续加载
  378. if (this.unregisteredTotal > 0 && this.unregisteredResources.length < this.unregisteredTotal) {
  379. this.loadMoreUnregistered()
  380. } else if (this.unregisteredTotal === 0) {
  381. this.loadMoreUnregistered()
  382. }
  383. }
  384. }
  385. },
  386. // 加载资源指定页数据(从后端加载,使用isUser参数过滤已注册用户)
  387. async loadRegisteredPage(pageNum) {
  388. if (this.registeredLoading) return
  389. this.registeredLoading = true
  390. this.registeredPageNum = pageNum
  391. try {
  392. // 获取当前登录用户ID
  393. const userInfo = uni.getStorageSync('userInfo') || {}
  394. const userId = uni.getStorageSync('userId')
  395. let currentUserId = userInfo.userId || userId || null
  396. console.log('=== loadRegisteredPage 调试信息 ===')
  397. console.log('userInfo:', JSON.stringify(userInfo))
  398. console.log('userId from storage:', userId)
  399. console.log('currentUserId:', currentUserId)
  400. if (currentUserId !== null && currentUserId !== undefined) {
  401. currentUserId = parseInt(currentUserId)
  402. if (isNaN(currentUserId) || currentUserId <= 0) {
  403. currentUserId = null
  404. }
  405. }
  406. if (!currentUserId) {
  407. console.log('❌ 未获取到有效的用户ID,无法加载资源')
  408. uni.showToast({
  409. title: '请先登录',
  410. icon: 'none'
  411. })
  412. this.registeredResources = []
  413. this.registeredLoading = false
  414. return
  415. }
  416. const baseUrl = 'https://api.zhongruanke.cn/api'
  417. // 构建查询参数,使用isUser=1参数只获取已注册用户
  418. let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=${pageNum}&pageSize=${this.registeredPageSize}&isUser=1`
  419. if (this.searchKeyword && this.searchKeyword.trim()) {
  420. url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
  421. }
  422. console.log('请求URL:', url)
  423. const [error, res] = await uni.request({
  424. url: url,
  425. method: 'GET',
  426. timeout: 15000
  427. })
  428. console.log('请求结果 - error:', error)
  429. console.log('请求结果 - res.statusCode:', res ? res.statusCode : 'null')
  430. console.log('请求结果 - res.data:', res ? JSON.stringify(res.data) : 'null')
  431. if (error) {
  432. console.log('❌ 请求失败:', JSON.stringify(error))
  433. uni.showToast({
  434. title: '网络请求失败',
  435. icon: 'none'
  436. })
  437. this.registeredResources = []
  438. this.registeredLoading = false
  439. return
  440. }
  441. if (res.statusCode === 200 && res.data && res.data.code === 200) {
  442. const pageData = res.data.data
  443. console.log('pageData:', JSON.stringify(pageData))
  444. if (pageData && pageData.records) {
  445. console.log('records数量:', pageData.records.length)
  446. // 转换数据格式,并过滤掉无效数据(null值)
  447. const resources = this.convertResourceData(pageData.records).filter(item => item !== null && item !== undefined)
  448. console.log('转换后资源数量:', resources.length)
  449. // 如果是第一页,直接替换;否则追加
  450. if (pageNum === 1) {
  451. this.registeredResources = resources
  452. } else {
  453. this.registeredResources = [...this.registeredResources, ...resources]
  454. }
  455. // 更新总数(使用后端返回的total)
  456. this.registeredTotal = pageData.total || 0
  457. console.log('资源总数:', this.registeredTotal)
  458. } else {
  459. console.log('⚠️ pageData或records为空')
  460. if (pageNum === 1) {
  461. this.registeredResources = []
  462. this.registeredTotal = 0
  463. }
  464. }
  465. } else {
  466. console.log('❌ 响应状态异常:', res.statusCode, res.data)
  467. uni.showToast({
  468. title: res.data?.message || '加载失败',
  469. icon: 'none'
  470. })
  471. }
  472. } catch (e) {
  473. console.log('❌ 加载资源异常:', e)
  474. if (this.registeredPageNum === 1) {
  475. this.registeredResources = []
  476. }
  477. } finally {
  478. this.registeredLoading = false
  479. }
  480. },
  481. // 加载线索指定页数据(从后端加载,使用isUser参数过滤未注册用户)
  482. async loadUnregisteredPage(pageNum) {
  483. if (this.unregisteredLoading) {
  484. return
  485. }
  486. this.unregisteredLoading = true
  487. this.unregisteredPageNum = pageNum
  488. try {
  489. // 获取当前登录用户ID
  490. const userInfo = uni.getStorageSync('userInfo') || {}
  491. const userId = uni.getStorageSync('userId')
  492. let currentUserId = userInfo.userId || userId || null
  493. console.log('=== loadUnregisteredPage 调试信息 ===')
  494. console.log('userInfo:', JSON.stringify(userInfo))
  495. console.log('userId from storage:', userId)
  496. console.log('currentUserId:', currentUserId)
  497. if (currentUserId !== null && currentUserId !== undefined) {
  498. currentUserId = parseInt(currentUserId)
  499. if (isNaN(currentUserId) || currentUserId <= 0) {
  500. currentUserId = null
  501. }
  502. }
  503. if (!currentUserId) {
  504. console.log('❌ 未获取到有效的用户ID,无法加载线索')
  505. this.unregisteredResources = []
  506. this.unregisteredLoading = false
  507. return
  508. }
  509. const baseUrl = 'https://api.zhongruanke.cn/api'
  510. // 构建查询参数,使用isUser=0参数只获取未注册用户(线索)
  511. let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=${pageNum}&pageSize=${this.unregisteredPageSize}&isUser=0`
  512. if (this.searchKeyword && this.searchKeyword.trim()) {
  513. url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
  514. }
  515. console.log('请求URL:', url)
  516. const [error, res] = await uni.request({
  517. url: url,
  518. method: 'GET',
  519. timeout: 15000
  520. })
  521. console.log('请求结果 - error:', error)
  522. console.log('请求结果 - res.statusCode:', res ? res.statusCode : 'null')
  523. if (error) {
  524. console.log('❌ 请求失败:', JSON.stringify(error))
  525. uni.showToast({
  526. title: '网络请求失败',
  527. icon: 'none'
  528. })
  529. this.unregisteredResources = []
  530. this.unregisteredLoading = false
  531. return
  532. }
  533. if (res.statusCode === 200 && res.data && res.data.code === 200) {
  534. const pageData = res.data.data
  535. console.log('pageData:', JSON.stringify(pageData))
  536. if (pageData && pageData.records) {
  537. console.log('records数量:', pageData.records.length)
  538. // 转换数据格式,并过滤掉无效数据(null值)
  539. const resources = this.convertResourceData(pageData.records).filter(item => item !== null && item !== undefined)
  540. console.log('转换后线索数量:', resources.length)
  541. // 如果是第一页,直接替换;否则追加
  542. if (pageNum === 1) {
  543. this.unregisteredResources = resources
  544. } else {
  545. this.unregisteredResources = [...this.unregisteredResources, ...resources]
  546. }
  547. // 更新总数(使用后端返回的total)
  548. this.unregisteredTotal = pageData.total || 0
  549. console.log('线索总数:', this.unregisteredTotal)
  550. } else {
  551. console.log('⚠️ pageData或records为空')
  552. if (pageNum === 1) {
  553. this.unregisteredResources = []
  554. this.unregisteredTotal = 0
  555. }
  556. }
  557. } else {
  558. console.log('❌ 响应状态异常:', res.statusCode, res.data)
  559. }
  560. } catch (e) {
  561. console.log('❌ 加载线索异常:', e)
  562. if (this.unregisteredPageNum === 1) {
  563. this.unregisteredResources = []
  564. }
  565. } finally {
  566. this.unregisteredLoading = false
  567. }
  568. },
  569. // 加载更多资源(从后端分页加载)
  570. async loadMoreRegistered() {
  571. if (this.registeredLoading) return
  572. // 如果已加载的数据已经达到或超过估算的总数,不再加载
  573. if (this.registeredResources.length >= this.registeredTotal && this.registeredTotal > 0) return
  574. this.registeredPageNum++
  575. await this.loadRegisteredPage(this.registeredPageNum)
  576. },
  577. // 加载更多线索(从后端分页加载)
  578. async loadMoreUnregistered() {
  579. if (this.unregisteredLoading) return
  580. // 如果已加载的数据已经达到或超过估算的总数,不再加载
  581. if (this.unregisteredResources.length >= this.unregisteredTotal && this.unregisteredTotal > 0) return
  582. this.unregisteredPageNum++
  583. await this.loadUnregisteredPage(this.unregisteredPageNum)
  584. },
  585. // 转换资源数据格式(提取公共方法)
  586. convertResourceData(records) {
  587. return records.map(item => {
  588. let requirement = item.mateSelectionCriteria || item.mate_selection_criteria || ''
  589. if (requirement) {
  590. requirement = requirement.trim()
  591. }
  592. const labels = []
  593. if (item.constellation) {
  594. labels.push(item.constellation)
  595. }
  596. if (item.occupation) {
  597. labels.push(item.occupation)
  598. }
  599. let avatarUrl = item.avatarUrl || item.avatar_url || item.avatar || ''
  600. if (!avatarUrl || avatarUrl.trim() === '' || avatarUrl === 'null' || avatarUrl === null || avatarUrl === undefined) {
  601. avatarUrl = ''
  602. } else {
  603. avatarUrl = avatarUrl.trim()
  604. }
  605. let resourceId = item.resourceId || item.resource_id
  606. if (resourceId === null || resourceId === undefined || resourceId === 'undefined' || resourceId === 'null') {
  607. return null
  608. }
  609. resourceId = parseInt(resourceId)
  610. if (isNaN(resourceId) || resourceId <= 0) {
  611. return null
  612. }
  613. let isUser = item.isUser !== null && item.isUser !== undefined ? item.isUser :
  614. (item.is_user !== null && item.is_user !== undefined ? item.is_user : 0)
  615. isUser = parseInt(isUser) || 0
  616. let userId = item.userId !== null && item.userId !== undefined ? item.userId :
  617. (item.user_id !== null && item.user_id !== undefined ? item.user_id : null)
  618. if (userId !== null && userId !== undefined) {
  619. userId = parseInt(userId)
  620. if (isNaN(userId) || userId <= 0) {
  621. userId = null
  622. }
  623. }
  624. let isMatch = item.isMatch !== null && item.isMatch !== undefined ? item.isMatch :
  625. (item.is_match !== null && item.is_match !== undefined ? item.is_match : 0)
  626. isMatch = parseInt(isMatch) || 0
  627. let resourceTags = []
  628. if (item.tags && Array.isArray(item.tags) && item.tags.length > 0) {
  629. resourceTags = item.tags
  630. } else if (labels && labels.length > 0) {
  631. resourceTags = labels
  632. }
  633. return {
  634. id: resourceId,
  635. resourceId: resourceId,
  636. resource_id: resourceId,
  637. avatar: avatarUrl,
  638. name: item.name || '',
  639. gender: item.gender === 1 ? '男' : item.gender === 2 ? '女' : '未知',
  640. status: item.status !== undefined && item.status !== null ? item.status : 0,
  641. rejectReason: item.rejectReason || item.reject_reason || '',
  642. isUser: isUser,
  643. userId: userId,
  644. isMatch: isMatch,
  645. isPlus: false,
  646. labels: resourceTags,
  647. requirement: requirement || '暂无要求',
  648. contact: item.phone ? item.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') : '',
  649. originalPhone: item.phone || '',
  650. isQuality: false
  651. }
  652. }).filter(item => item !== null)
  653. },
  654. // 加载我的资源数据(改为分页加载)
  655. async loadMyResources() {
  656. try {
  657. // 重置分页
  658. this.registeredPageNum = 1
  659. this.unregisteredPageNum = 1
  660. // 同时加载资源和线索,进入页面即可两端都查询完毕
  661. await Promise.all([
  662. this.loadRegisteredPage(1),
  663. this.loadUnregisteredPage(1)
  664. ])
  665. } catch (e) {
  666. }
  667. },
  668. // 搜索
  669. async handleSearch() {
  670. // 重置分页到第一页
  671. this.registeredPageNum = 1
  672. this.unregisteredPageNum = 1
  673. // 重新加载资源数据,包含搜索关键词
  674. await this.loadMyResources()
  675. },
  676. // 删除资源
  677. async handleDelete(id) {
  678. // 如果id无效,尝试从当前资源列表中查找
  679. if (id === null || id === undefined || id === 'undefined' || id === 'null' || id === '') {
  680. // 尝试从当前显示的资源中找到对应的资源
  681. const allDisplayData = this.currentTab === 'resource'
  682. ? this.getRegisteredDisplayData
  683. : this.getUnregisteredDisplayData
  684. // 如果仍然找不到,显示错误
  685. uni.showToast({
  686. title: '资源ID无效,无法删除',
  687. icon: 'none'
  688. })
  689. return
  690. }
  691. // 确保id是有效的整数
  692. let resourceId = parseInt(id)
  693. if (isNaN(resourceId) || resourceId <= 0) {
  694. // 如果解析失败,尝试从字符串中提取数字
  695. const match = String(id).match(/\d+/)
  696. if (match) {
  697. resourceId = parseInt(match[0])
  698. }
  699. if (isNaN(resourceId) || resourceId <= 0) {
  700. uni.showToast({
  701. title: '资源ID格式错误,无法删除',
  702. icon: 'none'
  703. })
  704. return
  705. }
  706. }
  707. uni.showModal({
  708. title: '删除确认',
  709. content: '确定要删除该资源吗?',
  710. success: async (res) => {
  711. if (res.confirm) {
  712. try {
  713. uni.showLoading({
  714. title: '删除中...'
  715. })
  716. const baseUrl = 'https://api.zhongruanke.cn/api'
  717. const [error, deleteRes] = await uni.request({
  718. url: `${baseUrl}/my-resource/delete/${resourceId}`,
  719. method: 'DELETE'
  720. })
  721. uni.hideLoading()
  722. if (error) {
  723. uni.showToast({
  724. title: '删除失败',
  725. icon: 'none'
  726. })
  727. return
  728. }
  729. if (deleteRes.statusCode === 200 && deleteRes.data && deleteRes.data.code === 200) {
  730. uni.showToast({
  731. title: '删除成功',
  732. icon: 'success'
  733. })
  734. // 删除成功后刷新资源列表
  735. await this.loadMyResources()
  736. } else {
  737. uni.showToast({
  738. title: deleteRes.data.message || '删除失败',
  739. icon: 'none'
  740. })
  741. }
  742. } catch (e) {
  743. uni.hideLoading()
  744. uni.showToast({
  745. title: '删除失败,请稍后重试',
  746. icon: 'none'
  747. })
  748. }
  749. }
  750. }
  751. })
  752. },
  753. // 精准匹配
  754. // 编辑资源
  755. handleEdit(id) {
  756. // 跳转到资源录入页面(编辑模式),传递资源ID
  757. uni.navigateTo({
  758. url: `/pages/matchmaker-workbench/resource-input?resourceId=${id}`,
  759. success: () => {
  760. },
  761. fail: (err) => {
  762. uni.showToast({
  763. title: '跳转失败',
  764. icon: 'none'
  765. })
  766. }
  767. })
  768. },
  769. handleMatch(id) {
  770. // 查找资源项
  771. const allResources = [...this.registeredResources, ...this.unregisteredResources]
  772. const resource = allResources.find(item => item.id === id)
  773. if (!resource) {
  774. uni.showToast({
  775. title: '资源不存在',
  776. icon: 'none'
  777. })
  778. return
  779. }
  780. // 检查用户是否已注册(isUser === 1 且 userId !== null)
  781. if (resource.isUser !== 1 || resource.userId === null || resource.userId === undefined) {
  782. uni.showToast({
  783. title: '该用户还未注册用户端,注册之后才能进行匹配',
  784. icon: 'none',
  785. duration: 3000
  786. })
  787. return
  788. }
  789. // 已注册用户,跳转到精准匹配页面
  790. uni.navigateTo({
  791. url: `/pages/matchmaker-workbench/precise-match?resourceId=${id}`
  792. })
  793. },
  794. // 复制联系方式
  795. handleCopyContact(contact) {
  796. if (!contact) {
  797. uni.showToast({
  798. title: '联系方式为空',
  799. icon: 'none'
  800. })
  801. return
  802. }
  803. // 如果是脱敏的手机号,需要从原始数据中获取完整号码
  804. // 这里需要根据实际情况调整,可能需要从item中获取原始phone
  805. // 暂时先复制显示的文本
  806. uni.setClipboardData({
  807. data: contact,
  808. success: () => {
  809. uni.showToast({
  810. title: '已复制到剪贴板',
  811. icon: 'success'
  812. })
  813. },
  814. fail: () => {
  815. uni.showToast({
  816. title: '复制失败',
  817. icon: 'none'
  818. })
  819. }
  820. })
  821. },
  822. // 客户点击事件,跳转到客户详情页面
  823. handleClientClick(id) {
  824. uni.navigateTo({
  825. url: `/pages/matchmaker-workbench/client-detail?resourceId=${id}`
  826. })
  827. },
  828. // 资源项点击事件(安全包装方法)
  829. handleResourceClickSafe(item, index) {
  830. // 如果 item 无效,尝试从数组中获取
  831. if (!item || item === null || item === undefined) {
  832. const dataArray = this.currentTab === 'resource' ? this.getRegisteredDisplayData : this.getUnregisteredDisplayData
  833. if (dataArray && Array.isArray(dataArray) && index >= 0 && index < dataArray.length) {
  834. item = dataArray[index]
  835. }
  836. }
  837. // 如果仍然无效,直接返回
  838. if (!item || item === null || item === undefined) {
  839. return
  840. }
  841. // 调用实际的点击处理方法
  842. this.handleResourceClick(item)
  843. },
  844. // 资源项点击事件
  845. handleResourceClick(item) {
  846. // 检查 item 是否存在
  847. if (!item || item === null || item === undefined) {
  848. return
  849. }
  850. // 检查 item.id 是否存在
  851. if (!item.id && item.id !== 0) {
  852. uni.showToast({
  853. title: '资源ID无效',
  854. icon: 'none',
  855. duration: 2000
  856. })
  857. return
  858. }
  859. // 判断是否为已注册用户(isUser === 1 且 userId !== null)
  860. if (item.isUser === 1 && item.userId !== null && item.userId !== undefined) {
  861. // 已注册,跳转到客户详情页面
  862. const resourceId = item.id
  863. uni.navigateTo({
  864. url: `/pages/matchmaker-workbench/client-detail?resourceId=${resourceId}`,
  865. success: () => {
  866. },
  867. fail: (err) => {
  868. uni.showToast({
  869. title: '跳转失败,请重试',
  870. icon: 'none'
  871. })
  872. }
  873. })
  874. } else {
  875. // 未注册,提示用户
  876. uni.showToast({
  877. title: '该用户还未注册用户端',
  878. icon: 'none',
  879. duration: 2000
  880. })
  881. }
  882. },
  883. // 添加资源
  884. handleAdd() {
  885. // 跳转到信息录入页面
  886. uni.navigateTo({
  887. url: '/pages/matchmaker-workbench/resource-input',
  888. success: () => {
  889. },
  890. fail: (err) => {
  891. uni.showToast({
  892. title: '页面跳转失败',
  893. icon: 'none'
  894. })
  895. }
  896. })
  897. },
  898. // 导航到工作台
  899. navigateToWorkbench() {
  900. uni.navigateTo({
  901. url: '/pages/matchmaker-workbench/index'
  902. })
  903. },
  904. // 导航到我的资源
  905. navigateToMyResources() {
  906. // 已在我的资源页面,无需跳转
  907. },
  908. // 导航到排行榜
  909. navigateToRanking() {
  910. uni.navigateTo({
  911. url: '/pages/matchmaker-workbench/ranking'
  912. })
  913. },
  914. // 导航到消息
  915. navigateToMessage() {
  916. uni.navigateTo({
  917. url: '/pages/matchmaker-workbench/message'
  918. })
  919. },
  920. // 导航到我的
  921. navigateToMine() {
  922. uni.navigateTo({
  923. url: '/pages/matchmaker-workbench/mine'
  924. })
  925. },
  926. // 启动自动刷新
  927. startAutoRefresh() {
  928. // 清除之前的定时器
  929. this.stopAutoRefresh()
  930. // 每30秒刷新一次,检查用户注册状态变化
  931. this.refreshTimer = setInterval(async () => {
  932. // 先批量检查并更新线索用户的注册状态
  933. await this.batchCheckClueRegistrationStatus()
  934. // 然后刷新资源列表
  935. await this.loadMyResources()
  936. }, 30000) // 30秒
  937. },
  938. // 批量检查并更新线索用户的注册状态
  939. async batchCheckClueRegistrationStatus() {
  940. try {
  941. // 获取红娘ID,优先使用userInfo中的matchmakerId,否则使用userId
  942. const userInfo = uni.getStorageSync('userInfo') || {}
  943. const userId = uni.getStorageSync('userId')
  944. let matchmakerId = userInfo.matchmakerId || userId || null
  945. if (!matchmakerId) {
  946. return
  947. }
  948. // 确保matchmakerId是有效的整数
  949. matchmakerId = parseInt(matchmakerId)
  950. if (isNaN(matchmakerId) || matchmakerId <= 0) {
  951. return
  952. }
  953. const baseUrl = 'https://api.zhongruanke.cn/api'
  954. const [error, res] = await uni.request({
  955. url: `${baseUrl}/my-resource/batch-check-clue-registration`,
  956. method: 'POST',
  957. data: {
  958. matchmakerId: matchmakerId
  959. }
  960. })
  961. if (error) {
  962. return
  963. }
  964. if (res.statusCode === 200 && res.data && res.data.code === 200) {
  965. const updateCount = res.data.data?.updateCount || 0
  966. }
  967. } catch (e) {
  968. }
  969. },
  970. // 停止自动刷新
  971. stopAutoRefresh() {
  972. if (this.refreshTimer) {
  973. clearInterval(this.refreshTimer)
  974. this.refreshTimer = null
  975. }
  976. },
  977. // 已注册资源图片加载错误处理
  978. handleImageErrorRegistered(index) {
  979. this.handleImageError(index, 'registered')
  980. },
  981. // 未注册资源图片加载错误处理
  982. handleImageErrorUnregistered(index) {
  983. this.handleImageError(index, 'unregistered')
  984. },
  985. // 已注册资源图片加载成功处理
  986. handleImageLoadRegistered(index) {
  987. this.handleImageLoad(index, 'registered')
  988. },
  989. // 未注册资源图片加载成功处理
  990. handleImageLoadUnregistered(index) {
  991. this.handleImageLoad(index, 'unregistered')
  992. },
  993. // 图片加载错误处理(内部方法)
  994. handleImageError(index, type) {
  995. try {
  996. // 获取当前显示的数据
  997. const displayData = type === 'registered' ? this.getRegisteredDisplayData : this.getUnregisteredDisplayData
  998. const resource = displayData && displayData[index]
  999. if (!resource) {
  1000. return
  1001. }
  1002. const originalUrl = resource.avatar
  1003. const resourceId = resource.id
  1004. if (originalUrl &&
  1005. originalUrl.trim() !== '' &&
  1006. !originalUrl.includes('placeholder') &&
  1007. !originalUrl.includes('default') &&
  1008. !originalUrl.includes('via.placeholder')) {
  1009. if (type === 'registered') {
  1010. const displayListIndex = this.registeredResources.findIndex(item => item.id === resourceId)
  1011. if (displayListIndex !== -1) {
  1012. this.$set(this.registeredResources[displayListIndex], 'avatar', '')
  1013. }
  1014. } else {
  1015. const displayListIndex = this.unregisteredResources.findIndex(item => item.id === resourceId)
  1016. if (displayListIndex !== -1) {
  1017. this.$set(this.unregisteredResources[displayListIndex], 'avatar', '')
  1018. }
  1019. }
  1020. }
  1021. } catch (e) {
  1022. }
  1023. },
  1024. // 图片加载成功处理(内部方法)
  1025. handleImageLoad(index, type) {
  1026. try {
  1027. // 获取当前显示的数据
  1028. const displayData = type === 'registered' ? this.getRegisteredDisplayData : this.getUnregisteredDisplayData
  1029. if (displayData && displayData[index]) {
  1030. }
  1031. } catch (e) {
  1032. }
  1033. }
  1034. }
  1035. }
  1036. </script>
  1037. <style lang="scss" scoped>
  1038. .my-resources {
  1039. min-height: 100vh;
  1040. background: #F5F5F5;
  1041. display: flex;
  1042. flex-direction: column;
  1043. }
  1044. /* 顶部导航栏 */
  1045. .header {
  1046. display: flex;
  1047. align-items: center;
  1048. justify-content: space-between;
  1049. padding: 20rpx 30rpx;
  1050. // padding-top: calc(20rpx + env(safe-area-inset-top));
  1051. background: #FFFFFF;
  1052. border-bottom: 1rpx solid #F0F0F0;
  1053. .header-left {
  1054. width: 40rpx; // 固定宽度,避免挤压标题
  1055. }
  1056. // 新增:返回按钮样式
  1057. .back-icon {
  1058. font-size: 36rpx;
  1059. color: #9C27B0; // 和标题颜色统一
  1060. font-weight: bold;
  1061. }
  1062. .header-title {
  1063. font-size: 36rpx;
  1064. font-weight: bold;
  1065. color: #9C27B0;
  1066. flex: 1; // 让标题占中间剩余空间,实现居中
  1067. text-align: center;
  1068. }
  1069. .header-right {
  1070. .dropdown-arrow {
  1071. font-size: 24rpx;
  1072. color: #9C27B0;
  1073. font-weight: normal;
  1074. }
  1075. }
  1076. }
  1077. /* 资源/线索切换标签 */
  1078. .tab-switcher {
  1079. display: flex;
  1080. align-items: center;
  1081. background: #FFFFFF;
  1082. border-bottom: 1rpx solid #F0F0F0;
  1083. padding: 0 30rpx;
  1084. .tab-item {
  1085. flex: 1;
  1086. display: flex;
  1087. align-items: center;
  1088. justify-content: center;
  1089. padding: 25rpx 0;
  1090. position: relative;
  1091. cursor: pointer;
  1092. transition: all 0.3s;
  1093. .tab-text {
  1094. font-size: 32rpx;
  1095. font-weight: 500;
  1096. color: #666;
  1097. margin-right: 8rpx;
  1098. }
  1099. .tab-count {
  1100. font-size: 26rpx;
  1101. color: #999;
  1102. }
  1103. &.active {
  1104. .tab-text {
  1105. color: #9C27B0;
  1106. font-weight: bold;
  1107. }
  1108. .tab-count {
  1109. color: #9C27B0;
  1110. }
  1111. &::after {
  1112. content: '';
  1113. position: absolute;
  1114. bottom: 0;
  1115. left: 0;
  1116. right: 0;
  1117. height: 4rpx;
  1118. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  1119. border-radius: 2rpx 2rpx 0 0;
  1120. }
  1121. }
  1122. &:active {
  1123. opacity: 0.7;
  1124. }
  1125. }
  1126. }
  1127. /* 搜索栏 */
  1128. .search-bar {
  1129. padding: 20rpx;
  1130. background: #F5F5F5;
  1131. .search-input-wrapper {
  1132. display: flex;
  1133. align-items: center;
  1134. background: #FFFFFF;
  1135. border-radius: 30rpx;
  1136. padding: 12rpx 20rpx;
  1137. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
  1138. .search-icon-small {
  1139. width: 32rpx;
  1140. height: 32rpx;
  1141. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
  1142. background-size: contain;
  1143. background-repeat: no-repeat;
  1144. background-position: center;
  1145. margin-right: 15rpx;
  1146. }
  1147. .search-input {
  1148. flex: 1;
  1149. font-size: 28rpx;
  1150. color: #333;
  1151. border: none;
  1152. outline: none;
  1153. background: transparent;
  1154. &::placeholder {
  1155. color: #999;
  1156. }
  1157. }
  1158. }
  1159. }
  1160. .content {
  1161. flex: 1;
  1162. height: 0; /* 配合 flex: 1 使用,确保 scroll-view 有明确高度 */
  1163. padding: 0 20rpx 140rpx;
  1164. box-sizing: border-box;
  1165. }
  1166. /* 资源分组 */
  1167. .resource-section {
  1168. margin-bottom: 30rpx;
  1169. min-height: calc(50vh - 100rpx); /* 确保至少占半屏高度 */
  1170. display: flex;
  1171. flex-direction: column;
  1172. .section-header {
  1173. display: flex;
  1174. align-items: center;
  1175. padding: 20rpx 0 15rpx;
  1176. margin-bottom: 10rpx;
  1177. flex-shrink: 0;
  1178. .section-title {
  1179. font-size: 32rpx;
  1180. font-weight: bold;
  1181. color: #9C27B0;
  1182. margin-right: 10rpx;
  1183. }
  1184. .section-count {
  1185. font-size: 26rpx;
  1186. color: #999;
  1187. font-weight: normal;
  1188. }
  1189. }
  1190. /* 资源列表容器,确保有固定高度 */
  1191. .resource-list-container {
  1192. flex: 1;
  1193. display: flex;
  1194. flex-direction: column;
  1195. min-height: calc(50vh - 200rpx);
  1196. }
  1197. }
  1198. /* 加载更多提示 */
  1199. .load-more-tip {
  1200. display: flex;
  1201. justify-content: center;
  1202. align-items: center;
  1203. padding: 30rpx 0;
  1204. .load-more-text {
  1205. font-size: 26rpx;
  1206. color: #999;
  1207. }
  1208. }
  1209. /* 没有更多数据提示 */
  1210. .no-more-tip {
  1211. display: flex;
  1212. justify-content: center;
  1213. align-items: center;
  1214. padding: 30rpx 0;
  1215. .no-more-text {
  1216. font-size: 26rpx;
  1217. color: #999;
  1218. }
  1219. }
  1220. /* 空状态 */
  1221. .empty-state {
  1222. display: flex;
  1223. justify-content: center;
  1224. align-items: center;
  1225. padding: 100rpx 0;
  1226. .empty-text {
  1227. font-size: 28rpx;
  1228. color: #999;
  1229. }
  1230. }
  1231. /* 资源列表 */
  1232. .resource-item {
  1233. background: #FFFFFF;
  1234. border-radius: 20rpx;
  1235. margin-bottom: 20rpx;
  1236. padding: 25rpx;
  1237. position: relative;
  1238. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  1239. /* 右上角选中图标 */
  1240. .select-icon {
  1241. position: absolute;
  1242. top: 20rpx;
  1243. right: 120rpx; /* 左移,为编辑按钮留出空间 */
  1244. width: 40rpx;
  1245. height: 40rpx;
  1246. background: #FF4444;
  1247. color: #FFFFFF;
  1248. border-radius: 50%;
  1249. display: flex;
  1250. align-items: center;
  1251. justify-content: center;
  1252. font-size: 24rpx;
  1253. font-weight: bold;
  1254. z-index: 10;
  1255. }
  1256. .edit-icon {
  1257. position: absolute;
  1258. top: 20rpx;
  1259. right: 20rpx;
  1260. padding: 8rpx 20rpx;
  1261. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  1262. border-radius: 20rpx;
  1263. display: flex;
  1264. align-items: center;
  1265. justify-content: center;
  1266. z-index: 10;
  1267. box-shadow: 0 2rpx 8rpx rgba(156, 39, 176, 0.3);
  1268. .edit-text {
  1269. color: #FFFFFF;
  1270. font-size: 24rpx;
  1271. font-weight: 500;
  1272. }
  1273. }
  1274. .resource-header {
  1275. display: flex;
  1276. align-items: flex-start;
  1277. margin-bottom: 20rpx;
  1278. padding-right: 50rpx;
  1279. .resource-avatar {
  1280. width: 100rpx;
  1281. height: 100rpx;
  1282. border-radius: 8rpx;
  1283. margin-right: 20rpx;
  1284. flex-shrink: 0;
  1285. background-color: #F5F5F5;
  1286. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23CCCCCC"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  1287. background-size: 60% 60%;
  1288. background-position: center;
  1289. background-repeat: no-repeat;
  1290. }
  1291. .resource-basic-info {
  1292. flex: 1;
  1293. min-width: 0;
  1294. .name-gender {
  1295. display: flex;
  1296. align-items: center;
  1297. gap: 10rpx;
  1298. margin-bottom: 12rpx;
  1299. .resource-name {
  1300. font-size: 30rpx;
  1301. font-weight: bold;
  1302. color: #333;
  1303. }
  1304. .resource-gender {
  1305. font-size: 26rpx;
  1306. color: #666;
  1307. &.gender-tag {
  1308. display: inline-block;
  1309. padding: 4rpx 12rpx;
  1310. background: #F3E5F5;
  1311. color: #9C27B0;
  1312. border-radius: 12rpx;
  1313. font-size: 22rpx;
  1314. font-weight: 500;
  1315. }
  1316. }
  1317. }
  1318. .status-tag-wrapper {
  1319. display: flex;
  1320. align-items: center;
  1321. .status-tag {
  1322. display: inline-block;
  1323. padding: 4rpx 12rpx;
  1324. border-radius: 12rpx;
  1325. font-size: 22rpx;
  1326. font-weight: 500;
  1327. margin-right: 8rpx;
  1328. &.approved {
  1329. background: #E3F2FD;
  1330. color: #2196F3;
  1331. }
  1332. &.pending {
  1333. background: #FFF3E0;
  1334. color: #FF9800;
  1335. }
  1336. &.register-tag {
  1337. &.registered {
  1338. background: #E8F5E9;
  1339. color: #4CAF50;
  1340. }
  1341. &.unregistered {
  1342. background: #FCE4EC;
  1343. color: #E91E63;
  1344. }
  1345. }
  1346. &.match-tag {
  1347. margin-left: 10rpx;
  1348. &.matched {
  1349. background: #E3F2FD;
  1350. color: #2196F3;
  1351. }
  1352. &.unmatched {
  1353. background: #FFF3E0;
  1354. color: #FF9800;
  1355. }
  1356. }
  1357. /* 审核状态标签样式 */
  1358. &.audit-tag {
  1359. margin-left: 10rpx;
  1360. /* 待审核 - 橙色/黄色 */
  1361. &.audit-pending {
  1362. background: #FFF3E0;
  1363. color: #FF9800;
  1364. border: 1rpx solid #FFB74D;
  1365. }
  1366. /* 审核通过 - 绿色 */
  1367. &.audit-approved {
  1368. background: #E8F5E9;
  1369. color: #4CAF50;
  1370. border: 1rpx solid #81C784;
  1371. }
  1372. /* 审核未通过 - 红色 */
  1373. &.audit-rejected {
  1374. background: #FFEBEE;
  1375. color: #F44336;
  1376. border: 1rpx solid #E57373;
  1377. }
  1378. }
  1379. }
  1380. }
  1381. }
  1382. }
  1383. .resource-details {
  1384. .labels {
  1385. display: flex;
  1386. flex-wrap: wrap;
  1387. gap: 10rpx;
  1388. margin-bottom: 15rpx;
  1389. .label {
  1390. display: inline-block;
  1391. padding: 6rpx 14rpx;
  1392. background: #F3E5F5;
  1393. color: #9C27B0;
  1394. border-radius: 15rpx;
  1395. font-size: 22rpx;
  1396. font-weight: 500;
  1397. }
  1398. }
  1399. .requirement-box {
  1400. background: #F3E5F5;
  1401. border-radius: 12rpx;
  1402. padding: 16rpx 20rpx;
  1403. margin-bottom: 15rpx;
  1404. display: flex;
  1405. align-items: center;
  1406. flex-wrap: wrap;
  1407. .requirement-label {
  1408. font-size: 28rpx;
  1409. color: #7B1FA2;
  1410. font-weight: 500;
  1411. margin-right: 8rpx;
  1412. white-space: nowrap;
  1413. }
  1414. .requirement-content {
  1415. font-size: 28rpx;
  1416. color: #7B1FA2;
  1417. font-weight: 400;
  1418. }
  1419. }
  1420. .contact-box {
  1421. margin-bottom: 20rpx;
  1422. display: flex;
  1423. align-items: center;
  1424. flex-wrap: wrap;
  1425. .contact-label {
  1426. font-size: 26rpx;
  1427. color: #333;
  1428. font-weight: 500;
  1429. margin-right: 10rpx;
  1430. white-space: nowrap;
  1431. }
  1432. .contact-number {
  1433. flex: 1;
  1434. font-size: 26rpx;
  1435. color: #333;
  1436. font-weight: 400;
  1437. min-width: 0;
  1438. }
  1439. .copy-btn {
  1440. font-size: 24rpx;
  1441. color: #9C27B0;
  1442. font-weight: 500;
  1443. margin-left: 15rpx;
  1444. white-space: nowrap;
  1445. cursor: pointer;
  1446. }
  1447. }
  1448. .action-buttons {
  1449. display: flex;
  1450. justify-content: space-between;
  1451. align-items: center;
  1452. gap: 15rpx;
  1453. .delete-btn {
  1454. flex: 1;
  1455. padding: 14rpx 0;
  1456. background: #FFEBEE;
  1457. color: #E91E63;
  1458. border-radius: 25rpx;
  1459. font-size: 26rpx;
  1460. font-weight: 500;
  1461. text-align: center;
  1462. }
  1463. .match-btn {
  1464. flex: 1.5;
  1465. padding: 14rpx 0;
  1466. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  1467. color: #FFFFFF;
  1468. border-radius: 25rpx;
  1469. font-size: 26rpx;
  1470. font-weight: 500;
  1471. text-align: center;
  1472. }
  1473. }
  1474. }
  1475. /* 优质资源标签 */
  1476. .quality-tag {
  1477. position: absolute;
  1478. top: 80rpx;
  1479. right: 20rpx;
  1480. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  1481. color: #FFFFFF;
  1482. font-size: 22rpx;
  1483. font-weight: bold;
  1484. padding: 8rpx 16rpx;
  1485. border-radius: 20rpx;
  1486. display: flex;
  1487. align-items: center;
  1488. gap: 4rpx;
  1489. box-shadow: 0 2rpx 8rpx rgba(156, 39, 176, 0.3);
  1490. z-index: 5;
  1491. .quality-star {
  1492. font-size: 20rpx;
  1493. }
  1494. .quality-text {
  1495. font-size: 22rpx;
  1496. }
  1497. }
  1498. }
  1499. /* 审核未通过原因 */
  1500. .reject-reason {
  1501. margin-top: 12rpx;
  1502. padding: 14rpx 16rpx;
  1503. background: #FFF3E0;
  1504. border: 1rpx solid #FFCC80;
  1505. border-radius: 10rpx;
  1506. color: #E65100;
  1507. font-size: 24rpx;
  1508. line-height: 1.5;
  1509. }
  1510. /* 添加按钮 */
  1511. .add-button {
  1512. position: fixed;
  1513. bottom: 200rpx;
  1514. right: 40rpx;
  1515. width: 100rpx;
  1516. height: 100rpx;
  1517. border-radius: 50%;
  1518. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  1519. display: flex;
  1520. align-items: center;
  1521. justify-content: center;
  1522. box-shadow: 0 4rpx 20rpx rgba(156, 39, 176, 0.4);
  1523. z-index: 999;
  1524. .add-button-icon {
  1525. font-size: 60rpx;
  1526. color: #FFFFFF;
  1527. line-height: 1;
  1528. font-weight: bold;
  1529. }
  1530. }
  1531. /* 底部导航 */
  1532. .tabbar {
  1533. position: fixed;
  1534. bottom: 0;
  1535. left: 0;
  1536. right: 0;
  1537. height: 100rpx;
  1538. background: #FFFFFF;
  1539. border-top: 1rpx solid #F0F0F0;
  1540. display: flex;
  1541. justify-content: space-around;
  1542. align-items: center;
  1543. padding-bottom: env(safe-area-inset-bottom);
  1544. .tabbar-item {
  1545. display: flex;
  1546. flex-direction: column;
  1547. align-items: center;
  1548. gap: 8rpx;
  1549. padding: 10rpx 0;
  1550. .tabbar-icon {
  1551. width: 44rpx;
  1552. height: 44rpx;
  1553. background-size: contain;
  1554. background-repeat: no-repeat;
  1555. background-position: center;
  1556. position: relative;
  1557. .badge {
  1558. position: absolute;
  1559. top: -8rpx;
  1560. right: -8rpx;
  1561. background: #FF4444;
  1562. color: #FFFFFF;
  1563. font-size: 20rpx;
  1564. font-weight: bold;
  1565. width: 32rpx;
  1566. height: 32rpx;
  1567. display: flex;
  1568. align-items: center;
  1569. justify-content: center;
  1570. border-radius: 16rpx;
  1571. }
  1572. }
  1573. .tabbar-text {
  1574. font-size: 20rpx;
  1575. color: #999;
  1576. }
  1577. &.active {
  1578. .tabbar-text {
  1579. color: #9C27B0;
  1580. font-weight: bold;
  1581. }
  1582. }
  1583. &.home .tabbar-icon {
  1584. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>');
  1585. }
  1586. &.active.home .tabbar-icon {
  1587. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>');
  1588. }
  1589. &.resources .tabbar-icon {
  1590. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
  1591. }
  1592. &.active.resources .tabbar-icon {
  1593. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
  1594. }
  1595. &.trophy .tabbar-icon {
  1596. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2zM5 8V7h2v3.82C5.84 10.4 5 9.3 5 8zm14 0c0 1.3-.84 2.4-2 2.82V7h2v1z"/></svg>');
  1597. }
  1598. &.active.trophy .tabbar-icon {
  1599. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2zM5 8V7h2v3.82C5.84 10.4 5 9.3 5 8zm14 0c0 1.3-.84 2.4-2 2.82V7h2v1z"/></svg>');
  1600. }
  1601. &.message .tabbar-icon {
  1602. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>');
  1603. }
  1604. &.active.message .tabbar-icon {
  1605. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>');
  1606. }
  1607. &.mine .tabbar-icon {
  1608. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  1609. }
  1610. &.active.mine .tabbar-icon {
  1611. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  1612. }
  1613. }
  1614. }
  1615. </style>