details.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // pages/details/details.js
  2. import httpRequestApi from '../../utils/APIRequest';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. anthologyHide: true,
  9. detailsHide: true,
  10. hide: true,
  11. str: '',
  12. summary: '',
  13. courseWareList: [],
  14. courseId: '',
  15. favoritesFlag: false,
  16. title: '',
  17. iconImg: ''
  18. },
  19. //点击收藏
  20. favorites: function () {
  21. this.setData({
  22. favoritesFlag: !this.data.favoritesFlag
  23. })
  24. console.log(this.data.courseId, this.data.title, this.data.iconImg)
  25. httpRequestApi.getCourseDetails({
  26. targetCode: this.data.courseId,
  27. title: this.data.title,
  28. iconImg: this.data.iconImg
  29. }).success((res)=>{
  30. console.log(res);
  31. })
  32. },
  33. //点击出现选集
  34. commentAnthology: function () {
  35. this.setData({
  36. anthologyHide: !this.data.anthologyHide
  37. })
  38. },
  39. //出现详情页
  40. commentDetails: function () {
  41. this.setData({
  42. detailsHide: !this.data.detailsHide
  43. })
  44. },
  45. //点击评论
  46. pinglun: function () {
  47. this.setData({
  48. hide: !this.data.hide
  49. })
  50. },
  51. //点击取消
  52. no: function () {
  53. this.setData({
  54. hide: !this.data.hide,
  55. str: ''
  56. })
  57. },
  58. //点击确定
  59. yes: function () {
  60. this.setData({
  61. hide: !this.data.hide,
  62. str: ''
  63. })
  64. },
  65. //获取输入值
  66. focus: function ({detail}) {
  67. this.setData({
  68. str: detail.value
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面加载
  73. */
  74. onLoad: function (options) {
  75. const courseId = options.id;
  76. httpRequestApi.getCourseDetails(courseId).success((res)=>{
  77. console.log(res);
  78. const data = res.data.data;
  79. this.setData({
  80. title: data.course.title,
  81. iconImg: data.course.iconImg,
  82. courseId,
  83. summary: data.course.summary,
  84. courseWareList: data.courseWareList
  85. })
  86. })
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload: function () {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh: function () {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage: function () {
  122. }
  123. })