class.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import httpRequestApi from '../../../utils/APIClient';
  2. import {formatDate} from '../../../utils/util';
  3. Page({
  4. data: {
  5. fullScreenBtn: false,
  6. playBtn: false,
  7. gesture: true,
  8. videoUrl: '',
  9. title: '',
  10. poster: '',
  11. works: [],
  12. total: ''
  13. },
  14. onLoad: function (option) {
  15. console.log(option);
  16. wx.setNavigationBarTitle({
  17. title: option.title //页面标题为路由参数
  18. })
  19. this.setData({
  20. title: option.title,
  21. id: option.id
  22. })
  23. let uid = wx.getStorageSync('uid');;
  24. httpRequestApi.getClassDetail(uid, option.id).success(res => {
  25. console.log(res);
  26. this.setData({
  27. title: res.data.data.title,
  28. videoUrl: res.data.data.playUrl
  29. })
  30. this.getReadInfo(1,10);
  31. })
  32. },
  33. goToReading: function () {
  34. let id = this.data.id;
  35. let title = this.data.title;
  36. wx.navigateTo({
  37. url: `../../main/reading/reading?id=${id}&title=${this.data.title}&img=${this.data.img}&video=${this.data.videoUrl}`
  38. })
  39. },
  40. goToWorks: function (e) {
  41. this.videoCtx = wx.createVideoContext('myVideo', this);
  42. this.videoCtx.stop();
  43. console.log(e);
  44. let readId = e.target.dataset.uid;
  45. let title = this.data.title;
  46. wx.navigateTo({
  47. url: `../../social/works/works?id=${readId}&tilte=${title}`
  48. })
  49. },
  50. collect: function (e) {
  51. let uid = wx.getStorageSync('uid');
  52. let data = {
  53. }
  54. httpRequestApi.collectBook(uid, data).success(res => {
  55. console.log(res);
  56. })
  57. },
  58. getReadInfo: function(pageNo,pageSize){
  59. const uid = wx.getStorageSync('uid');
  60. const data = {
  61. lessonId: 1 ,
  62. pageNo: pageNo,
  63. pageSize: pageSize
  64. };
  65. httpRequestApi.getClassRead(uid,data).success(res=>{
  66. const readInfo = res.data.data.list;
  67. const readTemp = [];
  68. readInfo.forEach(item => {
  69. const temp = {};
  70. temp.nickName = item.user.wechatName;
  71. temp.time = formatDate(item.userRead.gmtCreated, 3);
  72. temp.avatar = item.user.avatar;
  73. temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
  74. temp.uid = item.userRead.uid;
  75. temp.id = item.userRead.id;
  76. readTemp.push(temp);
  77. });
  78. this.setData({
  79. total: res.data.data.totalSize,
  80. works: readTemp
  81. })
  82. });
  83. },
  84. // 下拉加载
  85. scrollUpdate:function(e){
  86. console.log(e)
  87. }
  88. })