1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import httpRequestApi from '../../../utils/APIClient';
- import {formatDate} from '../../../utils/util';
- Page({
- data: {
- fullScreenBtn: false,
- playBtn: false,
- gesture: true,
- videoUrl: '',
- title: '',
- poster: '',
- works: [],
- total: '',
- title: '',
- id: '',
- iconImg: ''
- },
- onLoad: function (option) {
- console.log(option);
- wx.setNavigationBarTitle({
- title: option.title //页面标题为路由参数
- })
- this.setData({
- title: option.title,
- id: option.id
- })
- let uid = wx.getStorageSync('uid');;
- httpRequestApi.getClassDetail(uid, option.id).success(res => {
- console.log(res);
- this.setData({
- title: res.data.data.title,
- videoUrl: res.data.data.playUrl,
- iconImg: res.data.data.iconImg
- })
- this.getReadInfo(1,10);
- })
- },
- goToReading: function () {
- let id = this.data.id;
- let title = this.data.title;
- wx.navigateTo({
- url: `../../main/reading/reading?id=${id}&title=${this.data.title}&img=${this.data.img}&video=${this.data.videoUrl}`
- })
- },
- goToWorks: function (e) {
- this.videoCtx = wx.createVideoContext('myVideo', this);
- this.videoCtx.stop();
- console.log(e);
- let readId = e.target.dataset.uid;
- let title = this.data.title;
- wx.navigateTo({
- url: `../../social/works/works?id=${readId}&tilte=${title}`
- })
- },
- collect: function (e) {
- let uid = wx.getStorageSync('uid');
- let data = {
- targetCode: this.data.id,
- title: this.data.title,
- iconImg: this.data.iconImg
- }
- httpRequestApi.collectClass(uid, data).success(res => {
- console.log(res);
- })
- },
- getReadInfo: function(pageNo,pageSize){
- const uid = wx.getStorageSync('uid');
- const data = {
- lessonId: 1,
- pageNo: pageNo,
- pageSize: pageSize
- };
- httpRequestApi.getClassRead(uid,data).success(res=>{
- const readInfo = res.data.data.list;
- const readTemp = [];
- readInfo.forEach(item => {
- const temp = {};
- temp.nickName = item.user.wechatName;
- temp.time = formatDate(item.userRead.gmtCreated, 3);
- temp.avatar = item.user.avatar;
- temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
- temp.uid = item.userRead.uid;
- temp.id = item.userRead.id;
- readTemp.push(temp);
- });
- this.setData({
- total: res.data.data.totalSize,
- works: readTemp
- })
- });
- },
- // 下拉加载
- scrollUpdate:function(e){
- console.log(e)
- }
- })
|