diff --git a/pages/question/comments.js b/pages/question/comments.js
new file mode 100644
index 0000000000000000000000000000000000000000..363a125f65f1a1d5fab3a3a636dff35be3f7af47
--- /dev/null
+++ b/pages/question/comments.js
@@ -0,0 +1,47 @@
+// pages/question/comments.js
+var app = getApp();
+Page({
+ data:{
+ commonts:{}
+ },
+ onLoad:function(options){
+ // 页面初始化 options为页面跳转所带来的参数
+ var that = this;
+ //获取回答详情
+ wx.request({
+ url: 'https://api.cnblogs.com/api/questions/answers/'+options.id+'/comments',
+ method: 'GET',
+ data: {
+ },
+ header: {
+ 'Authorization': 'Bearer '+ app.accessToken
+ },
+ success: function (res) {
+ var data = {};
+ data.status = true;
+ data.data = res.data;
+ if(res.data.length < 1){
+ data.status = false;
+ }
+ that.setData({
+ commonts: data
+ });
+ },
+ fail: function () {
+ console.log('获取用户信息失败!');
+ }
+ });
+ },
+ onReady:function(){
+ // 页面渲染完成
+ },
+ onShow:function(){
+ // 页面显示
+ },
+ onHide:function(){
+ // 页面隐藏
+ },
+ onUnload:function(){
+ // 页面关闭
+ }
+})
\ No newline at end of file
diff --git a/pages/question/comments.json b/pages/question/comments.json
new file mode 100644
index 0000000000000000000000000000000000000000..9e26dfeeb6e641a33dae4961196235bdb965b21b
--- /dev/null
+++ b/pages/question/comments.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/pages/question/comments.wxml b/pages/question/comments.wxml
new file mode 100644
index 0000000000000000000000000000000000000000..6e5f5a4af224fa1fabfd3d8a418c31a7b830a502
--- /dev/null
+++ b/pages/question/comments.wxml
@@ -0,0 +1,37 @@
+
+
+
+ {{question.Title}}
+ {{question.Content}}
+
+
+ 评论
+
+
+
+
+ {{commont.Content}}
+
+ {{item.PostUserInfo.UserName}}|
+ 园豆:{{item.PostUserInfo.QScore}}|
+
+
+
+
+
+
+
+
+
+ 文本域
+
+
+
+
+ 0/200
+
+
+
+
+
+
diff --git a/pages/question/comments.wxss b/pages/question/comments.wxss
new file mode 100644
index 0000000000000000000000000000000000000000..b80382057b52711af86d05ae8f1277b30700ec3e
--- /dev/null
+++ b/pages/question/comments.wxss
@@ -0,0 +1 @@
+/* pages/question/comments.wxss */
\ No newline at end of file
diff --git a/pages/question/index.js b/pages/question/index.js
index 053f9d70a09268c7a52bca7881cd35afe97603b4..ce1f56928eb9b90338487792c00cc86737d34e13 100644
--- a/pages/question/index.js
+++ b/pages/question/index.js
@@ -19,7 +19,7 @@ Page({
data: {
},
header: {
- 'Authorization': 'Bearer '+ app.globalData.access_token
+ 'Authorization': 'Bearer '+ app.accessToken
},
success: function (res) {
that.setData({
@@ -36,7 +36,7 @@ Page({
data: {
},
header: {
- 'Authorization': 'Bearer '+ app.globalData.access_token
+ 'Authorization': 'Bearer '+ app.accessToken
},
success: function (res) {
that.setData({
diff --git a/pages/question/view.js b/pages/question/view.js
index 52bbd1750853c1b545c0be1c3bffd696a50f2b39..f4a0b241bace897f03f4bebbc22196f9e110021e 100644
--- a/pages/question/view.js
+++ b/pages/question/view.js
@@ -4,18 +4,20 @@ Page({
data:{
question:{},
answers:{},
- },
+ answerInput:'',
+ is_answer:false
+ },
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
var that = this;
- //获取问题列表
+ //获取问题详情
wx.request({
url: 'https://api.cnblogs.com/api/questions/'+options.id, //仅为示例,并非真实的接口地址
method: 'GET',
data: {
},
header: {
- 'Authorization': 'Bearer '+ app.globalData.access_token
+ 'Authorization': 'Bearer '+ app.accessToken
},
success: function (res) {
that.setData({
@@ -26,17 +28,40 @@ Page({
console.log('获取用户信息失败!');
}
});
+ //判断当前用户是否回答过某个问题
+ wx.request({
+ url: 'https://api.cnblogs.com/api/questions/'+options.id+'?userId='+app.user.SpaceUserId, //仅为示例,并非真实的接口地址
+ method: 'HEAD',
+ data: {
+ },
+ header: {
+ 'Authorization': 'Bearer '+ app.accessToken
+ },
+ success: function (res) {
+ console.log(res)
+ },
+ fail: function () {
+ console.log('获取用户信息失败!');
+ }
+ });
+ //获取问题的回答列表
wx.request({
url: 'https://api.cnblogs.com/api/questions/'+options.id+'/answers', //仅为示例,并非真实的接口地址
method: 'GET',
data: {
},
header: {
- 'Authorization': 'Bearer '+ app.globalData.access_token
+ 'Authorization': 'Bearer '+ app.accessToken
},
success: function (res) {
+ var data = {};
+ data.status = true;
+ data.data = res.data;
+ if(res.data.length < 1){
+ data.status = false;
+ }
that.setData({
- answers: res.data
+ answers: data
});
},
fail: function () {
@@ -55,5 +80,31 @@ Page({
},
onUnload:function(){
// 页面关闭
+ },
+ answer:function(e){
+ var questionId=e.target.dataset.questionId;
+ if(!questionId){
+
+ }
+ console.log(this.data.answerInput)
+ wx.request({
+ url: 'https://api.cnblogs.com/api/questions/'+questionId+'/answers', //仅为示例,并非真实的接口地址
+ method: 'POST',
+ data: {
+ "Answer": this.data.answerInput
+ },
+ header: {
+ 'Authorization': 'Bearer '+ app.accessToken
+ },
+ success: function (res) {
+ console.log(res)
+ },
+ fail: function () {
+ console.log('获取用户信息失败!');
+ }
+ });
+ },
+ listenAnswerInput:function(event){
+ this.data.answerInput = event.detail.value;
}
-})
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/pages/question/view.wxml b/pages/question/view.wxml
index 0c5600aaee7b5bcf315beae8b11a408ee469cd0e..76d66e38b45033553d1e44d1245bf16c41eba325 100644
--- a/pages/question/view.wxml
+++ b/pages/question/view.wxml
@@ -4,20 +4,35 @@
{{question.Title}}
{{question.Content}}
- 回答
-
+
+ 回答
+
+
- {{item.Answer}}
+ {{answer.Answer}}
- {{item.AnswerUserInfo.UserName}}|
- 园豆:{{item.AnswerUserInfo.QScore}}|
-
+ {{answer.AnswerUserInfo.UserName}}|
+ 园豆:{{answer.AnswerUserInfo.QScore}}|
+
+
+
+ 文本域
+
+
+
+
+ 0/200
+
+
+
+
+