Commit 66a4457b by 李伟康

feat(mobile): 优化移动端报告分享和设置功能

- 修改setClipboardData工具函数,增加hideToast参数控制是否显示提示
- 在报告分享功能中启用隐藏复制提示的功能
- 移除路由文件中的注释代码,清理条件判断逻辑
- 在报告组件中使用v-html渲染并添加formatText方法处理文本换行
- 在报告卡片页面增加reportId传递功能,优化iframe高度调整
- 为设置页面的开关组件添加非激活状态颜色配置
1 parent d59fed1c
...@@ -115,7 +115,7 @@ export default { ...@@ -115,7 +115,7 @@ export default {
}, },
shareReport () { shareReport () {
const { reportStartDate, reportEndDate, reportType, corpId } = this.query const { reportStartDate, reportEndDate, reportType, corpId } = this.query
utils.setClipboardData(`${window.location.origin}/#/mobile/report?reportStartDate=${reportStartDate}&reportEndDate=${reportEndDate}&reportType=${reportType}&corpId=${corpId}`, '链接复制成功,快去粘贴吧~') utils.setClipboardData(`${window.location.origin}/#/mobile/report?reportStartDate=${reportStartDate}&reportEndDate=${reportEndDate}&reportType=${reportType}&corpId=${corpId}`, '链接复制成功,快去粘贴吧~',true)
window.parent.postMessage( window.parent.postMessage(
{ type: 'COPY_SUCCESS' }, { type: 'COPY_SUCCESS' },
'*' '*'
......
...@@ -45,7 +45,7 @@ router.beforeEach((to, from, next) => { ...@@ -45,7 +45,7 @@ router.beforeEach((to, from, next) => {
store.state.app.showWindow = true store.state.app.showWindow = true
store.dispatch('registerHttp') store.dispatch('registerHttp')
} else { } else {
if (!isWxWork && to.name !== 'notWxWork') return next('/mobile/notWxWork') //上线打开 if (!isWxWork && to.name !== 'notWxWork') return next('/mobile/notWxWork')
store.dispatch('navigation', to) store.dispatch('navigation', to)
} }
next() next()
......
...@@ -120,7 +120,7 @@ const jumpChildrenPage = (to, params) => { ...@@ -120,7 +120,7 @@ const jumpChildrenPage = (to, params) => {
} }
/**拷贝 */ /**拷贝 */
const setClipboardData = (data, tips) => { const setClipboardData = (data, tips, hideToast) => {
let transfer = document.createElement('input') let transfer = document.createElement('input')
document.body.appendChild(transfer) document.body.appendChild(transfer)
transfer.value = data transfer.value = data
...@@ -128,7 +128,7 @@ const setClipboardData = (data, tips) => { ...@@ -128,7 +128,7 @@ const setClipboardData = (data, tips) => {
transfer.select() transfer.select()
if (document.execCommand('copy')) document.execCommand('copy') if (document.execCommand('copy')) document.execCommand('copy')
transfer.blur() transfer.blur()
Toast(tips || '内容已复制') if (!hideToast) Toast(tips || '内容已复制')
document.body.removeChild(transfer) document.body.removeChild(transfer)
} }
......
...@@ -83,8 +83,7 @@ ...@@ -83,8 +83,7 @@
<span class="dot">●</span> <span class="dot">●</span>
整体结论 整体结论
</div> </div>
<div class="content-text"> <div class="content-text" v-html="formatText(b.overallConclusion)">
{{ b.overallConclusion || '暂无整体结论' }}
</div> </div>
<!-- 行动建议 --> <!-- 行动建议 -->
...@@ -92,8 +91,7 @@ ...@@ -92,8 +91,7 @@
<span class="dot">●</span> <span class="dot">●</span>
行动建议 行动建议
</div> </div>
<div class="content-text"> <div class="content-text" v-html="formatText(b.actionSuggestion)">
{{ b.actionSuggestion || '暂无行动建议' }}
</div> </div>
</div> </div>
</template> </template>
...@@ -143,6 +141,12 @@ export default { ...@@ -143,6 +141,12 @@ export default {
} }
}, },
methods: { methods: {
// 格式化文本,将 \n 转换为 <br>
formatText (text) {
if (!text) return '暂无内容'
// 将换行符转换为 <br> 标签
return text.replace(/\n/g, '<br>')
},
// 格式化变化值 // 格式化变化值
formatChange (value) { formatChange (value) {
if (value === null || value === undefined) return '-' if (value === null || value === undefined) return '-'
......
...@@ -50,11 +50,20 @@ export default { ...@@ -50,11 +50,20 @@ export default {
return 150 return 150
} }
// 存储 reportId
let currentReportId = ''
window.addEventListener('message', function (event) { window.addEventListener('message', function (event) {
if (event.data && event.data.type === 'GET_IFRAME_HEIGHT') { if (event.data && event.data.type === 'GET_IFRAME_HEIGHT') {
// 保存 reportId
currentReportId = event.data.reportId || ''
// 发送 report-card 的高度给父页面 // 发送 report-card 的高度给父页面
window.parent.postMessage( window.parent.postMessage(
{ type: 'RESIZE_IFRAME', height: getReportCardHeight() }, {
type: 'RESIZE_IFRAME',
height: getReportCardHeight(),
reportId: currentReportId
},
'*' '*'
) )
} }
...@@ -64,7 +73,11 @@ export default { ...@@ -64,7 +73,11 @@ export default {
window.addEventListener('load', function () { window.addEventListener('load', function () {
setTimeout(function () { setTimeout(function () {
window.parent.postMessage( window.parent.postMessage(
{ type: 'RESIZE_IFRAME', height: getReportCardHeight() }, {
type: 'RESIZE_IFRAME',
height: getReportCardHeight(),
reportId: currentReportId
},
'*' '*'
) )
}, 200) }, 200)
...@@ -73,7 +86,11 @@ export default { ...@@ -73,7 +86,11 @@ export default {
// 监听 DOM 变化,动态调整高度 // 监听 DOM 变化,动态调整高度
const observer = new MutationObserver(function () { const observer = new MutationObserver(function () {
window.parent.postMessage( window.parent.postMessage(
{ type: 'RESIZE_IFRAME', height: getReportCardHeight() }, {
type: 'RESIZE_IFRAME',
height: getReportCardHeight(),
reportId: currentReportId
},
'*' '*'
) )
}) })
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
active-color="#0088FF" active-color="#0088FF"
size="18" size="18"
@change="switchChange($event, '展业周报', 'updateWeeklySubscribeStatus')" @change="switchChange($event, '展业周报', 'updateWeeklySubscribeStatus')"
inactive-color="#E6E6E6"
/> />
</div> </div>
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
active-color="#0088FF" active-color="#0088FF"
size="18" size="18"
@change="switchChange($event, '展业月报','updateMonthlySubscribeStatus')" @change="switchChange($event, '展业月报','updateMonthlySubscribeStatus')"
inactive-color="#E6E6E6"
/> />
</div> </div>
</div> </div>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!