Browse Source

多文本点击

master
jiazhipeng 2 years ago
parent
commit
eed42f4f77
  1. 2
      pages/index/index.wxml
  2. 43
      pages/user/service/info/index.js
  3. 3
      utils/wxParse/wxParse.wxss

2
pages/index/index.wxml

@ -172,7 +172,7 @@
</view> </view>
<!-- 2024年 夏季改UI新增景区舒适度和实时路况 --> <!-- 2024年 夏季改UI新增景区舒适度和实时路况 -->
<view style="display: flex;"> <view style="display: flex;">
<view bindtap="gotoUrl" data-event="comfort_click" data-title="景区舒适度" data-url="https://m.cloud.sz-trip.com/aiPlay" class="jqssd"> <view bindtap="gotoUrl" data-event="comfort_click" data-title="景区舒适度" data-url="https://test.m.cloud.sz-trip.com/aiPlay" class="jqssd">
<!-- <view bindtap="gotoUrl" data-event="comfort_click" data-title="景区舒适度" data-url="https://m.cloud.sz-trip.com/ScenicComfort" class="jqssd"> --> <!-- <view bindtap="gotoUrl" data-event="comfort_click" data-title="景区舒适度" data-url="https://m.cloud.sz-trip.com/ScenicComfort" class="jqssd"> -->
<image src="{{indexSeason.ai}}" mode=""/> <image src="{{indexSeason.ai}}" mode=""/>
</view> </view>

43
pages/user/service/info/index.js

@ -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({

3
utils/wxParse/wxParse.wxss

@ -17,9 +17,6 @@
color: #666; color: #666;
line-height: 1.8; line-height: 1.8;
} }
view{
word-break:break-all; overflow:auto;
}
.wxParse-inline{ .wxParse-inline{
display: inline; display: inline;
margin: 0; margin: 0;

Loading…
Cancel
Save