From 064bb44ec00dfcf486614a10d76a1e041775dfba Mon Sep 17 00:00:00 2001 From: huxuejian Date: Fri, 26 Jun 2026 15:12:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/team/business-card.vue | 741 ++------------------------ pages/team/components/teams-popup.vue | 28 +- pages/team/team-detail.vue | 9 +- routes/index.js | 4 + utils/api.js | 1 + 5 files changed, 78 insertions(+), 705 deletions(-) diff --git a/pages/team/business-card.vue b/pages/team/business-card.vue index 458c40d..82ee682 100644 --- a/pages/team/business-card.vue +++ b/pages/team/business-card.vue @@ -11,6 +11,11 @@ 全周期管理 + + + + 门诊预约 + @@ -21,11 +26,7 @@ 邮箱 - - - - 地址 - + @@ -42,8 +43,8 @@ - + - + @@ -101,27 +101,6 @@ - - - - - × - 便民服务 - - - - - {{ service.label }} - 🔗 - - - 暂无便民服务 - - - - - @@ -200,41 +179,6 @@ - - - - - 医院介绍 - × - - - - - - - 暂无医院介绍信息 - - - - - - - - - - 广医一院公众号 - × - - - - - - - - 扫描或长按二维码进入 - - - @@ -257,12 +201,28 @@ const { account } = storeToRefs(useAccount()); const env = __VITE_ENV__; const shareAppVersion = env.MP_SHARE_WX_APP_VERSION; +const activeTab = ref('hospital') // 'hospital' 或 'intro' const corpId = ref(''); const userid = ref('') const businessCard = ref(null); const teams = ref([]) -const showTeamPopup = ref(false) const hospitalInfo = computed(() => businessCard.value?.hospitalInfo || null); +const showPhoneModal = ref(false) +const showEmailModal = ref(false) +const showTeamPopup = ref(false) + + +function addFriend() { + uni.navigateTo({ + url: `/pages/team/friend?corpId=${corpId.value}&userid=${userid.value}` + }) +} + +function displayPhone() { + if (businessCard.value.externalContact) { + showPhoneModal.value = true + } +} function makePhoneCall(phone) { closePhoneModal() @@ -283,20 +243,21 @@ function setClipboardData(data) { }) } +function switchTab(tab) { + activeTab.value = tab +} + async function getCard() { const res = await api('getBusinessCard', { userid: userid.value, corpId: corpId.value }) businessCard.value = res && res.data ? res.data : null; + if (!hospitalInfo.value && activeTab.value === 'hospital') { + activeTab.value = 'intro' + } if (businessCard.value) { recordBusinessCardVisit() } } -async function displayPhone() { - if (businessCard.value.externalContact) { - showPhoneModal.value = true - } -} - async function showTeams() { const res = await api('getJoinedTeams', { mateId: userid.value, corpId: corpId.value }) teams.value = res && Array.isArray(res.data) ? res.data : []; @@ -343,6 +304,8 @@ async function getVisitorAccount() { } useLoad((opt) => { + console.clear() + console.log(account.value) if (opt.q) { const href = typeof opt.q === "string" ? decodeURIComponent(opt.q.trim()) : ""; const [, url = ""] = href.split("?"); @@ -371,7 +334,8 @@ onShareAppMessage((res) => { return { title: `【${businessCard.value.externalName || card.anotherName || ''}】电子名片`, type: shareAppVersion || 0, // 0 正式版本 | 1 开发版本 | 2 体验版本 - path: `/pages/team/business-card?corpId=${corpId.value}&userid=${userid.value}&shareOpenId=${account.value?.openid || ''}` + path: `/pages/team/business-card?corpId=${corpId.value}&userid=${userid.value}&shareOpenId=${account.value?.openid || ''}`, + imageUrl: 'https://ykt.youcan365.com/uploads/1782455619525-business-card.jpg' } } }) @@ -379,22 +343,9 @@ onShareAppMessage((res) => { const cardStore = ref({}) const accountStore = ref({}) -// 获取账户信息 -const accountInfo = computed(() => accountStore.getAccountInfo || {}) -const institutionInfo = computed(() => accountStore.getInstitutionInfo || {}) - -// 获取医生名片状态 -const doctorCardStatus = computed(() => accountStore.getDoctorCardStatus) - -// 判断是否有联系方式 -const hasContactInfo = computed(() => { - return cardStore.phoneVisible || cardStore.emailVisible || cardStore.addressVisible -}) // 弹窗显示状态 -const showServiceModal = ref(false) -const showPhoneModal = ref(false) -const showEmailModal = ref(false) + const showAddressModal = ref(false) const showMoreInfoModal = ref(false) const showOfficialAccountModal = ref(false) @@ -404,152 +355,18 @@ const showShareModal = ref(false) // 便民服务列表 const services = ref([]) -// Tab 切换状态 -const activeTab = ref('hospital') // 'hospital' 或 'intro' - -// 切换 tab -const switchTab = (tab) => { - activeTab.value = tab -} - -// 初始化 tab 状态 -const initTab = () => { - // 如果只有个人简介,默认显示个人简介 - if (!institutionInfo.value?.showHomepage) { - activeTab.value = 'intro' - } - // 如果只有医院信息,默认显示医院信息 - else if (!accountInfo.value.introduction) { - activeTab.value = 'hospital' - } - // 如果两者都有,默认显示医院信息 - else { - activeTab.value = 'hospital' - } -} - -// 防止在同一次拉取过程中重复创建名片 -let isAutoCreatingCard = false - - -const goToCard = () => { - uni.navigateTo({ - url: '/pages/card/card' - }) -} // 获取标签样式类名 const getTagClass = (index) => { const styles = ['grade', 'center', 'specialty'] return styles[index % 3] } -const goToQRCode = () => { - uni.navigateTo({ - url: '/pages/card/code' - }) -} -// 跳转到保存名片页 -const goToSave = () => { - uni.navigateTo({ - url: '/pages/business-card/card-qrcode/card-qrcode' - }) -} -// 处理Banner图片点击 -const handleBannerClick = (item) => { - if (!item || !item.link) { - return - } - - const link = item.link - - // 判断是否为外部链接 - if (link.startsWith('http://') || link.startsWith('https://')) { - // #ifdef H5 - window.open(link, '_blank') - // #endif - // #ifdef APP-PLUS - plus.runtime.openURL(link) - // #endif - // #ifdef MP-WEIXIN - // 微信小程序中,需要先复制链接,然后提示用户 - uni.setClipboardData({ - data: link, - success: () => { - uni.showToast({ - title: '链接已复制', - icon: 'success' - }) - } - }) - // #endif - } else { - // 内部链接,使用导航 - uni.navigateTo({ - url: link - }) - } -} -// 打开便民服务弹窗 -const openServiceModal = () => { - showServiceModal.value = true -} // 关闭便民服务弹窗 const closeServiceModal = () => { showServiceModal.value = false } -// 打开便民服务链接 -const openServiceLink = (service) => { - if (service.url) { - // 关闭弹窗 - closeServiceModal() - - // 显示确认对话框 - uni.showModal({ - title: '提示', - content: `即将跳转到:${service.label}`, - success: (res) => { - if (res.confirm) { - uni.showToast({ - title: '正在跳转中...', - icon: 'none' - }) - - // #ifdef H5 - // H5环境下使用window.open打开外部链接 - window.open(service.url, '_blank') - // #endif - - // #ifdef MP-WEIXIN - // 微信小程序环境下使用uni.navigateToMiniProgram或提示用户 - uni.showToast({ - title: '请在浏览器中打开链接', - icon: 'none', - duration: 2000 - }) - // #endif - - // #ifdef APP-PLUS - // App环境下使用plus.runtime.openURL - plus.runtime.openURL(service.url) - // #endif - } - } - }) - } else { - uni.showToast({ - title: '该服务暂无链接', - icon: 'none' - }) - } -} - -// 打开电话弹窗 -const openPhoneModal = () => { - showPhoneModal.value = true -} - // 关闭电话弹窗 const closePhoneModal = () => { showPhoneModal.value = false @@ -565,9 +382,9 @@ const closeEmailModal = () => { showEmailModal.value = false } -// 打开地址弹窗 const openAddressModal = () => { - showAddressModal.value = true + toast('门诊预约功能暂未开放') + // showAddressModal.value = true } // 关闭地址弹窗 @@ -575,211 +392,10 @@ const closeAddressModal = () => { showAddressModal.value = false } -// 打开医院介绍弹窗 -const openMoreInfoModal = () => { - showMoreInfoModal.value = true - -} - -// 关闭医院介绍弹窗 -const closeMoreInfoModal = () => { - showMoreInfoModal.value = false -} - -// 打开公众号弹窗 -const openOfficialAccountModal = () => { - showOfficialAccountModal.value = true -} - -// 关闭公众号弹窗 -const closeOfficialAccountModal = () => { - showOfficialAccountModal.value = false -} - -// 打开视频号弹窗 -const openVideoAccountModal = () => { - showVideoAccountModal.value = true -} - -// 关闭视频号弹窗 -const closeVideoAccountModal = () => { - showVideoAccountModal.value = false -} - - - -// 处理人才招聘点击 -const handleRecruitClick = () => { - const recruitUrl = 'https://www.gyfyyy.cn/cn/wap/news/xwsd/' - openExternalLink(recruitUrl) -} - -// 处理官网点击 -const handleWebsiteClick = () => { - const websiteUrl = 'https://www.gyfyyy.cn/' - openExternalLink(websiteUrl) -} - -// 打开外部链接的通用方法 -const openExternalLink = (url) => { - if (!url) { - uni.showToast({ - title: '链接地址无效', - icon: 'none' - }) - return - } - - // 判断是否为外部链接 - if (url.startsWith('http://') || url.startsWith('https://')) { - // #ifdef H5 - window.open(url, '_blank') - // #endif - // #ifdef APP-PLUS - plus.runtime.openURL(url) - // #endif - // #ifdef MP-WEIXIN - // 微信小程序中,需要先复制链接,然后提示用户 - uni.setClipboardData({ - data: url, - success: () => { - uni.showModal({ - title: '提示', - content: '链接已复制到剪贴板,请在浏览器中打开', - showCancel: false - }) - } - }) - // #endif - } else { - // 内部链接,使用导航 - uni.navigateTo({ - url: url - }) - } -} - -// 处理来院导航点击 -const handleNavigationClick = () => { - // 跳转到导航页面 - uni.navigateTo({ - url: '/pages/navigation/index' - }) -} -// 打开官网 -const openWebsite = () => { - // 在微信小程序中打开外部网址 - uni.showModal({ - title: '提示', - content: '即将打开医院官网,是否继续?', - success: (res) => { - if (res.confirm) { - uni.showToast({ - title: '正在跳转中...', - icon: 'none', - duration: 1500 - }) - } - } - }) -} - -// 打开互联网医院 -const openInternetHospital = () => { - // 在微信小程序中打开外部网址 - uni.showModal({ - title: '提示', - content: '即将打开互联网医院平台,是否继续?', - success: (res) => { - if (res.confirm) { - uni.showToast({ - title: '正在跳转中...', - icon: 'none', - duration: 3000 - }) - } - } - }) -} - -// 打开分享弹窗 -const openShareModal = () => { - showShareModal.value = true -} - -// 关闭分享弹窗 -const closeShareModal = () => { - showShareModal.value = false -} - -// 分享到企业微信 -const shareToWechatWork = () => { - uni.showToast({ - title: '分享到企业微信...', - icon: 'none' - }) - closeShareModal() -} - -// 分享到微信 -const shareToWechat = () => { - uni.showToast({ - title: '分享到微信...', - icon: 'none' - }) - closeShareModal() -} - - -// 跳转到编辑名片页 -const addFriend = () => { - uni.navigateTo({ - url: `/pages/team/friend?corpId=${corpId.value}&userid=${userid.value}` - }) -} - // 复制邮箱地址 const copyEmail = (email) => { closeEmailModal() - // #ifdef H5 - // H5环境下使用navigator.clipboard API - if (navigator.clipboard) { - navigator.clipboard.writeText(email).then(() => { - uni.showToast({ - title: '邮箱已复制', - icon: 'none' - }) - }).catch(() => { - // 降级方案:使用传统方法 - const textArea = document.createElement('textarea') - textArea.value = email - document.body.appendChild(textArea) - textArea.select() - document.execCommand('copy') - document.body.removeChild(textArea) - uni.showToast({ - title: '邮箱已复制', - icon: 'none' - }) - }) - } else { - // 降级方案 - const textArea = document.createElement('textarea') - textArea.value = email - document.body.appendChild(textArea) - textArea.select() - document.execCommand('copy') - document.body.removeChild(textArea) - uni.showToast({ - title: '邮箱已复制', - icon: 'none' - }) - } - // #endif - - // #ifdef MP-WEIXIN || APP-PLUS - // 微信小程序和App环境下使用uni.setClipboardData uni.setClipboardData({ data: email, success: () => { @@ -795,280 +411,6 @@ const copyEmail = (email) => { }) } }) - // #endif -} - -// 打开地图 -const openMap = (address) => { - // 关闭地址弹窗 - closeAddressModal() - - // #ifdef H5 - // H5环境下使用百度地图或高德地图网页版 - uni.showModal({ - title: '提示', - content: '即将在浏览器中打开地图,是否继续?', - success: (res) => { - if (res.confirm) { - // 使用百度地图网页版 - const mapUrl = `https://api.map.baidu.com/geocoder?address=${encodeURIComponent(address)}&output=html&src=webapp.baidu.openAPIdemo` - window.open(mapUrl, '_blank') - } - } - }) - // #endif - - // #ifdef MP-WEIXIN || APP-PLUS - // 微信小程序和App环境下使用uni.openLocation - uni.openLocation({ - latitude: 23.1291, // 广州的纬度 - longitude: 113.2644, // 广州的经度 - name: '广州医科大学附属第一医院', - address: address, - scale: 18, - success: () => { - console.log('地图打开成功') - }, - fail: (err) => { - console.error('地图打开失败:', err) - // 如果打开地图失败,提供备选方案 - uni.showModal({ - title: '提示', - content: '无法打开地图,是否复制地址到剪贴板?', - success: (res) => { - if (res.confirm) { - uni.setClipboardData({ - data: address, - success: () => { - uni.showToast({ - title: '地址已复制', - icon: 'none' - }) - } - }) - } - } - }) - } - }) - // #endif -} - - -const getDoctorCardListData = async () => { - try { - const res = await getDoctorCardList({ - staffId: accountStore.getAccountInfo.staffId - }) - - // 更新医生名片状态和基本信息 - if (res.success && res.data) { - // 提取基本信息(如果API返回了医生信息) - const basicInfo = res.data.staffInfo ? { - staffId: res.data.staffInfo.staffId || accountStore.getAccountInfo.staffId, - staffName: res.data.staffInfo.staffName || accountStore.getAccountInfo.staffName, - hospitalId: res.data.staffInfo.hospitalId || accountStore.getAccountInfo.hospitalId, - hospitalName: res.data.staffInfo.hospitalName || accountStore.getAccountInfo.hospitalName, - position: res.data.staffInfo.position || accountStore.getAccountInfo.position, - jobTitle: res.data.staffInfo.jobTitle || accountStore.getAccountInfo.jobTitle, - professionalTitle: res.data.staffInfo.professionalTitle || accountStore.getAccountInfo.professionalTitle, - phone: res.data.staffInfo.phone || accountStore.getAccountInfo.phone, - enterpriseWechatId: res.data.staffInfo.enterpriseWechatId || accountStore.getAccountInfo.enterpriseWechatId, - email: res.data.staffInfo.email || accountStore.getAccountInfo.email, - address: res.data.staffInfo.address || accountStore.getAccountInfo.address, - photo: res.data.staffInfo.photo || accountStore.getAccountInfo.photo, - introduction: res.data.staffInfo.introduction || accountStore.getAccountInfo.introduction, - departments: res.data.staffInfo.departments || accountStore.getAccountInfo.departments - } : null; - - accountStore.updateDoctorCardStatus( - res.data.hasCards || false, - res.data.message || '', - basicInfo - ) - - // 当接口返回明确没有名片时:自动创建名片,然后重新拉取列表 - if (res.data.hasCards === false) { - if (!isAutoCreatingCard) { - isAutoCreatingCard = true - try { - const account = accountStore.getAccountInfo - const departments = accountStore.getDepartments || [] - const primaryDept = - departments.find((d) => d.isPrimary) || departments[0] - - const externalDisplay = { - phone: cardStore.phoneVisible, - email: cardStore.emailVisible, - address: cardStore.addressVisible, - deptName: cardStore.deptNameVisible, - position: cardStore.positionVisible - } - - const convenienceServices = (cardStore.services || []).map((service) => ({ - serviceName: service.label || service.serviceName || '', - serviceUrl: service.url || service.serviceUrl || '' - })) - - const requestData = { - staffId: account.staffId, - shareMessage: cardStore.shareMessage, - phone: account.phone, - email: account.email, - address: account.address, - position: account.position, - photo: account.photo, - introduction: account.introduction, - externalDisplay, - convenienceServices - } - - // 设置主部门(保持与 edit-card.vue 一致) - if (primaryDept?.deptId) { - requestData.deptId = primaryDept.deptId - await setDeptStaffPrimary({ - staffId: account.staffId, - primaryDeptId: primaryDept.deptId - }) - accountStore.updatePrimaryDepartment(primaryDept.deptId) - } - - uni.showLoading({ title: '正在创建名片...' }) - const createRes = await createDoctorCard(requestData) - uni.hideLoading() - - if (!createRes?.success) { - throw new Error(createRes?.message || '创建名片失败') - } - - // 创建成功后重新拉取列表 - await getDoctorCardListData() - return - } catch (error) { - uni.hideLoading() - uni.showToast({ - title: '名片创建失败,请稍后重试', - icon: 'none', - duration: 2000 - }) - console.error('自动创建名片失败:', error) - } finally { - isAutoCreatingCard = false - } - } - } - - // 更新名片列表数据 - if (res.data.hasCards && res.data.cards) { - // 使用接口返回的名片数据 - const newCardList = res.data.cards.map(card => ({ - name: accountStore.getAccountInfo.staffName || '未知', - hospital: accountStore.getAccountInfo.hospitalName || '', - title: `${accountStore.getAccountInfo.deptName || ''} ${accountStore.getAccountInfo.position || ''}`, - version: card.version || '', - cardId: card.cardId - })) - - // 更新cardStore中的名片列表 - cardStore.setCardList(newCardList) - console.log('cardList:', newCardList) - - // 如果当前没有选中的名片,或者当前选中的名片不在新列表中,则选择第一张 - if (!cardStore.currentCardId || !newCardList.some(card => card.cardId === cardStore.currentCardId)) { - const firstCardId = newCardList[0].cardId || '' - cardStore.setCurrentCardId(firstCardId) - console.log('设置第一张名片为当前选中:', firstCardId) - - // 更新名片缓存数据 - await updateCardCache(firstCardId) - } else { - // 更新当前选中名片的缓存数据 - await updateCardCache(cardStore.currentCardId) - } - } else { - // 如果没有名片,使用默认数据 - const account = accountStore.getAccountInfo - const defaultCardList = [{ - name: account.staffName || '', - hospital: account.hospitalName || '', - title: `${account.deptName || ''} ${account.position || ''}`, - version: '全员通用版', - cardId: 'default' - }] - cardStore.setCardList(defaultCardList) - cardStore.setCurrentCardId('default') - } - } - } catch (error) { - console.error('获取名片列表失败:', error) - // 如果获取失败,默认设置为没有名片 - accountStore.updateDoctorCardStatus(false, '获取名片信息失败') - cardId.value = '' - - // 使用默认名片数据 - const account = accountStore.getAccountInfo - const defaultCardList = [{ - name: account.staffName || '', - hospital: account.hospitalName || '', - title: `${account.deptName || ''} ${account.position || ''}`, - version: '全员通用版', - cardId: 'default' - }] - cardStore.setCardList(defaultCardList) - cardStore.setCurrentCardId('default') - } -} - -// 更新名片缓存数据 -const updateCardCache = async (cardId) => { - if (!cardId) return - - try { - console.log('开始获取名片详情并更新缓存,cardId:', cardId) - const detailRes = await getDoctorCardDetail({ cardId }) - - if (detailRes.success && detailRes.data) { - const cardData = detailRes.data - console.log('名片详情数据:', cardData) - - // 更新名片分享语 - if (cardData.shareMessage) { - cardStore.shareMessage = cardData.shareMessage - } - - // 更新对外信息展示配置 - if (cardData.externalDisplay) { - cardStore.updateContactVisibility( - cardData.externalDisplay.phone || false, - cardData.externalDisplay.email || false, - cardData.externalDisplay.address || false, - cardData.externalDisplay.deptName || false, - cardData.externalDisplay.position || false - ) - } - - // 更新便民服务 - if (cardData.convenienceServices && cardData.convenienceServices.length > 0) { - cardStore.services = cardData.convenienceServices.map(service => ({ - label: service.serviceName, - url: service.serviceUrl - })) - } - - // 更新审核状态到缓存 - if (cardData.auditStatus) { - cardStore.setAuditStatus(cardData.auditStatus) - console.log('名片审核状态已缓存:', cardData.auditStatus) - } - - // 保存到本地存储 - cardStore.saveToStorage() - - console.log('名片缓存数据已更新') - } - } catch (error) { - console.error('更新名片缓存失败:', error) - } } @@ -1181,11 +523,12 @@ const updateCardCache = async (cardId) => { } .service-text { - font-size: 28rpx; + font-size: 32rpx; color: #fff; text-align: center; font-weight: 500; position: relative; + white-space: nowrap; z-index: 1; } diff --git a/pages/team/components/teams-popup.vue b/pages/team/components/teams-popup.vue index 8f4e855..52607b7 100644 --- a/pages/team/components/teams-popup.vue +++ b/pages/team/components/teams-popup.vue @@ -23,7 +23,12 @@