diff --git a/pages/detail/detail.js b/pages/detail/detail.js index 7f6b37c..3b2cb80 100644 --- a/pages/detail/detail.js +++ b/pages/detail/detail.js @@ -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, @@ -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, @@ -54,12 +51,10 @@ 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', @@ -67,26 +62,19 @@ Page({ '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(){ diff --git a/pages/detail/detail.wxss b/pages/detail/detail.wxss index 23a51fe..5012d3a 100644 --- a/pages/detail/detail.wxss +++ b/pages/detail/detail.wxss @@ -1,11 +1,7 @@ /*引入富文本解析自定义组件*/ @import "../../wxParse/wxParse.wxss"; - - .wxParse-script{display: none;} - - article, aside, details, diff --git a/pages/index/index.js b/pages/index/index.js index 7f3a93e..9be008c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -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, @@ -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})/; diff --git a/pages/section/section.js b/pages/section/section.js index d2d868a..c49d567 100644 --- a/pages/section/section.js +++ b/pages/section/section.js @@ -1,5 +1,3 @@ - - // section.js //require引入config.js文件 @@ -7,7 +5,6 @@ var CONFIG = require("../../utils/config.js"); // 页面注册 Page({ - data:{ themes:"", stories:"", @@ -21,7 +18,6 @@ Page({ this.getThemes(); }, - //主题日报列表 getThemes:function(){ var _this = this; @@ -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 }) @@ -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, @@ -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, @@ -70,7 +63,6 @@ Page({ editors:res.data.editors, curNav:themeid //更新当前选中专栏id 用于在前台页面进行比对 }) - //更新主题标题栏 wx.setNavigationBarTitle({ title: res.data.name, @@ -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 }) } - - - - }) diff --git a/utils/config.js b/utils/config.js index 86eda58..f5c5c84 100644 --- a/utils/config.js +++ b/utils/config.js @@ -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/" } }