diff --git a/common/js/util.js b/common/js/util.js index e831c80..8373949 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -5,6 +5,32 @@ import { Weixin } from 'common/js/wx-jssdk.js'; +// +export function decodeEntity(str, amp) { + const html4Entities = { + nbsp: ' ', iexcl: '¡', cent: '¢', pound: '£', curren: '₣', yen: '¥', brvbar: '§', sect: 'Ş', uml: '¨', copy: '©', ordf: 'ª', laquo: '«', not: '¬', shy: '­®', macr: '¯', deg: '°', plusmn: '±', sup2: '²', sup3: '³', acute: '´', micro: 'µ', para: '¶', middot: '·', cedil: '¸', sup1: '¹', ordm: 'º', raquo: '»', frac14: '¼', frac12: '½', frac34: '¾', iquest: '¿', agrave: 'à', aacute: 'á', acirc: 'â', atilde: 'ã', auml: 'ä', aring: 'å', aelig: 'æ', ccedil: 'ç', egrave: 'è', eacute: 'é', ecirc: 'ê', euml: 'ë', igrave: 'ì', iacute: 'í', icirc: 'î', iuml: 'ï', eth: 'ð', ntilde: 'ñ', ograve: 'ò', oacute: 'ó', ocirc: 'ô', otilde: 'õ', ouml: 'ö', times: 'ø', ugrave: 'ù', uacute: 'ú', ucirc: 'û', uuml: 'ü', yacute: 'ý', thorn: 'þ', yuml: 'ÿ', fnof: 'ƒ', alpha: 'α', beta: 'β', gamma: 'γ', delta: 'δ', epsilon: 'ε', zeta: 'ζ', eta: 'η', theta: 'θ', iota: 'ι', kappa: 'κ', lambda: 'λ', mu: 'μ', nu: 'ν', xi: 'ξ', omicron: 'ο', pi: 'π', rho: 'ρ', sigmaf: 'σ', sigma: 'σ', tau: 'τ', upsilon: 'υ', phi: 'φ', chi: 'ψ', omega: 'ω' + } + amp = amp === undefined ? true : amp + let i = str.indexOf('&') + while (i !== -1) { + const j = str.indexOf(';', i + 3) + let code + if (j === -1) break + if (str[i + 1] === '#') { + code = parseInt((str[i + 2] === 'x' ? '0' : '') + str.substring(i + 2, j)) + if (!isNaN(code)) { + str = str.substring(0, i) + String.fromCharCode(code) + str.substring(j + 1) + } + } else { + code = str.substring(i + 1, j) + if (html4Entities[code] || (code === 'amp' && amp)) { + str = str.substring(0, i) + (html4Entities[code] || '&') + str.substring(j + 1) + } + } + i = str.indexOf('&', i + 1) + } + return str +} // 关于页面路径,使用常量导出 @@ -635,8 +661,10 @@ export default { * @param {Object} link */ diyRedirectTo(link) { - //if (link == null || Object.keys(link).length == 1) return; + if (link.wap_url) { + link.wap_url = decodeEntity(link.wap_url); + } // 外部链接 if (link.wap_url && link.wap_url.indexOf('http') != -1) { @@ -902,11 +930,11 @@ export default { }, success: res => { if (res.code >= 0) { - uni.removeStorage({ - key: 'source_member', - success: res => { - } - }) + uni.removeStorage({ + key: 'source_member', + success: res => { + } + }) } } }) @@ -930,23 +958,23 @@ export default { success: res => { if (res.data.length) { // #ifdef MP-WEIXIN - uni.requestSubscribeMessage({ - tmplIds: res.data, - success: (res) => { - }, - fail: (res) => { - } - }) + uni.requestSubscribeMessage({ + tmplIds: res.data, + success: (res) => { + }, + fail: (res) => { + } + }) // #endif // #ifdef MP-ALIPAY - my.requestSubscribeMessage({ - entityIds: res.data, - success: res => { - }, - fail: res => { - } - }); + my.requestSubscribeMessage({ + entityIds: res.data, + success: res => { + }, + fail: res => { + } + }); // #endif } } diff --git a/pages_tool/webview/webview.vue b/pages_tool/webview/webview.vue index af80af0..36ad4d3 100644 --- a/pages_tool/webview/webview.vue +++ b/pages_tool/webview/webview.vue @@ -3,12 +3,14 @@ - +