|
|
|
@ -9,67 +9,65 @@ Page({ |
|
|
|
diagnosisData: {}, |
|
|
|
replies: [], |
|
|
|
baseUrl: baseUrl, |
|
|
|
refreshing: false |
|
|
|
refreshing: false, |
|
|
|
showPlanModal: false, // 控制弹框显示
|
|
|
|
planList: [] // 方案列表数据
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad(options) { |
|
|
|
if (options.data) { |
|
|
|
// 根据id加载兽医回复数据
|
|
|
|
const data = JSON.parse(decodeURIComponent(options.data)); |
|
|
|
if (options.id) { |
|
|
|
this.getwzdetails(options.id) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理用户图片 - 确保是数组格式
|
|
|
|
if (data.images) { |
|
|
|
if (typeof data.images === 'string') { |
|
|
|
data.images = data.images.split(',') |
|
|
|
// 问诊单详情
|
|
|
|
getwzdetails(id) { |
|
|
|
http.wzdDetails({ |
|
|
|
data: { |
|
|
|
id: id |
|
|
|
}, |
|
|
|
success: res => { |
|
|
|
console.log(1111, res); |
|
|
|
if (res.data.images) { |
|
|
|
if (typeof res.data.images === 'string') { |
|
|
|
res.data.images = res.data.images.split(',') |
|
|
|
} |
|
|
|
} else { |
|
|
|
res.data.images = []; |
|
|
|
} |
|
|
|
console.log('用户图片:', data.images); |
|
|
|
} else { |
|
|
|
data.images = []; |
|
|
|
} |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
diagnosisData: data, |
|
|
|
}) |
|
|
|
this.loadDiagnosisData(data.formId); |
|
|
|
} |
|
|
|
this.loadDiagnosisData(res.data.formId); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
diagnosisData: res.data, |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 加载问诊数据(兽医回复) |
|
|
|
* @param {string} id - 问诊ID |
|
|
|
*/ |
|
|
|
// 加载问诊数据(兽医回复)
|
|
|
|
loadDiagnosisData(id) { |
|
|
|
console.log('加载问诊数据:', id); |
|
|
|
http.wzdxq({ |
|
|
|
data: { |
|
|
|
consultationId: id |
|
|
|
}, |
|
|
|
success: res => { |
|
|
|
// 处理兽医回复的图片
|
|
|
|
let replies = []; |
|
|
|
|
|
|
|
if (res && res.rows) { |
|
|
|
replies = res.rows || []; |
|
|
|
|
|
|
|
// 遍历每个回复,处理图片字段
|
|
|
|
for (let i = 0; i < replies.length; i++) { |
|
|
|
const item = replies[i]; |
|
|
|
|
|
|
|
// 处理图片 - 确保是数组格式
|
|
|
|
if (item.images) { |
|
|
|
if (typeof item.images === 'string') { |
|
|
|
// 如果是空字符串,设为空数组
|
|
|
|
if (item.images.trim() === '') { |
|
|
|
item.images = []; |
|
|
|
} else { |
|
|
|
// 按逗号分割字符串
|
|
|
|
item.images = item.images.split(','); |
|
|
|
} |
|
|
|
} else if (Array.isArray(item.images)) { |
|
|
|
// 已经是数组,但需要过滤空值
|
|
|
|
item.images = item.images.filter(img => img && img.trim() !== ''); |
|
|
|
} else { |
|
|
|
item.images = []; |
|
|
|
@ -77,66 +75,123 @@ Page({ |
|
|
|
} else { |
|
|
|
item.images = []; |
|
|
|
} |
|
|
|
|
|
|
|
console.log(`兽医回复[${i}]图片:`, item.images); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log('兽医回复数据:', replies); |
|
|
|
this.setData({ |
|
|
|
replies: replies |
|
|
|
}) |
|
|
|
}, |
|
|
|
fail: err => { |
|
|
|
console.error('加载回复失败:', err); |
|
|
|
wx.showToast({ |
|
|
|
title: '加载失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 返回上一页 |
|
|
|
*/ |
|
|
|
goBack() { |
|
|
|
wx.navigateBack(); |
|
|
|
}, |
|
|
|
// 获取方案列表
|
|
|
|
getplanDetails(id) { |
|
|
|
http.planDetails({ |
|
|
|
data: { |
|
|
|
consultationId: id |
|
|
|
}, |
|
|
|
success: res => { |
|
|
|
console.log('方案列表:', res); |
|
|
|
let list = []; |
|
|
|
if (res.rows) { |
|
|
|
list = res.rows |
|
|
|
|
|
|
|
/** |
|
|
|
* 分享 |
|
|
|
*/ |
|
|
|
onShare() { |
|
|
|
wx.showActionSheet({ |
|
|
|
itemList: ['分享给好友', '保存到相册'], |
|
|
|
success: (res) => { |
|
|
|
if (res.tapIndex === 0) { |
|
|
|
wx.showToast({ |
|
|
|
title: '已分享', |
|
|
|
icon: 'success' |
|
|
|
// 处理图片字段
|
|
|
|
list.forEach(item => { |
|
|
|
if (item.images) { |
|
|
|
if (typeof item.images === 'string') { |
|
|
|
item.images = item.images ? item.images.split(',') : []; |
|
|
|
} |
|
|
|
} else { |
|
|
|
item.images = []; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
this.setData({ planList: list }); |
|
|
|
}, |
|
|
|
fail: err => { |
|
|
|
console.error('获取方案列表失败', err); |
|
|
|
wx.showToast({ |
|
|
|
title: '获取方案失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 显示方案弹框
|
|
|
|
showPlanModal() { |
|
|
|
const consultationId = this.data.diagnosisData.id || this.data.diagnosisData.formId; |
|
|
|
if (!consultationId) { |
|
|
|
wx.showToast({ title: '问诊单ID不存在', icon: 'none' }); |
|
|
|
return; |
|
|
|
} |
|
|
|
wx.showLoading({ title: '加载中...', mask: true }); |
|
|
|
this.getplanDetails(consultationId); |
|
|
|
setTimeout(() => { |
|
|
|
wx.hideLoading(); |
|
|
|
this.setData({ showPlanModal: true }); |
|
|
|
}, 500); |
|
|
|
}, |
|
|
|
|
|
|
|
// 隐藏方案弹框
|
|
|
|
hidePlanModal() { |
|
|
|
this.setData({ showPlanModal: false }); |
|
|
|
}, |
|
|
|
|
|
|
|
// 阻止事件冒泡
|
|
|
|
stopPropagation() { |
|
|
|
return; |
|
|
|
}, |
|
|
|
|
|
|
|
// 阻止触摸滚动
|
|
|
|
preventTouch() { |
|
|
|
return; |
|
|
|
}, |
|
|
|
|
|
|
|
// 预览方案图片
|
|
|
|
previewPlanImage(e) { |
|
|
|
const dataset = e.currentTarget.dataset; |
|
|
|
const currentUrl = dataset.url; |
|
|
|
const urls = dataset.urls || []; |
|
|
|
const base = dataset.base || baseUrl; |
|
|
|
|
|
|
|
const fullUrls = urls.map(item => { |
|
|
|
if (typeof item === 'string' && (item.startsWith('http://') || item.startsWith('https://'))) { |
|
|
|
return item; |
|
|
|
} |
|
|
|
return base + item; |
|
|
|
}); |
|
|
|
|
|
|
|
wx.previewImage({ |
|
|
|
current: currentUrl, |
|
|
|
urls: fullUrls |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 返回上一页 |
|
|
|
*/ |
|
|
|
goBack() { |
|
|
|
wx.navigateBack(); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 下拉刷新 |
|
|
|
*/ |
|
|
|
onRefresh() { |
|
|
|
this.setData({ |
|
|
|
refreshing: true |
|
|
|
}); |
|
|
|
|
|
|
|
this.setData({ refreshing: true }); |
|
|
|
if (this.data.diagnosisData && this.data.diagnosisData.formId) { |
|
|
|
this.loadDiagnosisData(this.data.diagnosisData.formId) |
|
|
|
this.loadDiagnosisData(this.data.diagnosisData.formId); |
|
|
|
} |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
this.setData({ |
|
|
|
refreshing: false |
|
|
|
}); |
|
|
|
this.setData({ refreshing: false }); |
|
|
|
wx.showToast({ |
|
|
|
title: '刷新成功', |
|
|
|
icon: 'success' |
|
|
|
@ -151,18 +206,12 @@ Page({ |
|
|
|
const dataset = e.currentTarget.dataset; |
|
|
|
const current = dataset.url; |
|
|
|
const urls = dataset.urls || []; |
|
|
|
|
|
|
|
// 构建完整URL数组
|
|
|
|
const urlsArray = urls.map(item => { |
|
|
|
// 如果已经是完整URL,直接返回
|
|
|
|
if (typeof item === 'string' && (item.startsWith('http://') || item.startsWith('https://'))) { |
|
|
|
return item; |
|
|
|
} |
|
|
|
// 否则拼接baseUrl
|
|
|
|
return baseUrl + item; |
|
|
|
}); |
|
|
|
|
|
|
|
console.log('预览用户图片:', urlsArray); |
|
|
|
wx.previewImage({ |
|
|
|
current: current, |
|
|
|
urls: urlsArray |
|
|
|
@ -170,39 +219,27 @@ Page({ |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 预览兽医回复图片 - 修复版 |
|
|
|
* 预览兽医回复图片 |
|
|
|
*/ |
|
|
|
previewReplyImage(e) { |
|
|
|
const dataset = e.currentTarget.dataset; |
|
|
|
|
|
|
|
// 获取数据 - 使用三种可能的来源
|
|
|
|
const currentFileName = dataset.url; // 当前点击的图片文件名
|
|
|
|
const currentFullUrl = dataset.fullurl; // 当前点击的图片完整URL
|
|
|
|
const urlsArray = dataset.urls || []; // 该回复的所有图片文件名数组
|
|
|
|
const currentIndex = dataset.currentIndex || 0; // 当前点击图片的索引
|
|
|
|
const replyIndex = dataset.replyIndex; // 回复在列表中的索引
|
|
|
|
|
|
|
|
console.log('预览兽医图片 - 数据集:', dataset); |
|
|
|
|
|
|
|
// 方法1: 从replies数据中获取当前回复的图片列表
|
|
|
|
let targetUrls = []; |
|
|
|
let targetCurrentUrl = ''; |
|
|
|
const currentFileName = dataset.url; |
|
|
|
const currentFullUrl = dataset.fullurl; |
|
|
|
const urlsArray = dataset.urls || []; |
|
|
|
const currentIndex = dataset.currentIndex || 0; |
|
|
|
const replyIndex = dataset.replyIndex; |
|
|
|
|
|
|
|
if (replyIndex !== undefined && this.data.replies[replyIndex]) { |
|
|
|
// 从replies数据中获取完整的图片列表
|
|
|
|
const reply = this.data.replies[replyIndex]; |
|
|
|
if (reply.images && reply.images.length > 0) { |
|
|
|
targetUrls = reply.images; |
|
|
|
|
|
|
|
// 构建完整URL数组
|
|
|
|
const targetUrls = reply.images; |
|
|
|
const fullUrls = targetUrls.map(img => { |
|
|
|
if (typeof img === 'string' && (img.startsWith('http://') || img.startsWith('https://'))) { |
|
|
|
return img; |
|
|
|
} |
|
|
|
return baseUrl + img; |
|
|
|
}); |
|
|
|
|
|
|
|
// 确定当前图片的完整URL
|
|
|
|
let targetCurrentUrl = ''; |
|
|
|
if (currentIndex < fullUrls.length) { |
|
|
|
targetCurrentUrl = fullUrls[currentIndex]; |
|
|
|
} else if (currentFullUrl) { |
|
|
|
@ -210,9 +247,6 @@ Page({ |
|
|
|
} else if (currentFileName) { |
|
|
|
targetCurrentUrl = baseUrl + currentFileName; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('预览兽医回复图片(从replies数据):', fullUrls, '当前:', targetCurrentUrl); |
|
|
|
|
|
|
|
wx.previewImage({ |
|
|
|
current: targetCurrentUrl, |
|
|
|
urls: fullUrls |
|
|
|
@ -221,17 +255,13 @@ Page({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 方法2: 使用dataset中的数据
|
|
|
|
if (urlsArray && urlsArray.length > 0) { |
|
|
|
// 构建完整URL数组
|
|
|
|
const fullUrls = urlsArray.map(item => { |
|
|
|
if (typeof item === 'string' && (item.startsWith('http://') || item.startsWith('https://'))) { |
|
|
|
return item; |
|
|
|
} |
|
|
|
return baseUrl + item; |
|
|
|
}); |
|
|
|
|
|
|
|
// 确定当前图片的完整URL
|
|
|
|
let currentUrl = ''; |
|
|
|
if (currentFullUrl) { |
|
|
|
currentUrl = currentFullUrl; |
|
|
|
@ -240,9 +270,6 @@ Page({ |
|
|
|
} else if (currentFileName) { |
|
|
|
currentUrl = baseUrl + currentFileName; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('预览兽医回复图片(从dataset):', fullUrls, '当前:', currentUrl); |
|
|
|
|
|
|
|
wx.previewImage({ |
|
|
|
current: currentUrl, |
|
|
|
urls: fullUrls |
|
|
|
@ -250,16 +277,13 @@ Page({ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 方法3: 只预览单张图片
|
|
|
|
if (currentFullUrl) { |
|
|
|
console.log('预览单张兽医图片:', [currentFullUrl]); |
|
|
|
wx.previewImage({ |
|
|
|
current: currentFullUrl, |
|
|
|
urls: [currentFullUrl] |
|
|
|
}); |
|
|
|
} else if (currentFileName) { |
|
|
|
const fullUrl = baseUrl + currentFileName; |
|
|
|
console.log('预览单张兽医图片(拼接后):', [fullUrl]); |
|
|
|
wx.previewImage({ |
|
|
|
current: fullUrl, |
|
|
|
urls: [fullUrl] |
|
|
|
|