|
@@ -1,5 +1,6 @@
|
|
|
// pages/details/details.js
|
|
|
import httpRequestApi from '../../utils/APIRequest';
|
|
|
+import util from '../../utils/util';
|
|
|
Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
@@ -14,15 +15,16 @@ Page({
|
|
|
courseId: '',
|
|
|
favoritesFlag: false,
|
|
|
title: '',
|
|
|
- iconImg: ''
|
|
|
+ iconImg: '',
|
|
|
+ postsList: [],
|
|
|
+ dateArr: []
|
|
|
},
|
|
|
//点击收藏
|
|
|
favorites: function () {
|
|
|
this.setData({
|
|
|
favoritesFlag: !this.data.favoritesFlag
|
|
|
})
|
|
|
- console.log(this.data.courseId, this.data.title, this.data.iconImg)
|
|
|
- httpRequestApi.getCourseDetails({
|
|
|
+ httpRequestApi.getDetailsFavorites({
|
|
|
targetCode: this.data.courseId,
|
|
|
title: this.data.title,
|
|
|
iconImg: this.data.iconImg
|
|
@@ -60,12 +62,32 @@ Page({
|
|
|
str: ''
|
|
|
})
|
|
|
},
|
|
|
- //点击确定
|
|
|
+ //点击确定评论
|
|
|
yes: function () {
|
|
|
- this.setData({
|
|
|
- hide: !this.data.hide,
|
|
|
- str: ''
|
|
|
- })
|
|
|
+ if(this.data.str === '') {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '请输入内容'
|
|
|
+ })
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ httpRequestApi.getDetailsPosts({
|
|
|
+ columnId: this.data.courseId,
|
|
|
+ columnNames: this.data.title,
|
|
|
+ detailDesc: this.data.str
|
|
|
+ }).success((res)=>{
|
|
|
+ if(res.data.success){
|
|
|
+ wx.showToast({
|
|
|
+ title: '评论成功'
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ hide: !this.data.hide,
|
|
|
+ str: ''
|
|
|
+ })
|
|
|
+ //获取评论列表
|
|
|
+ this.getPostsList(this.data.courseId);
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
//获取输入值
|
|
|
focus: function ({detail}) {
|
|
@@ -80,9 +102,10 @@ Page({
|
|
|
onLoad: function (options) {
|
|
|
const courseId = options.id;
|
|
|
httpRequestApi.getCourseDetails(courseId).success((res)=>{
|
|
|
- console.log(res);
|
|
|
+ console.log('课程详情', res);
|
|
|
const data = res.data.data;
|
|
|
this.setData({
|
|
|
+ favoritesFlag: data.isFavorites,
|
|
|
title: data.course.title,
|
|
|
iconImg: data.course.iconImg,
|
|
|
courseId,
|
|
@@ -90,6 +113,26 @@ Page({
|
|
|
courseWareList: data.courseWareList
|
|
|
})
|
|
|
})
|
|
|
+ //获取评论列表
|
|
|
+ this.getPostsList(courseId);
|
|
|
+ },
|
|
|
+ //获取评论列表
|
|
|
+ getPostsList: function (courseId) {
|
|
|
+ httpRequestApi.getPostsList({
|
|
|
+ courseId,
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 10
|
|
|
+ }).success((res)=>{
|
|
|
+ console.log('评论列表', res);
|
|
|
+ const dateArr = [];
|
|
|
+ res.data.data.list.forEach(item => {
|
|
|
+ dateArr.push(util.formatTime(new Date(item.gmtCreated)));
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ postsList: res.data.data.list,
|
|
|
+ dateArr
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -103,7 +146,6 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
-
|
|
|
},
|
|
|
|
|
|
/**
|