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 86557a5 commit 16be86c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 50 deletions.
22 changes: 5 additions & 17 deletions pages/detail/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ Page({
},
//评论页面跳转
showComments:function(e){
console.log(e.currentTarget.id);
wx.navigateTo({
url: '../comments/comments?id='+e.currentTarget.id
})
},
loadExtraData:function(newsid){

console.log(CONFIG.API_URL.NEWS_EXTRADATA_QUERY+newsid);
var _this = this;
wx.request({
url: CONFIG.API_URL.NEWS_EXTRADATA_QUERY+newsid,
Expand All @@ -44,7 +41,7 @@ Page({
'Content-Type': 'application/json'
},
success: function(res) {
console.log(res.data);
console.log(" 获取文章评论:" + JSON.stringify(res));
_this.setData({
comments:res.data.comments,
popularity:res.data.popularity,
Expand All @@ -54,39 +51,30 @@ Page({
}
})
},
// 加载文章内容
onLoad: function(option){
console.log(JSON.stringify(option.id));
dialog.loading();

var _this = this;

wx.request({
url: CONFIG.API_URL.NEWS_DETAIL_QUERY+option.id,
method: 'GET',
header: {
'Content-Type': 'application/json'
},
success: function(res) {
console.log(res.data)
console.log(res.data.body)
// //html解析
// var str = util.coder(res.data.body);

console.log("加载文章内容:" + JSON.stringify(res));

//富文本解析
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
})


//加载新闻额外信息
//加载评论信息
_this.loadExtraData(res.data.id);

},
complete:function(){
setTimeout(function(){
Expand Down
4 changes: 0 additions & 4 deletions pages/detail/detail.wxss
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/*引入富文本解析自定义组件*/
@import "../../wxParse/wxParse.wxss";


.wxParse-script{display: none;}



article,
aside,
details,
Expand Down
7 changes: 1 addition & 6 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ Page({
},
//知乎日报详情页跳转
dailyDetail:function(e){

console.log("**************"+JSON.stringify(e));
console.log("**************"+e.currentTarget.id);

wx.navigateTo({
url: '../detail/detail?id='+e.currentTarget.id,
Expand All @@ -49,10 +46,8 @@ Page({
'Content-Type': 'application/json'
},
success: function(res) {
console.log(res);//errMsg: "request:ok", data: Object, statusCode: 200
console.log("获取最新日报数据:" + JSON.stringify(res));//errMsg: "request:ok", data: Object, statusCode: 200
if(res.statusCode == 200){
console.log(res.data);

//日期格式化 '19930701' -> 1993-07-01
var dateString = res.data.date;
var pattern = /(\d{4})(\d{2})(\d{2})/;
Expand Down
22 changes: 3 additions & 19 deletions pages/section/section.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@


// section.js

//require引入config.js文件
var CONFIG = require("../../utils/config.js");

// 页面注册
Page({

data:{
themes:"",
stories:"",
Expand All @@ -21,7 +18,6 @@ Page({
this.getThemes();
},


//主题日报列表
getThemes:function(){
var _this = this;
Expand All @@ -32,7 +28,7 @@ Page({
'Content-Type': 'application/json'
},
success: function(res) {
console.log("news_themes_url->"+JSON.stringify(res.data));
console.log("获取主题日报列表:"+JSON.stringify(res));
_this.setData({
themes:res.data.others
})
Expand All @@ -48,9 +44,8 @@ Page({
this.getThemesContent(themeid);
},

//新闻主题内容
//日报专栏内容
getThemesContent:function(themeid){
console.log(CONFIG.API_URL.NEWS_THEMES_CONTETN_QUERY+themeid);
var _this = this;
wx.request({
url: CONFIG.API_URL.NEWS_THEMES_CONTETN_QUERY+themeid,
Expand All @@ -59,9 +54,7 @@ Page({
'Content-Type': 'application/json'
},
success: function(res) {
console.log("news_themes_content_url->"+JSON.stringify(res.data));
console.log("res.data.name->"+res.data.name);
console.log("res.data.editors->"+res.data.editors[0].avatar);
console.log("获取日报专栏内容:"+JSON.stringify(res));
_this.setData({
stories:res.data.stories,
themename:res.data.name,
Expand All @@ -70,7 +63,6 @@ Page({
editors:res.data.editors,
curNav:themeid //更新当前选中专栏id 用于在前台页面进行比对
})

//更新主题标题栏
wx.setNavigationBarTitle({
title: res.data.name,
Expand All @@ -83,20 +75,12 @@ Page({
})
}
})


},
//知乎日报详情页跳转
dailyDetail:function(e){
console.log("**************"+JSON.stringify(e));
console.log("**************"+e.currentTarget.id);
wx.navigateTo({
url: '../detail/detail?id='+e.currentTarget.id
})
}





})
8 changes: 4 additions & 4 deletions utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const CONFIG = {
API_URL:{
//最新日报
NEWS_LATEST_QUERY:WEB_API_URL+"/api/4/news/latest",
//日报详情
//文章详情
NEWS_DETAIL_QUERY:WEB_API_URL+"/api/4/news/",
//新闻额外信息
//文章评论信息
NEWS_EXTRADATA_QUERY:WEB_API_URL+"/api/4/story-extra/",
// 新闻主题列表
// 专栏列表
NEWS_THEMES_QUERY:WEB_API_URL+"/api/4/themes",
// 新闻主题内容
// 专栏内容
NEWS_THEMES_CONTETN_QUERY:WEB_API_URL+"/api/4/theme/"
}
}
Expand Down

0 comments on commit 16be86c

Please sign in to comment.