Skip to content

Commit

Permalink
修复文章详情内容显示富文本解析
Browse files Browse the repository at this point in the history
  • Loading branch information
fozero committed Nov 11, 2017
1 parent a4dc0d2 commit 86557a5
Show file tree
Hide file tree
Showing 147 changed files with 2,434 additions and 1,254 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
"uploadFile": 10000,
"downloadFile": 10000
},
"debug":true
"debug":false
}
12 changes: 8 additions & 4 deletions pages/detail/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Page({
newsid:"",
title:"",
imgsrc:"",
wxParseData:"",
article:"",
comments:0,
popularity:0,
long_comments:0,
Expand Down Expand Up @@ -68,15 +68,19 @@ Page({
},
success: function(res) {
console.log(res.data)

console.log(res.data.body)
// //html解析
// var str = util.coder(res.data.body);


var article = res.data.body;
WxParse.wxParse('article', 'html', article, _this,0);

// wxParseData: WxParse('html', res.data.body)//使用WxParse组件解析html markdow解析将html替换成md
_this.setData({
newsid:res.data.id,
title:res.data.title,
imgsrc:res.data.image,
wxParseData:WxParse('html',res.data.body)//使用WxParse组件解析html markdow解析将html替换成md
imgsrc:res.data.image
})


Expand Down
2 changes: 1 addition & 1 deletion pages/detail/detail.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"navigationBarTitleText": "知乎日报详情"
"navigationBarTitleText": "日报详情"
}
30 changes: 23 additions & 7 deletions pages/detail/detail.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,34 @@

<view class="container">

<view style="height:240px;position:relative;">
<image src="{{imgsrc}}"></image>
<!-- <view style="position:relative;">
<image src="{{imgsrc}}" mode="aspectFill" style='width:100%;'></image>
<view style="position:absolute;top:158px;color:#fff;font-size:20px;padding:10px;">{{title}}</view>
</view>
</view> -->

<!--知乎内容html解析-->
<view class="wxParse">
<template is="wxParse" data="{{wxParseData}}"/>
<!-- <view class="wxParse">

</view> -->
<template is="wxParse" data="{{wxParseData:article.nodes}}"/>


<view style="background-color:#fff;position:fixed;right:10px;bottom:30px;padding:10px;color:#333;box-shadow:0px 0px 2px 1px #B4CDCD;font-size:14px;line-height:40px;">
<view id="{{newsid}}" style='text-align:center;' bindtap="doLike">
{{popularity}}赞
</view>
<view style='height:1px;background:#ccc;width:100%;'></view>
<view id="{{newsid}}" style='text-align:center;' bindtap="showComments">
{{comments}}评论
</view>
</view>





<!--额外信息-->
<view style="background-color:#4abdcc;position:fixed;bottom:0;width:100%;padding:5px;height:42px;color:#fff;display:flex;flex-direction:row-reverse;">
<!-- <view style="background-color:#4abdcc;position:fixed;bottom:0;width:100%;padding:5px;height:42px;color:#fff;display:flex;flex-direction:row-reverse;">
<view id="{{newsid}}" class="" style="" bindtap="doLike" style="margin-right: 20px;height:42px;line-height:42px;">
<image src="../../images/ico_like.png" style="width:22px;height:22px;"></image>
<text>{{popularity}}</text>
Expand All @@ -25,6 +41,6 @@
<image src="../../images/ico_answer.png" style="width:22px;height:22px;"></image>
<text>{{comments}}</text>
</view>
</view>
</view> -->

</view>
Loading

0 comments on commit 86557a5

Please sign in to comment.