diff --git a/pages/news/index.js b/pages/news/index.js
index 7db67da075d7341ee6281e4f51a222b8cb800982..e89c9ea6d34b3673bae056675362fbc943cb6e61 100644
--- a/pages/news/index.js
+++ b/pages/news/index.js
@@ -1,19 +1,110 @@
// pages/news/index.js
+var WxParse = require('../../vendor/wxParse/wxParse.js')
+
Page({
- data:{},
- onLoad:function(options){
- // 页面初始化 options为页面跳转所带来的参数
- },
- onReady:function(){
- // 页面渲染完成
- },
- onShow:function(){
- // 页面显示
- },
- onHide:function(){
- // 页面隐藏
- },
- onUnload:function(){
- // 页面关闭
- }
+ data: {
+ news: '',
+ comments: [],
+ newsId: 0,
+ blogApp: '',
+ commentInput: '',
+ pageIndex: 1,
+ pageSize: 10,
+ },
+ onLoad: function (options) {
+ this.loadNews(options);
+ this.loadComments(options);
+ },
+
+ loadNews: function (options) {
+ // 页面初始化 options为页面跳转所带来的参数
+ var that = this;
+ wx.request({
+ url: 'https://api.cnblogs.com/api/newsitems/' + options.newsId + '/body',
+ method: 'GET',
+ header: {
+ "Content-Type": "application/json; charset=utf-8",
+ "Authorization": "Bearer " + getApp().accessToken
+ },
+ success: function (res) {
+ if (res) {
+ that.setData({
+ news: res.data,
+ newsId: options.newsId,
+// blogApp: options.blogApp
+ })
+
+ WxParse.wxParse('news', 'html', that.data.news, that, 5);
+ }
+
+ },
+ fail: function () {
+ // fail
+ },
+ complete: function () {
+ // complete
+ }
+ })
+ },
+
+ loadComments: function (options) {
+ var that = this;
+ wx.request({
+ url: 'https://api.cnblogs.com/api/news/' + options.newsId +
+ '/comments?pageIndex=' + this.data.pageIndex + '&pageSize=' + this.data.pageSize,
+ method: 'GET',
+ header: {
+ "Content-Type": "application/json; charset=utf-8",
+ "Authorization": "Bearer " + getApp().accessToken
+ },
+ success: function (res) {
+
+ if (res) {
+ that.setData({
+ comments: res.data
+ })
+ }
+ },
+ fail: function () {
+ // fail
+ },
+ complete: function () {
+ // complete
+ }
+ })
+ },
+
+ addComment: function (options) {
+ console.log(options);
+ wx.request({
+ url: 'https://api.cnblogs.com/api/blogs/' + this.data.blogApp + '/posts/' + this.data.postId + '/comments',
+ method: 'POST',
+ data: {
+ "content": this.data.commentInput
+ },
+ header: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ 'Authorization': 'Bearer ' + getApp().accessToken,
+ },
+ success: function (res) {
+ console.log(res)
+ }
+
+ });
+ },
+ listenCommontInput: function (event) {
+ this.data.commentInput = event.detail.value;
+ },
+ onReady: function () {
+ // 页面渲染完成
+ },
+ onShow: function () {
+ // 页面显示
+ },
+ onHide: function () {
+ // 页面隐藏
+ },
+ onUnload: function () {
+ // 页面关闭
+ }
})
\ No newline at end of file
diff --git a/pages/news/index.wxml b/pages/news/index.wxml
index 1411a3e7405ac2470ae92c26d25a998b985315c9..21a8b8f3d68365599057621ab0cf570f76524d16 100644
--- a/pages/news/index.wxml
+++ b/pages/news/index.wxml
@@ -1,2 +1,33 @@
-pages/news/index.wxml
+
+
+
+ 热门评论
+
+
+
+
+
+
+
+
+ {{commont.Author}}|
+
+
+ {{commont.Body}}
+
+
+
+
+
+
+
+
+
+
+ 0/200
+
+
+
+
+
\ No newline at end of file
diff --git a/utils/util.js b/utils/util.js
index 6581a59c838a7e40765acf4fa9ad0fd8bc9e7796..d88310bd21c1cc0bc947ef3e5ac77359e7d12d33 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -26,5 +26,5 @@ function json2Form(json) {
module.exports = {
json2Form: json2Form,
- formatTime: formatTime
+ formatTime: formatTime,
}
diff --git a/vendor/wxParse/html2json.js b/vendor/wxParse/html2json.js
index 38a9cb269ff598621f3af687761e93fe0eeda1af..91b7d6abb658a717ac567d900e37c39569185af1 100644
--- a/vendor/wxParse/html2json.js
+++ b/vendor/wxParse/html2json.js
@@ -88,14 +88,14 @@ function html2json(html, bindName) {
var name = attr.name;
var value = attr.value;
if (name == 'class') {
- console.dir(value);
+// console.dir(value);
// value = value.join("")
node.classStr = value;
}
// has multi attibutes
// make it array of attribute
if (name == 'style') {
- console.dir(value);
+// console.dir(value);
// value = value.join("")
node.styleStr = value;
}
diff --git a/vendor/wxParse/wxParse.js b/vendor/wxParse/wxParse.js
index ea4b6b08fc60e4b7b4584ebaf938b1b06844a83b..3e340031a0e23cf8c7c53ba4a2277cc06f0b8d8d 100644
--- a/vendor/wxParse/wxParse.js
+++ b/vendor/wxParse/wxParse.js
@@ -25,12 +25,12 @@ function wxParse(bindName = 'wxParseData', type='html', data=' windowWidth) {//在图片width大于手机屏幕width时候
autoWidth = windowWidth;
- console.log("autoWidth" + autoWidth);
+// console.log("autoWidth" + autoWidth);
autoHeight = (autoWidth * originalHeight) / originalWidth;
- console.log("autoHeight" + autoHeight);
+// console.log("autoHeight" + autoHeight);
results.imageWidth = autoWidth;
results.imageheight = autoHeight;
} else {//否则展示原来的数据