|
|
@ -9,6 +9,7 @@ Page({ |
|
|
*/ |
|
|
*/ |
|
|
data: { |
|
|
data: { |
|
|
info:null, |
|
|
info:null, |
|
|
|
|
|
linkData:[] |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -28,7 +29,10 @@ Page({ |
|
|
var that = this; |
|
|
var that = this; |
|
|
WxParse.wxParse('article', 'html', article, that, 0); |
|
|
WxParse.wxParse('article', 'html', article, that, 0); |
|
|
|
|
|
|
|
|
|
|
|
// console.log(this.data)
|
|
|
|
|
|
let arrayData = [] |
|
|
|
|
|
this.parseTagA(this.data.article.nodes, arrayData) |
|
|
|
|
|
this.setData({linkData: arrayData}) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
@ -37,15 +41,48 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
// wxParse 解析a标签
|
|
|
// wxParse 解析a标签
|
|
|
wxParseTagATap: function(e){ |
|
|
wxParseTagATap: function(e){ |
|
|
var href = e.currentTarget.dataset.src; |
|
|
console.log(e) |
|
|
console.log(href); |
|
|
let href = e.currentTarget.dataset.src; |
|
|
|
|
|
let linkTarget = this.data.linkData.find(v=>v.href == href) |
|
|
|
|
|
if (linkTarget) { |
|
|
|
|
|
if (linkTarget["attr-minilink"]) { |
|
|
|
|
|
wx.navigateTo({url: linkTarget["attr-minilink"]}) |
|
|
|
|
|
} else { |
|
|
if(href.indexOf("http") >= 0){ |
|
|
if(href.indexOf("http") >= 0){ |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(href) |
|
|
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(href) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (this.data.link) { |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: this.data.link |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
// console.log(e.currentTarget)
|
|
|
|
|
|
// var href = e.currentTarget.dataset.src;
|
|
|
|
|
|
// console.log(href);
|
|
|
|
|
|
// if(href.indexOf("http") >= 0){
|
|
|
|
|
|
// wx.navigateTo({
|
|
|
|
|
|
// url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(href)
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 递归article取出所有a标签
|
|
|
|
|
|
parseTagA:function (nodes, array) { |
|
|
|
|
|
nodes.forEach(v=>{ |
|
|
|
|
|
if (v.attr && v.attr.href) { |
|
|
|
|
|
array.push(v.attr) |
|
|
|
|
|
} |
|
|
|
|
|
if (Array.isArray(v.nodes) && v.nodes.length>0) { |
|
|
|
|
|
this.parseTagA(v.nodes,array) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showService:function(){ |
|
|
showService:function(){ |
|
|
util.pagePoint({ |
|
|
util.pagePoint({ |
|
|
|