| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244 |
- <template>
- <view class="my-resources">
- <!-- 顶部导航栏 -->
- <view class="header">
- <text class="header-title">我的资源</text>
- <view class="header-right">
- <text class="dropdown-arrow">▼</text>
- </view>
- </view>
- <!-- 搜索栏 -->
- <view class="search-bar">
- <view class="search-input-wrapper">
- <view class="search-icon-small"></view>
- <input type="text" class="search-input" placeholder="请输入搜索关键词" v-model="searchKeyword" @input="handleSearch" />
- </view>
- </view>
- <scroll-view scroll-y class="content">
- <!-- 资源部分(已注册用户) -->
- <view class="resource-section" v-if="registeredResources.length > 0">
- <view class="section-header">
- <text class="section-title">资源</text>
- <text class="section-count">({{ registeredResources.length }})</text>
- </view>
- <view class="resource-item" v-for="(item, index) in registeredResources" :key="item.id" @click="handleResourceClick(item)">
- <!-- 右上角选中图标 -->
- <view class="select-icon">✓-</view>
-
- <view class="resource-header">
- <image
- :src="item.avatar"
- mode="aspectFill"
- class="resource-avatar"
- @error="handleImageErrorRegistered(index)"
- @load="handleImageLoadRegistered(index)"
- :lazy-load="true"
- ></image>
- <view class="resource-basic-info">
- <view class="name-gender">
- <text class="resource-name">{{ item.name }}</text>
- <text class="resource-gender gender-tag">{{ item.gender }}</text>
- </view>
- <view class="status-tag-wrapper">
- <text class="status-tag register-tag registered">已注册</text>
- <text class="status-tag match-tag" :class="{ 'matched': item.isMatch === 1, 'unmatched': item.isMatch === 0 || !item.isMatch }">
- {{ item.isMatch === 1 ? '已匹配' : '未匹配' }}
- </text>
- </view>
- </view>
- </view>
- <view class="resource-details">
- <view class="labels">
- <text class="label" v-for="(label, idx) in item.labels" :key="idx">{{ label }}</text>
- </view>
- <view class="requirement-box">
- <text class="requirement-label">择偶要求:</text>
- <text class="requirement-content">{{ item.requirement }}</text>
- </view>
- <view class="contact-box">
- <text class="contact-label">联系方式:</text>
- <text class="contact-number">{{ item.contact }}</text>
- <text class="copy-btn" @click.stop="handleCopyContact(item.originalPhone || item.contact)">复制</text>
- </view>
- <view class="action-buttons">
- <view class="delete-btn" @click.stop="handleDelete(item.id)">删除</view>
- <view class="match-btn" @click.stop="handleMatch(item.id)">精准匹配</view>
- </view>
- </view>
- <!-- 优质资源标签 -->
- <view class="quality-tag" v-if="item.isQuality">
- <text class="quality-star">★</text>
- <text class="quality-text">优质资源</text>
- </view>
- </view>
- </view>
- <!-- 线索部分(未注册用户) -->
- <view class="resource-section" v-if="unregisteredResources.length > 0">
- <view class="section-header">
- <text class="section-title">线索</text>
- <text class="section-count">({{ unregisteredResources.length }})</text>
- </view>
- <view class="resource-item" v-for="(item, index) in unregisteredResources" :key="item.id" @click="handleResourceClick(item)">
- <!-- 右上角选中图标 -->
- <view class="select-icon">✓-</view>
-
- <view class="resource-header">
- <image
- :src="item.avatar"
- mode="aspectFill"
- class="resource-avatar"
- @error="handleImageErrorUnregistered(index)"
- @load="handleImageLoadUnregistered(index)"
- :lazy-load="true"
- ></image>
- <view class="resource-basic-info">
- <view class="name-gender">
- <text class="resource-name">{{ item.name }}</text>
- <text class="resource-gender gender-tag">{{ item.gender }}</text>
- </view>
- <view class="status-tag-wrapper">
- <text class="status-tag register-tag unregistered">未注册</text>
- </view>
- </view>
- </view>
- <view class="resource-details">
- <view class="labels">
- <text class="label" v-for="(label, idx) in item.labels" :key="idx">{{ label }}</text>
- </view>
- <view class="requirement-box">
- <text class="requirement-label">择偶要求:</text>
- <text class="requirement-content">{{ item.requirement }}</text>
- </view>
- <view class="contact-box">
- <text class="contact-label">联系方式:</text>
- <text class="contact-number">{{ item.contact }}</text>
- <text class="copy-btn" @click.stop="handleCopyContact(item.originalPhone || item.contact)">复制</text>
- </view>
- <view class="action-buttons">
- <view class="delete-btn" @click.stop="handleDelete(item.id)">删除</view>
- <view class="match-btn" @click.stop="handleMatch(item.id)">精准匹配</view>
- </view>
- </view>
- <!-- 优质资源标签 -->
- <view class="quality-tag" v-if="item.isQuality">
- <text class="quality-star">★</text>
- <text class="quality-text">优质资源</text>
- </view>
- </view>
- </view>
- <!-- 空状态 -->
- <view class="empty-state" v-if="registeredResources.length === 0 && unregisteredResources.length === 0">
- <text class="empty-text">暂无资源</text>
- </view>
- </scroll-view>
- <!-- 底部添加按钮 -->
- <view class="add-button" @click="handleAdd">
- <text class="add-button-icon">+</text>
- </view>
- <!-- 底部导航 -->
- <view class="tabbar">
- <view class="tabbar-item" @click="navigateToWorkbench">
- <view class="tabbar-icon home"></view>
- <text class="tabbar-text">工作台</text>
- </view>
- <view class="tabbar-item active" @click="navigateToMyResources">
- <view class="tabbar-icon resources"></view>
- <text class="tabbar-text">我的资源</text>
- </view>
- <view class="tabbar-item" @click="navigateToRanking">
- <view class="tabbar-icon trophy"></view>
- <text class="tabbar-text">排行榜</text>
- </view>
- <view class="tabbar-item" @click="navigateToMessage">
- <view class="tabbar-icon message">
- <view class="badge">3</view>
- </view>
- <text class="tabbar-text">消息</text>
- </view>
- <view class="tabbar-item" @click="navigateToMine">
- <view class="tabbar-icon mine"></view>
- <text class="tabbar-text">我的</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import api from '@/utils/api.js'
-
- export default {
- data() {
- return {
- searchKeyword: '',
- isFirstLoad: true, // 标记是否为首次加载
- resources: [], // 保留用于兼容
- registeredResources: [], // 已注册用户(资源部分)
- unregisteredResources: [], // 未注册用户(线索部分)
- refreshTimer: null // 定时刷新器
- }
- },
- onLoad() {
- // 加载我的资源数据
- this.loadMyResources()
- this.isFirstLoad = false
-
- // 监听刷新事件
- uni.$on('refreshResourceList', () => {
- console.log('收到刷新资源列表事件')
- this.loadMyResources()
- })
-
- // 启动定时刷新,每30秒检查一次用户注册状态变化
- this.startAutoRefresh()
- },
- onShow() {
- // 页面显示时刷新列表(从其他页面返回时,非首次加载)
- if (!this.isFirstLoad) {
- this.loadMyResources()
- }
- // 重新启动定时刷新
- this.startAutoRefresh()
- },
- onHide() {
- // 页面隐藏时停止定时刷新
- this.stopAutoRefresh()
- },
- onUnload() {
- // 页面卸载时移除事件监听和停止定时刷新
- uni.$off('refreshResourceList')
- this.stopAutoRefresh()
- },
- methods: {
- // 加载我的资源数据
- async loadMyResources() {
- try {
- // 获取当前登录用户ID
- const userInfo = uni.getStorageSync('userInfo') || {}
- const userId = uni.getStorageSync('userId')
- let currentUserId = userInfo.userId || userId || null
-
- // 验证并转换currentUserId为有效的整数
- if (currentUserId !== null && currentUserId !== undefined) {
- currentUserId = parseInt(currentUserId)
- if (isNaN(currentUserId) || currentUserId <= 0) {
- currentUserId = null
- }
- }
-
- if (!currentUserId) {
- console.error('无法获取当前登录用户ID')
- uni.showToast({
- title: '请先登录',
- icon: 'none'
- })
- return
- }
-
- // 调用后端接口,传递当前用户ID作为matchmakerId
- const baseUrl = process.env.NODE_ENV === 'development'
- ? 'http://localhost:8083/api' // 开发环境 - 通过网关
- : 'https://your-domain.com/api' // 生产环境
-
- // 构建查询参数,确保currentUserId是有效的整数
- let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=1&pageSize=100`
- if (this.searchKeyword && this.searchKeyword.trim()) {
- url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
- }
-
- const [error, res] = await uni.request({
- url: url,
- method: 'GET'
- })
-
- if (error) {
- console.error('加载资源数据失败:', error)
- return
- }
-
- if (res.statusCode === 200 && res.data && res.data.code === 200) {
- // 处理返回的数据
- const pageData = res.data.data
- console.log('=== 后端返回的完整数据 ===')
- console.log('pageData:', JSON.stringify(pageData, null, 2))
- if (pageData && pageData.records) {
- console.log('records数量:', pageData.records.length)
- if (pageData.records.length > 0) {
- console.log('第一条记录的完整数据:', JSON.stringify(pageData.records[0], null, 2))
- }
- // 将后端数据转换为前端需要的格式
- const allResources = pageData.records.map(item => {
- // 直接使用mate_selection_criteria字段作为择偶要求
- // 支持多种可能的字段名(mateSelectionCriteria或mate_selection_criteria)
- let requirement = item.mateSelectionCriteria || item.mate_selection_criteria || ''
- // 去除首尾空格,如果为空则显示"暂无要求"
- if (requirement) {
- requirement = requirement.trim()
- }
-
- // 处理标签(可以根据实际需求扩展)
- const labels = []
- if (item.constellation) {
- labels.push(item.constellation)
- }
- if (item.occupation) {
- labels.push(item.occupation)
- }
-
- // 处理头像URL:确保使用完整的URL
- // 尝试多种可能的字段名
- let avatarUrl = item.avatarUrl || item.avatar_url || item.avatar || ''
-
- console.log('=== 头像URL处理 ===')
- console.log('资源ID:', item.resourceId, '姓名:', item.name)
- console.log('原始数据字段:', {
- avatarUrl: item.avatarUrl,
- avatar_url: item.avatar_url,
- avatar: item.avatar,
- 'item完整对象': item
- })
- console.log('提取的avatarUrl值:', avatarUrl, '类型:', typeof avatarUrl, '是否为空:', !avatarUrl)
-
- // 如果头像URL为空或null,设置为空字符串(让CSS背景图显示)
- if (!avatarUrl || avatarUrl.trim() === '' || avatarUrl === 'null' || avatarUrl === null || avatarUrl === undefined) {
- avatarUrl = '' // 设置为空,让CSS默认背景显示
- console.log('⚠️ 头像URL为空,设置为空字符串,将显示CSS默认背景')
- } else {
- // 确保URL是完整的(如果已经是完整URL则直接使用)
- avatarUrl = avatarUrl.trim()
-
- // 如果URL不是以http开头,可能需要拼接基础URL(根据实际情况调整)
- if (!avatarUrl.startsWith('http://') && !avatarUrl.startsWith('https://')) {
- console.warn('⚠️ 头像URL不是完整URL,可能需要拼接:', avatarUrl)
- // 如果是相对路径,可以尝试拼接MinIO基础URL
- // avatarUrl = 'http://115.190.125.125:9000/' + avatarUrl
- }
-
- // 确保MinIO URL可以正常访问(可能需要处理跨域)
- // 如果MinIO配置了公共访问,直接使用URL即可
- console.log('✅ 使用用户头像URL:', avatarUrl)
-
- // 验证URL格式
- if (avatarUrl.includes('115.190.125.125:9000')) {
- console.log('✅ 检测到MinIO URL,URL格式:', avatarUrl)
- }
- }
-
- console.log('最终设置的avatarUrl:', avatarUrl)
- console.log('=== 头像URL处理结束 ===')
-
- // 确保resourceId是有效的整数
- let resourceId = item.resourceId || item.resource_id
-
- // 调试日志:检查resourceId的来源
- console.log('=== resourceId处理 ===')
- console.log('原始item.resourceId:', item.resourceId, '类型:', typeof item.resourceId)
- console.log('原始item.resource_id:', item.resource_id, '类型:', typeof item.resource_id)
- console.log('提取的resourceId:', resourceId, '类型:', typeof resourceId)
-
- if (resourceId === null || resourceId === undefined || resourceId === 'undefined' || resourceId === 'null') {
- console.warn('资源ID无效,跳过该资源:', item)
- return null // 返回null,后续会被filter过滤掉
- }
- resourceId = parseInt(resourceId)
- if (isNaN(resourceId) || resourceId <= 0) {
- console.warn('资源ID格式错误,跳过该资源:', item)
- return null // 返回null,后续会被filter过滤掉
- }
- console.log('处理后的resourceId:', resourceId, '类型:', typeof resourceId)
- console.log('=== resourceId处理结束 ===')
-
- // 处理isUser字段,支持多种可能的字段名(isUser或is_user)
- let isUser = item.isUser !== null && item.isUser !== undefined ? item.isUser :
- (item.is_user !== null && item.is_user !== undefined ? item.is_user : 0)
- // 确保isUser是数字类型
- isUser = parseInt(isUser) || 0
-
- // 处理isMatch字段
- let isMatch = item.isMatch !== null && item.isMatch !== undefined ? item.isMatch :
- (item.is_match !== null && item.is_match !== undefined ? item.is_match : 0)
- isMatch = parseInt(isMatch) || 0
-
- // 调试日志:检查isUser字段
- console.log('=== isUser字段处理 ===')
- console.log('资源ID:', resourceId, '姓名:', item.name)
- console.log('原始数据:', {
- isUser: item.isUser,
- is_user: item.is_user,
- 'item完整对象': item
- })
- console.log('处理后的isUser值:', isUser, '类型:', typeof isUser)
- console.log('=== isUser字段处理结束 ===')
-
- // 处理标签(从后端返回的tags字段,如果没有则使用原有的labels)
- let resourceTags = []
- if (item.tags && Array.isArray(item.tags) && item.tags.length > 0) {
- // 使用后端返回的标签
- resourceTags = item.tags
- } else if (labels && labels.length > 0) {
- // 如果没有tags,使用原有的labels(星座、职业等)
- resourceTags = labels
- }
-
- return {
- id: resourceId,
- avatar: avatarUrl, // 使用处理后的头像URL
- name: item.name || '',
- gender: item.gender === 1 ? '男' : item.gender === 2 ? '女' : '未知',
- status: '已审核', // 可以根据实际字段判断
- isUser: isUser, // 添加isUser字段,默认为0
- isMatch: isMatch, // 添加isMatch字段,默认为0
- isPlus: false,
- labels: resourceTags, // 使用处理后的标签列表
- requirement: requirement || '暂无要求',
- contact: item.phone ? item.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') : '',
- originalPhone: item.phone || '', // 保存原始完整手机号用于复制
- isQuality: false
- }
- }).filter(item => item !== null) // 过滤掉无效的资源(resourceId无效的)
-
- // 将资源分为两部分:已注册和未注册
- this.registeredResources = allResources.filter(item => item.isUser === 1)
- this.unregisteredResources = allResources.filter(item => item.isUser === 0)
-
- // 保留resources用于兼容(包含所有资源)
- this.resources = allResources
-
- console.log('处理后的资源列表 - 已注册:', this.registeredResources.length, '未注册:', this.unregisteredResources.length)
- }
- }
- } catch (e) {
- console.error('加载资源数据失败:', e)
- }
- },
- // 搜索
- async handleSearch() {
- // 重新加载资源数据,包含搜索关键词
- await this.loadMyResources()
- },
- // 删除资源
- async handleDelete(id) {
- // 验证id是否有效
- if (id === null || id === undefined || id === 'undefined' || id === 'null' || id === '') {
- console.error('删除资源失败: 资源ID无效', id)
- uni.showToast({
- title: '资源ID无效,无法删除',
- icon: 'none'
- })
- return
- }
-
- // 确保id是有效的整数
- const resourceId = parseInt(id)
- if (isNaN(resourceId) || resourceId <= 0) {
- console.error('删除资源失败: 资源ID格式错误', id)
- uni.showToast({
- title: '资源ID格式错误,无法删除',
- icon: 'none'
- })
- return
- }
-
- uni.showModal({
- title: '删除确认',
- content: '确定要删除该资源吗?',
- success: async (res) => {
- if (res.confirm) {
- try {
- uni.showLoading({
- title: '删除中...'
- })
-
- const baseUrl = process.env.NODE_ENV === 'development'
- ? 'http://localhost:8083/api' // 开发环境 - 通过网关
- : 'https://your-domain.com/api' // 生产环境
-
- const [error, deleteRes] = await uni.request({
- url: `${baseUrl}/my-resource/delete/${resourceId}`,
- method: 'DELETE'
- })
-
- uni.hideLoading()
-
- if (error) {
- console.error('删除资源失败:', error)
- uni.showToast({
- title: '删除失败',
- icon: 'none'
- })
- return
- }
-
- if (deleteRes.statusCode === 200 && deleteRes.data && deleteRes.data.code === 200) {
- uni.showToast({
- title: '删除成功',
- icon: 'success'
- })
-
- // 删除成功后刷新资源列表
- await this.loadMyResources()
- } else {
- uni.showToast({
- title: deleteRes.data.message || '删除失败',
- icon: 'none'
- })
- }
- } catch (e) {
- uni.hideLoading()
- console.error('删除资源异常:', e)
- uni.showToast({
- title: '删除失败,请稍后重试',
- icon: 'none'
- })
- }
- }
- }
- })
- },
- // 精准匹配
- handleMatch(id) {
- // 查找资源项
- const allResources = [...this.registeredResources, ...this.unregisteredResources]
- const resource = allResources.find(item => item.id === id)
-
- if (!resource) {
- uni.showToast({
- title: '资源不存在',
- icon: 'none'
- })
- return
- }
-
- // 检查用户是否已注册
- if (resource.isUser !== 1) {
- uni.showToast({
- title: '该用户还未注册用户端,注册之后才能进行匹配',
- icon: 'none',
- duration: 3000
- })
- return
- }
-
- // 已注册用户,跳转到精准匹配页面
- console.log('精准匹配:', id)
- uni.navigateTo({
- url: `/pages/matchmaker-workbench/precise-match?resourceId=${id}`
- })
- },
- // 复制联系方式
- handleCopyContact(contact) {
- if (!contact) {
- uni.showToast({
- title: '联系方式为空',
- icon: 'none'
- })
- return
- }
-
- // 如果是脱敏的手机号,需要从原始数据中获取完整号码
- // 这里需要根据实际情况调整,可能需要从item中获取原始phone
- // 暂时先复制显示的文本
- uni.setClipboardData({
- data: contact,
- success: () => {
- uni.showToast({
- title: '已复制到剪贴板',
- icon: 'success'
- })
- },
- fail: () => {
- uni.showToast({
- title: '复制失败',
- icon: 'none'
- })
- }
- })
- },
- // 客户点击事件,跳转到客户详情页面
- handleClientClick(id) {
- uni.navigateTo({
- url: `/pages/matchmaker-workbench/client-detail?resourceId=${id}`
- })
- },
- // 资源项点击事件
- handleResourceClick(item) {
- console.log('=== 点击资源项 ===')
- console.log('item对象:', JSON.stringify(item, null, 2))
- console.log('item.id:', item.id)
- console.log('item.isUser:', item.isUser)
-
- // 判断是否为已注册用户
- if (item.isUser === 1) {
- // 已注册,跳转到客户详情页面
- const resourceId = item.id
- console.log('准备跳转,resourceId:', resourceId)
- uni.navigateTo({
- url: `/pages/matchmaker-workbench/client-detail?resourceId=${resourceId}`,
- success: () => {
- console.log('跳转成功,resourceId:', resourceId)
- },
- fail: (err) => {
- console.error('跳转失败:', err)
- }
- })
- } else {
- // 未注册,提示用户
- uni.showToast({
- title: '该用户还未注册用户端',
- icon: 'none',
- duration: 2000
- })
- }
- },
- // 添加资源
- handleAdd() {
- // 跳转到信息录入页面
- uni.navigateTo({
- url: '/pages/matchmaker-workbench/resource-input',
- success: () => {
- console.log('跳转到信息录入页面成功')
- },
- fail: (err) => {
- console.error('跳转失败:', err)
- uni.showToast({
- title: '页面跳转失败',
- icon: 'none'
- })
- }
- })
- },
- // 导航到工作台
- navigateToWorkbench() {
- uni.navigateTo({
- url: '/pages/matchmaker-workbench/index'
- })
- },
- // 导航到我的资源
- navigateToMyResources() {
- // 已在我的资源页面,无需跳转
- },
- // 导航到排行榜
- navigateToRanking() {
- uni.navigateTo({
- url: '/pages/matchmaker-workbench/ranking'
- })
- },
- // 导航到消息
- navigateToMessage() {
- uni.navigateTo({
- url: '/pages/matchmaker-workbench/message'
- })
- },
- // 导航到我的
- navigateToMine() {
- uni.navigateTo({
- url: '/pages/matchmaker-workbench/mine'
- })
- },
- // 启动自动刷新
- startAutoRefresh() {
- // 清除之前的定时器
- this.stopAutoRefresh()
- // 每30秒刷新一次,检查用户注册状态变化
- this.refreshTimer = setInterval(() => {
- console.log('定时刷新:检查用户注册状态变化')
- this.loadMyResources()
- }, 30000) // 30秒
- },
- // 停止自动刷新
- stopAutoRefresh() {
- if (this.refreshTimer) {
- clearInterval(this.refreshTimer)
- this.refreshTimer = null
- }
- },
- // 已注册资源图片加载错误处理
- handleImageErrorRegistered(index) {
- this.handleImageError(index, 'registered')
- },
- // 未注册资源图片加载错误处理
- handleImageErrorUnregistered(index) {
- this.handleImageError(index, 'unregistered')
- },
- // 已注册资源图片加载成功处理
- handleImageLoadRegistered(index) {
- this.handleImageLoad(index, 'registered')
- },
- // 未注册资源图片加载成功处理
- handleImageLoadUnregistered(index) {
- this.handleImageLoad(index, 'unregistered')
- },
- // 图片加载错误处理(内部方法)
- handleImageError(index, type) {
- try {
- const resourceList = type === 'registered' ? this.registeredResources : this.unregisteredResources
- const resource = resourceList && resourceList[index]
- if (!resource) {
- console.warn('图片加载失败:资源不存在,index:', index, 'type:', type)
- return
- }
-
- const originalUrl = resource.avatar
- console.error('❌ 图片加载失败:', {
- index: index,
- type: type,
- resourceName: resource.name,
- resourceId: resource.id,
- originalAvatarUrl: originalUrl,
- 'URL类型': typeof originalUrl,
- 'URL长度': originalUrl ? originalUrl.length : 0,
- '是否包含placeholder': originalUrl && originalUrl.includes('placeholder'),
- '完整resource对象': resource
- })
-
- // 如果图片加载失败,且不是已经设置的默认占位图,则设置为空(显示CSS背景)
- // 避免重复设置导致循环
- if (originalUrl &&
- originalUrl.trim() !== '' &&
- !originalUrl.includes('placeholder') &&
- !originalUrl.includes('default') &&
- !originalUrl.includes('via.placeholder')) {
- // 设置为空字符串,让CSS默认背景显示
- console.log('图片加载失败,将URL设置为空,显示CSS默认背景')
- if (type === 'registered') {
- this.$set(this.registeredResources[index], 'avatar', '')
- } else {
- this.$set(this.unregisteredResources[index], 'avatar', '')
- }
- } else {
- console.log('图片加载失败,但URL已经是占位图或空,无需处理')
- console.log('当前URL:', originalUrl)
- }
- } catch (e) {
- console.error('处理图片错误时发生异常:', e)
- }
- },
- // 图片加载成功处理(内部方法)
- handleImageLoad(index, type) {
- try {
- const resourceList = type === 'registered' ? this.registeredResources : this.unregisteredResources
- if (resourceList && resourceList[index]) {
- console.log('图片加载成功:', {
- index: index,
- type: type,
- resource: resourceList[index]?.name,
- avatarUrl: resourceList[index]?.avatar
- })
- }
- } catch (e) {
- console.error('处理图片加载成功时发生异常:', e)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .my-resources {
- min-height: 100vh;
- background: #F5F5F5;
- display: flex;
- flex-direction: column;
- }
- /* 顶部导航栏 */
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20rpx 30rpx;
- padding-top: calc(20rpx + env(safe-area-inset-top));
- background: #FFFFFF;
- border-bottom: 1rpx solid #F0F0F0;
- .header-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #9C27B0;
- }
- .header-right {
- .dropdown-arrow {
- font-size: 24rpx;
- color: #9C27B0;
- font-weight: normal;
- }
- }
- }
- /* 搜索栏 */
- .search-bar {
- padding: 20rpx;
- background: #F5F5F5;
- .search-input-wrapper {
- display: flex;
- align-items: center;
- background: #FFFFFF;
- border-radius: 30rpx;
- padding: 12rpx 20rpx;
- box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
- .search-icon-small {
- width: 32rpx;
- height: 32rpx;
- 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>');
- background-size: contain;
- background-repeat: no-repeat;
- background-position: center;
- margin-right: 15rpx;
- }
- .search-input {
- flex: 1;
- font-size: 28rpx;
- color: #333;
- border: none;
- outline: none;
- background: transparent;
- &::placeholder {
- color: #999;
- }
- }
- }
- }
- .content {
- flex: 1;
- padding: 0 20rpx 140rpx;
- }
- /* 资源分组 */
- .resource-section {
- margin-bottom: 30rpx;
-
- .section-header {
- display: flex;
- align-items: center;
- padding: 20rpx 0 15rpx;
- margin-bottom: 10rpx;
-
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #9C27B0;
- margin-right: 10rpx;
- }
-
- .section-count {
- font-size: 26rpx;
- color: #999;
- font-weight: normal;
- }
- }
- }
- /* 空状态 */
- .empty-state {
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 100rpx 0;
-
- .empty-text {
- font-size: 28rpx;
- color: #999;
- }
- }
- /* 资源列表 */
- .resource-item {
- background: #FFFFFF;
- border-radius: 20rpx;
- margin-bottom: 20rpx;
- padding: 25rpx;
- position: relative;
- box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
- /* 右上角选中图标 */
- .select-icon {
- position: absolute;
- top: 20rpx;
- right: 20rpx;
- width: 40rpx;
- height: 40rpx;
- background: #FF4444;
- color: #FFFFFF;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 24rpx;
- font-weight: bold;
- z-index: 10;
- }
- .resource-header {
- display: flex;
- align-items: flex-start;
- margin-bottom: 20rpx;
- padding-right: 50rpx;
- .resource-avatar {
- width: 100rpx;
- height: 100rpx;
- border-radius: 8rpx;
- margin-right: 20rpx;
- flex-shrink: 0;
- background-color: #F5F5F5;
- 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>');
- background-size: 60% 60%;
- background-position: center;
- background-repeat: no-repeat;
- }
- .resource-basic-info {
- flex: 1;
- min-width: 0;
- .name-gender {
- display: flex;
- align-items: center;
- gap: 10rpx;
- margin-bottom: 12rpx;
- .resource-name {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .resource-gender {
- font-size: 26rpx;
- color: #666;
-
- &.gender-tag {
- display: inline-block;
- padding: 4rpx 12rpx;
- background: #F3E5F5;
- color: #9C27B0;
- border-radius: 12rpx;
- font-size: 22rpx;
- font-weight: 500;
- }
- }
- }
- .status-tag-wrapper {
- display: flex;
- align-items: center;
- .status-tag {
- display: inline-block;
- padding: 4rpx 12rpx;
- border-radius: 12rpx;
- font-size: 22rpx;
- font-weight: 500;
- margin-right: 8rpx;
- &.approved {
- background: #E3F2FD;
- color: #2196F3;
- }
- &.pending {
- background: #FFF3E0;
- color: #FF9800;
- }
-
- &.register-tag {
- &.registered {
- background: #E8F5E9;
- color: #4CAF50;
- }
-
- &.unregistered {
- background: #FCE4EC;
- color: #E91E63;
- }
- }
-
- &.match-tag {
- margin-left: 10rpx;
-
- &.matched {
- background: #E3F2FD;
- color: #2196F3;
- }
-
- &.unmatched {
- background: #FFF3E0;
- color: #FF9800;
- }
- }
- }
- }
- }
- }
- .resource-details {
- .labels {
- display: flex;
- flex-wrap: wrap;
- gap: 10rpx;
- margin-bottom: 15rpx;
- .label {
- display: inline-block;
- padding: 6rpx 14rpx;
- background: #F3E5F5;
- color: #9C27B0;
- border-radius: 15rpx;
- font-size: 22rpx;
- font-weight: 500;
- }
- }
- .requirement-box {
- background: #F3E5F5;
- border-radius: 12rpx;
- padding: 16rpx 20rpx;
- margin-bottom: 15rpx;
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- .requirement-label {
- font-size: 28rpx;
- color: #7B1FA2;
- font-weight: 500;
- margin-right: 8rpx;
- white-space: nowrap;
- }
- .requirement-content {
- font-size: 28rpx;
- color: #7B1FA2;
- font-weight: 400;
- }
- }
- .contact-box {
- margin-bottom: 20rpx;
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- .contact-label {
- font-size: 26rpx;
- color: #333;
- font-weight: 500;
- margin-right: 10rpx;
- white-space: nowrap;
- }
- .contact-number {
- flex: 1;
- font-size: 26rpx;
- color: #333;
- font-weight: 400;
- min-width: 0;
- }
- .copy-btn {
- font-size: 24rpx;
- color: #9C27B0;
- font-weight: 500;
- margin-left: 15rpx;
- white-space: nowrap;
- cursor: pointer;
- }
- }
- .action-buttons {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 15rpx;
- .delete-btn {
- flex: 1;
- padding: 14rpx 0;
- background: #FFEBEE;
- color: #E91E63;
- border-radius: 25rpx;
- font-size: 26rpx;
- font-weight: 500;
- text-align: center;
- }
- .match-btn {
- flex: 1.5;
- padding: 14rpx 0;
- background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
- color: #FFFFFF;
- border-radius: 25rpx;
- font-size: 26rpx;
- font-weight: 500;
- text-align: center;
- }
- }
- }
- /* 优质资源标签 */
- .quality-tag {
- position: absolute;
- top: 80rpx;
- right: 20rpx;
- background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
- color: #FFFFFF;
- font-size: 22rpx;
- font-weight: bold;
- padding: 8rpx 16rpx;
- border-radius: 20rpx;
- display: flex;
- align-items: center;
- gap: 4rpx;
- box-shadow: 0 2rpx 8rpx rgba(156, 39, 176, 0.3);
- z-index: 5;
- .quality-star {
- font-size: 20rpx;
- }
- .quality-text {
- font-size: 22rpx;
- }
- }
- }
- /* 添加按钮 */
- .add-button {
- position: fixed;
- bottom: 130rpx;
- right: 40rpx;
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 4rpx 20rpx rgba(156, 39, 176, 0.4);
- z-index: 999;
- .add-button-icon {
- font-size: 60rpx;
- color: #FFFFFF;
- line-height: 1;
- font-weight: bold;
- }
- }
- /* 底部导航 */
- .tabbar {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- height: 100rpx;
- background: #FFFFFF;
- border-top: 1rpx solid #F0F0F0;
- display: flex;
- justify-content: space-around;
- align-items: center;
- padding-bottom: env(safe-area-inset-bottom);
- .tabbar-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 8rpx;
- padding: 10rpx 0;
- .tabbar-icon {
- width: 44rpx;
- height: 44rpx;
- background-size: contain;
- background-repeat: no-repeat;
- background-position: center;
- position: relative;
- .badge {
- position: absolute;
- top: -8rpx;
- right: -8rpx;
- background: #FF4444;
- color: #FFFFFF;
- font-size: 20rpx;
- font-weight: bold;
- width: 32rpx;
- height: 32rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 16rpx;
- }
- }
- .tabbar-text {
- font-size: 20rpx;
- color: #999;
- }
- &.active {
- .tabbar-text {
- color: #9C27B0;
- font-weight: bold;
- }
- }
- &.home .tabbar-icon {
- 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>');
- }
- &.active.home .tabbar-icon {
- 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>');
- }
- &.resources .tabbar-icon {
- 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>');
- }
- &.trophy .tabbar-icon {
- 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>');
- }
- &.active.trophy .tabbar-icon {
- 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>');
- }
- &.message .tabbar-icon {
- 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>');
- }
- &.active.message .tabbar-icon {
- 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>');
- }
- &.mine .tabbar-icon {
- 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>');
- }
- &.active.mine .tabbar-icon {
- 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>');
- }
- }
- }
- </style>
|