my-resources.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. <template>
  2. <view class="my-resources">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <text class="header-title">我的资源</text>
  6. <view class="header-right">
  7. <text class="dropdown-arrow">▼</text>
  8. </view>
  9. </view>
  10. <!-- 搜索栏 -->
  11. <view class="search-bar">
  12. <view class="search-input-wrapper">
  13. <view class="search-icon-small"></view>
  14. <input type="text" class="search-input" placeholder="请输入搜索关键词" v-model="searchKeyword" @input="handleSearch" />
  15. </view>
  16. </view>
  17. <scroll-view scroll-y class="content">
  18. <!-- 资源列表 -->
  19. <view class="resource-item" v-for="(item, index) in resources" :key="index" @click="handleResourceClick(item)">
  20. <!-- 右上角选中图标 -->
  21. <view class="select-icon">✓-</view>
  22. <view class="resource-header">
  23. <image
  24. :src="item.avatar"
  25. mode="aspectFill"
  26. class="resource-avatar"
  27. @error="handleImageError(index)"
  28. @load="handleImageLoad(index)"
  29. :lazy-load="true"
  30. ></image>
  31. <view class="resource-basic-info">
  32. <view class="name-gender">
  33. <text class="resource-name">{{ item.name }}</text>
  34. <text class="resource-gender gender-tag">{{ item.gender }}</text>
  35. </view>
  36. <view class="status-tag-wrapper">
  37. <text class="status-tag register-tag" :class="{ 'registered': item.isUser === 1, 'unregistered': item.isUser === 0 }">{{ item.isUser === 1 ? '已注册' : '未注册' }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="resource-details">
  42. <view class="labels">
  43. <text class="label" v-for="(label, idx) in item.labels" :key="idx">{{ label }}</text>
  44. </view>
  45. <view class="requirement-box">
  46. <text class="requirement-label">择偶要求:</text>
  47. <text class="requirement-content">{{ item.requirement }}</text>
  48. </view>
  49. <view class="contact-box">
  50. <text class="contact-label">联系方式:</text>
  51. <text class="contact-number">{{ item.contact }}</text>
  52. <text class="copy-btn" @click.stop="handleCopyContact(item.originalPhone || item.contact)">复制</text>
  53. </view>
  54. <view class="action-buttons">
  55. <view class="delete-btn" @click.stop="handleDelete(item.id)">删除</view>
  56. <view class="match-btn" @click.stop="handleMatch(item.id)">精准匹配</view>
  57. </view>
  58. </view>
  59. <!-- 优质资源标签 -->
  60. <view class="quality-tag" v-if="item.isQuality">
  61. <text class="quality-star">★</text>
  62. <text class="quality-text">优质资源</text>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. <!-- 底部添加按钮 -->
  67. <view class="add-button" @click="handleAdd">
  68. <text class="add-button-icon">+</text>
  69. </view>
  70. <!-- 底部导航 -->
  71. <view class="tabbar">
  72. <view class="tabbar-item" @click="navigateToWorkbench">
  73. <view class="tabbar-icon home"></view>
  74. <text class="tabbar-text">工作台</text>
  75. </view>
  76. <view class="tabbar-item active" @click="navigateToMyResources">
  77. <view class="tabbar-icon resources"></view>
  78. <text class="tabbar-text">我的资源</text>
  79. </view>
  80. <view class="tabbar-item" @click="navigateToRanking">
  81. <view class="tabbar-icon trophy"></view>
  82. <text class="tabbar-text">排行榜</text>
  83. </view>
  84. <view class="tabbar-item" @click="navigateToMessage">
  85. <view class="tabbar-icon message">
  86. <view class="badge">3</view>
  87. </view>
  88. <text class="tabbar-text">消息</text>
  89. </view>
  90. <view class="tabbar-item" @click="navigateToMine">
  91. <view class="tabbar-icon mine"></view>
  92. <text class="tabbar-text">我的</text>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import api from '@/utils/api.js'
  99. export default {
  100. data() {
  101. return {
  102. searchKeyword: '',
  103. isFirstLoad: true, // 标记是否为首次加载
  104. resources: [
  105. {
  106. id: 1,
  107. avatar: 'https://example.com/avatar1.jpg',
  108. name: '小高',
  109. gender: '男',
  110. status: '已审核',
  111. isPlus: true,
  112. labels: ['气质男', '小清新'],
  113. requirement: '165+ 本科',
  114. contact: '123****8912',
  115. isQuality: false
  116. },
  117. {
  118. id: 2,
  119. avatar: 'https://example.com/avatar2.jpg',
  120. name: '小美',
  121. gender: '女',
  122. status: '已审核',
  123. isPlus: true,
  124. labels: ['温柔', '知性', '爱读书'],
  125. requirement: '175+ 硕士 有房',
  126. contact: '138****6543',
  127. isQuality: false
  128. },
  129. {
  130. id: 3,
  131. avatar: 'https://example.com/avatar3.jpg',
  132. name: '阿强',
  133. gender: '男',
  134. status: '待审核',
  135. isPlus: false,
  136. labels: ['阳光', '运动型'],
  137. requirement: '160+ 大专以上',
  138. contact: '159****2234',
  139. isQuality: true
  140. }
  141. ]
  142. }
  143. },
  144. onLoad() {
  145. // 加载我的资源数据
  146. this.loadMyResources()
  147. this.isFirstLoad = false
  148. // 监听刷新事件
  149. uni.$on('refreshResourceList', () => {
  150. console.log('收到刷新资源列表事件')
  151. this.loadMyResources()
  152. })
  153. },
  154. onShow() {
  155. // 页面显示时刷新列表(从其他页面返回时,非首次加载)
  156. if (!this.isFirstLoad) {
  157. this.loadMyResources()
  158. }
  159. },
  160. onUnload() {
  161. // 页面卸载时移除事件监听
  162. uni.$off('refreshResourceList')
  163. },
  164. methods: {
  165. // 加载我的资源数据
  166. async loadMyResources() {
  167. try {
  168. // 获取当前登录用户ID
  169. const userInfo = uni.getStorageSync('userInfo') || {}
  170. const userId = uni.getStorageSync('userId')
  171. let currentUserId = userInfo.userId || userId || null
  172. // 验证并转换currentUserId为有效的整数
  173. if (currentUserId !== null && currentUserId !== undefined) {
  174. currentUserId = parseInt(currentUserId)
  175. if (isNaN(currentUserId) || currentUserId <= 0) {
  176. currentUserId = null
  177. }
  178. }
  179. if (!currentUserId) {
  180. console.error('无法获取当前登录用户ID')
  181. uni.showToast({
  182. title: '请先登录',
  183. icon: 'none'
  184. })
  185. return
  186. }
  187. // 调用后端接口,传递当前用户ID作为matchmakerId
  188. const baseUrl = process.env.NODE_ENV === 'development'
  189. ? 'http://localhost:8083/api' // 开发环境 - 通过网关
  190. : 'https://your-domain.com/api' // 生产环境
  191. // 构建查询参数,确保currentUserId是有效的整数
  192. let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=1&pageSize=100`
  193. if (this.searchKeyword && this.searchKeyword.trim()) {
  194. url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
  195. }
  196. const [error, res] = await uni.request({
  197. url: url,
  198. method: 'GET'
  199. })
  200. if (error) {
  201. console.error('加载资源数据失败:', error)
  202. return
  203. }
  204. if (res.statusCode === 200 && res.data && res.data.code === 200) {
  205. // 处理返回的数据
  206. const pageData = res.data.data
  207. console.log('=== 后端返回的完整数据 ===')
  208. console.log('pageData:', JSON.stringify(pageData, null, 2))
  209. if (pageData && pageData.records) {
  210. console.log('records数量:', pageData.records.length)
  211. if (pageData.records.length > 0) {
  212. console.log('第一条记录的完整数据:', JSON.stringify(pageData.records[0], null, 2))
  213. }
  214. // 将后端数据转换为前端需要的格式
  215. this.resources = pageData.records.map(item => {
  216. // 直接使用mate_selection_criteria字段作为择偶要求
  217. // 支持多种可能的字段名(mateSelectionCriteria或mate_selection_criteria)
  218. let requirement = item.mateSelectionCriteria || item.mate_selection_criteria || ''
  219. // 去除首尾空格,如果为空则显示"暂无要求"
  220. if (requirement) {
  221. requirement = requirement.trim()
  222. }
  223. // 处理标签(可以根据实际需求扩展)
  224. const labels = []
  225. if (item.constellation) {
  226. labels.push(item.constellation)
  227. }
  228. if (item.occupation) {
  229. labels.push(item.occupation)
  230. }
  231. // 处理头像URL:确保使用完整的URL
  232. // 尝试多种可能的字段名
  233. let avatarUrl = item.avatarUrl || item.avatar_url || item.avatar || ''
  234. console.log('=== 头像URL处理 ===')
  235. console.log('资源ID:', item.resourceId, '姓名:', item.name)
  236. console.log('原始数据字段:', {
  237. avatarUrl: item.avatarUrl,
  238. avatar_url: item.avatar_url,
  239. avatar: item.avatar,
  240. 'item完整对象': item
  241. })
  242. console.log('提取的avatarUrl值:', avatarUrl, '类型:', typeof avatarUrl, '是否为空:', !avatarUrl)
  243. // 如果头像URL为空或null,设置为空字符串(让CSS背景图显示)
  244. if (!avatarUrl || avatarUrl.trim() === '' || avatarUrl === 'null' || avatarUrl === null || avatarUrl === undefined) {
  245. avatarUrl = '' // 设置为空,让CSS默认背景显示
  246. console.log('⚠️ 头像URL为空,设置为空字符串,将显示CSS默认背景')
  247. } else {
  248. // 确保URL是完整的(如果已经是完整URL则直接使用)
  249. avatarUrl = avatarUrl.trim()
  250. // 如果URL不是以http开头,可能需要拼接基础URL(根据实际情况调整)
  251. if (!avatarUrl.startsWith('http://') && !avatarUrl.startsWith('https://')) {
  252. console.warn('⚠️ 头像URL不是完整URL,可能需要拼接:', avatarUrl)
  253. // 如果是相对路径,可以尝试拼接MinIO基础URL
  254. // avatarUrl = 'http://115.190.125.125:9000/' + avatarUrl
  255. }
  256. // 确保MinIO URL可以正常访问(可能需要处理跨域)
  257. // 如果MinIO配置了公共访问,直接使用URL即可
  258. console.log('✅ 使用用户头像URL:', avatarUrl)
  259. // 验证URL格式
  260. if (avatarUrl.includes('115.190.125.125:9000')) {
  261. console.log('✅ 检测到MinIO URL,URL格式:', avatarUrl)
  262. }
  263. }
  264. console.log('最终设置的avatarUrl:', avatarUrl)
  265. console.log('=== 头像URL处理结束 ===')
  266. // 确保resourceId是有效的整数
  267. let resourceId = item.resourceId || item.resource_id
  268. // 调试日志:检查resourceId的来源
  269. console.log('=== resourceId处理 ===')
  270. console.log('原始item.resourceId:', item.resourceId, '类型:', typeof item.resourceId)
  271. console.log('原始item.resource_id:', item.resource_id, '类型:', typeof item.resource_id)
  272. console.log('提取的resourceId:', resourceId, '类型:', typeof resourceId)
  273. if (resourceId === null || resourceId === undefined || resourceId === 'undefined' || resourceId === 'null') {
  274. console.warn('资源ID无效,跳过该资源:', item)
  275. return null // 返回null,后续会被filter过滤掉
  276. }
  277. resourceId = parseInt(resourceId)
  278. if (isNaN(resourceId) || resourceId <= 0) {
  279. console.warn('资源ID格式错误,跳过该资源:', item)
  280. return null // 返回null,后续会被filter过滤掉
  281. }
  282. console.log('处理后的resourceId:', resourceId, '类型:', typeof resourceId)
  283. console.log('=== resourceId处理结束 ===')
  284. // 处理isUser字段,支持多种可能的字段名(isUser或is_user)
  285. let isUser = item.isUser !== null && item.isUser !== undefined ? item.isUser :
  286. (item.is_user !== null && item.is_user !== undefined ? item.is_user : 0)
  287. // 确保isUser是数字类型
  288. isUser = parseInt(isUser) || 0
  289. // 调试日志:检查isUser字段
  290. console.log('=== isUser字段处理 ===')
  291. console.log('资源ID:', resourceId, '姓名:', item.name)
  292. console.log('原始数据:', {
  293. isUser: item.isUser,
  294. is_user: item.is_user,
  295. 'item完整对象': item
  296. })
  297. console.log('处理后的isUser值:', isUser, '类型:', typeof isUser)
  298. console.log('=== isUser字段处理结束 ===')
  299. // 处理标签(从后端返回的tags字段,如果没有则使用原有的labels)
  300. let resourceTags = []
  301. if (item.tags && Array.isArray(item.tags) && item.tags.length > 0) {
  302. // 使用后端返回的标签
  303. resourceTags = item.tags
  304. } else if (labels && labels.length > 0) {
  305. // 如果没有tags,使用原有的labels(星座、职业等)
  306. resourceTags = labels
  307. }
  308. return {
  309. id: resourceId,
  310. avatar: avatarUrl, // 使用处理后的头像URL
  311. name: item.name || '',
  312. gender: item.gender === 1 ? '男' : item.gender === 2 ? '女' : '未知',
  313. status: '已审核', // 可以根据实际字段判断
  314. isUser: isUser, // 添加isUser字段,默认为0
  315. isPlus: false,
  316. labels: resourceTags, // 使用处理后的标签列表
  317. requirement: requirement || '暂无要求',
  318. contact: item.phone ? item.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') : '',
  319. originalPhone: item.phone || '', // 保存原始完整手机号用于复制
  320. isQuality: false
  321. }
  322. }).filter(item => item !== null) // 过滤掉无效的资源(resourceId无效的)
  323. console.log('处理后的资源列表:', this.resources)
  324. }
  325. }
  326. } catch (e) {
  327. console.error('加载资源数据失败:', e)
  328. }
  329. },
  330. // 搜索
  331. async handleSearch() {
  332. // 重新加载资源数据,包含搜索关键词
  333. await this.loadMyResources()
  334. },
  335. // 删除资源
  336. async handleDelete(id) {
  337. // 验证id是否有效
  338. if (id === null || id === undefined || id === 'undefined' || id === 'null' || id === '') {
  339. console.error('删除资源失败: 资源ID无效', id)
  340. uni.showToast({
  341. title: '资源ID无效,无法删除',
  342. icon: 'none'
  343. })
  344. return
  345. }
  346. // 确保id是有效的整数
  347. const resourceId = parseInt(id)
  348. if (isNaN(resourceId) || resourceId <= 0) {
  349. console.error('删除资源失败: 资源ID格式错误', id)
  350. uni.showToast({
  351. title: '资源ID格式错误,无法删除',
  352. icon: 'none'
  353. })
  354. return
  355. }
  356. uni.showModal({
  357. title: '删除确认',
  358. content: '确定要删除该资源吗?',
  359. success: async (res) => {
  360. if (res.confirm) {
  361. try {
  362. uni.showLoading({
  363. title: '删除中...'
  364. })
  365. const baseUrl = process.env.NODE_ENV === 'development'
  366. ? 'http://localhost:8083/api' // 开发环境 - 通过网关
  367. : 'https://your-domain.com/api' // 生产环境
  368. const [error, deleteRes] = await uni.request({
  369. url: `${baseUrl}/my-resource/delete/${resourceId}`,
  370. method: 'DELETE'
  371. })
  372. uni.hideLoading()
  373. if (error) {
  374. console.error('删除资源失败:', error)
  375. uni.showToast({
  376. title: '删除失败',
  377. icon: 'none'
  378. })
  379. return
  380. }
  381. if (deleteRes.statusCode === 200 && deleteRes.data && deleteRes.data.code === 200) {
  382. uni.showToast({
  383. title: '删除成功',
  384. icon: 'success'
  385. })
  386. // 删除成功后刷新资源列表
  387. await this.loadMyResources()
  388. } else {
  389. uni.showToast({
  390. title: deleteRes.data.message || '删除失败',
  391. icon: 'none'
  392. })
  393. }
  394. } catch (e) {
  395. uni.hideLoading()
  396. console.error('删除资源异常:', e)
  397. uni.showToast({
  398. title: '删除失败,请稍后重试',
  399. icon: 'none'
  400. })
  401. }
  402. }
  403. }
  404. })
  405. },
  406. // 精准匹配
  407. handleMatch(id) {
  408. // 实现精准匹配功能
  409. console.log('精准匹配:', id)
  410. uni.navigateTo({
  411. url: `/pages/matchmaker-workbench/precise-match?id=${id}`
  412. })
  413. },
  414. // 复制联系方式
  415. handleCopyContact(contact) {
  416. if (!contact) {
  417. uni.showToast({
  418. title: '联系方式为空',
  419. icon: 'none'
  420. })
  421. return
  422. }
  423. // 如果是脱敏的手机号,需要从原始数据中获取完整号码
  424. // 这里需要根据实际情况调整,可能需要从item中获取原始phone
  425. // 暂时先复制显示的文本
  426. uni.setClipboardData({
  427. data: contact,
  428. success: () => {
  429. uni.showToast({
  430. title: '已复制到剪贴板',
  431. icon: 'success'
  432. })
  433. },
  434. fail: () => {
  435. uni.showToast({
  436. title: '复制失败',
  437. icon: 'none'
  438. })
  439. }
  440. })
  441. },
  442. // 客户点击事件,跳转到客户详情页面
  443. handleClientClick(id) {
  444. uni.navigateTo({
  445. url: `/pages/matchmaker-workbench/client-detail?resourceId=${id}`
  446. })
  447. },
  448. // 资源项点击事件
  449. handleResourceClick(item) {
  450. console.log('=== 点击资源项 ===')
  451. console.log('item对象:', JSON.stringify(item, null, 2))
  452. console.log('item.id:', item.id)
  453. console.log('item.isUser:', item.isUser)
  454. // 判断是否为已注册用户
  455. if (item.isUser === 1) {
  456. // 已注册,跳转到客户详情页面
  457. const resourceId = item.id
  458. console.log('准备跳转,resourceId:', resourceId)
  459. uni.navigateTo({
  460. url: `/pages/matchmaker-workbench/client-detail?resourceId=${resourceId}`,
  461. success: () => {
  462. console.log('跳转成功,resourceId:', resourceId)
  463. },
  464. fail: (err) => {
  465. console.error('跳转失败:', err)
  466. }
  467. })
  468. } else {
  469. // 未注册,提示用户
  470. uni.showToast({
  471. title: '该用户还未注册用户端',
  472. icon: 'none',
  473. duration: 2000
  474. })
  475. }
  476. },
  477. // 添加资源
  478. handleAdd() {
  479. // 跳转到信息录入页面
  480. uni.navigateTo({
  481. url: '/pages/matchmaker-workbench/resource-input',
  482. success: () => {
  483. console.log('跳转到信息录入页面成功')
  484. },
  485. fail: (err) => {
  486. console.error('跳转失败:', err)
  487. uni.showToast({
  488. title: '页面跳转失败',
  489. icon: 'none'
  490. })
  491. }
  492. })
  493. },
  494. // 导航到工作台
  495. navigateToWorkbench() {
  496. uni.navigateTo({
  497. url: '/pages/matchmaker-workbench/index'
  498. })
  499. },
  500. // 导航到我的资源
  501. navigateToMyResources() {
  502. // 已在我的资源页面,无需跳转
  503. },
  504. // 导航到排行榜
  505. navigateToRanking() {
  506. uni.navigateTo({
  507. url: '/pages/matchmaker-workbench/ranking'
  508. })
  509. },
  510. // 导航到消息
  511. navigateToMessage() {
  512. uni.navigateTo({
  513. url: '/pages/matchmaker-workbench/message'
  514. })
  515. },
  516. // 导航到我的
  517. navigateToMine() {
  518. uni.navigateTo({
  519. url: '/pages/matchmaker-workbench/mine'
  520. })
  521. },
  522. // 图片加载错误处理
  523. handleImageError(index) {
  524. try {
  525. const resource = this.resources && this.resources[index]
  526. if (!resource) {
  527. console.warn('图片加载失败:资源不存在,index:', index)
  528. return
  529. }
  530. const originalUrl = resource.avatar
  531. console.error('❌ 图片加载失败:', {
  532. index: index,
  533. resourceName: resource.name,
  534. resourceId: resource.id,
  535. originalAvatarUrl: originalUrl,
  536. 'URL类型': typeof originalUrl,
  537. 'URL长度': originalUrl ? originalUrl.length : 0,
  538. '是否包含placeholder': originalUrl && originalUrl.includes('placeholder'),
  539. '完整resource对象': resource
  540. })
  541. // 如果图片加载失败,且不是已经设置的默认占位图,则设置为空(显示CSS背景)
  542. // 避免重复设置导致循环
  543. if (originalUrl &&
  544. originalUrl.trim() !== '' &&
  545. !originalUrl.includes('placeholder') &&
  546. !originalUrl.includes('default') &&
  547. !originalUrl.includes('via.placeholder')) {
  548. // 设置为空字符串,让CSS默认背景显示
  549. console.log('图片加载失败,将URL设置为空,显示CSS默认背景')
  550. this.$set(this.resources[index], 'avatar', '')
  551. } else {
  552. console.log('图片加载失败,但URL已经是占位图或空,无需处理')
  553. console.log('当前URL:', originalUrl)
  554. }
  555. } catch (e) {
  556. console.error('处理图片错误时发生异常:', e)
  557. }
  558. },
  559. // 图片加载成功处理
  560. handleImageLoad(index) {
  561. try {
  562. if (this.resources && this.resources[index]) {
  563. console.log('图片加载成功:', {
  564. index: index,
  565. resource: this.resources[index]?.name,
  566. avatarUrl: this.resources[index]?.avatar
  567. })
  568. }
  569. } catch (e) {
  570. console.error('处理图片加载成功时发生异常:', e)
  571. }
  572. }
  573. }
  574. }
  575. </script>
  576. <style lang="scss" scoped>
  577. .my-resources {
  578. min-height: 100vh;
  579. background: #F5F5F5;
  580. display: flex;
  581. flex-direction: column;
  582. }
  583. /* 顶部导航栏 */
  584. .header {
  585. display: flex;
  586. align-items: center;
  587. justify-content: space-between;
  588. padding: 20rpx 30rpx;
  589. padding-top: calc(20rpx + env(safe-area-inset-top));
  590. background: #FFFFFF;
  591. border-bottom: 1rpx solid #F0F0F0;
  592. .header-title {
  593. font-size: 36rpx;
  594. font-weight: bold;
  595. color: #9C27B0;
  596. }
  597. .header-right {
  598. .dropdown-arrow {
  599. font-size: 24rpx;
  600. color: #9C27B0;
  601. font-weight: normal;
  602. }
  603. }
  604. }
  605. /* 搜索栏 */
  606. .search-bar {
  607. padding: 20rpx;
  608. background: #F5F5F5;
  609. .search-input-wrapper {
  610. display: flex;
  611. align-items: center;
  612. background: #FFFFFF;
  613. border-radius: 30rpx;
  614. padding: 12rpx 20rpx;
  615. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
  616. .search-icon-small {
  617. width: 32rpx;
  618. height: 32rpx;
  619. 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>');
  620. background-size: contain;
  621. background-repeat: no-repeat;
  622. background-position: center;
  623. margin-right: 15rpx;
  624. }
  625. .search-input {
  626. flex: 1;
  627. font-size: 28rpx;
  628. color: #333;
  629. border: none;
  630. outline: none;
  631. background: transparent;
  632. &::placeholder {
  633. color: #999;
  634. }
  635. }
  636. }
  637. }
  638. .content {
  639. flex: 1;
  640. padding: 0 20rpx 140rpx;
  641. }
  642. /* 资源列表 */
  643. .resource-item {
  644. background: #FFFFFF;
  645. border-radius: 20rpx;
  646. margin-bottom: 20rpx;
  647. padding: 25rpx;
  648. position: relative;
  649. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  650. /* 右上角选中图标 */
  651. .select-icon {
  652. position: absolute;
  653. top: 20rpx;
  654. right: 20rpx;
  655. width: 40rpx;
  656. height: 40rpx;
  657. background: #FF4444;
  658. color: #FFFFFF;
  659. border-radius: 50%;
  660. display: flex;
  661. align-items: center;
  662. justify-content: center;
  663. font-size: 24rpx;
  664. font-weight: bold;
  665. z-index: 10;
  666. }
  667. .resource-header {
  668. display: flex;
  669. align-items: flex-start;
  670. margin-bottom: 20rpx;
  671. padding-right: 50rpx;
  672. .resource-avatar {
  673. width: 100rpx;
  674. height: 100rpx;
  675. border-radius: 8rpx;
  676. margin-right: 20rpx;
  677. flex-shrink: 0;
  678. background-color: #F5F5F5;
  679. 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>');
  680. background-size: 60% 60%;
  681. background-position: center;
  682. background-repeat: no-repeat;
  683. }
  684. .resource-basic-info {
  685. flex: 1;
  686. min-width: 0;
  687. .name-gender {
  688. display: flex;
  689. align-items: center;
  690. gap: 10rpx;
  691. margin-bottom: 12rpx;
  692. .resource-name {
  693. font-size: 30rpx;
  694. font-weight: bold;
  695. color: #333;
  696. }
  697. .resource-gender {
  698. font-size: 26rpx;
  699. color: #666;
  700. &.gender-tag {
  701. display: inline-block;
  702. padding: 4rpx 12rpx;
  703. background: #F3E5F5;
  704. color: #9C27B0;
  705. border-radius: 12rpx;
  706. font-size: 22rpx;
  707. font-weight: 500;
  708. }
  709. }
  710. }
  711. .status-tag-wrapper {
  712. display: flex;
  713. align-items: center;
  714. .status-tag {
  715. display: inline-block;
  716. padding: 4rpx 12rpx;
  717. border-radius: 12rpx;
  718. font-size: 22rpx;
  719. font-weight: 500;
  720. margin-right: 8rpx;
  721. &.approved {
  722. background: #E3F2FD;
  723. color: #2196F3;
  724. }
  725. &.pending {
  726. background: #FFF3E0;
  727. color: #FF9800;
  728. }
  729. &.register-tag {
  730. &.registered {
  731. background: #E8F5E9;
  732. color: #4CAF50;
  733. }
  734. &.unregistered {
  735. background: #FCE4EC;
  736. color: #E91E63;
  737. }
  738. }
  739. }
  740. }
  741. }
  742. }
  743. .resource-details {
  744. .labels {
  745. display: flex;
  746. flex-wrap: wrap;
  747. gap: 10rpx;
  748. margin-bottom: 15rpx;
  749. .label {
  750. display: inline-block;
  751. padding: 6rpx 14rpx;
  752. background: #F3E5F5;
  753. color: #9C27B0;
  754. border-radius: 15rpx;
  755. font-size: 22rpx;
  756. font-weight: 500;
  757. }
  758. }
  759. .requirement-box {
  760. background: #F3E5F5;
  761. border-radius: 12rpx;
  762. padding: 16rpx 20rpx;
  763. margin-bottom: 15rpx;
  764. display: flex;
  765. align-items: center;
  766. flex-wrap: wrap;
  767. .requirement-label {
  768. font-size: 28rpx;
  769. color: #7B1FA2;
  770. font-weight: 500;
  771. margin-right: 8rpx;
  772. white-space: nowrap;
  773. }
  774. .requirement-content {
  775. font-size: 28rpx;
  776. color: #7B1FA2;
  777. font-weight: 400;
  778. }
  779. }
  780. .contact-box {
  781. margin-bottom: 20rpx;
  782. display: flex;
  783. align-items: center;
  784. flex-wrap: wrap;
  785. .contact-label {
  786. font-size: 26rpx;
  787. color: #333;
  788. font-weight: 500;
  789. margin-right: 10rpx;
  790. white-space: nowrap;
  791. }
  792. .contact-number {
  793. flex: 1;
  794. font-size: 26rpx;
  795. color: #333;
  796. font-weight: 400;
  797. min-width: 0;
  798. }
  799. .copy-btn {
  800. font-size: 24rpx;
  801. color: #9C27B0;
  802. font-weight: 500;
  803. margin-left: 15rpx;
  804. white-space: nowrap;
  805. cursor: pointer;
  806. }
  807. }
  808. .action-buttons {
  809. display: flex;
  810. justify-content: space-between;
  811. align-items: center;
  812. gap: 15rpx;
  813. .delete-btn {
  814. flex: 1;
  815. padding: 14rpx 0;
  816. background: #FFEBEE;
  817. color: #E91E63;
  818. border-radius: 25rpx;
  819. font-size: 26rpx;
  820. font-weight: 500;
  821. text-align: center;
  822. }
  823. .match-btn {
  824. flex: 1.5;
  825. padding: 14rpx 0;
  826. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  827. color: #FFFFFF;
  828. border-radius: 25rpx;
  829. font-size: 26rpx;
  830. font-weight: 500;
  831. text-align: center;
  832. }
  833. }
  834. }
  835. /* 优质资源标签 */
  836. .quality-tag {
  837. position: absolute;
  838. top: 80rpx;
  839. right: 20rpx;
  840. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  841. color: #FFFFFF;
  842. font-size: 22rpx;
  843. font-weight: bold;
  844. padding: 8rpx 16rpx;
  845. border-radius: 20rpx;
  846. display: flex;
  847. align-items: center;
  848. gap: 4rpx;
  849. box-shadow: 0 2rpx 8rpx rgba(156, 39, 176, 0.3);
  850. z-index: 5;
  851. .quality-star {
  852. font-size: 20rpx;
  853. }
  854. .quality-text {
  855. font-size: 22rpx;
  856. }
  857. }
  858. }
  859. /* 添加按钮 */
  860. .add-button {
  861. position: fixed;
  862. bottom: 130rpx;
  863. right: 40rpx;
  864. width: 100rpx;
  865. height: 100rpx;
  866. border-radius: 50%;
  867. background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
  868. display: flex;
  869. align-items: center;
  870. justify-content: center;
  871. box-shadow: 0 4rpx 20rpx rgba(156, 39, 176, 0.4);
  872. z-index: 999;
  873. .add-button-icon {
  874. font-size: 60rpx;
  875. color: #FFFFFF;
  876. line-height: 1;
  877. font-weight: bold;
  878. }
  879. }
  880. /* 底部导航 */
  881. .tabbar {
  882. position: fixed;
  883. bottom: 0;
  884. left: 0;
  885. right: 0;
  886. height: 100rpx;
  887. background: #FFFFFF;
  888. border-top: 1rpx solid #F0F0F0;
  889. display: flex;
  890. justify-content: space-around;
  891. align-items: center;
  892. padding-bottom: env(safe-area-inset-bottom);
  893. .tabbar-item {
  894. display: flex;
  895. flex-direction: column;
  896. align-items: center;
  897. gap: 8rpx;
  898. padding: 10rpx 0;
  899. .tabbar-icon {
  900. width: 44rpx;
  901. height: 44rpx;
  902. background-size: contain;
  903. background-repeat: no-repeat;
  904. background-position: center;
  905. position: relative;
  906. .badge {
  907. position: absolute;
  908. top: -8rpx;
  909. right: -8rpx;
  910. background: #FF4444;
  911. color: #FFFFFF;
  912. font-size: 20rpx;
  913. font-weight: bold;
  914. width: 32rpx;
  915. height: 32rpx;
  916. display: flex;
  917. align-items: center;
  918. justify-content: center;
  919. border-radius: 16rpx;
  920. }
  921. }
  922. .tabbar-text {
  923. font-size: 20rpx;
  924. color: #999;
  925. }
  926. &.active {
  927. .tabbar-text {
  928. color: #9C27B0;
  929. font-weight: bold;
  930. }
  931. }
  932. &.home .tabbar-icon {
  933. 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>');
  934. }
  935. &.active.home .tabbar-icon {
  936. 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>');
  937. }
  938. &.resources .tabbar-icon {
  939. 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>');
  940. }
  941. &.trophy .tabbar-icon {
  942. 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="M18 6l-1.42 1.42-1.59-1.59L13 8.17l-1.42-1.42L9 8.17l-1.59-1.59L6 6l3 3V18c0 1.1.9 2 2 2h4c1.1 0 2-.9 2-2V9l3-3zm-4 12H8v-7.5l4-4 4 4V18z"/></svg>');
  943. }
  944. &.active.trophy .tabbar-icon {
  945. 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="M18 6l-1.42 1.42-1.59-1.59L13 8.17l-1.42-1.42L9 8.17l-1.59-1.59L6 6l3 3V18c0 1.1.9 2 2 2h4c1.1 0 2-.9 2-2V9l3-3zm-4 12H8v-7.5l4-4 4 4V18z"/></svg>');
  946. }
  947. &.message .tabbar-icon {
  948. 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>');
  949. }
  950. &.active.message .tabbar-icon {
  951. 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>');
  952. }
  953. &.mine .tabbar-icon {
  954. 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>');
  955. }
  956. &.active.mine .tabbar-icon {
  957. 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>');
  958. }
  959. }
  960. }
  961. </style>