my-resources.vue 36 KB

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