class.js 2.5 KB

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