|
@@ -9,8 +9,76 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- productionData: {}
|
|
|
+ productionData: {},
|
|
|
+ text: '',
|
|
|
+ discussDatas: [],
|
|
|
+ messageLength: '',
|
|
|
+ type: '',
|
|
|
+ favors: '',
|
|
|
+ like: false
|
|
|
},
|
|
|
+ /* 获取输入内容 */
|
|
|
+ bindKeyInput (e) {
|
|
|
+ this.setData({
|
|
|
+ text: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 发送评论 */
|
|
|
+ sendText (e) {
|
|
|
+ let text = this.data.text.trim();
|
|
|
+ let postsId = e.currentTarget.dataset.id;
|
|
|
+ let _this = this;
|
|
|
+ if(text == ''){
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '请输入评论内容',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+ } else if (res.cancel) {
|
|
|
+ console.log('用户点击取消')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.data.text = "";
|
|
|
+ let data = {
|
|
|
+ "postsId": postsId,
|
|
|
+ "content": text
|
|
|
+ };
|
|
|
+ login.getOpenidSessionKey((res) => {
|
|
|
+ //console.log(res.data.data.uid);
|
|
|
+ APIClient.getDiscussSchedule({
|
|
|
+ uid: res.data.data.uid
|
|
|
+ }, data).success((res) => {
|
|
|
+ if(res.data.success) {
|
|
|
+ this.data.discussDatas.push(res.data.data);
|
|
|
+ this.setData({
|
|
|
+ discussDatas: this.data.discussDatas,
|
|
|
+ messageLength: this.data.discussDatas.length
|
|
|
+ });
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }, function() {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
|
|
|
+ showCancel: false,
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+ } else if (res.cancel) {
|
|
|
+ console.log('用户点击取消')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ text: ''
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
/*预览图片*/
|
|
|
listenerButtonPreviewImage: function(e) {
|
|
|
let imgUrl = [];
|
|
@@ -30,7 +98,7 @@ Page({
|
|
|
},
|
|
|
/*点赞接口*/
|
|
|
like: function () {
|
|
|
- const postsId = util.getUrl().postsId;
|
|
|
+ const postsId = util.getUrl().postId;
|
|
|
//判断分享过来的参数是否有postId查询单挑显示
|
|
|
if(postsId) {
|
|
|
login.getOpenidSessionKey(res => {
|
|
@@ -42,7 +110,8 @@ Page({
|
|
|
console.log(res.data)
|
|
|
if(res.data.success) {
|
|
|
this.setData({
|
|
|
- productionData: res.data.data,
|
|
|
+ favors: res.data.data.favors,
|
|
|
+ like: true
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -68,9 +137,22 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- wx.setNavigationBarTitle({
|
|
|
- title: '作品分享'
|
|
|
+ const type = options.type;
|
|
|
+ this.setData({
|
|
|
+ type: type
|
|
|
})
|
|
|
+ if(type == 2) {
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: '作品分享'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(type == 1) {
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: '答疑讨论'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
const postsId = options.postId || '';
|
|
|
//判断分享过来的参数是否有postId查询单挑显示
|
|
|
if(postsId) {
|
|
@@ -84,6 +166,9 @@ Page({
|
|
|
if(res.data.success) {
|
|
|
this.setData({
|
|
|
productionData: res.data.data,
|
|
|
+ discussDatas: res.data.data.replyList,
|
|
|
+ messageLength: res.data.data.replyList.length,
|
|
|
+ favors:res.data.data.postsAttributeInfo.favors
|
|
|
})
|
|
|
}
|
|
|
})
|