|
|
|
|
@ -16,6 +16,8 @@ import imageService from '@/utils/imageService' |
|
|
|
|
import { messageSend } from '@/utils/api' |
|
|
|
|
import { Post } from '@/utils/https' |
|
|
|
|
import { SJHLCmdList } from '@/utils/constant' |
|
|
|
|
import { jumpOpenWeb } from '@/utils' |
|
|
|
|
import utils from '@/utils/utils' |
|
|
|
|
import MeScroll from 'mescroll.js' |
|
|
|
|
import 'mescroll.js/mescroll.min.css' |
|
|
|
|
|
|
|
|
|
@ -78,20 +80,11 @@ function appraiseIsClose(val, param) { |
|
|
|
|
if (current) current.disabled = false |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if (current) { |
|
|
|
|
try { |
|
|
|
|
const settled = current.parentNode.children[1] |
|
|
|
|
const unsettled = current.parentNode.children[0] |
|
|
|
|
current.disabled = true |
|
|
|
|
current.classList.add('active') |
|
|
|
|
if (current.innerText === '有帮助') { |
|
|
|
|
unsettled.disabled = true |
|
|
|
|
} else if (current.innerText === '没有帮助') { |
|
|
|
|
settled.disabled = true |
|
|
|
|
} |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log(err) |
|
|
|
|
} |
|
|
|
|
// 评价成功后隐藏整块 help-button-box |
|
|
|
|
if (param?.item) { |
|
|
|
|
param.item.hideHelpButton = true |
|
|
|
|
} else if (current?.parentNode) { |
|
|
|
|
current.parentNode.style.display = 'none' |
|
|
|
|
} |
|
|
|
|
if (res?.data != null) { |
|
|
|
|
store.setChatList(res.data) |
|
|
|
|
@ -566,9 +559,110 @@ onMounted(async () => { |
|
|
|
|
restoreScrollPosition() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
const invokedJumpKeys = new Set() |
|
|
|
|
|
|
|
|
|
function getLatestMessageText(item) { |
|
|
|
|
return String( |
|
|
|
|
item?.msgText || |
|
|
|
|
item?.message?.[0]?.options?.label || |
|
|
|
|
item?.raw?.msgText || |
|
|
|
|
item?.answer || |
|
|
|
|
item?.content || |
|
|
|
|
'', |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function extractJumpOpenWebCalls(msgText) { |
|
|
|
|
const text = String(msgText || '') |
|
|
|
|
const calls = [] |
|
|
|
|
// 1) 显式 jumpOpenWeb('type','url','urlType') |
|
|
|
|
if (text.includes('jumpOpenWeb')) { |
|
|
|
|
console.log('jumpOpenWeb'); |
|
|
|
|
const re = |
|
|
|
|
/jumpOpenWeb\s*\(\s*(['"`])(.*?)\1\s*,\s*(['"`])(.*?)\3(?:\s*,\s*(['"`])(.*?)\5)?\s*\)/g |
|
|
|
|
let match = re.exec(text) |
|
|
|
|
while (match) { |
|
|
|
|
console.log('match[2]',match[2]); |
|
|
|
|
calls.push({ |
|
|
|
|
type: match[2], |
|
|
|
|
url: match[4], |
|
|
|
|
urlType: match[6], |
|
|
|
|
}) |
|
|
|
|
match = re.exec(text) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2) 微信开放标签 wx-open-launch-weapp → 小程序内自动跳转(与 text-folding 一致) |
|
|
|
|
// 示例:<wx-open-launch-weapp class="open-wx-web-button" path="/packageMember/..."> |
|
|
|
|
if (text.includes('wx-open-launch-weapp') ) { |
|
|
|
|
const pathRe = /<wx-open-launch-weapp[^>]*\spath="([^"]+)"/gi |
|
|
|
|
let pathMatch = pathRe.exec(text) |
|
|
|
|
const seenPath = new Set() |
|
|
|
|
console.log('pathMatch',pathMatch); |
|
|
|
|
while (pathMatch) { |
|
|
|
|
const path = pathMatch[1] |
|
|
|
|
if (path && !seenPath.has(path)) { |
|
|
|
|
seenPath.add(path) |
|
|
|
|
calls.push({ |
|
|
|
|
type: 'YY_GWXCX', |
|
|
|
|
url: path, |
|
|
|
|
urlType: undefined, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
pathMatch = pathRe.exec(text) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
console.log('calls', calls) |
|
|
|
|
return calls |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function maybeAutoJumpOpenWeb(list) { |
|
|
|
|
const arr = Array.isArray(list) ? list : list?.value |
|
|
|
|
if (!arr?.length) return |
|
|
|
|
|
|
|
|
|
const latest = arr[arr.length - 1] |
|
|
|
|
if (!latest) return |
|
|
|
|
|
|
|
|
|
// 用户消息不自动跳转 |
|
|
|
|
const fromFlag = String(latest?.fromFlag ?? latest?.raw?.fromFlag ?? '') |
|
|
|
|
if (fromFlag === '1' || latest?.type === 'user') return |
|
|
|
|
|
|
|
|
|
const msgText = getLatestMessageText(latest) |
|
|
|
|
const calls = extractJumpOpenWebCalls(msgText) |
|
|
|
|
if (!calls.length) return |
|
|
|
|
|
|
|
|
|
const msgKey = String(latest?.VIEW_ID || latest?.timestamp || latest?.id || arr.length) |
|
|
|
|
calls.forEach(({ type, url, urlType },index) => { |
|
|
|
|
if (!type || !url) return |
|
|
|
|
const key = `${msgKey}::${type}::${url}::${urlType || ''}` |
|
|
|
|
if (invokedJumpKeys.has(key)) return |
|
|
|
|
invokedJumpKeys.add(key) |
|
|
|
|
|
|
|
|
|
// 与 text-folding 一致:同消息只自动跳一次,并稍延时等待渲染 |
|
|
|
|
const storageKey = `weapp_auto_jump_${msgKey}` |
|
|
|
|
if (type === 'YY_GWXCX') { |
|
|
|
|
try { |
|
|
|
|
if (sessionStorage.getItem(storageKey)) return |
|
|
|
|
sessionStorage.setItem(storageKey, '1') |
|
|
|
|
} catch (e) { } |
|
|
|
|
console.log('[auto jumpOpenWeb YY_GWXCX]', url) |
|
|
|
|
setTimeout(() => { |
|
|
|
|
if(index === 0) jumpOpenWeb(type, url, urlType) |
|
|
|
|
}, 300) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('[auto jumpOpenWeb]', type, url, urlType) |
|
|
|
|
if(index === 0) jumpOpenWeb(type, url, urlType) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
chatArr, |
|
|
|
|
() => { |
|
|
|
|
(list) => { |
|
|
|
|
// 最新消息 a 标签内 jumpOpenWeb 入参实时调用 |
|
|
|
|
maybeAutoJumpOpenWeb(list) |
|
|
|
|
|
|
|
|
|
// 从其他路由返回、正在恢复滚动位置时,不要强制滚到底部 |
|
|
|
|
if (isRestoringScroll.value || shouldRestoreScroll.value) return |
|
|
|
|
nextTick(() => { |
|
|
|
|
|