my-resources.vue 36 KB

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